[gnus git] branch master updated: =2= gnus-art: fix button entries with identical regexp ; gnus-art: simplify condition

Julien Danjou <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  33a8056f8348d957aa6f42c06600c1b155edd530 (commit)
       via  846f55ecfc9219981b08f540c46e799d0254f386 (commit)
      from  153ca4cb91420e28b3803b06865792639683500f (commit)


- Log -----------------------------------------------------------------
commit 33a8056f8348d957aa6f42c06600c1b155edd530
Author: Julien Danjou <[email protected]>
Date:   Wed Jan 19 15:53:51 2011 +0100

    gnus-art: fix button entries with identical regexp
    
    Signed-off-by: Julien Danjou <[email protected]>

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 841142d..0e301b3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,8 @@
 2011-01-19  Julien Danjou  <[email protected]>
 
 	* gnus-art.el (gnus-article-add-buttons): Simplify condition.
+	(gnus-button-push): Remove gnus-button-entry function, it fails heavily
+	if you have the same regexp several times.
 
 2011-01-15  Glenn Morris  <[email protected]>
 
diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el
index 56f631a..2f9a15d 100644
--- a/lisp/gnus-art.el
+++ b/lisp/gnus-art.el
@@ -4413,7 +4413,6 @@ commands:
   (gnus-update-format-specifications nil 'article-mode)
   (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
   (set (make-local-variable 'gnus-page-broken) nil)
-  (make-local-variable 'gnus-button-marker-list)
   (make-local-variable 'gnus-article-current-summary)
   (make-local-variable 'gnus-article-mime-handles)
   (make-local-variable 'gnus-article-decoded-p)
@@ -4436,10 +4435,6 @@ commands:
   (mm-enable-multibyte)
   (gnus-run-mode-hooks 'gnus-article-mode-hook))
 
-(defvar gnus-button-marker-list nil
-  "Regexp matching any of the regexps from `gnus-button-alist'.
-Internal variable.")
-
 (defun gnus-article-setup-buffer ()
   "Initialize the article buffer."
   (let* ((name (if gnus-single-article-buffer "*Article*"
@@ -4483,8 +4478,6 @@ Internal variable.")
 	  (setq gnus-article-mime-handle-alist nil)
 	  (buffer-disable-undo)
 	  (setq buffer-read-only t)
-	  ;; This list just keeps growing if we don't reset it.
-	  (setq gnus-button-marker-list nil)
 	  (unless (eq major-mode 'gnus-article-mode)
 	    (gnus-article-mode))
 	  (setq truncate-lines gnus-article-truncate-lines)
@@ -7726,28 +7719,16 @@ It does this by highlighting everything after
   "Say whether PROP exists in the region."
   (text-property-not-all b e prop nil))
 
-(defun gnus-article-add-buttons (&optional force)
+(defun gnus-article-add-buttons ()
   "Find external references in the article and make buttons of them.
 \"External references\" are things like Message-IDs and URLs, as
 specified by `gnus-button-alist'."
-  (interactive (list 'force))
+  (interactive)
   (gnus-with-article-buffer
     (let ((inhibit-point-motion-hooks t)
 	  (case-fold-search t)
 	  (alist gnus-button-alist)
 	  beg entry regexp)
-      ;; Remove all old markers.
-      (let (marker entry new-list)
-	(while (setq marker (pop gnus-button-marker-list))
-	  (if (or (< marker (point-min)) (>= marker (point-max)))
-	      (push marker new-list)
-	    (goto-char marker)
-	    (when (setq entry (gnus-button-entry))
-	      (put-text-property (match-beginning (nth 1 entry))
-				 (match-end (nth 1 entry))
-				 'gnus-callback nil))
-	    (set-marker marker nil)))
-	(setq gnus-button-marker-list new-list))
       ;; We skip the headers.
       (article-goto-body)
       (setq beg (point))
@@ -7764,11 +7745,10 @@ specified by `gnus-button-alist'."
 	      ;; That optional form returned non-nil, so we add the
 	      ;; button.
 	      (setq from (set-marker (make-marker) from))
-	      (push from gnus-button-marker-list)
 	      (unless (and (eq (car entry) 'gnus-button-url-regexp)
 			   (gnus-article-extend-url-button from start end))
 		(gnus-article-add-button start end
-					 'gnus-button-push from)
+					 'gnus-button-push (list from entry))
 		(gnus-put-text-property
 		 start end
 		 'gnus-string (buffer-substring-no-properties
@@ -7915,24 +7895,17 @@ url is put as the `gnus-button-url' overlay property on the button."
     (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
       (gnus-set-mode-line 'article))))
 
-(defun gnus-button-entry ()
-  ;; Return the first entry in `gnus-button-alist' matching this place.
-  (let ((alist gnus-button-alist)
-	(entry nil))
-    (while alist
-      (setq entry (pop alist))
-      (if (looking-at (eval (car entry)))
-	  (setq alist nil)
-	(setq entry nil)))
-    entry))
-
-(defun gnus-button-push (marker)
+(defun gnus-button-push (marker-and-entry)
   ;; Push button starting at MARKER.
   (save-excursion
+    (let ((marker (car marker-and-entry))
+          (entry (cadr marker-and-entry))
+          (inhibit-point-motion-hooks t))
     (goto-char marker)
-    (let* ((entry (gnus-button-entry))
-	   (inhibit-point-motion-hooks t)
-	   (fun (nth 3 entry))
+      ;; This is obviously true, or something bad is happening :)
+      ;; But we need it to have the match-data
+      (when (looking-at (car entry))
+        (let ((fun (nth 3 entry))
 	   (args (or (and (eq (car entry) 'gnus-button-url-regexp)
 			  (get-char-property marker 'gnus-button-url))
 		     (mapcar (lambda (group)
@@ -7941,6 +7914,7 @@ url is put as the `gnus-button-url' overlay property on the button."
 				  0 (length string) nil string)
 				 string))
 			     (nthcdr 4 entry)))))
+
       (cond
        ((fboundp fun)
 	(apply fun args))
@@ -7949,7 +7923,7 @@ url is put as the `gnus-button-url' overlay property on the button."
 	(apply (symbol-value fun) args))
        (t
 	(gnus-message 1 "You must define `%S' to use this button"
-		      (cons fun args)))))))
+                          (cons fun args)))))))))
 
 (defun gnus-parse-news-url (url)
   (let (scheme server port group message-id articles)

commit 846f55ecfc9219981b08f540c46e799d0254f386
Author: Julien Danjou <[email protected]>
Date:   Wed Jan 19 15:23:39 2011 +0100

    gnus-art: simplify condition
    
    Signed-off-by: Julien Danjou <[email protected]>

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6d2ad21..841142d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-19  Julien Danjou  <[email protected]>
+
+	* gnus-art.el (gnus-article-add-buttons): Simplify condition.
+
 2011-01-15  Glenn Morris  <[email protected]>
 
 	* message.el (message-mail): A compose-mail function should
diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el
index 3694426..56f631a 100644
--- a/lisp/gnus-art.el
+++ b/lisp/gnus-art.el
@@ -7758,8 +7758,7 @@ specified by `gnus-button-alist'."
 	  (let ((start (match-beginning (nth 1 entry)))
 		(end (match-end (nth 1 entry)))
 		(from (match-beginning 0)))
-	    (when (and (or (eq t (nth 2 entry))
-			   (eval (nth 2 entry)))
+	    (when (and (eval (nth 2 entry))
 		       (not (gnus-button-in-region-p
 			     start end 'gnus-callback)))
 	      ;; That optional form returned non-nil, so we add the

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog   |    6 ++++
 lisp/gnus-art.el |   89 +++++++++++++++++++-----------------------------------
 2 files changed, 37 insertions(+), 58 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.