aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/gnus/gnus-art.el91
-rw-r--r--lisp/gnus/gnus-html.el36
-rw-r--r--lisp/gnus/gnus-icalendar.el5
-rw-r--r--lisp/gnus/gnus-sum.el30
-rw-r--r--lisp/gnus/mm-decode.el35
5 files changed, 60 insertions, 137 deletions
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index a38300ef66a..6d297d4c1d4 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -4381,7 +4381,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
4381;;; Gnus article mode 4381;;; Gnus article mode
4382;;; 4382;;;
4383 4383
4384(set-keymap-parent gnus-article-mode-map widget-keymap) 4384(set-keymap-parent gnus-article-mode-map button-buffer-map)
4385 4385
4386(gnus-define-keys gnus-article-mode-map 4386(gnus-define-keys gnus-article-mode-map
4387 " " gnus-article-goto-next-page 4387 " " gnus-article-goto-next-page
@@ -4874,6 +4874,7 @@ General format specifiers can also be used. See Info node
4874 4874
4875(defvar gnus-mime-button-map 4875(defvar gnus-mime-button-map
4876 (let ((map (make-sparse-keymap))) 4876 (let ((map (make-sparse-keymap)))
4877 (define-key map "\r" 'gnus-article-push-button)
4877 (define-key map [mouse-2] 'gnus-article-push-button) 4878 (define-key map [mouse-2] 'gnus-article-push-button)
4878 (define-key map [down-mouse-3] 'gnus-mime-button-menu) 4879 (define-key map [down-mouse-3] 'gnus-mime-button-menu)
4879 (dolist (c gnus-mime-button-commands) 4880 (dolist (c gnus-mime-button-commands)
@@ -4888,7 +4889,9 @@ General format specifiers can also be used. See Info node
4888 gnus-mime-button-commands))) 4889 gnus-mime-button-commands)))
4889 4890
4890(defvar gnus-url-button-commands 4891(defvar gnus-url-button-commands
4891 '((gnus-article-copy-string "u" "Copy URL to kill ring"))) 4892 '((gnus-article-copy-string "u" "Copy URL to kill ring")
4893 (push-button "\r" "Push the button")
4894 (push-button [mouse-2] "Push the button")))
4892 4895
4893(defvar gnus-url-button-map 4896(defvar gnus-url-button-map
4894 (let ((map (make-sparse-keymap))) 4897 (let ((map (make-sparse-keymap)))
@@ -5849,26 +5852,12 @@ all parts."
5849 ;; Exclude a newline. 5852 ;; Exclude a newline.
5850 (1- (point)) 5853 (1- (point))
5851 (point))) 5854 (point)))
5852 (when gnus-article-button-face 5855 (make-text-button
5853 (overlay-put (make-overlay b e nil t) 5856 b e
5854 'face gnus-article-button-face)) 5857 'keymap gnus-mime-button-map
5855 (widget-convert-button 5858 'face gnus-article-button-face
5856 'link b e 5859 'help-echo
5857 :mime-handle handle 5860 "mouse-2: toggle the MIME part; down-mouse-3: more options")))
5858 :action 'gnus-widget-press-button
5859 :button-keymap gnus-mime-button-map
5860 :help-echo
5861 (lambda (widget)
5862 (format
5863 "%S: %s the MIME part; %S: more options"
5864 'mouse-2
5865 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5866 "hide" "show")
5867 'down-mouse-3)))))
5868
5869(defun gnus-widget-press-button (elems _el)
5870 (goto-char (widget-get elems :from))
5871 (gnus-article-press-button))
5872 5861
5873(defvar gnus-displaying-mime nil) 5862(defvar gnus-displaying-mime nil)
5874 5863
@@ -6151,10 +6140,9 @@ If nil, don't show those extra buttons."
6151 mouse-face ,gnus-article-mouse-face 6140 mouse-face ,gnus-article-mouse-face
6152 face ,gnus-article-button-face 6141 face ,gnus-article-button-face
6153 gnus-part ,id 6142 gnus-part ,id
6143 button t
6154 article-type multipart 6144 article-type multipart
6155 rear-nonsticky t)) 6145 rear-nonsticky t))
6156 (widget-convert-button 'link from (point)
6157 :action 'gnus-widget-press-button)
6158 ;; Do the handles 6146 ;; Do the handles
6159 (while (setq handle (pop handles)) 6147 (while (setq handle (pop handles))
6160 (add-text-properties 6148 (add-text-properties
@@ -6175,10 +6163,9 @@ If nil, don't show those extra buttons."
6175 mouse-face ,gnus-article-mouse-face 6163 mouse-face ,gnus-article-mouse-face
6176 face ,gnus-article-button-face 6164 face ,gnus-article-button-face
6177 gnus-part ,id 6165 gnus-part ,id
6166 button t
6178 gnus-data ,handle 6167 gnus-data ,handle
6179 rear-nonsticky t)) 6168 rear-nonsticky t))
6180 (widget-convert-button 'link from (point)
6181 :action 'gnus-widget-press-button)
6182 (insert " ")) 6169 (insert " "))
6183 (insert "\n\n")) 6170 (insert "\n\n"))
6184 (when preferred 6171 (when preferred
@@ -8025,7 +8012,7 @@ url is put as the `gnus-button-url' overlay property on the button."
8025 (match-beginning 1)) 8012 (match-beginning 1))
8026 points))))) 8013 points)))))
8027 (match-beginning 2))) 8014 (match-beginning 2)))
8028 (let (gnus-article-mouse-face widget-mouse-face) 8015 (let (gnus-article-mouse-face)
8029 (while points 8016 (while points
8030 (gnus-article-add-button (pop points) (pop points) 8017 (gnus-article-add-button (pop points) (pop points)
8031 'gnus-button-push 8018 'gnus-button-push
@@ -8074,18 +8061,19 @@ url is put as the `gnus-button-url' overlay property on the button."
8074 8061
8075(defun gnus-article-add-button (from to fun &optional data text) 8062(defun gnus-article-add-button (from to fun &optional data text)
8076 "Create a button between FROM and TO with callback FUN and data DATA." 8063 "Create a button between FROM and TO with callback FUN and data DATA."
8077 (when gnus-article-button-face
8078 (overlay-put (make-overlay from to nil t)
8079 'face gnus-article-button-face))
8080 (add-text-properties 8064 (add-text-properties
8081 from to 8065 from to
8082 (nconc (and gnus-article-mouse-face 8066 (nconc (and gnus-article-mouse-face
8083 (list 'mouse-face gnus-article-mouse-face)) 8067 (list 'mouse-face gnus-article-mouse-face))
8084 (list 'gnus-callback fun) 8068 (list 'gnus-callback fun
8069 'button-data data
8070 'action fun
8071 'keymap gnus-url-button-map
8072 'category t
8073 'button t)
8085 (and data (list 'gnus-data data)))) 8074 (and data (list 'gnus-data data))))
8086 (widget-convert-button 'link from to :action 'gnus-widget-press-button 8075 (when gnus-article-button-face
8087 :help-echo (or text "Follow the link") 8076 (add-face-text-property from to gnus-article-button-face t)))
8088 :keymap gnus-url-button-map))
8089 8077
8090(defun gnus-article-copy-string () 8078(defun gnus-article-copy-string ()
8091 "Copy the string in the button to the kill ring." 8079 "Copy the string in the button to the kill ring."
@@ -8413,13 +8401,8 @@ url is put as the `gnus-button-url' overlay property on the button."
8413 ;; Exclude a newline. 8401 ;; Exclude a newline.
8414 (1- (point)) 8402 (1- (point))
8415 (point))) 8403 (point)))
8416 (when gnus-article-button-face 8404 (make-text-button b e 'keymap gnus-prev-page-map
8417 (overlay-put (make-overlay b e nil t) 8405 'face gnus-article-button-face)))
8418 'face gnus-article-button-face))
8419 (widget-convert-button
8420 'link b e
8421 :action 'gnus-button-prev-page
8422 :button-keymap gnus-prev-page-map)))
8423 8406
8424(defun gnus-button-next-page (&optional _args _more-args) 8407(defun gnus-button-next-page (&optional _args _more-args)
8425 "Go to the next page." 8408 "Go to the next page."
@@ -8449,13 +8432,8 @@ url is put as the `gnus-button-url' overlay property on the button."
8449 ;; Exclude a newline. 8432 ;; Exclude a newline.
8450 (1- (point)) 8433 (1- (point))
8451 (point))) 8434 (point)))
8452 (when gnus-article-button-face 8435 (make-text-button b e 'keymap gnus-next-page-map
8453 (overlay-put (make-overlay b e nil t) 8436 'face gnus-article-button-face)))
8454 'face gnus-article-button-face))
8455 (widget-convert-button
8456 'link b e
8457 :action 'gnus-button-next-page
8458 :button-keymap gnus-next-page-map)))
8459 8437
8460(defun gnus-article-button-next-page (_arg) 8438(defun gnus-article-button-next-page (_arg)
8461 "Go to the next page." 8439 "Go to the next page."
@@ -8708,6 +8686,7 @@ For example:
8708 8686
8709(defvar gnus-mime-security-button-map 8687(defvar gnus-mime-security-button-map
8710 (let ((map (make-sparse-keymap))) 8688 (let ((map (make-sparse-keymap)))
8689 (define-key map "\r" 'gnus-article-push-button)
8711 (define-key map [mouse-2] 'gnus-article-push-button) 8690 (define-key map [mouse-2] 'gnus-article-push-button)
8712 (define-key map [down-mouse-3] 'gnus-mime-security-button-menu) 8691 (define-key map [down-mouse-3] 'gnus-mime-security-button-menu)
8713 (dolist (c gnus-mime-security-button-commands) 8692 (dolist (c gnus-mime-security-button-commands)
@@ -8843,20 +8822,8 @@ For example:
8843 ;; Exclude a newline. 8822 ;; Exclude a newline.
8844 (1- (point)) 8823 (1- (point))
8845 (point))) 8824 (point)))
8846 (when gnus-article-button-face 8825 (make-text-button b e 'keymap gnus-mime-security-button-map
8847 (overlay-put (make-overlay b e nil t) 8826 'face gnus-article-button-face)))
8848 'face gnus-article-button-face))
8849 (widget-convert-button
8850 'link b e
8851 :mime-handle handle
8852 :action 'gnus-widget-press-button
8853 :button-keymap gnus-mime-security-button-map
8854 :help-echo
8855 (lambda (_widget)
8856 (format
8857 "%S: show detail; %S: more options"
8858 'mouse-2
8859 'down-mouse-3)))))
8860 8827
8861(defun gnus-mime-display-security (handle) 8828(defun gnus-mime-display-security (handle)
8862 (save-restriction 8829 (save-restriction
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index f36c3897876..92d760f4bf7 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -84,7 +84,7 @@ fit these criteria."
84 (define-key map "i" 'gnus-html-browse-image) 84 (define-key map "i" 'gnus-html-browse-image)
85 (define-key map "\r" 'gnus-html-browse-url) 85 (define-key map "\r" 'gnus-html-browse-url)
86 (define-key map "u" 'gnus-article-copy-string) 86 (define-key map "u" 'gnus-article-copy-string)
87 (define-key map [tab] 'widget-forward) 87 (define-key map [tab] 'button-forward)
88 map)) 88 map))
89 89
90(defun gnus-html-encode-url (url) 90(defun gnus-html-encode-url (url)
@@ -180,12 +180,10 @@ fit these criteria."
180 'image-displayer `(lambda (url start end) 180 'image-displayer `(lambda (url start end)
181 (gnus-html-display-image url start end 181 (gnus-html-display-image url start end
182 ,alt-text)) 182 ,alt-text))
183 'help-echo alt-text
184 'button t
185 'keymap gnus-html-image-map
183 'gnus-image (list url start end alt-text))) 186 'gnus-image (list url start end alt-text)))
184 (widget-convert-button
185 'url-link start (point)
186 :help-echo alt-text
187 :keymap gnus-html-image-map
188 url)
189 (if (string-match "\\`cid:" url) 187 (if (string-match "\\`cid:" url)
190 ;; URLs with cid: have their content stashed in other 188 ;; URLs with cid: have their content stashed in other
191 ;; parts of the MIME structure, so just insert them 189 ;; parts of the MIME structure, so just insert them
@@ -207,21 +205,15 @@ fit these criteria."
207 (delete-region start end)) 205 (delete-region start end))
208 "*") 206 "*")
209 'cid)) 207 'cid))
210 (widget-convert-button 208 (make-text-button start end
211 'link start end 209 'help-echo url
212 :action 'gnus-html-insert-image 210 'keymap gnus-html-image-map)))
213 :help-echo url
214 :keymap gnus-html-image-map
215 :button-keymap gnus-html-image-map)))
216 ;; Normal, external URL. 211 ;; Normal, external URL.
217 (if (or inhibit-images 212 (if (or inhibit-images
218 (gnus-html-image-url-blocked-p url blocked-images)) 213 (gnus-html-image-url-blocked-p url blocked-images))
219 (widget-convert-button 214 (make-text-button start end
220 'link start end 215 'help-echo url
221 :action 'gnus-html-insert-image 216 'keymap gnus-html-image-map)
222 :help-echo url
223 :keymap gnus-html-image-map
224 :button-keymap gnus-html-image-map)
225 ;; Non-blocked url 217 ;; Non-blocked url
226 (let ((width 218 (let ((width
227 (when (string-match "width=\"?\\([0-9]+\\)" parameters) 219 (when (string-match "width=\"?\\([0-9]+\\)" parameters)
@@ -444,11 +436,9 @@ Return a string with image data."
444 (let ((image (gnus-rescale-image image (gnus-html-maximum-image-size)))) 436 (let ((image (gnus-rescale-image image (gnus-html-maximum-image-size))))
445 (delete-region start end) 437 (delete-region start end)
446 (gnus-put-image image alt-text 'external) 438 (gnus-put-image image alt-text 'external)
447 (widget-convert-button 439 (make-text-button start (point)
448 'url-link start (point) 440 'help-echo alt-text
449 :help-echo alt-text 441 'keymap gnus-html-displayed-image-map)
450 :keymap gnus-html-displayed-image-map
451 url)
452 (put-text-property start (point) 'gnus-alt-text alt-text) 442 (put-text-property start (point) 'gnus-alt-text alt-text)
453 (when url 443 (when url
454 (add-text-properties 444 (add-text-properties
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 402e233d7fd..529cafe23e8 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -777,9 +777,8 @@ These will be used to retrieve the RSVP information from ical events."
777 ,callback 777 ,callback
778 keymap ,gnus-mime-button-map 778 keymap ,gnus-mime-button-map
779 face ,gnus-article-button-face 779 face ,gnus-article-button-face
780 gnus-data ,data)) 780 button t
781 (widget-convert-button 'link start (point) 781 gnus-data ,data))))
782 :action 'gnus-widget-press-button)))
783 782
784(defun gnus-icalendar-send-buffer-by-mail (buffer-name subject) 783(defun gnus-icalendar-send-buffer-by-mail (buffer-name subject)
785 (let ((message-signature nil)) 784 (let ((message-signature nil))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 320130f49bc..73f0eb39184 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9410,7 +9410,9 @@ Obeys the standard process/prefix convention."
9410 (t 9410 (t
9411 (error "Couldn't select virtual nndoc group"))))) 9411 (error "Couldn't select virtual nndoc group")))))
9412 9412
9413(defun gnus-summary-widget-forward (arg) 9413(define-obsolete-function-alias 'gnus-summary-widget-forward
9414 #'gnus-summary-button-forward "27.1")
9415(defun gnus-summary-button-forward (arg)
9414 "Move point to the next field or button in the article. 9416 "Move point to the next field or button in the article.
9415With optional ARG, move across that many fields." 9417With optional ARG, move across that many fields."
9416 (interactive "p") 9418 (interactive "p")
@@ -9420,9 +9422,11 @@ With optional ARG, move across that many fields."
9420 (error "No article window found")))) 9422 (error "No article window found"))))
9421 (select-window win) 9423 (select-window win)
9422 (select-frame-set-input-focus (window-frame win)) 9424 (select-frame-set-input-focus (window-frame win))
9423 (widget-forward arg))) 9425 (forward-button arg)))
9424 9426
9425(defun gnus-summary-widget-backward (arg) 9427(define-obsolete-function-alias 'gnus-summary-widget-backward
9428 #'gnus-summary-button-backward "27.1")
9429(defun gnus-summary-button-backward (arg)
9426 "Move point to the previous field or button in the article. 9430 "Move point to the previous field or button in the article.
9427With optional ARG, move across that many fields." 9431With optional ARG, move across that many fields."
9428 (interactive "p") 9432 (interactive "p")
@@ -9432,30 +9436,28 @@ With optional ARG, move across that many fields."
9432 (error "No article window found")))) 9436 (error "No article window found"))))
9433 (select-window win) 9437 (select-window win)
9434 (select-frame-set-input-focus (window-frame win)) 9438 (select-frame-set-input-focus (window-frame win))
9435 (unless (widget-at (point)) 9439 (unless (button-at (point))
9436 (goto-char (point-max))) 9440 (goto-char (point-max)))
9437 (widget-backward arg))) 9441 (backward-button arg)))
9438 9442
9439(defcustom gnus-collect-urls-primary-text "Link" 9443(defcustom gnus-collect-urls-primary-text "Link"
9440 "The widget text for the default link in `gnus-summary-browse-url'." 9444 "The button text for the default link in `gnus-summary-browse-url'."
9441 :version "27.1" 9445 :version "27.1"
9442 :type 'string 9446 :type 'string
9443 :group 'gnus-article-various) 9447 :group 'gnus-article-various)
9444 9448
9445(defun gnus-collect-urls () 9449(defun gnus-collect-urls ()
9446 "Return the list of URLs in the buffer after (point). 9450 "Return the list of URLs in the buffer after (point).
9447The 1st element is the widget named by `gnus-collect-urls-primary-text'." 9451The 1st element is the button named by `gnus-collect-urls-primary-text'."
9448 (let ((pt (point)) urls primary) 9452 (let ((pt (point)) urls primary)
9449 (while (progn (widget-move 1 t) ; no echo 9453 (while (forward-button 1 nil nil t)
9450 ;; `widget-move' wraps around to top of buffer.
9451 (> (point) pt))
9452 (setq pt (point)) 9454 (setq pt (point))
9453 (when-let ((w (widget-at pt)) 9455 (when-let ((w (button-at pt))
9454 (u (or (widget-value w) 9456 (u (or (button-get w 'shr-url)
9455 (get-text-property pt 'gnus-string)))) 9457 (get-text-property pt 'gnus-string))))
9456 (when (string-match-p "\\`[[:alpha:]]+://" u) 9458 (when (string-match-p "\\`[[:alpha:]]+://" u)
9457 (if (and gnus-collect-urls-primary-text (null primary) 9459 (if (and gnus-collect-urls-primary-text (null primary)
9458 (string= gnus-collect-urls-primary-text (widget-text w))) 9460 (string= gnus-collect-urls-primary-text (button-label w)))
9459 (setq primary u) 9461 (setq primary u)
9460 (push u urls))))) 9462 (push u urls)))))
9461 (setq urls (nreverse urls)) 9463 (setq urls (nreverse urls))
@@ -9489,7 +9491,7 @@ default."
9489 (gnus-summary-select-article) 9491 (gnus-summary-select-article)
9490 (gnus-with-article-buffer 9492 (gnus-with-article-buffer
9491 (article-goto-body) 9493 (article-goto-body)
9492 ;; Back up a char, in case body starts with a widget. 9494 ;; Back up a char, in case body starts with a button.
9493 (backward-char) 9495 (backward-char)
9494 (setq urls (gnus-collect-urls)) 9496 (setq urls (gnus-collect-urls))
9495 (setq target 9497 (setq target
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index c73bec0f19f..cba9633b539 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1829,7 +1829,6 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t)
1829 (shr-insert-document document) 1829 (shr-insert-document document)
1830 (unless (bobp) 1830 (unless (bobp)
1831 (insert "\n")) 1831 (insert "\n"))
1832 (mm-convert-shr-links)
1833 (mm-handle-set-undisplayer 1832 (mm-handle-set-undisplayer
1834 handle 1833 handle
1835 (let ((min (point-min-marker)) 1834 (let ((min (point-min-marker))
@@ -1838,40 +1837,6 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t)
1838 (let ((inhibit-read-only t)) 1837 (let ((inhibit-read-only t))
1839 (delete-region min max)))))))) 1838 (delete-region min max))))))))
1840 1839
1841(defvar shr-image-map)
1842(defvar shr-map)
1843(autoload 'widget-convert-button "wid-edit")
1844(defvar widget-keymap)
1845
1846(defun mm-convert-shr-links ()
1847 (let ((start (point-min))
1848 end keymap)
1849 (while (and start
1850 (< start (point-max)))
1851 (when (setq start (text-property-not-all start (point-max) 'shr-url nil))
1852 (setq end (next-single-property-change start 'shr-url nil (point-max)))
1853 (widget-convert-button
1854 'url-link start end
1855 :help-echo (get-text-property start 'help-echo)
1856 :keymap (setq keymap (copy-keymap
1857 (if (mm-images-in-region-p start end)
1858 shr-image-map
1859 shr-map)))
1860 (get-text-property start 'shr-url))
1861 ;; Mask keys that launch `widget-button-click'.
1862 ;; Those bindings are provided by `widget-keymap'
1863 ;; that is a parent of `gnus-article-mode-map'.
1864 (dolist (key (where-is-internal 'widget-button-click widget-keymap))
1865 (unless (lookup-key keymap key)
1866 (define-key keymap key #'ignore)))
1867 ;; Avoid `shr-next-link' and `shr-previous-link' in `keymap' so
1868 ;; TAB and M-TAB run `widget-forward' and `widget-backward' instead.
1869 (substitute-key-definition 'shr-next-link nil keymap)
1870 (substitute-key-definition 'shr-previous-link nil keymap)
1871 (dolist (overlay (overlays-at start))
1872 (overlay-put overlay 'face nil))
1873 (setq start end)))))
1874
1875(defun mm-handle-filename (handle) 1840(defun mm-handle-filename (handle)
1876 "Return filename of HANDLE if any." 1841 "Return filename of HANDLE if any."
1877 (or (mail-content-type-get (mm-handle-type handle) 1842 (or (mail-content-type-get (mm-handle-type handle)