changeset 110166:514c8efbfdbb

gnus-html: Comment fix.; gnus-art.el: Provide an `u' command on urls and the like that copies the string over to the kill ring; Also have the `u' command work for HTML links.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 04 Sep 2010 00:12:44 +0000
parents b96da2a6e0df
children b8559a372ac8
files lisp/gnus/ChangeLog lisp/gnus/gnus-art.el lisp/gnus/gnus-html.el
diffstat 3 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Sat Sep 04 00:04:48 2010 +0000
+++ b/lisp/gnus/ChangeLog	Sat Sep 04 00:12:44 2010 +0000
@@ -1,3 +1,9 @@
+2010-09-03  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-art.el (gnus-article-copy-string): New command and key binding.
+
+	* gnus-html.el: Doc fix.
+
 2010-09-03  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-html.el (gnus-html-put-image): Use gnus-graphic-display-p,
--- a/lisp/gnus/gnus-art.el	Sat Sep 04 00:04:48 2010 +0000
+++ b/lisp/gnus/gnus-art.el	Sat Sep 04 00:12:44 2010 +0000
@@ -4823,6 +4823,22 @@
 		(vector (caddr c) (car c) :active t))
 	      gnus-mime-button-commands)))
 
+(defvar gnus-url-button-commands
+  '((gnus-article-copy-string "u" "Copy URL to kill ring")))
+
+(defvar gnus-url-button-map
+  (let ((map (make-sparse-keymap)))
+    (dolist (c gnus-url-button-commands)
+      (define-key map (cadr c) (car c)))
+    map))
+
+(easy-menu-define
+  gnus-url-button-menu gnus-url-button-map "URL button menu."
+  `("Url Button"
+    ,@(mapcar (lambda (c)
+		(vector (caddr c) (car c) :active t))
+	      gnus-url-button-commands)))
+
 (defmacro gnus-bind-safe-url-regexp (&rest body)
   "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
   `(let ((mm-w3m-safe-url-regexp
@@ -7813,7 +7829,11 @@
 	      (unless (and (eq (car entry) 'gnus-button-url-regexp)
 			   (gnus-article-extend-url-button from start end))
 		(gnus-article-add-button start end
-					 'gnus-button-push from)))))))))
+					 'gnus-button-push from)
+		(gnus-put-text-property
+		 start end
+		 'gnus-data (buffer-substring-no-properties
+			     start end))))))))))
 
 (defun gnus-article-extend-url-button (beg start end)
   "Extend url button if url is folded into two or more lines.
@@ -7918,8 +7938,19 @@
 	  (and data (list 'gnus-data data))))
   (widget-convert-button 'link from to :action 'gnus-widget-press-button
 			 :help-echo (or text "Follow the link")
+			 :keymap gnus-url-button-map
 			 :button-keymap gnus-widget-button-keymap))
 
+(defun gnus-article-copy-string ()
+  "Copy the string in the button to the kill ring."
+  (interactive)
+  (gnus-article-check-buffer)
+  (let ((data (get-text-property (point) 'gnus-data)))
+    (when data
+      (with-temp-buffer
+	(insert data)
+	(copy-region-as-kill (point-min) (point-max))))))
+
 ;;; Internal functions:
 
 (defun gnus-article-set-globals ()
--- a/lisp/gnus/gnus-html.el	Sat Sep 04 00:04:48 2010 +0000
+++ b/lisp/gnus/gnus-html.el	Sat Sep 04 00:12:44 2010 +0000
@@ -1,4 +1,4 @@
-;;; gnus-html.el --- Quoted-Printable functions
+;;; gnus-html.el --- Render HTML in a buffer.
 
 ;; Copyright (C) 2010  Free Software Foundation, Inc.