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

Re: [PATCH] w3m-lnum add highlight

In [emacs-w3m : No.11641] Andrey Kotlarski wrote:
> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.w3m as well.

Gmane doesn't work nowadays at last for the emacs-w3m list. :<

> Hello,

> long time no hear, but here comes another set of additions/improvements
> to w3m-lnum.el.  Main things are:
> There are little fixes and refactoring here and there as well.  I've
> been using this stuff for some weeks without issues.

Thank you very much for the patch.  .That's cool!
I've installed it with some modifications to make it work for
XEmacs and old Emacsen.   Here's what I did:
2011-09-04  Katsumi Yamaoka  <yamaoka@xxxxxxx>

	* w3m-lnum.el (w3m-link-numbering, w3m-linknum-minibuffer-prompt)
	(w3m-linknum-match): Use old defface style for XEmacs.
	(w3m-link-set-numbering): Replace w3m-string-match-p w/ string-match-p.
	(w3m-highlight-numbered-anchor, w3m-get-match-info): Fix range passed
	to overlays-in to make it work for XEmacs.

--- w3m-lnum.el~	2011-09-04 23:37:52.953125000 +0000
+++ w3m-lnum.el	2011-09-04 23:39:38.812500000 +0000
@@ -50,30 +50,30 @@
 (defface w3m-link-numbering
   '((((class color) (min-colors 16) (background light))
-     :foreground "gray60")
+     (:foreground "gray60"))
     (((class color) (min-colors 16) (background dark))
-     :foreground "gray50")
-    (t :foreground "gray"))
+     (:foreground "gray50"))
+    (t (:foreground "gray")))
   "Face used to highlight link numbers."
   :group 'w3m-face)
 ;; backward-compatibility alias
 (put 'w3m-link-numbering-face 'face-alias 'w3m-link-numbering)
 (defface w3m-linknum-minibuffer-prompt
-  '((((class color) (background light) (type tty)) :foreground "blue")
-    (((class color) (background dark)) :foreground "cyan")
-    (t :foreground "medium blue"))
+  '((((class color) (background light) (type tty)) (:foreground "blue"))
+    (((class color) (background dark)) (:foreground "cyan"))
+    (t (:foreground "medium blue")))
   "Face for w3m linknum minibuffer prompt."
   :group 'w3m-face)
 (defface w3m-linknum-match
   '((((class color) (background light) (type tty))
-     :background "yellow" :foreground "black")
+     (:background "yellow" :foreground "black"))
     (((class color) (background dark) (type tty))
-     :background "blue" :foreground "white")
-    (((class color) (background light)) :background "yellow1")
-    (((class color) (background dark)) :background "RoyalBlue3")
-    (t :background "gray"))
+     (:background "blue" :foreground "white"))
+    (((class color) (background light)) (:background "yellow1"))
+    (((class color) (background dark)) (:background "RoyalBlue3"))
+    (t (:background "gray")))
   "Face used to highlight matches in `w3m-link-numbering-mode'."
   :group 'w3m-face)
@@ -225,7 +225,7 @@
 	  (context (or (car (assoc-default
-			     'string-match-p))
+			     'w3m-string-match-p))
       (while (and pos
 		  (setq pos (funcall next-func pos))
@@ -497,7 +497,8 @@
   "Highlight specified by ARG number anchor.
 Return selected anchor."
   (let (newly-marked)
-    (dolist (overlay (overlays-in (1- (window-start)) (window-end)))
+    (dolist (overlay (overlays-in (max (1- (window-start)) (point-min))
+				  (window-end)))
        ((overlay-get overlay 'w3m-linknum-match)
 	(delete-overlay overlay))
@@ -526,7 +527,8 @@
 (defmacro w3m-get-match-info (condition found-tag)
   "For the first overlay matching CONDITION throw through FOUND-TAG
 anchor info."
-  `(dolist (overlay (overlays-in (1- (window-start)) (window-end)))
+  `(dolist (overlay (overlays-in (max (1- (window-start)) (point-min))
+				 (window-end)))
      (if ,condition
 	 (let* ((pos (overlay-start overlay))
 		(href (w3m-anchor pos)))