* bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs
@ 2010-05-02 23:09 Deniz Dogan
2012-12-04 22:54 ` Deniz Dogan
0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2010-05-02 23:09 UTC (permalink / raw)
To: 6082; +Cc: Ryan Yeske
[-- 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")
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs
2010-05-02 23:09 bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs Deniz Dogan
@ 2012-12-04 22:54 ` Deniz Dogan
2012-12-05 3:36 ` Chong Yidong
2012-12-05 3:47 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Deniz Dogan @ 2012-12-04 22:54 UTC (permalink / raw)
To: 6082
I am nowadays maintaining rcirc and since no one has responded in nearly
three years, is it okay to implement this change?
Deniz
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs
2012-12-04 22:54 ` Deniz Dogan
@ 2012-12-05 3:36 ` Chong Yidong
2012-12-05 3:47 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2012-12-05 3:36 UTC (permalink / raw)
To: Deniz Dogan; +Cc: 6082
Deniz Dogan <deniz@dogan.se> writes:
> I am nowadays maintaining rcirc and since no one has responded in
> nearly three years, is it okay to implement this change?
If you are maintaining rcirc, you make the call, i.e. go ahead. (On the
trunk, of course, not on emacs-24.)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs
2012-12-04 22:54 ` Deniz Dogan
2012-12-05 3:36 ` Chong Yidong
@ 2012-12-05 3:47 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-12-05 3:47 UTC (permalink / raw)
To: Deniz Dogan; +Cc: 6082
> I am nowadays maintaining rcirc and since no one has responded in nearly
> three years, is it okay to implement this change?
You're the maintainer!
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-05 3:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-02 23:09 bug#6082: [PATCH] rcirc: rcirc-browse-url: Use only URLs before point and exclude consecutive duplicate URLs Deniz Dogan
2012-12-04 22:54 ` Deniz Dogan
2012-12-05 3:36 ` Chong Yidong
2012-12-05 3:47 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).