[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: [PATCH] w3m-lnum add highlight



The following message is a courtesy copy of an article
that has been posted to gmane.emacs.w3m as well.

Hello again,
I made a few little changes.  Sometimes when numbering appears, desired
link number may run out of sight.  So I added keys to scroll page while
entering link number.  Again, have a look if this is ok with XEmacs
too.  Here's a ChangeLog:

2010-09-06  Andrey Kotlarski  <m00naticus@xxxxxxxxx>

	* w3m-lnum.el (w3m-linknum-remove-overlays): Simplified.
	(w3m-link-numbering-mode): Using `or' instead of `unless'.
	(w3m-read-int-interactive): Added ability to scroll page while
	selecting number.

Here's the diff:

--- w3m-lnum-cvs.el             2010-07-31 01:57:15.727342157 +0300
+++ w3m-lnum.el         	2010-08-07 19:52:45.668371247 +0300
@@ -125,19 +125,12 @@
   (push (cons 'w3m-link-numbering-mode w3m-link-numbering-mode-map)
 	minor-mode-map-alist))
 
-(defun w3m-linknum-remove-overlays (&optional arg)
-  "Remove numbering and match overlays.
-With ARG remove only temporary match"
-  (if arg
-      (catch 'done
-	(dolist (overlay (overlays-in (point-min) (point-max)))
-	  (when (overlay-get overlay 'w3m-linknum-match)
-	    (delete-overlay overlay)
-	    (throw 'done nil))))
-    (dolist (overlay (overlays-in (point-min) (point-max)))
-      (if (or (overlay-get overlay 'w3m-link-numbering-overlay)
-	      (overlay-get overlay 'w3m-linknum-match))
-	  (delete-overlay overlay)))))
+(defun w3m-linknum-remove-overlays ()
+  "Remove numbering and match overlays."
+  (dolist (overlay (overlays-in (point-min) (point-max)))
+    (if (or (overlay-get overlay 'w3m-link-numbering-overlay)
+	    (overlay-get overlay 'w3m-linknum-match))
+	(delete-overlay overlay))))
 
 ;;;###autoload
 (defun w3m-link-numbering-mode (&optional arg)
@@ -147,16 +140,16 @@
   (interactive "P")
   (let ((w3m-linknum-status w3m-link-numbering-mode))
     ;; find current numbering status of w3m buffers
-    (unless (eq major-mode 'w3m-mode)
-      (save-current-buffer
-	(setq w3m-linknum-status
-	      (catch 'found-w3m
-		(dolist (buf (buffer-list))
-		  (set-buffer buf)
-		  (if (eq major-mode 'w3m-mode)
-		      (throw 'found-w3m w3m-link-numbering-mode)))))))
-    (setq arg (not (if arg
-		       (zerop arg)
+    (or (eq major-mode 'w3m-mode)
+	(save-current-buffer
+	  (setq w3m-linknum-status
+		(catch 'found-w3m
+		  (dolist (buf (buffer-list))
+		    (set-buffer buf)
+		    (if (eq major-mode 'w3m-mode)
+			(throw 'found-w3m
+			       w3m-link-numbering-mode)))))))
+    (setq arg (not (if arg (zerop arg)
 		     w3m-linknum-status)))
     (unless (eq arg w3m-linknum-status)	; if change of mode status
       (if arg
@@ -234,6 +227,11 @@
 	       (setq num (/ num 10)
 		     temp-prompt (format "%s%d" prompt num))
 	       (funcall fun num))
+	      ((eq ch 32) (w3m-scroll-up-or-next-url nil)) ;space
+	      ((eq ch 'delete)				   ;delete
+	       (w3m-scroll-down-or-previous-url nil))
+	      ((eq ch 60) (w3m-scroll-right nil)) ;<
+	      ((eq ch 62) (w3m-scroll-left nil))  ;>
 	      ((and (w3m-static-if (featurep 'xemacs)
 			(characterp ch)
 		      (numberp ch))