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

customizable w3m-next-url w3m-previous-url



Hi,
I think it would be a good idea to have next-url and previous-url
matching customizable (to a certain extent) by the user.
I modified my copy of w3m.el like this (I downloaded emacs-w3m from
this git mirror: https://github.com/jwiegley/emacs-w3m):

diff --git a/w3m.el b/w3m.el
index 87f9e1b..24bfced 100644
--- a/w3m.el
+++ b/w3m.el
@@ -3561,6 +3561,16 @@ The database is kept in `w3m-entity-table'."
        (error nil))
     (and w3m-imitate-widget-button t)))

+(defcustom w3m-next-url-words (list "next")
+  "Words matching ``next page'' links."
+  :type '(repeat string)
+  :group 'w3m)
+
+(defcustom w3m-previous-url-words (list "prev" "previous")
+  "Words matching ``previous page'' links."
+  :type '(repeat string)
+  :group 'w3m)
+
 (defun w3m-fontify-anchors ()
   "Fontify anchor tags in the buffer which contains halfdump."
   (let ((help (w3m-make-help-echo w3m-balloon-help))
@@ -3626,6 +3636,11 @@ The database is kept in `w3m-entity-table'."
                                       "\n"
                                       (w3m-url-readable-string href))))
              (setq bhhref (w3m-url-readable-string href)))
+           (let ((link-text (buffer-substring start end)))
+             (cond ((member link-text w3m-next-url-words)
+                    (setq w3m-next-url href))
+                   ((member link-text w3m-previous-url-words)
+                    (setq w3m-previous-url href))))
            (w3m-add-text-properties start end
                                     (list 'w3m-href-anchor href
                                           'w3m-balloon-help bhhref
I think this could be extended adding support for link text regexps instead
of whole string comparison.
Please let me know what you think about it :-)
Alessandro Piras