summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorLeo Liu <sdl.web@gmail.com>2011-07-27 11:44:45 +0800
committerLeo Liu <sdl.web@gmail.com>2011-07-27 11:44:45 +0800
commit1ddd96f5cf0b06846edd03d6b225c31206cee0b7 (patch)
treebd5ec0a933dddeabf117a56e133f0134fb08ba88 /lisp
parentb248a85d103b7f34b9747e8d6884179bf3d4decb (diff)
downloademacs-1ddd96f5cf0b06846edd03d6b225c31206cee0b7.tar.gz
emacs-1ddd96f5cf0b06846edd03d6b225c31206cee0b7.tar.bz2
emacs-1ddd96f5cf0b06846edd03d6b225c31206cee0b7.zip
Simplify url handling in rcirc-mode
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/net/rcirc.el37
2 files changed, 17 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8a25116efcb..ebbd696eddf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2011-07-27 Leo Liu <sdl.web@gmail.com>
+
+ Simplify url handling in rcirc-mode.
+
+ * net/rcirc.el (rcirc-browse-url-map, rcirc-browse-url-at-point)
+ (rcirc-browse-url-at-mouse): Remove.
+ * net/rcirc.el (rcirc-markup-urls): Use `make-button'.
+
2011-07-26 Alan Mackenzie <acm@muc.de>
Fontify bitfield declarations properly.
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index f7f5f61fafe..9e04abb8cd5 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -935,14 +935,6 @@ IRC command completion is performed only if '/' is the first input char."
map)
"Keymap for rcirc mode.")
-(defvar rcirc-browse-url-map
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "RET") 'rcirc-browse-url-at-point)
- (define-key map (kbd "<mouse-2>") 'rcirc-browse-url-at-mouse)
- (define-key map [follow-link] 'mouse-face)
- map)
- "Keymap used for browsing URLs in `rcirc-mode'.")
-
(defvar rcirc-short-buffer-name nil
"Generated abbreviation to use to indicate buffer activity.")
@@ -2351,21 +2343,6 @@ keywords when no KEYWORD is given."
(browse-url (completing-read "rcirc browse-url: "
completions nil nil initial-input 'history)
arg)))
-
-(defun rcirc-browse-url-at-point (point)
- "Send URL at point to `browse-url'."
- (interactive "d")
- (let ((beg (previous-single-property-change (1+ point) 'mouse-face))
- (end (next-single-property-change point 'mouse-face)))
- (browse-url (buffer-substring-no-properties beg end))))
-
-(defun rcirc-browse-url-at-mouse (event)
- "Send URL at mouse click to `browse-url'."
- (interactive "e")
- (let ((position (event-end event)))
- (with-current-buffer (window-buffer (posn-window position))
- (rcirc-browse-url-at-point (posn-point position)))))
-
(defun rcirc-markup-timestamp (sender response)
(goto-char (point-min))
@@ -2406,12 +2383,16 @@ keywords when no KEYWORD is given."
(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)))
- (rcirc-add-face start end 'rcirc-url)
- (add-text-properties start end (list 'mouse-face 'highlight
- 'keymap rcirc-browse-url-map))
+ (end (match-end 0))
+ (url (match-string-no-properties 0)))
+ (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 (buffer-substring-no-properties start end) rcirc-urls))))
+ (push url rcirc-urls))))
(defun rcirc-markup-keywords (sender response)
(when (and (string= response "PRIVMSG")