From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
To: 6082@debbugs.gnu.org
Cc: Ryan Yeske <rcyeske@gmail.com>
Subject: bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs
Date: Mon, 3 May 2010 01:09:24 +0200 [thread overview]
Message-ID: <w2z7b501d5c1005021609ue9bf4a95j3109d351a6ecacf2@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 515 bytes --]
Attached is a patch which does the following:
Modifies rcirc-browse-url to only complete to buffers that are before
point in the current buffer. To accomplish this, the structure of
rcirc-urls has changed from being just a list of strings to a list of
strings and buffer positions.
Modifies rcirc-markup-urls to conform to the new structure of
rcirc-urls and so that any URL that is already the latest recognized
URL is not added to the list of URLs. This prevents "consecutive
duplicate URLs" from being stored.
[-- Attachment #2: rcirc-browse-url-deniz-dogan.diff --]
[-- Type: text/plain, Size: 2514 bytes --]
=== modified file 'lisp/net/rcirc.el'
--- lisp/net/rcirc.el 2010-01-13 08:35:10 +0000
+++ lisp/net/rcirc.el 2010-05-02 22:52:48 +0000
@@ -350,7 +350,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
@@ -2180,12 +2181,21 @@
"\\)")
"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 (nth 1 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)))
@@ -2242,13 +2252,16 @@
(defun rcirc-markup-urls (sender response)
(while (re-search-forward rcirc-url-regexp nil t)
- (let ((start (match-beginning 0))
- (end (match-end 0)))
+ (let* ((start (match-beginning 0))
+ (end (match-end 0))
+ (link-text (buffer-substring-no-properties start end)))
(rcirc-add-face start end 'rcirc-url)
(add-text-properties start end (list 'mouse-face 'highlight
'keymap rcirc-browse-url-map))
- ;; record the url
- (push (buffer-substring-no-properties start end) rcirc-urls))))
+ ;; record the url if it is not already the latest stored url
+ (when (or (not rcirc-urls)
+ (not (string= link-text (caar rcirc-urls))))
+ (push (list link-text start) rcirc-urls)))))
(defun rcirc-markup-keywords (sender response)
(when (and (string= response "PRIVMSG")
next reply other threads:[~2010-05-02 23:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-02 23:09 Deniz Dogan [this message]
2012-12-04 22:54 ` bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs Deniz Dogan
2012-12-05 3:36 ` Chong Yidong
2012-12-05 3:47 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=w2z7b501d5c1005021609ue9bf4a95j3109d351a6ecacf2@mail.gmail.com \
--to=deniz.a.m.dogan@gmail.com \
--cc=6082@debbugs.gnu.org \
--cc=rcyeske@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.