aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2011-07-27 11:44:45 +0800
committerLeo Liu2011-07-27 11:44:45 +0800
commit1ddd96f5cf0b06846edd03d6b225c31206cee0b7 (patch)
treebd5ec0a933dddeabf117a56e133f0134fb08ba88
parentb248a85d103b7f34b9747e8d6884179bf3d4decb (diff)
downloademacs-1ddd96f5cf0b06846edd03d6b225c31206cee0b7.tar.gz
emacs-1ddd96f5cf0b06846edd03d6b225c31206cee0b7.zip
Simplify url handling in rcirc-mode
-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 @@
12011-07-27 Leo Liu <sdl.web@gmail.com>
2
3 Simplify url handling in rcirc-mode.
4
5 * net/rcirc.el (rcirc-browse-url-map, rcirc-browse-url-at-point)
6 (rcirc-browse-url-at-mouse): Remove.
7 * net/rcirc.el (rcirc-markup-urls): Use `make-button'.
8
12011-07-26 Alan Mackenzie <acm@muc.de> 92011-07-26 Alan Mackenzie <acm@muc.de>
2 10
3 Fontify bitfield declarations properly. 11 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."
935 map) 935 map)
936 "Keymap for rcirc mode.") 936 "Keymap for rcirc mode.")
937 937
938(defvar rcirc-browse-url-map
939 (let ((map (make-sparse-keymap)))
940 (define-key map (kbd "RET") 'rcirc-browse-url-at-point)
941 (define-key map (kbd "<mouse-2>") 'rcirc-browse-url-at-mouse)
942 (define-key map [follow-link] 'mouse-face)
943 map)
944 "Keymap used for browsing URLs in `rcirc-mode'.")
945
946(defvar rcirc-short-buffer-name nil 938(defvar rcirc-short-buffer-name nil
947 "Generated abbreviation to use to indicate buffer activity.") 939 "Generated abbreviation to use to indicate buffer activity.")
948 940
@@ -2351,21 +2343,6 @@ keywords when no KEYWORD is given."
2351 (browse-url (completing-read "rcirc browse-url: " 2343 (browse-url (completing-read "rcirc browse-url: "
2352 completions nil nil initial-input 'history) 2344 completions nil nil initial-input 'history)
2353 arg))) 2345 arg)))
2354
2355(defun rcirc-browse-url-at-point (point)
2356 "Send URL at point to `browse-url'."
2357 (interactive "d")
2358 (let ((beg (previous-single-property-change (1+ point) 'mouse-face))
2359 (end (next-single-property-change point 'mouse-face)))
2360 (browse-url (buffer-substring-no-properties beg end))))
2361
2362(defun rcirc-browse-url-at-mouse (event)
2363 "Send URL at mouse click to `browse-url'."
2364 (interactive "e")
2365 (let ((position (event-end event)))
2366 (with-current-buffer (window-buffer (posn-window position))
2367 (rcirc-browse-url-at-point (posn-point position)))))
2368
2369 2346
2370(defun rcirc-markup-timestamp (sender response) 2347(defun rcirc-markup-timestamp (sender response)
2371 (goto-char (point-min)) 2348 (goto-char (point-min))
@@ -2406,12 +2383,16 @@ keywords when no KEYWORD is given."
2406 (while (and rcirc-url-regexp ;; nil means disable URL catching 2383 (while (and rcirc-url-regexp ;; nil means disable URL catching
2407 (re-search-forward rcirc-url-regexp nil t)) 2384 (re-search-forward rcirc-url-regexp nil t))
2408 (let ((start (match-beginning 0)) 2385 (let ((start (match-beginning 0))
2409 (end (match-end 0))) 2386 (end (match-end 0))
2410 (rcirc-add-face start end 'rcirc-url) 2387 (url (match-string-no-properties 0)))
2411 (add-text-properties start end (list 'mouse-face 'highlight 2388 (make-button start end
2412 'keymap rcirc-browse-url-map)) 2389 'face 'rcirc-url
2390 'follow-link t
2391 'rcirc-url url
2392 'action (lambda (button)
2393 (browse-url (button-get button 'rcirc-url))))
2413 ;; record the url 2394 ;; record the url
2414 (push (buffer-substring-no-properties start end) rcirc-urls)))) 2395 (push url rcirc-urls))))
2415 2396
2416(defun rcirc-markup-keywords (sender response) 2397(defun rcirc-markup-keywords (sender response)
2417 (when (and (string= response "PRIVMSG") 2398 (when (and (string= response "PRIVMSG")