emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111111: * lisp/net/rcirc.el (rcirc-u


From: Deniz Dogan
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111111: * lisp/net/rcirc.el (rcirc-urls): Update documentation.
Date: Wed, 05 Dec 2012 17:45:37 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111111
fixes bug: http://debbugs.gnu.org/6082
committer: Deniz Dogan <address@hidden>
branch nick: trunk
timestamp: Wed 2012-12-05 17:45:37 +0100
message:
  * lisp/net/rcirc.el (rcirc-urls): Update documentation.
  (rcirc-condition-filter): New function.
  (rcirc-browse-url, rcirc-markup-urls): Use only URLs before point
  and exclude consecutive duplicate URLs.
modified:
  lisp/ChangeLog
  lisp/net/rcirc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-05 14:06:06 +0000
+++ b/lisp/ChangeLog    2012-12-05 16:45:37 +0000
@@ -1,3 +1,10 @@
+2012-12-05  Deniz Dogan  <address@hidden>
+
+       * net/rcirc.el (rcirc-urls): Update documentation.
+       (rcirc-condition-filter): New function.
+       (rcirc-browse-url, rcirc-markup-urls): Use only URLs before point
+       and exclude consecutive duplicate URLs (Bug#6082).
+
 2012-12-05  Michael Albinus  <address@hidden>
 
        * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):

=== modified file 'lisp/net/rcirc.el'
--- a/lisp/net/rcirc.el 2012-10-23 15:06:07 +0000
+++ b/lisp/net/rcirc.el 2012-12-05 16:45:37 +0000
@@ -406,7 +406,8 @@
   "The channel or user associated with this buffer.")
 
 (defvar rcirc-urls nil
-  "List of urls seen in the current buffer.")
+  "List of URLs seen in the current buffer and the position in
+the buffer where the URL starts.")
 (put 'rcirc-urls 'permanent-local t)
 
 (defvar rcirc-timeout-seconds 600
@@ -2392,12 +2393,23 @@
    "\\)")
   "Regexp matching URLs.  Set to nil to disable URL features in rcirc.")
 
+(defun rcirc-condition-filter (condp lst)
+  "Given a condition and a list, returns the list with elements
+that do not satisfy the condition removed."
+  (delq nil (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
+
 (defun rcirc-browse-url (&optional arg)
-  "Prompt for URL to browse based on URLs in buffer."
+  "Prompt for URL to browse based on URLs in buffer before point.
+
+If ARG is given, opens the URL in a new browser window."
   (interactive "P")
-  (let ((completions (mapcar (lambda (x) (cons x nil)) rcirc-urls))
-        (initial-input (car rcirc-urls))
-        (history (cdr rcirc-urls)))
+  (let* ((point (point))
+         (filtered (rcirc-condition-filter
+                    (lambda (x) (>= point (cdr x)))
+                    rcirc-urls))
+         (completions (mapcar (lambda (x) (car x)) filtered))
+         (initial-input (caar filtered))
+         (history (mapcar (lambda (x) (car x)) (cdr filtered))))
     (browse-url (completing-read "rcirc browse-url: "
                                  completions nil nil initial-input 'history)
                 arg)))
@@ -2441,17 +2453,19 @@
 (defun rcirc-markup-urls (sender response)
   (while (and rcirc-url-regexp ;; nil means disable URL catching
               (re-search-forward rcirc-url-regexp nil t))
-    (let ((start (match-beginning 0))
-         (end (match-end 0))
-         (url (match-string-no-properties 0)))
+    (let* ((start (match-beginning 0))
+           (end (match-end 0))
+           (url (match-string-no-properties 0))
+           (link-text (buffer-substring-no-properties start end)))
       (make-button start end
                   'face 'rcirc-url
                   'follow-link t
                   'rcirc-url url
                   'action (lambda (button)
                             (browse-url (button-get button 'rcirc-url))))
-      ;; record the url
-      (push url rcirc-urls))))
+      ;; record the url if it is not already the latest stored url
+      (when (not (string= link-text (caar rcirc-urls)))
+        (push (cons link-text start) rcirc-urls)))))
 
 (defun rcirc-markup-keywords (sender response)
   (when (and (string= response "PRIVMSG")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]