1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2016 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (defvar w3m-minor-mode-map
)
46 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
47 (autoload 'gnus-button-mailto
"gnus-msg")
48 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
49 (autoload 'parse-time-string
"parse-time" nil nil
)
50 (autoload 'ansi-color-apply-on-region
"ansi-color")
51 (autoload 'mm-url-insert-file-contents-external
"mm-url")
52 (autoload 'mm-extern-cache-contents
"mm-extern")
53 (autoload 'url-expand-file-name
"url-expand")
55 (defgroup gnus-article nil
57 :link
'(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link
'(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link
'(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link
'(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link
'(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link
'(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link
'(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link
'(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link
'(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link
'(custom-manual "(gnus)Using MIME")
104 :group
'gnus-article
)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link
'(custom-manual "(gnus)Article Buttons")
109 :group
'gnus-article
)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link
'(custom-manual "(gnus)Misc Article")
114 :group
'gnus-article
)
116 (defcustom gnus-ignored-headers
119 (concat "^" header
":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
158 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
159 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
160 "Envelope-Sender" "Envelope-Recipients"))
161 "*All headers that start with this regexp will be hidden.
162 This variable can also be a list of regexps of headers to be ignored.
163 If `gnus-visible-headers' is non-nil, this variable will be ignored."
164 :type
'(choice regexp
166 :group
'gnus-article-hiding
)
168 (defcustom gnus-visible-headers
169 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
174 (repeat :value-to-internal
(lambda (widget value
)
175 (custom-split-regexp-maybe value
))
176 :match
(lambda (widget value
)
178 (widget-editable-list-match widget value
)))
180 (const :tag
"Use gnus-ignored-headers" nil
)
182 :group
'gnus-article-hiding
)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "*This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type
'(repeat regexp
)
192 :group
'gnus-article-hiding
)
194 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 `empty' Headers with no content.
199 `newsgroups' Newsgroup identical to Gnus group.
200 `to-address' To identical to To-address.
201 `to-list' To identical to To-list.
202 `cc-list' CC identical to To-list.
203 `followup-to' Followup-to identical to Newsgroups.
204 `reply-to' Reply-to identical to From.
205 `date' Date less than four days old.
206 `long-to' To and/or Cc longer than 1024 characters.
207 `many-to' Multiple To and/or Cc."
208 :type
'(set (const :tag
"Headers with no content." empty
)
209 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
210 (const :tag
"To identical to To-address." to-address
)
211 (const :tag
"To identical to To-list." to-list
)
212 (const :tag
"CC identical to To-list." cc-list
)
213 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
214 (const :tag
"Reply-to identical to From." reply-to
)
215 (const :tag
"Date less than four days old." date
)
216 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
217 (const :tag
"Multiple To and/or Cc headers." many-to
))
218 :group
'gnus-article-hiding
)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
228 :group
'gnus-article-hiding
)
230 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
231 "Regexp matching signature separator.
232 This can also be a list of regexps. In that case, it will be checked
233 from head to tail looking for a separator. Searches will be done from
234 the end of the buffer."
235 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
237 (repeat :tag
"List of regexp" regexp
))
238 :group
'gnus-article-signature
)
240 (defcustom gnus-signature-limit nil
241 "Provide a limit to what is considered a signature.
242 If it is a number, no signature may not be longer (in characters) than
243 that number. If it is a floating point number, no signature may be
244 longer (in lines) than that number. If it is a function, the function
245 will be called without any parameters, and if it returns nil, there is
246 no signature in the buffer. If it is a string, it will be used as a
247 regexp. If it matches, the text in question is not a signature.
249 This can also be a list of the above values."
250 :type
'(choice (const nil
)
254 (regexp :value
".*"))
255 :group
'gnus-article-signature
)
257 (defcustom gnus-hidden-properties
258 ;; We use to have `intangible' here as well, but Emacs's command loop moves
259 ;; point out of invisible text anyway, so `intangible' is clearly not
260 ;; needed there. And XEmacs doesn't handle `intangible' anyway.
262 "Property list to use for hiding text."
264 :group
'gnus-article-hiding
)
266 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
267 ;; frames in a session.
268 (defcustom gnus-article-x-face-command
269 (if (gnus-image-type-available-p 'pbm
)
270 'gnus-display-x-face-in-from
272 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
273 ; uncompface; } | icontopbm | display -")
274 "*String or function to be executed to display an X-Face header.
275 If it is a string, the command will be executed in a sub-shell
276 asynchronously. The compressed face will be piped to this command."
277 :type
`(choice string
278 (function-item gnus-display-x-face-in-from
)
282 :group
'gnus-article-washing
)
284 (defcustom gnus-article-x-face-too-ugly nil
285 "Regexp matching posters whose face shouldn't be shown automatically."
286 :type
'(choice regexp
(const nil
))
287 :group
'gnus-article-washing
)
289 (defcustom gnus-article-banner-alist nil
290 "Banner alist for stripping.
292 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
294 :type
'(repeat (cons symbol regexp
))
295 :group
'gnus-article-washing
)
297 (gnus-define-group-parameter
300 "Alist of regexps (to match group names) and banner."
301 :variable-group gnus-article-washing
303 '(choice :tag
"Banner"
305 (const :tag
"Remove signature" signature
)
306 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
308 (const :tag
"None" nil
))
310 "If non-nil, specify how to remove `banners' from articles.
312 Symbol `signature' means to remove signatures delimited by
313 `gnus-signature-separator'. Any other symbol is used to look up a
314 regular expression to match the banner in `gnus-article-banner-alist'.
315 A string is used as a regular expression to match the banner
318 (defcustom gnus-article-address-banner-alist nil
319 "Alist of mail addresses and banners.
320 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
321 to match a mail address in the From: header, BANNER is one of a symbol
322 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
323 If ADDRESS matches author's mail address, it will remove things like
324 advertisements. For example:
326 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\\\='\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
330 (regexp :tag
"Address")
331 (choice :tag
"Banner" :value nil
332 (const :tag
"Remove signature" signature
)
333 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
335 (const :tag
"None" nil
))))
337 :group
'gnus-article-washing
)
339 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
341 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
342 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
345 (defun gnus-emphasis-custom-value-to-external (value)
346 (gnus-emphasis-custom-with-format
347 (if (consp (car value
))
348 (list (format format
(car (car value
)) (cdr (car value
)))
350 (if (nth 1 value
) 2 3)
354 (defun gnus-emphasis-custom-value-to-internal (value)
355 (gnus-emphasis-custom-with-format
356 (let ((regexp (concat "\\`"
357 (format (regexp-quote format
)
358 "\\([^()]+\\)" "\\([^()]+\\)")
361 (if (string-match regexp
(setq pattern
(car value
)))
362 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
367 (defcustom gnus-emphasis-alist
369 '(("\\*" "\\*" bold nil
2)
372 ("_/" "/_" underline-italic
)
373 ("_\\*" "\\*_" underline-bold
)
374 ("\\*/" "/\\*" bold-italic
)
375 ("_\\*/" "/\\*_" underline-bold-italic
))))
377 (gnus-emphasis-custom-with-format
378 (mapcar (lambda (spec)
379 (list (format format
(car spec
) (cadr spec
))
382 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
384 '(;; I've never seen anyone use this strikethru convention whereas I've
385 ;; several times seen it triggered by normal text. --Stef
386 ;; Miles suggests that this form is sometimes used but for italics,
387 ;; so maybe we should map it to `italic'.
388 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
389 ;; 2 3 gnus-emphasis-strikethru)
390 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
391 2 3 gnus-emphasis-underline
))))
392 "*Alist that says how to fontify certain phrases.
393 Each item looks like this:
395 (\"_\\\\(\\\\w+\\\\)_\" 0 1 \\='underline)
397 The first element is a regular expression to be matched. The second
398 is a number that says what regular expression grouping used to find
399 the entire emphasized word. The third is a number that says what
400 regexp grouping should be displayed and highlighted. The fourth
401 is the face used for highlighting."
405 :format
"%[Customizing Style%]\n%v"
407 (group :tag
"Default"
408 :value
("" 0 0 default
)
411 (let ((value (widget-get
412 (cadr (widget-get (widget-get widget
:parent
)
415 (if (not (eq (nth 2 value
) 'default
))
419 (gnus-emphasis-custom-value-to-external value
))))
420 (widget-group-value-create widget
))
422 (integer :format
"Match group: %v")
423 (integer :format
"Emphasize group: %v")
426 :value
(("_" .
"_") nil default
)
428 (regexp :format
"Start regexp: %v")
429 (regexp :format
"End regexp: %v"))
430 (boolean :format
"Show start and end patterns: %[%v%]\n"
431 :on
" On " :off
" Off ")
433 :get
(lambda (symbol)
434 (mapcar 'gnus-emphasis-custom-value-to-internal
435 (default-value symbol
)))
436 :set
(lambda (symbol value
)
437 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
439 :group
'gnus-article-emphasis
)
441 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
442 "A regexp to describe whitespace which should not be emphasized.
443 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
444 The former avoids underlining of leading and trailing whitespace,
445 and the latter avoids underlining any whitespace at all."
447 :group
'gnus-article-emphasis
450 (defface gnus-emphasis-bold
'((t (:bold t
)))
451 "Face used for displaying strong emphasized text (*word*)."
452 :group
'gnus-article-emphasis
)
454 (defface gnus-emphasis-italic
'((t (:italic t
)))
455 "Face used for displaying italic emphasized text (/word/)."
456 :group
'gnus-article-emphasis
)
458 (defface gnus-emphasis-underline
'((t (:underline t
)))
459 "Face used for displaying underlined emphasized text (_word_)."
460 :group
'gnus-article-emphasis
)
462 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
463 "Face used for displaying underlined bold emphasized text (_*word*_)."
464 :group
'gnus-article-emphasis
)
466 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
467 "Face used for displaying underlined italic emphasized text (_/word/_)."
468 :group
'gnus-article-emphasis
)
470 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
471 "Face used for displaying bold italic emphasized text (/*word*/)."
472 :group
'gnus-article-emphasis
)
474 (defface gnus-emphasis-underline-bold-italic
475 '((t (:bold t
:italic t
:underline t
)))
476 "Face used for displaying underlined bold italic emphasized text.
477 Example: (_/*word*/_)."
478 :group
'gnus-article-emphasis
)
480 (defface gnus-emphasis-strikethru
'((t (:strike-through t
)))
481 "Face used for displaying strike-through text (-word-)."
482 :group
'gnus-article-emphasis
)
484 (defface gnus-emphasis-highlight-words
485 '((t (:background
"black" :foreground
"yellow")))
486 "Face used for displaying highlighted words."
487 :group
'gnus-article-emphasis
)
489 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
490 "Format for display of Date headers in article bodies.
491 See `format-time-string' for the possible values.
493 The variable can also be function, which should return a complete Date
494 header. The function is called with one argument, the time, which can
495 be fed to `format-time-string'."
496 :type
'(choice string function
)
497 :link
'(custom-manual "(gnus)Article Date")
498 :group
'gnus-article-washing
)
500 (defcustom gnus-save-all-headers t
501 "*If non-nil, don't remove any headers before saving.
502 This will be overridden by the `:headers' property that the symbol of
503 the saver function, which is specified by `gnus-default-article-saver',
505 :group
'gnus-article-saving
508 (defcustom gnus-prompt-before-saving
'always
509 "*This variable says how much prompting is to be done when saving articles.
510 If it is nil, no prompting will be done, and the articles will be
511 saved to the default files. If this variable is `always', each and
512 every article that is saved will be preceded by a prompt, even when
513 saving large batches of articles. If this variable is neither nil not
514 `always', there the user will be prompted once for a file name for
515 each invocation of the saving commands."
516 :group
'gnus-article-saving
517 :type
'(choice (item always
)
518 (item :tag
"never" nil
)
519 (sexp :tag
"once" :format
"%t\n" :value t
)))
521 (defcustom gnus-article-show-cursor nil
522 "If non-nil, show the cursor in the Article buffer even when not selected."
527 (defcustom gnus-saved-headers gnus-visible-headers
528 "Headers to keep if `gnus-save-all-headers' is nil.
529 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
530 If that variable is nil, however, all headers that match this regexp
531 will be kept while the rest will be deleted before saving. This and
532 `gnus-save-all-headers' will be overridden by the `:headers' property
533 that the symbol of the saver function, which is specified by
534 `gnus-default-article-saver', might have."
535 :group
'gnus-article-saving
538 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
539 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
540 "A function to save articles in your favorite format.
541 The function will be called by way of the `gnus-summary-save-article'
542 command, and friends such as `gnus-summary-save-article-rmail'.
544 Gnus provides the following functions:
546 * gnus-summary-save-in-rmail (Rmail format)
547 * gnus-summary-save-in-mail (Unix mail format)
548 * gnus-summary-save-in-folder (MH folder)
549 * gnus-summary-save-in-file (article format)
550 * gnus-summary-save-body-in-file (article body)
551 * gnus-summary-save-in-vm (use VM's folder format)
552 * gnus-summary-write-to-file (article format -- overwrite)
553 * gnus-summary-write-body-to-file (article body -- overwrite)
554 * gnus-summary-save-in-pipe (article format)
556 The symbol of each function may have the following properties:
559 The value non-nil means save decoded articles. This is meaningful
560 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
561 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
562 `gnus-summary-save-in-pipe'.
565 The value specifies an alternative function which appends, not
566 overwrites, articles to a file. This implies that when saving many
567 articles at a time, `gnus-prompt-before-saving' is bound to t and all
568 articles are saved in a single file. This is meaningful only with
569 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
572 The value specifies the symbol of a variable of which the value
573 specifies headers to be saved. If it is omitted,
574 `gnus-save-all-headers' and `gnus-saved-headers' control what
575 headers should be saved."
576 :group
'gnus-article-saving
577 :type
'(radio (function-item gnus-summary-save-in-rmail
)
578 (function-item gnus-summary-save-in-mail
)
579 (function-item gnus-summary-save-in-folder
)
580 (function-item gnus-summary-save-in-file
)
581 (function-item gnus-summary-save-body-in-file
)
582 (function-item gnus-summary-save-in-vm
)
583 (function-item gnus-summary-write-to-file
)
584 (function-item gnus-summary-write-body-to-file
)
585 (function-item gnus-summary-save-in-pipe
)
588 (defcustom gnus-article-save-coding-system
589 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
590 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
591 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
592 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
593 "Coding system used to save decoded articles to a file.
595 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
596 which can safely encode any characters in text. This is used by the
599 * gnus-summary-save-article-file
600 * gnus-summary-save-article-body-file
601 * gnus-summary-write-article-file
602 * gnus-summary-write-article-body-file
604 and the functions to which you may set `gnus-default-article-saver':
606 * gnus-summary-save-in-file
607 * gnus-summary-save-body-in-file
608 * gnus-summary-write-to-file
609 * gnus-summary-write-body-to-file
611 Those commands and functions save just text displayed in the article
612 buffer to a file if the value of this variable is non-nil. Note that
613 buttonized MIME parts will be lost in a saved file in that case.
614 Otherwise, raw articles will be saved."
615 :group
'gnus-article-saving
617 :format
"%{%t%}:\n %[Value Menu%] %v"
618 (const :tag
"Save raw articles" nil
)
621 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
622 '((const :tag
"UTF-8" utf-8
)
623 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
624 (const :tag
"Emacs internal" emacs-mule
)
625 (const :tag
"escape-quoted" escape-quoted
))))
626 (symbol :tag
"Coding system")))
628 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
629 "A function generating a file name to save articles in Rmail format.
630 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
631 :group
'gnus-article-saving
634 (defcustom gnus-mail-save-name
'gnus-plain-save-name
635 "A function generating a file name to save articles in Unix mail format.
636 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
637 :group
'gnus-article-saving
640 (defcustom gnus-folder-save-name
'gnus-folder-save-name
641 "A function generating a file name to save articles in MH folder.
642 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
643 :group
'gnus-article-saving
646 (defcustom gnus-file-save-name
'gnus-numeric-save-name
647 "A function generating a file name to save articles in article format.
648 The function is called with NEWSGROUP, HEADERS, and optional
650 :group
'gnus-article-saving
653 (defcustom gnus-split-methods
654 '((gnus-article-archive-name)
655 (gnus-article-nndoc-name))
656 "*Variable used to suggest where articles are to be saved.
657 For instance, if you would like to save articles related to Gnus in
658 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
659 you could set this variable to something like:
661 ((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
662 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
664 This variable is an alist where the key is the match and the
665 value is a list of possible files to save in if the match is
668 If the match is a string, it is used as a regexp match on the
669 article. If the match is a symbol, that symbol will be funcalled
670 from the buffer of the article to be saved with the newsgroup as the
671 parameter. If it is a list, it will be evalled in the same buffer.
673 If this form or function returns a string, this string will be used as a
674 possible file name; and if it returns a non-nil list, that list will be
675 used as possible file names."
676 :group
'gnus-article-saving
677 :type
'(repeat (choice (list :value
(fun) function
)
678 (cons :value
("" "") regexp
(repeat string
))
681 (defcustom gnus-page-delimiter
"^\^L"
682 "*Regexp describing what to use as article page delimiters.
683 The default value is \"^\^L\", which is a form linefeed at the
684 beginning of a line."
686 :group
'gnus-article-various
)
688 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
689 "*The format specification for the article mode line.
690 See `gnus-summary-mode-line-format' for a closer description.
692 The following additional specs are available:
694 %w The article washing status.
695 %m The number of MIME parts in the article."
698 :group
'gnus-article-various
)
700 (defcustom gnus-article-mode-hook nil
701 "*A hook for Gnus article mode."
703 :group
'gnus-article-various
)
705 (defcustom gnus-article-menu-hook nil
706 "*Hook run after the creation of the article mode menu."
708 :group
'gnus-article-various
)
710 (defcustom gnus-article-prepare-hook nil
711 "*A hook called after an article has been prepared in the article buffer."
713 :group
'gnus-article-various
)
715 (defcustom gnus-copy-article-ignored-headers nil
716 "List of headers to be removed when copying an article.
717 Each element is a regular expression."
718 :version
"23.1" ;; No Gnus
719 :type
'(repeat regexp
)
720 :group
'gnus-article-various
)
722 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
723 "Gnus 5.10 (Emacs 22.1)")
726 '((t (:weight bold
)))
727 "Face used for highlighting a button in the article buffer."
728 :group
'gnus-article-buttons
)
730 (defcustom gnus-article-button-face
'gnus-button
731 "Face used for highlighting buttons in the article buffer.
733 An article button is a piece of text that you can activate by pressing
734 `RET' or `mouse-2' above it."
736 :group
'gnus-article-buttons
)
738 (defcustom gnus-article-mouse-face
'highlight
739 "Face used for mouse highlighting in the article buffer.
741 Article buttons will be displayed in this face when the cursor is
744 :group
'gnus-article-buttons
)
746 (defcustom gnus-signature-face
'gnus-signature
747 "Face used for highlighting a signature in the article buffer.
748 Obsolete; use the face `gnus-signature' for customizations instead."
750 :group
'gnus-article-highlight
751 :group
'gnus-article-signature
)
753 (defface gnus-signature
756 "Face used for highlighting a signature in the article buffer."
757 :group
'gnus-article-highlight
758 :group
'gnus-article-signature
)
759 ;; backward-compatibility alias
760 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
761 (put 'gnus-signature-face
'obsolete-face
"22.1")
763 (defface gnus-header-from
766 (:foreground
"PaleGreen1"))
769 (:foreground
"red3"))
772 "Face used for displaying from headers."
773 :group
'gnus-article-headers
774 :group
'gnus-article-highlight
)
775 ;; backward-compatibility alias
776 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
777 (put 'gnus-header-from-face
'obsolete-face
"22.1")
779 (defface gnus-header-subject
782 (:foreground
"SeaGreen1"))
785 (:foreground
"red4"))
787 (:bold t
:italic t
)))
788 "Face used for displaying subject headers."
789 :group
'gnus-article-headers
790 :group
'gnus-article-highlight
)
791 ;; backward-compatibility alias
792 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
793 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
795 (defface gnus-header-newsgroups
798 (:foreground
"yellow" :italic t
))
801 (:foreground
"MidnightBlue" :italic t
))
804 "Face used for displaying newsgroups headers.
805 In the default setup this face is only used for crossposted
807 :group
'gnus-article-headers
808 :group
'gnus-article-highlight
)
809 ;; backward-compatibility alias
810 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
811 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
813 (defface gnus-header-name
816 (:foreground
"SpringGreen2"))
819 (:foreground
"maroon"))
822 "Face used for displaying header names."
823 :group
'gnus-article-headers
824 :group
'gnus-article-highlight
)
825 ;; backward-compatibility alias
826 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
827 (put 'gnus-header-name-face
'obsolete-face
"22.1")
829 (defface gnus-header-content
832 (:foreground
"SpringGreen1" :italic t
))
835 (:foreground
"indianred4" :italic t
))
837 (:italic t
))) "Face used for displaying header content."
838 :group
'gnus-article-headers
839 :group
'gnus-article-highlight
)
840 ;; backward-compatibility alias
841 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
842 (put 'gnus-header-content-face
'obsolete-face
"22.1")
844 (defcustom gnus-header-face-alist
845 '(("From" nil gnus-header-from
)
846 ("Subject" nil gnus-header-subject
)
847 ("Newsgroups:.*," nil gnus-header-newsgroups
)
848 ("" gnus-header-name gnus-header-content
))
849 "*Controls highlighting of article headers.
851 An alist of the form (HEADER NAME CONTENT).
853 HEADER is a regular expression which should match the name of a
854 header and NAME and CONTENT are either face names or nil.
856 The name of each header field will be displayed using the face
857 specified by the first element in the list where HEADER matches
858 the header name and NAME is non-nil. Similarly, the content will
859 be displayed by the first non-nil matching CONTENT face."
860 :group
'gnus-article-headers
861 :group
'gnus-article-highlight
862 :type
'(repeat (list (regexp :tag
"Header")
864 (item :tag
"skip" nil
)
865 (face :value default
))
866 (choice :tag
"Content"
867 (item :tag
"skip" nil
)
868 (face :value default
)))))
870 (defcustom gnus-face-properties-alist
'((pbm .
(:face gnus-x-face
))
872 "Alist of image types and properties applied to Face and X-Face images.
875 ;; Specify the altitude of Face images in the From header.
876 \(setq gnus-face-properties-alist
877 \\='((pbm . (:face gnus-x-face :ascent 80))
878 (png . (:ascent 80))))
880 ;; Show Face images as pressed buttons.
881 \(setq gnus-face-properties-alist
882 \\='((pbm . (:face gnus-x-face :relief -2))
883 (png . (:relief -2))))
885 See the manual for the valid properties for various image types.
886 Currently, `pbm' is used for X-Face images and `png' is used for Face
888 :version
"23.1" ;; No Gnus
889 :group
'gnus-article-headers
890 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
892 (defcustom gnus-article-decode-hook
893 '(article-decode-charset article-decode-encoded-words
894 article-decode-group-name article-decode-idna-rhs
)
895 "*Hook run to decode charsets in articles."
896 :group
'gnus-article-headers
899 (defcustom gnus-display-mime-function
'gnus-display-mime
900 "Function to display MIME articles."
901 :group
'gnus-article-mime
904 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
905 "Function used to decode headers.")
907 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
908 "Function used to decode addresses.")
910 (defvar gnus-article-dumbquotes-map
930 "Table for MS-to-Latin1 translation.")
932 (defcustom gnus-ignored-mime-types nil
933 "List of MIME types that should be ignored by Gnus."
935 :group
'gnus-article-mime
936 :type
'(repeat regexp
))
938 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
939 "List of MIME types that should not be given buttons when rendered inline.
940 See also `gnus-buttonized-mime-types' which may override this variable.
941 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
943 :group
'gnus-article-mime
944 :type
'(repeat regexp
))
946 (defcustom gnus-buttonized-mime-types nil
947 "List of MIME types that should be given buttons when rendered inline.
948 If set, this variable overrides `gnus-unbuttonized-mime-types'.
949 To see e.g. security buttons you could set this to
950 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
951 this list to display radio buttons that allow you to choose one of two
952 media types those mails include. See also `mm-discouraged-alternatives'.
953 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
955 :group
'gnus-article-mime
956 :type
'(repeat regexp
))
958 (defcustom gnus-inhibit-mime-unbuttonizing nil
959 "If non-nil, all MIME parts get buttons.
960 When nil (the default value), then some MIME parts do not get buttons,
961 as described by the variables `gnus-buttonized-mime-types' and
962 `gnus-unbuttonized-mime-types'."
964 :group
'gnus-article-mime
967 (defcustom gnus-body-boundary-delimiter
"_"
968 "String used to delimit header and body.
969 This variable is used by `gnus-article-treat-body-boundary' which can
970 be controlled by `gnus-treat-body-boundary'."
972 :group
'gnus-article-various
973 :type
'(choice (item :tag
"None" :value nil
)
976 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
978 "Defines the location of the faces database.
979 For information on obtaining this database of pretty pictures, please
980 see http://www.cs.indiana.edu/picons/ftp/index.html"
982 :type
'(repeat directory
)
983 :link
'(url-link :tag
"download"
984 "http://www.cs.indiana.edu/picons/ftp/index.html")
985 :link
'(custom-manual "(gnus)Picons")
988 (defun gnus-picons-installed-p ()
989 "Say whether picons are installed on your machine."
990 (let ((installed nil
))
991 (dolist (database gnus-picon-databases
)
992 (when (file-exists-p database
)
996 (defcustom gnus-article-mime-part-function nil
997 "Function called with a MIME handle as the argument.
998 This is meant for people who want to do something automatic based
999 on parts -- for instance, adding Vcard info to a database."
1000 :group
'gnus-article-mime
1001 :type
'(choice (const nil
)
1004 (defcustom gnus-mime-multipart-functions nil
1005 "An alist of MIME types to functions to display them."
1007 :group
'gnus-article-mime
1008 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1010 (defcustom gnus-article-date-headers
'(combined-lapsed)
1011 "A list of Date header formats to display.
1012 Valid formats are `ut' (Universal Time), `local' (local time
1013 zone), `english' (readable English), `lapsed' (elapsed time),
1014 `combined-lapsed' (both the original date and the elapsed time),
1015 `original' (the original date header), `iso8601' (ISO8601
1016 format), and `user-defined' (a user-defined format defined by the
1017 `gnus-article-time-format' variable).
1019 You have as many date headers as you want in the article buffer.
1020 Some of these headers are updated automatically. See
1021 `gnus-article-update-date-headers' for details."
1023 :group
'gnus-article-headers
1025 (const :tag
"Universal time (UT)" ut
)
1026 (const :tag
"Local time zone" local
)
1027 (const :tag
"Readable English" english
)
1028 (const :tag
"Elapsed time" lapsed
)
1029 (const :tag
"Original and elapsed time" combined-lapsed
)
1030 (const :tag
"Original date header" original
)
1031 (const :tag
"ISO8601 format" iso8601
)
1032 (const :tag
"User-defined" user-defined
)))
1034 (defcustom gnus-article-update-date-headers nil
1035 "A number that says how often to update the date header (in seconds).
1036 If nil, don't update it at all."
1038 :group
'gnus-article-headers
1040 (item :tag
"Don't update" :value nil
)
1043 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1044 "Function called with a MIME handle as the argument.
1045 This is meant for people who want to view first matched part.
1046 For `undisplayed-alternative' (default), the first undisplayed
1047 part or alternative part is used. For `undisplayed', the first
1048 undisplayed part is used. For a function, the first part which
1049 the function return t is used. For nil, the first part is
1052 :group
'gnus-article-mime
1054 (item :tag
"first" :value nil
)
1055 (item :tag
"undisplayed" :value undisplayed
)
1056 (item :tag
"undisplayed or alternative"
1057 :value undisplayed-alternative
)
1060 (defcustom gnus-mime-action-alist
1061 '(("save to file" . gnus-mime-save-part
)
1062 ("save and strip" . gnus-mime-save-part-and-strip
)
1063 ("replace with file" . gnus-mime-replace-part
)
1064 ("delete part" . gnus-mime-delete-part
)
1065 ("display as text" . gnus-mime-inline-part
)
1066 ("view the part" . gnus-mime-view-part
)
1067 ("pipe to command" . gnus-mime-pipe-part
)
1068 ("toggle display" . gnus-article-press-button
)
1069 ("toggle display" . gnus-article-view-part-as-charset
)
1070 ("view as type" . gnus-mime-view-part-as-type
)
1071 ("view internally" . gnus-mime-view-part-internally
)
1072 ("view externally" . gnus-mime-view-part-externally
))
1073 "An alist of actions that run on the MIME attachment."
1074 :group
'gnus-article-mime
1075 :type
'(repeat (cons (string :tag
"name")
1078 (defcustom gnus-auto-select-part
1
1079 "Advance to next MIME part when deleting or stripping parts.
1081 When 0, point will be placed on the same part as before. When
1082 positive (negative), move point forward (backwards) this many
1083 parts. When nil, redisplay article."
1084 :version
"23.1" ;; No Gnus
1085 :group
'gnus-article-mime
1086 :type
'(choice (const nil
:tag
"Redisplay article.")
1087 (const 1 :tag
"Next part.")
1088 (const 0 :tag
"Current part.")
1092 ;;; The treatment variables
1095 (defvar gnus-part-display-hook nil
1096 "Hook called on parts that are to receive treatment.")
1098 (defvar gnus-article-treat-custom
1099 '(choice (const :tag
"Off" nil
)
1101 (const :tag
"Header" head
)
1102 (const :tag
"First" first
)
1103 (const :tag
"Last" last
)
1104 (integer :tag
"Less")
1105 (repeat :tag
"Groups" regexp
)
1106 (sexp :tag
"Predicate")))
1108 (defvar gnus-article-treat-head-custom
1109 '(choice (const :tag
"Off" nil
)
1110 (const :tag
"Header" head
)))
1112 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1113 "text/x-patch" "text/html")
1114 "Part types eligible for treatment.")
1116 (defvar gnus-inhibit-treatment nil
1117 "Whether to inhibit treatment.")
1119 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1120 "Highlight the signature.
1121 Valid values are nil, t, `head', `first', `last', an integer or a
1122 predicate. See Info node `(gnus)Customizing Articles'."
1123 :group
'gnus-article-treat
1124 :link
'(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom
)
1126 (put 'gnus-treat-highlight-signature
'highlight t
)
1128 (defcustom gnus-treat-buttonize
'(and 100000 (typep "text/plain"))
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group
'gnus-article-treat
1133 :link
'(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom
)
1135 (put 'gnus-treat-buttonize
'highlight t
)
1137 (defcustom gnus-treat-buttonize-head
'head
1138 "Add buttons to the head.
1139 Valid values are nil, t, `head', `first', `last', an integer or a
1140 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group
'gnus-article-treat
1142 :link
'(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-head-custom
)
1144 (put 'gnus-treat-buttonize-head
'highlight t
)
1146 (defcustom gnus-treat-date
'head
1147 "Display dates according to the `gnus-article-date-headers' variable.
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1151 :group
'gnus-article-treat
1152 :link
'(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-head-custom
)
1155 (defcustom gnus-treat-emphasize
50000
1157 Valid values are nil, t, `head', `first', `last', an integer or a
1158 predicate. See Info node `(gnus)Customizing Articles'."
1159 :group
'gnus-article-treat
1160 :link
'(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom
)
1162 (put 'gnus-treat-emphasize
'highlight t
)
1164 (defcustom gnus-treat-strip-cr nil
1165 "Remove carriage returns.
1166 Valid values are nil, t, `head', `first', `last', an integer or a
1167 predicate. See Info node `(gnus)Customizing Articles'."
1169 :group
'gnus-article-treat
1170 :link
'(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-custom
)
1173 (defcustom gnus-treat-unsplit-urls nil
1174 "Remove newlines from within URLs.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group
'gnus-article-treat
1179 :link
'(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom
)
1182 (defcustom gnus-treat-leading-whitespace nil
1183 "Remove leading whitespace in headers.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1187 :group
'gnus-article-treat
1188 :link
'(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom
)
1191 (defcustom gnus-treat-hide-headers
'head
1193 Valid values are nil, t, `head', `first', `last', an integer or a
1194 predicate. See Info node `(gnus)Customizing Articles'."
1195 :group
'gnus-article-treat
1196 :link
'(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-head-custom
)
1199 (defcustom gnus-treat-hide-boring-headers nil
1200 "Hide boring headers.
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group
'gnus-article-treat
1204 :link
'(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-head-custom
)
1207 (defcustom gnus-treat-hide-signature nil
1208 "Hide the signature.
1209 Valid values are nil, t, `head', `first', `last', an integer or a
1210 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group
'gnus-article-treat
1212 :link
'(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom
)
1215 (defcustom gnus-treat-fill-article nil
1217 Valid values are nil, t, `head', `first', `last', an integer or a
1218 predicate. See Info node `(gnus)Customizing Articles'."
1219 :group
'gnus-article-treat
1220 :link
'(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-custom
)
1223 (defcustom gnus-treat-hide-citation nil
1225 Valid values are nil, t, `head', `first', `last', an integer or a
1226 predicate. See Info node `(gnus)Customizing Articles'.
1228 See `gnus-article-highlight-citation' for variables used to
1229 control what it hides."
1230 :group
'gnus-article-treat
1231 :link
'(custom-manual "(gnus)Customizing Articles")
1232 :type gnus-article-treat-custom
)
1234 (defcustom gnus-treat-hide-citation-maybe nil
1235 "Hide cited text according to certain conditions.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'.
1239 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1240 how to control what it hides."
1241 :group
'gnus-article-treat
1242 :link
'(custom-manual "(gnus)Customizing Articles")
1243 :type gnus-article-treat-custom
)
1245 (defcustom gnus-treat-strip-list-identifiers
'head
1246 "Strip list identifiers from `gnus-list-identifiers'.
1247 Valid values are nil, t, `head', `first', `last', an integer or a
1248 predicate. See Info node `(gnus)Customizing Articles'."
1250 :group
'gnus-article-treat
1251 :link
'(custom-manual "(gnus)Customizing Articles")
1252 :type gnus-article-treat-custom
)
1254 (gnus-define-group-parameter
1257 "Alist of regexps and correspondent identifiers."
1258 :variable-group gnus-article-washing
1260 '(choice :tag
"Identifier"
1262 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1264 (const :tag
"None" nil
))
1266 "If non-nil, specify how to remove `identifiers' from articles' subject.
1268 Any symbol is used to look up a regular expression to match the
1269 banner in `gnus-list-identifiers'. A string is used as a regular
1270 expression to match the identifier directly.")
1272 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1273 "Gnus 5.10 (Emacs 22.1)")
1275 (defcustom gnus-treat-strip-pem nil
1276 "Strip PEM signatures.
1277 Valid values are nil, t, `head', `first', `last', an integer or a
1278 predicate. See Info node `(gnus)Customizing Articles'."
1279 :group
'gnus-article-treat
1280 :link
'(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-custom
)
1283 (defcustom gnus-treat-strip-banner t
1284 "Strip banners from articles.
1285 The banner to be stripped is specified in the `banner' group parameter.
1286 Valid values are nil, t, `head', `first', `last', an integer or a
1287 predicate. See Info node `(gnus)Customizing Articles'."
1288 :group
'gnus-article-treat
1289 :link
'(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-custom
)
1292 (defcustom gnus-treat-highlight-headers
'head
1293 "Highlight the headers.
1294 Valid values are nil, t, `head', `first', `last', an integer or a
1295 predicate. See Info node `(gnus)Customizing Articles'."
1296 :group
'gnus-article-treat
1297 :link
'(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-head-custom
)
1299 (put 'gnus-treat-highlight-headers
'highlight t
)
1301 (defcustom gnus-treat-highlight-citation t
1302 "Highlight cited text.
1303 Valid values are nil, t, `head', `first', `last', an integer or a
1304 predicate. See Info node `(gnus)Customizing Articles'."
1305 :group
'gnus-article-treat
1306 :link
'(custom-manual "(gnus)Customizing Articles")
1307 :type gnus-article-treat-custom
)
1308 (put 'gnus-treat-highlight-citation
'highlight t
)
1310 (defcustom gnus-treat-strip-headers-in-body t
1311 "Strip the X-No-Archive header line from the beginning of the body.
1312 Valid values are nil, t, `head', `first', `last', an integer or a
1313 predicate. See Info node `(gnus)Customizing Articles'."
1315 :group
'gnus-article-treat
1316 :link
'(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom
)
1319 (defcustom gnus-treat-strip-trailing-blank-lines nil
1320 "Strip trailing blank lines.
1321 Valid values are nil, t, `head', `first', `last', an integer or a
1322 predicate. See Info node `(gnus)Customizing Articles'.
1324 When set to t, it also strips trailing blanks in all MIME parts.
1325 Consider to use `last' instead."
1326 :group
'gnus-article-treat
1327 :link
'(custom-manual "(gnus)Customizing Articles")
1328 :type gnus-article-treat-custom
)
1330 (defcustom gnus-treat-strip-leading-blank-lines nil
1331 "Strip leading blank lines.
1332 Valid values are nil, t, `head', `first', `last', an integer or a
1333 predicate. See Info node `(gnus)Customizing Articles'.
1335 When set to t, it also strips trailing blanks in all MIME parts."
1336 :group
'gnus-article-treat
1337 :link
'(custom-manual "(gnus)Customizing Articles")
1338 :type gnus-article-treat-custom
)
1340 (defcustom gnus-treat-strip-multiple-blank-lines nil
1341 "Strip multiple blank lines.
1342 Valid values are nil, t, `head', `first', `last', an integer or a
1343 predicate. See Info node `(gnus)Customizing Articles'."
1344 :group
'gnus-article-treat
1345 :link
'(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom
)
1348 (defcustom gnus-treat-unfold-headers
'head
1349 "Unfold folded header lines.
1350 Valid values are nil, t, `head', `first', `last', an integer or a
1351 predicate. See Info node `(gnus)Customizing Articles'."
1353 :group
'gnus-article-treat
1354 :link
'(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-custom
)
1357 (defcustom gnus-article-unfold-long-headers nil
1358 "If non-nil, allow unfolding headers even if the header is long.
1359 If it is a regexp, only long headers matching this regexp are unfolded.
1360 If it is t, all long headers are unfolded.
1362 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1363 :version
"23.1" ;; No Gnus
1364 :group
'gnus-article-treat
1365 :type
'(choice (const nil
)
1366 (const :tag
"all" t
)
1369 (defcustom gnus-treat-fold-headers nil
1371 Valid values are nil, t, `head', `first', `last', an integer or a
1372 predicate. See Info node `(gnus)Customizing Articles'."
1374 :group
'gnus-article-treat
1375 :link
'(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-custom
)
1378 (defcustom gnus-treat-fold-newsgroups
'head
1379 "Fold the Newsgroups and Followup-To headers.
1380 Valid values are nil, t, `head', `first', `last', an integer or a
1381 predicate. See Info node `(gnus)Customizing Articles'."
1383 :group
'gnus-article-treat
1384 :link
'(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom
)
1387 (defcustom gnus-treat-overstrike t
1388 "Treat overstrike highlighting.
1389 Valid values are nil, t, `head', `first', `last', an integer or a
1390 predicate. See Info node `(gnus)Customizing Articles'."
1391 :group
'gnus-article-treat
1392 :link
'(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom
)
1394 (put 'gnus-treat-overstrike
'highlight t
)
1396 (defcustom gnus-treat-ansi-sequences t
1397 "Treat ANSI SGR control sequences.
1398 Valid values are nil, t, `head', `first', `last', an integer or a
1399 predicate. See Info node `(gnus)Customizing Articles'."
1400 :group
'gnus-article-treat
1401 :link
'(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom
)
1404 (make-obsolete-variable 'gnus-treat-display-xface
1405 'gnus-treat-display-x-face
"Emacs 22.1")
1407 (defcustom gnus-treat-display-x-face
1408 (and (not noninteractive
)
1409 (gnus-image-type-available-p 'xbm
)
1411 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1412 (executable-find "icontopbm"))
1413 ;; shell-command-to-string may signal an error, e.g. if
1414 ;; shell-file-name is not found.
1417 "Display X-Face headers.
1418 Valid values are nil and `head'.
1419 See Info node `(gnus)Customizing Articles' and Info node
1420 `(gnus)X-Face' for details."
1421 :group
'gnus-article-treat
1423 :link
'(custom-manual "(gnus)Customizing Articles")
1424 :link
'(custom-manual "(gnus)X-Face")
1425 :type gnus-article-treat-head-custom
1426 :set
(lambda (symbol value
)
1429 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1431 ((boundp 'gnus-treat-display-xface
)
1433 ** gnus-treat-display-xface is an obsolete variable;\
1434 use gnus-treat-display-x-face instead")
1435 (default-value 'gnus-treat-display-xface
))
1436 ((get 'gnus-treat-display-xface
'saved-value
)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1443 (put 'gnus-treat-display-x-face
'highlight t
)
1445 (defcustom gnus-treat-display-face
1446 (and (not noninteractive
)
1447 (gnus-image-type-available-p 'png
)
1449 "Display Face headers.
1450 Valid values are nil, t, `head', `first', `last', an integer or a
1451 predicate. See Info node `(gnus)Customizing Articles' and Info
1452 node `(gnus)Face' for details."
1453 :group
'gnus-article-treat
1455 :link
'(custom-manual "(gnus)Customizing Articles")
1456 :link
'(custom-manual "(gnus)X-Face")
1457 :type gnus-article-treat-head-custom
)
1458 (put 'gnus-treat-display-face
'highlight t
)
1460 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1462 Valid values are nil, t, `head', `first', `last', an integer or a
1463 predicate. See Info node `(gnus)Customizing Articles' and Info
1464 node `(gnus)Smileys' for details."
1465 :group
'gnus-article-treat
1467 :link
'(custom-manual "(gnus)Customizing Articles")
1468 :link
'(custom-manual "(gnus)Smileys")
1469 :type gnus-article-treat-custom
)
1470 (put 'gnus-treat-display-smileys
'highlight t
)
1472 (defcustom gnus-treat-from-picon
1473 (if (and (gnus-image-type-available-p 'xpm
)
1474 (gnus-picons-installed-p))
1476 "Display picons in the From header.
1477 Valid values are nil, t, `head', `first', `last', an integer or a
1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1479 node `(gnus)Picons' for details."
1481 :group
'gnus-article-treat
1483 :link
'(custom-manual "(gnus)Customizing Articles")
1484 :link
'(custom-manual "(gnus)Picons")
1485 :type gnus-article-treat-head-custom
)
1486 (put 'gnus-treat-from-picon
'highlight t
)
1488 (defcustom gnus-treat-mail-picon
1489 (if (and (gnus-image-type-available-p 'xpm
)
1490 (gnus-picons-installed-p))
1492 "Display picons in To and Cc headers.
1493 Valid values are nil, t, `head', `first', `last', an integer or a
1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1495 node `(gnus)Picons' for details."
1497 :group
'gnus-article-treat
1499 :link
'(custom-manual "(gnus)Customizing Articles")
1500 :link
'(custom-manual "(gnus)Picons")
1501 :type gnus-article-treat-head-custom
)
1502 (put 'gnus-treat-mail-picon
'highlight t
)
1504 (defcustom gnus-treat-newsgroups-picon
1505 (if (and (gnus-image-type-available-p 'xpm
)
1506 (gnus-picons-installed-p))
1508 "Display picons in the Newsgroups and Followup-To headers.
1509 Valid values are nil, t, `head', `first', `last', an integer or a
1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1511 node `(gnus)Picons' for details."
1513 :group
'gnus-article-treat
1515 :link
'(custom-manual "(gnus)Customizing Articles")
1516 :link
'(custom-manual "(gnus)Picons")
1517 :type gnus-article-treat-head-custom
)
1518 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1520 (defcustom gnus-treat-from-gravatar nil
1521 "Display gravatars in the From header.
1522 Valid values are nil, t, `head', `first', `last', an integer or a
1523 predicate. See Info node `(gnus)Customizing Articles' and Info
1524 node `(gnus)Gravatars' for details."
1526 :group
'gnus-article-treat
1527 :group
'gnus-gravatar
1528 :link
'(custom-manual "(gnus)Customizing Articles")
1529 :link
'(custom-manual "(gnus)Gravatars")
1530 :type gnus-article-treat-head-custom
)
1531 (put 'gnus-treat-from-gravatar
'highlight t
)
1533 (defcustom gnus-treat-mail-gravatar nil
1534 "Display gravatars in To and Cc headers.
1535 Valid values are nil, t, `head', `first', `last', an integer or a
1536 predicate. See Info node `(gnus)Customizing Articles' and Info
1537 node `(gnus)Gravatars' for details."
1539 :group
'gnus-article-treat
1540 :group
'gnus-gravatar
1541 :link
'(custom-manual "(gnus)Customizing Articles")
1542 :link
'(custom-manual "(gnus)Gravatars")
1543 :type gnus-article-treat-head-custom
)
1544 (put 'gnus-treat-mail-gravatar
'highlight t
)
1546 (defcustom gnus-treat-body-boundary
1547 (if (or gnus-treat-newsgroups-picon
1548 gnus-treat-mail-picon
1549 gnus-treat-from-picon
1550 gnus-treat-from-gravatar
1551 gnus-treat-mail-gravatar
)
1552 ;; If there's much decoration, the user might prefer a boundary.
1555 "Draw a boundary at the end of the headers.
1556 Valid values are nil and `head'.
1557 See Info node `(gnus)Customizing Articles' for details."
1559 :group
'gnus-article-treat
1560 :link
'(custom-manual "(gnus)Customizing Articles")
1561 :type gnus-article-treat-head-custom
)
1563 (defcustom gnus-treat-capitalize-sentences nil
1564 "Capitalize sentence-starting words.
1565 Valid values are nil, t, `head', `first', `last', an integer or a
1566 predicate. See Info node `(gnus)Customizing Articles'."
1568 :group
'gnus-article-treat
1569 :link
'(custom-manual "(gnus)Customizing Articles")
1570 :type gnus-article-treat-custom
)
1572 (defcustom gnus-treat-wash-html nil
1574 Valid values are nil, t, `head', `first', `last', an integer or a
1575 predicate. See Info node `(gnus)Customizing Articles'."
1577 :group
'gnus-article-treat
1578 :link
'(custom-manual "(gnus)Customizing Articles")
1579 :type gnus-article-treat-custom
)
1581 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1583 Valid values are nil, t, `head', `first', `last', an integer or a
1584 predicate. See Info node `(gnus)Customizing Articles'."
1586 :group
'gnus-article-treat
1587 :link
'(custom-manual "(gnus)Customizing Articles")
1588 :type gnus-article-treat-custom
)
1590 (defcustom gnus-treat-x-pgp-sig nil
1592 To automatically treat X-PGP-Sig, set it to head.
1593 Valid values are nil, t, `head', `first', `last', an integer or a
1594 predicate. See Info node `(gnus)Customizing Articles'."
1596 :group
'gnus-article-treat
1597 :group
'mime-security
1598 :link
'(custom-manual "(gnus)Customizing Articles")
1599 :type gnus-article-treat-custom
)
1601 (defvar gnus-article-encrypt-protocol-alist
1602 '(("PGP" . mml2015-self-encrypt
)))
1604 ;; Set to nil if more than one protocol added to
1605 ;; gnus-article-encrypt-protocol-alist.
1606 (defcustom gnus-article-encrypt-protocol
"PGP"
1607 "The protocol used for encrypt articles.
1608 It is a string, such as \"PGP\". If nil, ask user."
1611 :group
'mime-security
)
1613 (defcustom gnus-use-idna t
1614 "Whether IDNA decoding of headers is used when viewing messages."
1616 :group
'gnus-article-headers
1619 (defcustom gnus-article-over-scroll nil
1620 "If non-nil, allow scrolling the article buffer even when there no more text."
1622 :group
'gnus-article
1625 (defcustom gnus-inhibit-images nil
1626 "Non-nil means inhibit displaying of images inline in the article body."
1628 :group
'gnus-article
1631 (defcustom gnus-blocked-images
'gnus-block-private-groups
1632 "Images that have URLs matching this regexp will be blocked.
1633 This can also be a function to be evaluated. If so, it will be
1634 called with the group name as the parameter, and should return a
1638 :type
'(choice (const :tag
"Allow all" nil
)
1639 (regexp :tag
"Regular expression")
1640 (function :tag
"Use a function")))
1642 ;;; Internal variables
1644 (defvar gnus-english-month-names
1645 '("January" "February" "March" "April" "May" "June" "July" "August"
1646 "September" "October" "November" "December"))
1648 (defvar article-goto-body-goes-to-point-min-p nil
)
1649 (defvar gnus-article-wash-types nil
)
1650 (defvar gnus-article-emphasis-alist nil
)
1651 (defvar gnus-article-image-alist nil
)
1653 (defvar gnus-article-mime-handle-alist-1 nil
)
1654 (defvar gnus-treatment-function-alist
1655 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1656 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1657 (gnus-treat-strip-banner gnus-article-strip-banner
)
1658 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1659 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1660 (gnus-treat-buttonize gnus-article-add-buttons
)
1661 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1662 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1663 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1664 (gnus-treat-display-x-face gnus-article-display-x-face
)
1665 (gnus-treat-display-face gnus-article-display-face
)
1666 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1667 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1668 (gnus-treat-hide-signature gnus-article-hide-signature
)
1669 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1670 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1671 (gnus-treat-from-picon gnus-treat-from-picon
)
1672 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1673 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1674 (gnus-treat-strip-pem gnus-article-hide-pem
)
1675 (gnus-treat-date gnus-article-treat-date
)
1676 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1677 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1678 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1679 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1680 (gnus-treat-strip-trailing-blank-lines
1681 gnus-article-remove-trailing-blank-lines
)
1682 (gnus-treat-strip-leading-blank-lines
1683 gnus-article-strip-leading-blank-lines
)
1684 (gnus-treat-strip-multiple-blank-lines
1685 gnus-article-strip-multiple-blank-lines
)
1686 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1687 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1688 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1689 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1690 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1691 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1692 (gnus-treat-display-smileys gnus-treat-smiley
)
1693 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1694 (gnus-treat-wash-html gnus-article-wash-html
)
1695 (gnus-treat-emphasize gnus-article-emphasize
)
1696 (gnus-treat-hide-citation gnus-article-hide-citation
)
1697 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1698 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1699 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1701 (defvar gnus-article-mime-handle-alist nil
)
1702 (defvar article-lapsed-timer nil
)
1703 (defvar gnus-article-current-summary nil
)
1705 (defvar gnus-article-mode-syntax-table
1706 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1707 ;; This causes the citation match run O(2^n).
1708 ;; (modify-syntax-entry ?- "w" table)
1709 (modify-syntax-entry ?
> ")<" table
)
1710 (modify-syntax-entry ?
< "(>" table
)
1711 ;; make M-. in article buffers work for `foo' strings
1712 (modify-syntax-entry ?
' " " table
)
1713 (modify-syntax-entry ?
` " " table
)
1715 "Syntax table used in article mode buffers.
1716 Initialized from `text-mode-syntax-table'.")
1718 (defvar gnus-save-article-buffer nil
)
1720 (defvar gnus-number-of-articles-to-be-saved nil
)
1722 (defvar gnus-inhibit-hiding nil
)
1724 (defvar gnus-article-edit-mode nil
)
1726 ;;; Macros for dealing with the article buffer.
1728 (defmacro gnus-with-article-headers
(&rest forms
)
1729 `(with-current-buffer gnus-article-buffer
1731 (let ((inhibit-read-only t
)
1732 (inhibit-point-motion-hooks t
)
1733 (case-fold-search t
))
1734 (article-narrow-to-head)
1737 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1738 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1740 (defmacro gnus-with-article-buffer
(&rest forms
)
1741 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1742 (with-current-buffer gnus-article-buffer
1743 (let ((inhibit-read-only t
))
1746 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1747 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1749 (defun gnus-article-goto-header (header)
1750 "Go to HEADER, which is a regular expression."
1751 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1753 (defsubst gnus-article-hide-text
(b e props
)
1754 "Set text PROPS on the B to E region."
1755 (gnus-add-text-properties-when 'article-type nil b e props
))
1757 (defsubst gnus-article-unhide-text
(b e
)
1758 "Remove hidden text properties from region between B and E."
1759 (remove-text-properties b e gnus-hidden-properties
))
1761 (defun gnus-article-hide-text-type (b e type
)
1762 "Hide text of TYPE between B and E."
1763 (gnus-add-wash-type type
)
1764 (gnus-article-hide-text
1765 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1767 (defun gnus-article-unhide-text-type (b e type
)
1768 "Unhide text of TYPE between B and E."
1769 (gnus-delete-wash-type type
)
1770 (remove-text-properties
1771 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1773 (defun gnus-article-delete-text-of-type (type)
1774 "Delete text of TYPE in the current buffer."
1776 (let ((b (point-min)))
1777 (if (eq type
'multipart
)
1778 ;; Remove MIME buttons associated with multipart/alternative parts.
1781 (while (if (get-text-property (point) 'gnus-part
)
1783 (when (setq b
(next-single-property-change (point)
1788 (skip-chars-forward "\n")
1789 (when (eq (get-text-property b
'article-type
) 'multipart
)
1790 (delete-region b
(point)))))
1791 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1793 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1796 (defun gnus-article-delete-invisible-text ()
1797 "Delete all invisible text in the current buffer."
1799 (let ((b (point-min)))
1800 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1802 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1805 (defsubst gnus-article-header-rank
()
1806 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1807 (let ((list gnus-sorted-header-list
)
1810 (if (looking-at (car list
))
1812 (setq list
(cdr list
))
1816 (defun article-hide-headers (&optional _arg _delete
)
1817 "Hide unwanted headers and possibly sort them as well."
1819 ;; This function might be inhibited.
1820 (unless gnus-inhibit-hiding
1821 (let ((inhibit-read-only t
)
1822 (case-fold-search t
)
1823 (max (1+ (length gnus-sorted-header-list
)))
1824 (inhibit-point-motion-hooks t
)
1825 (cur (current-buffer))
1826 ignored visible beg
)
1828 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1829 ;; group parameters, so we should go to the summary buffer.
1832 (progn (set-buffer gnus-summary-buffer
) t
)
1834 (setq ignored
(when (not gnus-visible-headers
)
1835 (cond ((stringp gnus-ignored-headers
)
1836 gnus-ignored-headers
)
1837 ((listp gnus-ignored-headers
)
1838 (mapconcat 'identity
1839 gnus-ignored-headers
1841 visible
(cond ((stringp gnus-visible-headers
)
1842 gnus-visible-headers
)
1843 ((and gnus-visible-headers
1844 (listp gnus-visible-headers
))
1845 (mapconcat 'identity
1846 gnus-visible-headers
1850 ;; First we narrow to just the headers.
1851 (article-narrow-to-head)
1852 ;; Hide any "From " lines at the beginning of (mail) articles.
1853 (while (looking-at "From ")
1856 (delete-region (point-min) (point)))
1857 ;; Then treat the rest of the header lines.
1858 ;; Then we use the two regular expressions
1859 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1860 ;; select which header lines is to remain visible in the
1862 (while (re-search-forward "^[^ \t:]*:" nil t
)
1864 ;; Mark the rank of the header.
1866 (point) (1+ (point)) 'message-rank
1867 (if (or (and visible
(looking-at visible
))
1869 (not (looking-at ignored
))))
1870 (gnus-article-header-rank)
1873 (message-sort-headers-1)
1874 (when (setq beg
(text-property-any
1875 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1876 ;; We delete the unwanted headers.
1877 (gnus-add-wash-type 'headers
)
1878 (add-text-properties (point-min) (+ 5 (point-min))
1879 '(article-type headers dummy-invisible t
))
1880 (delete-region beg
(point-max))))))))
1882 (defun article-hide-boring-headers (&optional arg
)
1883 "Toggle hiding of headers that aren't very interesting.
1884 If given a negative prefix, always show; if given a positive prefix,
1886 (interactive (gnus-article-hidden-arg))
1887 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1888 (not gnus-show-all-headers
))
1891 (let ((inhibit-read-only t
)
1892 (inhibit-point-motion-hooks t
))
1893 (article-narrow-to-head)
1894 (dolist (elem gnus-boring-article-headers
)
1895 (goto-char (point-min))
1897 ;; Hide empty headers.
1899 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1901 (gnus-article-hide-text-type
1905 (if (re-search-forward "^[^ \t]" nil t
)
1909 ;; Hide boring Newsgroups header.
1910 ((eq elem
'newsgroups
)
1911 (when (gnus-string-equal
1912 (gnus-fetch-field "newsgroups")
1913 (gnus-group-real-name
1914 (if (boundp 'gnus-newsgroup-name
)
1917 (gnus-article-hide-header "newsgroups")))
1918 ((eq elem
'to-address
)
1919 (let ((to (message-fetch-field "to"))
1921 (gnus-parameter-to-address
1922 (if (boundp 'gnus-newsgroup-name
)
1923 gnus-newsgroup-name
""))))
1924 (when (and to to-address
1927 ;; only one address in To
1928 (nth 1 (mail-extract-address-components to
))
1930 (gnus-article-hide-header "to"))))
1932 (let ((to (message-fetch-field "to"))
1934 (gnus-parameter-to-list
1935 (if (boundp 'gnus-newsgroup-name
)
1936 gnus-newsgroup-name
""))))
1937 (when (and to to-list
1940 ;; only one address in To
1941 (nth 1 (mail-extract-address-components to
))
1943 (gnus-article-hide-header "to"))))
1945 (let ((cc (message-fetch-field "cc"))
1947 (gnus-parameter-to-list
1948 (if (boundp 'gnus-newsgroup-name
)
1949 gnus-newsgroup-name
""))))
1950 (when (and cc to-list
1953 ;; only one address in CC
1954 (nth 1 (mail-extract-address-components cc
))
1956 (gnus-article-hide-header "cc"))))
1957 ((eq elem
'followup-to
)
1958 (when (gnus-string-equal
1959 (message-fetch-field "followup-to")
1960 (message-fetch-field "newsgroups"))
1961 (gnus-article-hide-header "followup-to")))
1962 ((eq elem
'reply-to
)
1963 (if (gnus-group-find-parameter
1964 gnus-newsgroup-name
'broken-reply-to
)
1965 (gnus-article-hide-header "reply-to")
1966 (let ((from (message-fetch-field "from"))
1967 (reply-to (message-fetch-field "reply-to")))
1974 (lambda (x) (downcase (cadr x
)))
1975 (mail-extract-address-components from t
))
1978 (lambda (x) (downcase (cadr x
)))
1979 (mail-extract-address-components reply-to t
))
1981 (gnus-article-hide-header "reply-to")))))
1983 (let ((date (with-current-buffer gnus-original-article-buffer
1984 ;; If date in `gnus-article-buffer' is localized
1985 ;; (`gnus-treat-date-user-defined'),
1986 ;; `days-between' might fail.
1987 (message-fetch-field "date"))))
1989 (< (days-between (current-time-string) date
)
1991 (gnus-article-hide-header "date"))))
1993 (let ((to (message-fetch-field "to"))
1994 (cc (message-fetch-field "cc")))
1995 (when (> (length to
) 1024)
1996 (gnus-article-hide-header "to"))
1997 (when (> (length cc
) 1024)
1998 (gnus-article-hide-header "cc"))))
2002 (goto-char (point-min))
2003 (while (re-search-forward "^to:" nil t
)
2004 (setq to-count
(1+ to-count
)))
2005 (when (> to-count
1)
2006 (while (> to-count
0)
2007 (goto-char (point-min))
2009 (re-search-forward "^to:" nil nil to-count
)
2011 (narrow-to-region (point) (point-max))
2012 (gnus-article-hide-header "to"))
2013 (setq to-count
(1- to-count
))))
2014 (goto-char (point-min))
2015 (while (re-search-forward "^cc:" nil t
)
2016 (setq cc-count
(1+ cc-count
)))
2017 (when (> cc-count
1)
2018 (while (> cc-count
0)
2019 (goto-char (point-min))
2021 (re-search-forward "^cc:" nil nil cc-count
)
2023 (narrow-to-region (point) (point-max))
2024 (gnus-article-hide-header "cc"))
2025 (setq cc-count
(1- cc-count
)))))))))))))
2027 (defun gnus-article-hide-header (header)
2029 (goto-char (point-min))
2030 (when (re-search-forward (concat "^" header
":") nil t
)
2031 (gnus-article-hide-text-type
2035 (if (re-search-forward "^[^ \t]" nil t
)
2040 (defvar gnus-article-normalized-header-length
40
2041 "Length of normalized headers.")
2043 (defun article-normalize-headers ()
2044 "Make all header lines 40 characters long."
2046 (let ((inhibit-read-only t
)
2050 (article-narrow-to-head)
2053 ((< (setq column
(- (point-at-eol) (point)))
2054 gnus-article-normalized-header-length
)
2056 (insert (make-string
2057 (- gnus-article-normalized-header-length column
)
2059 ((> column gnus-article-normalized-header-length
)
2062 (forward-char gnus-article-normalized-header-length
)
2069 (forward-line 1))))))
2071 (defun article-treat-dumbquotes ()
2072 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2073 Note that this function guesses whether a character is a sm*rtq**t* or
2074 not, so it should only be used interactively.
2076 Sm*rtq**t*s are M****s***'s unilateral extension to the
2077 iso-8859-1 character map in an attempt to provide more quoting
2078 characters. If you see something like \\222 or \\264 where
2079 you're expecting some kind of apostrophe or quotation mark, then
2082 (article-translate-strings gnus-article-dumbquotes-map
))
2084 (defvar org-entities
)
2086 (defun article-treat-non-ascii ()
2087 "Translate many Unicode characters into their ASCII equivalents."
2089 (require 'org-entities
)
2090 (let ((table (make-char-table nil
)))
2091 (dolist (elem org-entities
)
2092 (when (and (listp elem
)
2093 (= (length (nth 6 elem
)) 1))
2094 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
))))
2096 (when (article-goto-body)
2097 (let ((inhibit-read-only t
)
2100 (if (not (setq replace
(aref table
(following-char))))
2103 (setq props
(text-properties-at (point)))
2105 (add-text-properties (point) (progn (insert replace
) (point))
2107 (insert replace
)))))))))
2109 (defun article-translate-strings (map)
2110 "Translate all string in the body of the article according to MAP.
2111 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2113 (when (article-goto-body)
2114 (let ((inhibit-read-only t
))
2116 (let ((from (car elem
))
2120 (while (search-forward from nil t
)
2123 (if (eq (following-char) from
)
2127 (forward-char 1)))))))))))
2129 (defun article-treat-overstrike ()
2130 "Translate overstrikes into bold text."
2133 (when (article-goto-body)
2134 (let ((inhibit-read-only t
))
2135 (while (search-forward "\b" nil t
)
2136 (let ((next (char-after))
2137 (previous (char-after (- (point) 2))))
2138 ;; We do the boldification/underlining by hiding the
2139 ;; overstrikes and putting the proper text property
2143 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2144 (put-text-property (point) (1+ (point)) 'face
'bold
))
2146 (gnus-article-hide-text-type
2147 (1- (point)) (1+ (point)) 'overstrike
)
2149 (- (point) 2) (1- (point)) 'face
'underline
))
2151 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2153 (point) (1+ (point)) 'face
'underline
)))))))))
2155 (defun article-treat-ansi-sequences ()
2156 "Translate ANSI SGR control sequences into overlays or extents."
2159 (when (article-goto-body)
2160 (let ((inhibit-read-only t
))
2161 (ansi-color-apply-on-region (point) (point-max))))))
2163 (defun gnus-article-treat-unfold-headers ()
2164 "Unfold folded message headers.
2165 Only the headers that fit into the current window width will be
2168 (gnus-with-article-headers
2172 (mail-header-narrow-to-field)
2173 (let* ((header (buffer-string))
2175 (or (equal gnus-article-unfold-long-headers t
)
2176 (and (stringp gnus-article-unfold-long-headers
)
2177 (string-match gnus-article-unfold-long-headers
2181 (goto-char (point-min))
2182 (while (re-search-forward "\n[\t ]" nil t
)
2183 (replace-match " " t t
)))
2184 (setq length
(- (point-max) (point-min) 1))
2185 (when (or unfoldable
2186 (< length
(window-width)))
2187 (while (re-search-forward "\n[\t ]" nil t
)
2188 (replace-match " " t t
))))
2189 (goto-char (point-max)))))))
2191 (defun gnus-article-treat-fold-headers ()
2192 "Fold message headers."
2194 (gnus-with-article-headers
2197 (mail-header-narrow-to-field)
2198 (mail-header-fold-field)
2199 (goto-char (point-max))))))
2201 (defun gnus-treat-smiley ()
2202 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2204 (gnus-with-article-buffer
2205 (if (memq 'smiley gnus-article-wash-types
)
2206 (gnus-delete-images 'smiley
)
2208 (let ((images (smiley-region (point) (point-max))))
2210 (gnus-add-wash-type 'smiley
)
2211 (dolist (image images
)
2212 (gnus-add-image 'smiley image
)))))))
2214 (defun gnus-article-remove-images ()
2215 "Remove all images from the article buffer."
2217 (gnus-with-article-buffer
2220 (dolist (elem gnus-article-image-alist
)
2221 (gnus-delete-images (car elem
))))))
2223 (autoload 'w3m-toggle-inline-images
"w3m")
2225 (defun gnus-article-show-images ()
2226 "Show any images that are in the HTML-rendered article buffer.
2227 This only works if the article in question is HTML."
2229 (gnus-with-article-buffer
2232 (if (eq mm-text-html-renderer
'w3m
)
2233 (w3m-toggle-inline-images)
2234 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2236 (destructuring-bind (start end function
) region
2237 (funcall function
(get-text-property start
'image-url
)
2240 (defun gnus-article-treat-fold-newsgroups ()
2241 "Unfold folded message headers.
2242 Only the headers that fit into the current window width will be
2245 (gnus-with-article-headers
2246 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2248 (mail-header-narrow-to-field)
2249 (while (re-search-forward ", *" nil t
)
2250 (replace-match ", " t t
))
2251 (mail-header-fold-field)
2252 (goto-char (point-max))))))
2254 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2255 "Value of `truncate-lines' in Gnus Article buffer.
2256 Valid values are nil, t, `head', `first', `last', an integer or a
2257 predicate. See Info node `(gnus)Customizing Articles'."
2258 :version
"23.1" ;; No Gnus
2259 :group
'gnus-article
2260 ;; :link '(custom-manual "(gnus)Customizing Articles")
2263 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2264 "Toggle whether to fold or truncate long lines in article the buffer.
2265 If ARG is non-nil and not a number, toggle
2266 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2267 long lines if and only if arg is positive."
2270 ((and (numberp arg
) (> arg
0))
2271 (setq gnus-article-truncate-lines t
))
2273 (setq gnus-article-truncate-lines nil
))
2275 (setq gnus-article-truncate-lines
2276 (not gnus-article-truncate-lines
))))
2277 (gnus-with-article-buffer
2279 ((and (numberp arg
) (> arg
0))
2280 (setq truncate-lines nil
))
2282 (setq truncate-lines t
)))
2283 (toggle-truncate-lines)))
2285 (defun gnus-article-treat-body-boundary ()
2286 "Place a boundary line at the end of the headers."
2288 (when (and gnus-body-boundary-delimiter
2289 (> (length gnus-body-boundary-delimiter
) 0))
2290 (gnus-with-article-headers
2291 (goto-char (point-max))
2292 (let ((start (point)))
2293 (insert "X-Boundary: ")
2294 (add-text-properties start
(point) gnus-hidden-properties
)
2295 (insert (let (str (max (window-width)))
2296 (while (>= max
(length str
))
2297 (setq str
(concat str gnus-body-boundary-delimiter
)))
2298 (substring str
0 max
))
2300 (put-text-property start
(point) 'gnus-decoration
'header
)))))
2302 (defun article-fill-long-lines ()
2303 "Fill lines that are wider than the window width."
2306 (let ((inhibit-read-only t
)
2307 (width (window-width (get-buffer-window (current-buffer)))))
2310 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2313 (when (>= (current-column) (min fill-column width
))
2314 (narrow-to-region (min (1+ (point)) (point-max))
2316 (let ((goback (point-marker)))
2317 (fill-paragraph nil
)
2318 (goto-char (marker-position goback
)))
2320 (forward-line 1)))))))
2322 (defun article-capitalize-sentences ()
2323 "Capitalize the first word in each sentence."
2326 (let ((inhibit-read-only t
)
2327 (paragraph-start "^[\n\^L]"))
2331 (forward-sentence)))))
2333 (defun article-remove-cr ()
2334 "Remove trailing CRs and then translate remaining CRs into LFs."
2337 (let ((inhibit-read-only t
))
2338 (goto-char (point-min))
2339 (while (re-search-forward "\r+$" nil t
)
2340 (replace-match "" t t
))
2341 (goto-char (point-min))
2342 (while (search-forward "\r" nil t
)
2343 (replace-match "\n" t t
)))))
2345 (defun article-remove-trailing-blank-lines ()
2346 "Remove all trailing blank lines from the article."
2349 (let ((inhibit-read-only t
))
2350 (goto-char (point-max))
2354 (while (and (not (bobp))
2355 (looking-at "^[ \t]*$")
2356 (not (gnus-annotation-in-region-p
2357 (point) (point-at-eol))))
2362 (defvar gnus-face-properties-alist
)
2364 (defun article-display-face (&optional force
)
2365 "Display any Face headers in the header."
2366 (interactive (list 'force
))
2367 (let ((wash-face-p buffer-read-only
))
2368 (gnus-with-article-headers
2369 ;; When displaying parts, this function can be called several times on
2370 ;; the same article, without any intended toggle semantic (as typing `W
2371 ;; D d' would have). So face deletion must occur only when we come from
2372 ;; an interactive command, that is when the *Article* buffer is
2374 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2375 (gnus-delete-images 'face
)
2376 (let ((from (message-fetch-field "from"))
2378 (save-current-buffer
2379 (when (and wash-face-p
2380 (gnus-buffer-live-p gnus-original-article-buffer
)
2381 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2382 (set-buffer gnus-original-article-buffer
))
2384 (mail-narrow-to-head)
2386 ;; Check whether this face is censored.
2387 (not (and gnus-article-x-face-too-ugly
2389 (setq from
(message-fetch-field "from")))
2390 (string-match gnus-article-x-face-too-ugly
2392 (while (gnus-article-goto-header "Face")
2393 (push (mail-header-field-value) faces
)))))
2395 (goto-char (point-min))
2397 (unless (setq from
(gnus-article-goto-header "from"))
2400 (insert " [no 'from' set]\n"))
2402 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2404 (apply 'gnus-create-image png
'png t
2405 (cdr (assq 'png gnus-face-properties-alist
))))
2408 (gnus-add-wash-type 'face
)
2409 (gnus-add-image 'face image
)
2410 (gnus-put-image image nil
'face
)))))))))))
2412 (defun article-display-x-face (&optional force
)
2413 "Look for an X-Face header and display it if present."
2414 (interactive (list 'force
))
2415 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2416 (gnus-with-article-headers
2417 ;; Delete the old process, if any.
2418 (when (process-status "article-x-face")
2419 (delete-process "article-x-face"))
2420 ;; See the comment in `article-display-face'.
2421 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2422 ;; We have already displayed X-Faces, so we remove them
2424 (gnus-delete-images 'xface
)
2426 (let ((from (message-fetch-field "from"))
2428 (save-current-buffer
2429 (when (and wash-face-p
2430 (gnus-buffer-live-p gnus-original-article-buffer
)
2431 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2432 ;; If type `W f', use gnus-original-article-buffer,
2433 ;; otherwise use the current buffer because displaying
2434 ;; RFC822 parts calls this function too.
2435 (set-buffer gnus-original-article-buffer
))
2437 (mail-narrow-to-head)
2438 (and gnus-article-x-face-command
2440 ;; Check whether this face is censored.
2441 (not (and gnus-article-x-face-too-ugly
2443 (setq from
(message-fetch-field "from")))
2444 (string-match gnus-article-x-face-too-ugly
2446 (while (gnus-article-goto-header "X-Face")
2447 (push (mail-header-field-value) x-faces
)))))
2449 ;; We display the face.
2450 (cond ((functionp gnus-article-x-face-command
)
2451 ;; The command is a lisp function, so we call it.
2452 (mapc gnus-article-x-face-command x-faces
))
2453 ((stringp gnus-article-x-face-command
)
2454 ;; The command is a string, so we interpret the command
2455 ;; as a, well, command, and fork it off.
2456 (let ((process-connection-type nil
))
2457 (set-process-query-on-exit-flag
2459 "article-x-face" nil shell-file-name
2460 shell-command-switch gnus-article-x-face-command
)
2462 ;; Sending multiple EOFs to xv doesn't work,
2463 ;; so we only do a single external face.
2465 (insert (car x-faces
))
2466 (process-send-region "article-x-face"
2467 (point-min) (point-max)))
2468 (process-send-eof "article-x-face")))
2470 (error "`%s' set to `%s' is not a function"
2471 gnus-article-x-face-command
2472 'gnus-article-x-face-command
)))))))))
2474 (defun article-decode-mime-words ()
2475 "Decode all MIME-encoded words in the article."
2477 (gnus-with-article-buffer
2478 (let ((inhibit-point-motion-hooks t
)
2479 (mail-parse-charset gnus-newsgroup-charset
)
2480 (mail-parse-ignored-charsets
2481 (with-current-buffer gnus-summary-buffer
2482 gnus-newsgroup-ignored-charsets
)))
2483 (mail-decode-encoded-word-region (point-min) (point-max)))))
2485 (defun article-decode-charset (&optional prompt
)
2486 "Decode charset-encoded text in the article.
2487 If PROMPT (the prefix), prompt for a coding system to use."
2489 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2490 (inhibit-read-only t
)
2491 (mail-parse-charset gnus-newsgroup-charset
)
2492 (mail-parse-ignored-charsets
2493 (save-excursion (condition-case nil
2494 (set-buffer gnus-summary-buffer
)
2496 gnus-newsgroup-ignored-charsets
))
2497 ct cte ctl charset format
)
2500 (article-narrow-to-head)
2501 (setq ct
(message-fetch-field "Content-Type" t
)
2502 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2503 ctl
(and ct
(mail-header-parse-content-type ct
))
2506 (read-coding-system "Charset to decode: "))
2508 (mail-content-type-get ctl
'charset
)))
2509 format
(and ctl
(mail-content-type-get ctl
'format
)))
2511 (setq cte
(mail-header-strip cte
)))
2512 (if (and ctl
(not (string-match "/" (car ctl
))))
2514 (goto-char (point-max)))
2517 (narrow-to-region (point) (point-max))
2518 (when (and (eq mail-parse-charset
'gnus-decoded
)
2519 (eq (mm-body-7-or-8) '8bit
))
2520 ;; The text code could have been decoded.
2521 (setq charset mail-parse-charset
))
2522 (when (and (or (not ctl
)
2523 (equal (car ctl
) "text/plain"))
2524 (not format
)) ;; article with format will decode later.
2526 charset
(and cte
(intern (downcase
2527 (gnus-strip-whitespace cte
))))
2530 (defun article-decode-encoded-words ()
2531 "Remove encoded-word encoding from headers."
2532 (let ((inhibit-point-motion-hooks t
)
2533 (mail-parse-charset gnus-newsgroup-charset
)
2534 (mail-parse-ignored-charsets
2535 (save-excursion (condition-case nil
2536 (set-buffer gnus-summary-buffer
)
2538 gnus-newsgroup-ignored-charsets
))
2539 (inhibit-read-only t
)
2541 (goto-char (point-min))
2542 (when (search-forward "\n\n" nil
'move
)
2549 (memq (char-after) '(?
\t ?
)))))
2550 (setq start
(point))
2552 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2553 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2554 (funcall gnus-decode-address-function start end
)
2555 (funcall gnus-decode-header-function start end
))
2556 (goto-char (setq end start
)))))
2558 (defun article-decode-group-name ()
2559 "Decode group names in Newsgroups, Followup-To and Xref headers."
2560 (let ((inhibit-point-motion-hooks t
)
2561 (inhibit-read-only t
)
2562 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2564 (when (and (or gnus-group-name-charset-method-alist
2565 gnus-group-name-charset-group-alist
)
2566 (gnus-buffer-live-p gnus-original-article-buffer
))
2568 (article-narrow-to-head)
2569 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2570 (with-current-buffer gnus-original-article-buffer
2571 (goto-char (point-min)))
2572 (setq regexp
(concat "^" header
2573 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2574 (while (re-search-forward regexp nil t
)
2575 (replace-match (save-match-data
2576 (gnus-decode-newsgroups
2577 ;; XXX how to use data in article buffer?
2578 (with-current-buffer gnus-original-article-buffer
2579 (re-search-forward regexp nil t
)
2581 gnus-newsgroup-name method
))
2583 (goto-char (point-min)))))))
2585 (defun article-decode-idna-rhs ()
2586 "Decode IDNA strings in RHS in various headers in current buffer.
2587 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2588 Mail-Reply-To: and Mail-Followup-To:."
2591 (let ((inhibit-point-motion-hooks t
)
2592 (inhibit-read-only t
))
2593 (article-narrow-to-head)
2594 (goto-char (point-min))
2595 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2597 (when (save-match-data
2598 (and (setq ace
(match-string 1))
2600 (and (re-search-backward "^[^ \t]" nil t
)
2601 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2602 (setq unicode
(puny-decode-domain ace
))))
2603 (unless (string= ace unicode
)
2604 (replace-match unicode nil nil nil
1)))))))))
2606 (defun article-de-quoted-unreadable (&optional force read-charset
)
2607 "Translate a quoted-printable-encoded article.
2608 If FORCE, decode the article whether it is marked as quoted-printable
2610 If READ-CHARSET, ask for a coding system."
2611 (interactive (list 'force current-prefix-arg
))
2613 (let ((inhibit-read-only t
) type charset
)
2614 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2615 (with-current-buffer gnus-original-article-buffer
2617 (gnus-fetch-field "content-transfer-encoding"))
2618 (let* ((ct (gnus-fetch-field "content-type"))
2619 (ctl (and ct
(mail-header-parse-content-type ct
))))
2620 (setq charset
(and ctl
2621 (mail-content-type-get ctl
'charset
)))
2622 (if (stringp charset
)
2623 (setq charset
(intern (downcase charset
)))))))
2625 (setq charset
(read-coding-system "Charset: " charset
)))
2627 (setq charset gnus-newsgroup-charset
))
2629 (and type
(let ((case-fold-search t
))
2630 (string-match "quoted-printable" type
))))
2632 (quoted-printable-decode-region
2633 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2635 (defun article-de-base64-unreadable (&optional force read-charset
)
2636 "Translate a base64 article.
2637 If FORCE, decode the article whether it is marked as base64 not.
2638 If READ-CHARSET, ask for a coding system."
2639 (interactive (list 'force current-prefix-arg
))
2641 (let ((inhibit-read-only t
) type charset
)
2642 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2643 (with-current-buffer gnus-original-article-buffer
2645 (gnus-fetch-field "content-transfer-encoding"))
2646 (let* ((ct (gnus-fetch-field "content-type"))
2647 (ctl (and ct
(mail-header-parse-content-type ct
))))
2648 (setq charset
(and ctl
2649 (mail-content-type-get ctl
'charset
)))
2650 (if (stringp charset
)
2651 (setq charset
(intern (downcase charset
)))))))
2653 (setq charset
(read-coding-system "Charset: " charset
)))
2655 (setq charset gnus-newsgroup-charset
))
2657 (and type
(let ((case-fold-search t
))
2658 (string-match "base64" type
))))
2661 (narrow-to-region (point) (point-max))
2662 (base64-decode-region (point-min) (point-max))
2663 (decode-coding-region
2664 (point-min) (point-max)
2665 (mm-charset-to-coding-system charset nil t
)))))))
2667 (declare-function rfc1843-decode-region
"rfc1843" (from to
))
2669 (defun article-decode-HZ ()
2670 "Translate a HZ-encoded article."
2674 (let ((inhibit-read-only t
))
2675 (rfc1843-decode-region (point-min) (point-max)))))
2677 (defun article-unsplit-urls ()
2678 "Remove the newlines that some other mailers insert into URLs."
2681 (let ((inhibit-read-only t
))
2682 (goto-char (point-min))
2683 (while (re-search-forward
2684 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2685 (replace-match "\\1\\3" t
)))
2686 (when (called-interactively-p 'any
)
2687 (gnus-treat-article nil
))))
2689 (defun article-wash-html ()
2690 "Format an HTML article."
2693 (buffer-read-only nil
))
2694 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2695 (with-current-buffer gnus-original-article-buffer
2696 (setq handles
(mm-dissect-buffer t t
))))
2698 (delete-region (point) (point-max))
2699 (mm-enable-multibyte)
2700 (mm-inline-text-html handles
)))
2702 (defvar gnus-article-browse-html-temp-list nil
2703 "List of temporary files created by `gnus-article-browse-html-parts'.
2704 Internal variable.")
2706 (defcustom gnus-article-browse-delete-temp
'ask
2707 "What to do with temporary files from `gnus-article-browse-html-parts'.
2708 If nil, don't delete temporary files. If it is t, delete them on
2709 exit from the summary buffer. If it is the symbol `file', query
2710 on each file, if it is `ask' ask once when exiting from the
2712 :group
'gnus-article
2713 :version
"23.1" ;; No Gnus
2714 :type
'(choice (const :tag
"Don't delete" nil
)
2715 (const :tag
"Don't ask" t
)
2716 (const :tag
"Ask" ask
)
2717 (const :tag
"Ask for each file" file
)))
2719 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2721 (defun gnus-article-browse-delete-temp-files (&optional how
)
2722 "Delete temp-files created by `gnus-article-browse-html-parts'."
2723 (when (and gnus-article-browse-html-temp-list
2725 (or how
(setq how gnus-article-browse-delete-temp
))
2727 (let ((files (length gnus-article-browse-html-temp-list
)))
2730 "Delete the temporary HTML file? "
2731 (format "Delete all %s temporary HTML files? "
2733 (setq gnus-article-browse-html-temp-list nil
)))
2735 (dolist (file gnus-article-browse-html-temp-list
)
2736 (cond ((file-directory-p file
)
2737 (when (or (not (eq how
'file
))
2740 "Delete temporary HTML file(s) in directory `%s'? "
2741 (file-name-as-directory file
))))
2742 (gnus-delete-directory file
)))
2743 ((file-exists-p file
)
2744 (when (or (not (eq how
'file
))
2746 (format "Delete temporary HTML file `%s'? " file
)))
2747 (delete-file file
)))))
2748 ;; Also remove file from the list when not deleted or if file doesn't
2750 (setq gnus-article-browse-html-temp-list nil
))
2751 gnus-article-browse-html-temp-list
)
2753 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2754 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2755 Return file name relative to the parent of DIRECTORY."
2759 (dolist (handle handles
)
2761 ((not (listp handle
)))
2762 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2764 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2765 ((equal (mm-handle-media-supertype handle
) "multipart")
2766 (when (setq file
(gnus-article-browse-html-save-cid-content
2767 cid handle directory
))
2768 (throw 'found file
)))
2769 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2770 (setq file
(or (mm-handle-filename handle
)
2772 (make-temp-name "cid")
2773 (car (rassoc (car (mm-handle-type handle
))
2774 mailcap-mime-extensions
))))
2775 afile
(expand-file-name file directory
))
2776 (mm-save-part-to-file handle afile
)
2777 (throw 'found
(concat (file-name-nondirectory
2778 (directory-file-name directory
))
2781 (defun gnus-article-browse-html-parts (list &optional header
)
2782 "View all \"text/html\" parts from LIST.
2783 Recurse into multiparts. The optional HEADER that should be a decoded
2784 message header will be added to the bodies of the \"text/html\" parts."
2785 ;; Internal function used by `gnus-article-browse-html-article'.
2786 (let (type file charset content cid-dir tmp-file showed
)
2787 ;; Find and show the html-parts.
2788 (dolist (handle list
)
2789 ;; If HTML, show it:
2790 (cond ((not (listp handle
)))
2791 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2792 (and (equal (car type
) "message/external-body")
2794 (setq file
(mm-handle-filename handle
)))
2795 (or (mm-handle-cache handle
)
2796 (condition-case code
2797 (progn (mm-extern-cache-contents handle
) t
)
2799 (gnus-message 3 "%s" (error-message-string code
))
2800 (when (>= gnus-verbose
3) (sit-for 2))
2803 (setq handle
(mm-handle-cache handle
)
2804 type
(mm-handle-type handle
))
2805 (equal (car type
) "text/html"))))
2806 (setq charset
(mail-content-type-get type
'charset
)
2807 content
(mm-get-part handle
))
2809 (if (eq charset
'gnus-decoded
)
2810 (mm-enable-multibyte)
2811 (mm-disable-multibyte))
2813 ;; resolve cid contents
2814 (let ((case-fold-search t
)
2815 st base regexp cid-file
)
2816 (goto-char (point-min))
2817 (when (and (re-search-forward "<head[\t\n >]" nil t
)
2819 (setq st
(match-end 0))
2820 (re-search-forward "</head[\t\n >]" nil t
))
2821 (re-search-backward "<base\
2822 \\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+href=\"\\([^\"]+\\)\"[^>]*>" st t
))
2823 (setq base
(match-string 1))
2824 (replace-match "<!--\\&-->")
2826 (dolist (tag '(("a" .
"href") ("form" .
"action")
2828 (setq regexp
(concat "<" (car tag
)
2829 "\\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+"
2830 (cdr tag
) "=\"\\([^\"]+\\)"))
2831 (while (re-search-forward regexp nil t
)
2835 (url-expand-file-name (match-string 1)
2837 (error (match-string 1)))
2838 (delete-region (match-beginning 1)
2841 (while (re-search-forward "\
2842 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2845 (setq cid-dir
(make-temp-file "cid" t
))
2846 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2849 (when (setq cid-file
2850 (gnus-article-browse-html-save-cid-content
2852 (with-current-buffer gnus-article-buffer
2853 gnus-article-mime-handles
)
2855 (replace-match cid-file nil nil nil
1))))
2856 (unless content
(setq content
(buffer-string))))
2857 (when (or charset header
(not file
))
2858 (setq tmp-file
(make-temp-file
2859 ;; Do we need to care for 8.3 filenames?
2860 "mm-" nil
".html")))
2861 ;; Add a meta html tag to specify charset and a header.
2864 (let (title eheader body hcharset coding
)
2866 (mm-enable-multibyte)
2867 (setq case-fold-search t
)
2868 (insert header
"\n")
2869 (setq title
(message-fetch-field "subject"))
2870 (goto-char (point-min))
2871 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2873 (replace-match (cond ((match-beginning 1) "<")
2874 ((match-beginning 2) ">")
2875 ((match-beginning 3) "&")
2877 (goto-char (point-min))
2878 (while (re-search-forward "^[\t ]+" nil t
)
2881 (delete-region (match-beginning 0)
2884 (goto-char (point-min))
2885 (insert "<div align=\"left\">\n")
2886 (goto-char (point-max))
2887 (insert "</div>\n<hr>\n")
2888 ;; We have to examine charset one by one since
2889 ;; charset specified in parts might be different.
2890 (if (eq charset
'gnus-decoded
)
2891 (setq charset
'utf-8
2892 eheader
(encode-coding-string (buffer-string)
2895 (encode-coding-string title charset
))
2896 body
(encode-coding-string content charset
))
2897 (setq hcharset
(mm-find-mime-charset-region (point-min)
2899 (cond ((= (length hcharset
) 1)
2900 (setq hcharset
(car hcharset
)
2901 coding
(mm-charset-to-coding-system
2903 ((> (length hcharset
) 1)
2904 (setq hcharset
'utf-8
2910 (mm-charset-to-coding-system charset
2912 (if (eq coding body
)
2913 (setq eheader
(encode-coding-string
2914 (buffer-string) coding
)
2916 (encode-coding-string
2919 (setq charset
'utf-8
2920 eheader
(encode-coding-string
2921 (buffer-string) charset
)
2923 (encode-coding-string
2925 body
(encode-coding-string
2926 (decode-coding-string
2929 (setq charset hcharset
2930 eheader
(encode-coding-string
2931 (buffer-string) coding
)
2933 (encode-coding-string
2936 (setq eheader
(string-as-unibyte (buffer-string))
2939 (mm-disable-multibyte)
2942 (mm-add-meta-html-tag handle charset t
))
2944 (goto-char (point-min))
2945 (unless (search-forward "<title>" nil t
)
2946 (re-search-forward "<head>\\s-*" nil t
)
2947 (insert "<title>" title
"</title>\n")))
2948 (goto-char (point-min))
2949 (or (re-search-forward
2950 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2952 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2954 (mm-write-region (point-min) (point-max)
2955 tmp-file nil nil nil
'binary t
))))
2957 (mm-with-unibyte-buffer
2958 (insert (if (eq charset
'gnus-decoded
)
2959 (encode-coding-string content
2960 (setq charset
'utf-8
))
2962 (if (or (mm-add-meta-html-tag handle charset
)
2964 (mm-write-region (point-min) (point-max)
2965 tmp-file nil nil nil
'binary t
)
2966 (setq tmp-file nil
))))
2968 (mm-save-part-to-file handle tmp-file
)))
2970 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2971 (add-hook 'gnus-summary-prepare-exit-hook
2972 'gnus-article-browse-delete-temp-files
)
2973 (add-hook 'gnus-exit-gnus-hook
2975 (gnus-article-browse-delete-temp-files t
)))
2976 ;; FIXME: Warn if there's an <img> tag?
2977 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2979 ;; If multipart, recurse
2980 ((equal (mm-handle-media-supertype handle
) "multipart")
2981 (when (gnus-article-browse-html-parts handle header
)
2983 ((equal (mm-handle-media-type handle
) "message/rfc822")
2984 (mm-with-multibyte-buffer
2985 (mm-insert-part handle
)
2986 (setq handle
(mm-dissect-buffer t t
))
2987 (when (and (bufferp (car handle
))
2988 (stringp (car (mm-handle-type handle
))))
2989 (setq handle
(list handle
)))
2991 (article-decode-encoded-words)
2992 (let ((gnus-visible-headers
2993 (or (get 'gnus-visible-headers
'standard-value
)
2994 gnus-visible-headers
)))
2995 (article-hide-headers))
2996 (goto-char (point-min))
2997 (search-forward "\n\n" nil
'move
)
2998 (skip-chars-backward "\t\n ")
2999 (setq header
(buffer-substring (point-min) (point)))))
3001 (gnus-article-browse-html-parts handle header
)
3002 (mm-destroy-parts handle
))
3006 (defun gnus-article-browse-html-article (&optional arg
)
3007 "View \"text/html\" parts of the current article with a WWW browser.
3008 Inline images embedded in a message using the cid scheme, as they are
3009 generally considered to be safe, will be processed properly.
3010 The message header is added to the beginning of every html part unless
3011 the prefix argument ARG is given.
3013 Warning: Spammers use links to images (using the http scheme) in HTML
3014 articles to verify whether you have read the message. As
3015 `gnus-article-browse-html-article' passes the HTML content to the
3016 browser without eliminating these \"web bugs\" you should only
3017 use it for mails from trusted senders.
3019 If you always want to display HTML parts in the browser, set
3020 `mm-text-html-renderer' to nil.
3022 This command creates temporary files to pass HTML contents including
3023 images if any to the browser, and deletes them when exiting the group
3025 ;; Cf. `mm-w3m-safe-url-regexp'
3028 (gnus-summary-show-article)
3029 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3030 gnus-visible-headers
))
3031 ;; As we insert a <hr>, there's no need for the body boundary.
3032 (gnus-treat-body-boundary nil
))
3033 (gnus-summary-show-article)))
3034 (with-current-buffer gnus-article-buffer
3035 (let ((header (unless arg
3038 (buffer-substring-no-properties
3039 (goto-char (point-min))
3040 (if (search-forward "\n\n" nil t
)
3042 (goto-char (point-max))
3043 (skip-chars-backward "\t\n ")
3046 (set-buffer gnus-original-article-buffer
)
3047 (setq parts
(mm-dissect-buffer t t
))
3048 ;; If singlepart, enforce a list.
3049 (when (and (bufferp (car parts
))
3050 (stringp (car (mm-handle-type parts
))))
3051 (setq parts
(list parts
)))
3053 (unless (gnus-article-browse-html-parts parts header
)
3054 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3055 (mm-destroy-parts parts
)
3057 (gnus-summary-show-article)))))
3059 (defun article-hide-list-identifiers ()
3060 "Remove list identifiers from the Subject header.
3061 The `gnus-list-identifiers' variable specifies what to do."
3063 (let ((inhibit-point-motion-hooks t
)
3064 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3065 (inhibit-read-only t
))
3069 (article-narrow-to-head)
3070 (goto-char (point-min))
3071 (while (re-search-forward
3072 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3074 (delete-region (match-beginning 2) (match-end 0))
3075 (beginning-of-line))
3076 (when (re-search-forward
3077 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3078 (delete-region (match-beginning 1) (match-end 1))))))))
3080 (defun article-hide-pem (&optional arg
)
3081 "Toggle hiding of any PEM headers and signatures in the current article.
3082 If given a negative prefix, always show; if given a positive prefix,
3084 (interactive (gnus-article-hidden-arg))
3085 (unless (gnus-article-check-hidden-text 'pem arg
)
3087 (let ((inhibit-read-only t
) end
)
3088 (goto-char (point-min))
3089 ;; Hide the horrendously ugly "header".
3090 (when (and (search-forward
3091 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3093 (setq end
(1+ (match-beginning 0))))
3094 (gnus-add-wash-type 'pem
)
3095 (gnus-article-hide-text-type
3097 (if (search-forward "\n\n" nil t
)
3101 ;; Hide the trailer as well
3102 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3104 (gnus-article-hide-text-type
3105 (match-beginning 0) (match-end 0) 'pem
)))))))
3107 (defun article-strip-banner ()
3108 "Strip the banners specified by the `banner' group parameter and by
3109 `gnus-article-address-banner-alist'."
3113 (let ((inhibit-point-motion-hooks t
))
3114 (when (gnus-parameter-banner gnus-newsgroup-name
)
3115 (article-really-strip-banner
3116 (gnus-parameter-banner gnus-newsgroup-name
)))
3117 (when gnus-article-address-banner-alist
3118 ;; Note that the From header is decoded here, so it is
3119 ;; required that the *-extract-address-components function
3120 ;; supports non-ASCII text.
3121 (let ((from (save-restriction
3123 (article-narrow-to-head)
3124 (mail-fetch-field "from"))))
3127 (cadr (funcall gnus-extract-address-components
3130 (dolist (pair gnus-article-address-banner-alist
)
3131 (when (string-match (car pair
) from
)
3133 (article-really-strip-banner (cdr pair
)))))))))))))
3135 (defun article-really-strip-banner (banner)
3136 "Strip the banner specified by the argument."
3139 (let ((inhibit-point-motion-hooks t
)
3140 (gnus-signature-limit nil
)
3141 (inhibit-read-only t
))
3144 ((eq banner
'signature
)
3145 (when (gnus-article-narrow-to-signature)
3148 (delete-region (point) (point-max))))
3150 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3151 (while (re-search-forward banner nil t
)
3152 (delete-region (match-beginning 0) (match-end 0)))))
3154 (while (re-search-forward banner nil t
)
3155 (delete-region (match-beginning 0) (match-end 0)))))))))
3157 (defun article-babel ()
3158 "Translate article using an online translation service."
3161 (gnus-with-article-buffer
3162 (when (article-goto-body)
3163 (let* ((start (point))
3165 (orig (buffer-substring start end
))
3166 (trans (babel-as-string orig
)))
3168 (narrow-to-region start end
)
3169 (delete-region start end
)
3172 (defun article-hide-signature (&optional arg
)
3173 "Hide the signature in the current article.
3174 If given a negative prefix, always show; if given a positive prefix,
3176 (interactive (gnus-article-hidden-arg))
3177 (unless (gnus-article-check-hidden-text 'signature arg
)
3180 (let ((inhibit-read-only t
))
3181 (when (gnus-article-narrow-to-signature)
3182 (gnus-article-hide-text-type
3183 (point-min) (point-max) 'signature
))))))
3184 (gnus-set-mode-line 'article
))
3186 (defun article-strip-headers-in-body ()
3187 "Strip offensive headers from bodies."
3191 (let ((case-fold-search t
))
3192 (when (looking-at "x-no-archive:")
3193 (gnus-delete-line)))))
3195 (defun article-strip-leading-blank-lines ()
3196 "Remove all blank lines from the beginning of the article."
3199 (let ((inhibit-point-motion-hooks t
)
3200 (inhibit-read-only t
))
3201 (when (article-goto-body)
3202 (while (and (not (eobp))
3203 (looking-at "[ \t]*$"))
3204 (gnus-delete-line))))))
3206 (defun article-narrow-to-head ()
3207 "Narrow the buffer to the head of the message.
3208 Point is left at the beginning of the narrowed-to region."
3210 (goto-char (point-min))
3212 ;; Absolutely no headers displayed.
3216 ((search-forward "\n\n" nil
1)
3218 ;; Nothing but headers.
3221 (goto-char (point-min)))
3223 (defun article-goto-body ()
3224 "Place point at the start of the body."
3225 (goto-char (point-min))
3227 ;; This variable is only bound when dealing with separate
3229 (article-goto-body-goes-to-point-min-p
3231 ((search-forward "\n\n" nil t
)
3234 (goto-char (point-max))
3237 (defun article-strip-multiple-blank-lines ()
3238 "Replace consecutive blank lines with one empty line."
3241 (let ((inhibit-point-motion-hooks t
)
3242 (inhibit-read-only t
))
3243 ;; First make all blank lines empty.
3245 (while (re-search-forward "^[ \t]+$" nil t
)
3246 (unless (gnus-annotation-in-region-p
3247 (match-beginning 0) (match-end 0))
3248 (replace-match "" nil t
)))
3249 ;; Then replace multiple empty lines with a single empty line.
3251 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3252 (unless (gnus-annotation-in-region-p
3253 (match-beginning 0) (match-end 0))
3254 (delete-region (match-beginning 1) (match-end 1)))))))
3256 (defun article-strip-leading-space ()
3257 "Remove all white space from the beginning of the lines in the article."
3260 (let ((inhibit-point-motion-hooks t
)
3261 (inhibit-read-only t
))
3263 (while (re-search-forward "^[ \t]+" nil t
)
3264 (replace-match "" t t
)))))
3266 (defun article-strip-trailing-space ()
3267 "Remove all white space from the end of the lines in the article."
3270 (let ((inhibit-point-motion-hooks t
)
3271 (inhibit-read-only t
))
3273 (while (re-search-forward "[ \t]+$" nil t
)
3274 (replace-match "" t t
)))))
3276 (defun article-strip-blank-lines ()
3277 "Strip leading, trailing and multiple blank lines."
3279 (article-strip-leading-blank-lines)
3280 (article-remove-trailing-blank-lines)
3281 (article-strip-multiple-blank-lines))
3283 (defun article-strip-all-blank-lines ()
3284 "Strip all blank lines."
3287 (let ((inhibit-point-motion-hooks t
)
3288 (inhibit-read-only t
))
3290 (while (re-search-forward "^[ \t]*\n" nil t
)
3291 (replace-match "" t t
)))))
3293 (defun gnus-article-narrow-to-signature ()
3294 "Narrow to the signature; return t if a signature is found, else nil."
3295 (let ((inhibit-point-motion-hooks t
))
3296 (when (gnus-article-search-signature)
3298 ;; Check whether we have some limits to what we consider
3299 ;; to be a signature.
3300 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3301 (list gnus-signature-limit
)))
3303 (while (setq limit
(pop limits
))
3304 (if (or (and (integerp limit
)
3305 (< (- (point-max) (point)) limit
))
3307 (< (count-lines (point) (point-max)) limit
))
3308 (and (functionp limit
)
3310 (and (stringp limit
)
3311 (not (re-search-forward limit nil t
))))
3312 () ; This limit did not succeed.
3316 (narrow-to-region (point) (point-max))
3319 (defun gnus-article-search-signature ()
3320 "Search the current buffer for the signature separator.
3321 Put point at the beginning of the signature separator."
3322 (let ((cur (point)))
3323 (goto-char (point-max))
3324 (if (if (stringp gnus-signature-separator
)
3325 (re-search-backward gnus-signature-separator nil t
)
3326 (let ((seps gnus-signature-separator
))
3328 (not (re-search-backward (car seps
) nil t
)))
3335 (defun gnus-article-hidden-arg ()
3336 "Return the current prefix arg as a number, or 0 if no prefix."
3337 (list (if current-prefix-arg
3338 (prefix-numeric-value current-prefix-arg
)
3341 (defun gnus-article-check-hidden-text (type arg
)
3342 "Return nil if hiding is necessary.
3343 Arg can be nil or a number. nil and positive means hide, negative
3344 means show, 0 means toggle."
3347 (let ((hide (gnus-article-hidden-text-p type
)))
3353 (gnus-article-show-hidden-text type
)
3356 (if (eq hide
'hidden
)
3358 (gnus-article-show-hidden-text type
)
3362 (defun gnus-article-hidden-text-p (type)
3363 "Say whether the current buffer contains hidden text of type TYPE."
3364 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3366 (not (get-text-property pos
'invisible
))
3367 (not (get-text-property pos
'dummy-invisible
)))
3369 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3374 (defun gnus-article-show-hidden-text (type &optional _dummy
)
3375 "Show all hidden text of type TYPE.
3376 Originally it is hide instead of DUMMY."
3377 (let ((inhibit-read-only t
)
3378 (inhibit-point-motion-hooks t
))
3379 (gnus-remove-text-properties-when
3381 (point-min) (point-max)
3382 (cons 'article-type
(cons type
3383 gnus-hidden-properties
)))
3384 (gnus-delete-wash-type type
)))
3386 (defconst article-time-units
3387 `((year .
,(* 365.25 24 60 60))
3388 (week .
,(* 7 24 60 60))
3389 (day .
,(* 24 60 60))
3393 "Mapping from time units to seconds.")
3395 (defun gnus-article-forward-header ()
3396 "Move point to the start of the next header.
3397 If the current header is a continuation header, this can be several
3402 (if (looking-at "[ \t]+[^ \t]")
3406 (defun article-treat-date ()
3407 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3408 (with-current-buffer gnus-summary-buffer
3409 gnus-article-date-headers
)
3410 gnus-article-date-headers
)
3413 (defun article-date-ut (&optional type _highlight date-position
)
3414 "Convert DATE date to TYPE in the current article.
3415 The default type is `ut'. See `gnus-article-date-headers' for
3417 (interactive (list 'ut t
))
3418 (let* ((case-fold-search t
)
3419 (inhibit-read-only t
)
3420 (inhibit-point-motion-hooks t
)
3421 (visible-date (mail-fetch-field "Date"))
3422 pos date bface eface
)
3426 (goto-char date-position
)
3427 (setq date
(get-text-property (point) 'original-date
))
3428 (when (looking-at "[^:]+:[\t ]*")
3429 (setq bface
(get-text-property (match-beginning 0) 'face
)
3430 eface
(get-text-property (match-end 0) 'face
)))
3431 (delete-region (point)
3433 (gnus-article-forward-header)
3435 (article-transform-date date type bface eface
))
3438 (goto-char (point-min))
3439 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3440 (and (setq pos
(next-single-property-change
3441 (point) 'original-date
))
3443 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3444 (1+ (match-beginning 0))
3446 (while (setq pos
(text-property-not-all pos
(point-max)
3447 'gnus-date-type nil
))
3448 (setq date
(get-text-property pos
'original-date
))
3450 (when (looking-at "[^:]+:[\t ]*")
3451 (setq bface
(get-text-property (match-beginning 0) 'face
)
3452 eface
(get-text-property (match-end 0) 'face
)))
3453 (delete-region pos
(or (text-property-any pos
(point-max)
3454 'gnus-date-type nil
)
3456 (unless date
;; the 1st time
3457 (goto-char (point-min))
3458 (while (re-search-forward "^Date:[\t ]*" nil t
)
3459 (setq date
(get-text-property (match-beginning 0)
3461 bface
(get-text-property (match-beginning 0) 'face
)
3462 eface
(get-text-property (match-end 0) 'face
))
3463 (delete-region (point-at-bol) (progn
3464 (gnus-article-forward-header)
3466 (when (and (not date
)
3468 (setq date visible-date
))
3470 (article-transform-date date type bface eface
))
3471 (goto-char (point-max))
3474 (defun article-transform-date (date type bface eface
)
3475 (dolist (this-type (cond
3485 (add-text-properties
3488 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3490 (list 'original-date date
'gnus-date-type this-type
))))
3493 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3494 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3495 (when (match-beginning 2)
3496 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3497 (while (and (zerop (forward-line 1))
3498 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3499 (when (match-beginning 1)
3500 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3502 (defun article-make-date-line (date type
)
3503 "Return a DATE line of TYPE."
3504 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3506 (error "Unknown conversion type: %s" type
))
3508 (let ((time (ignore-errors (date-to-time date
))))
3510 ;; Convert to the local timezone.
3512 (concat "Date: " (message-make-date time
)))
3513 ;; Convert to Universal Time.
3518 (let* ((e (parse-time-string date
))
3519 (tm (apply 'encode-time e
))
3521 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3522 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3523 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3527 ;; Get the original date from the article.
3528 ((eq type
'original
)
3529 (concat "Date: " (if (string-match "\n+$" date
)
3530 (substring date
0 (match-beginning 0))
3532 ;; Let the user define the format.
3533 ((eq type
'user-defined
)
3534 (let ((format (or (condition-case nil
3535 (with-current-buffer gnus-summary-buffer
3536 gnus-article-time-format
)
3538 gnus-article-time-format
)))
3539 (if (functionp format
)
3540 (funcall format time
)
3541 (concat "Date: " (format-time-string format time
)))))
3544 (let ((tz (car (current-time-zone time
))))
3547 (format-time-string "%Y%m%dT%H%M%S" time
)
3548 (format "%s%02d%02d"
3549 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3550 (/ (%
(abs tz
) 3600) 60)))))
3551 ;; Do a lapsed format.
3553 (concat "Date: " (article-lapsed-string time
)))
3554 ;; A combined date/lapsed format.
3555 ((eq type
'combined-lapsed
)
3556 (let ((date-string (article-make-date-line date
'original
))
3562 (concat " (" (article-lapsed-string time segments
) ")"))
3563 (> (+ (length date-string
)
3564 (length lapsed-string
))
3567 (setq segments
(1- segments
)))
3569 (concat date-string lapsed-string
)
3571 ;; Display the date in proper English
3573 (let ((dtime (decode-time time
)))
3576 (number-to-string (nth 3 dtime
))
3577 (let ((digit (%
(nth 3 dtime
) 10)))
3579 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3585 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3587 (number-to-string (nth 5 dtime
))
3589 (format "%02d" (nth 2 dtime
))
3591 (format "%02d" (nth 1 dtime
)))))))
3593 (format "Date: %s (from Gnus)" date
))))
3595 (defun article-lapsed-string (time &optional max-segments
)
3596 ;; If the date is seriously mangled, the timezone functions are
3597 ;; liable to bug out, so we ignore all errors.
3598 (let* ((now (current-time))
3599 (real-time (time-subtract now time
))
3600 (real-sec (and real-time
3601 (+ (* (float (car real-time
)) 65536)
3603 (sec (and real-time
(abs real-sec
)))
3606 (unless max-segments
3607 (setq max-segments
(length article-time-units
)))
3615 ;; This is a bit convoluted, but basically we go
3616 ;; through the time units for years, weeks, etc,
3617 ;; and divide things to see whether that results
3618 ;; in positive answers.
3621 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3622 (>= segments max-segments
))
3623 ;; The (remaining) seconds are too few to
3624 ;; be divided into this time unit.
3626 ;; It's big enough, so we output it.
3627 (setq sec
(- sec
(* num
(cdr unit
))))
3629 (concat (if prev
", " "") (int-to-string
3631 " " (symbol-name (car unit
))
3632 (if (> num
1) "s" ""))
3634 segments
(1+ segments
)))))
3635 article-time-units
"")
3636 ;; If dates are odd, then it might appear like the
3637 ;; article was sent in the future.
3640 " in the future"))))))
3642 (defun article-date-local (&optional highlight
)
3643 "Convert the current article date to the local timezone."
3644 (interactive (list t
))
3645 (article-date-ut 'local highlight
))
3647 (defun article-date-english (&optional highlight
)
3648 "Convert the current article date to something that is proper English."
3649 (interactive (list t
))
3650 (article-date-ut 'english highlight
))
3652 (defun article-date-original (&optional highlight
)
3653 "Convert the current article date to what it was originally.
3654 This is only useful if you have used some other date conversion
3655 function and want to see what the date was before converting."
3656 (interactive (list t
))
3657 (article-date-ut 'original highlight
))
3659 (defun article-date-lapsed (&optional highlight
)
3660 "Convert the current article date to time lapsed since it was sent."
3661 (interactive (list t
))
3662 (article-date-ut 'lapsed highlight
))
3664 (defun article-date-combined-lapsed (&optional highlight
)
3665 "Convert the current article date to time lapsed since it was sent."
3666 (interactive (list t
))
3667 (article-date-ut 'combined-lapsed highlight
))
3669 (defun article-update-date-lapsed ()
3670 "Function to be run from a timer to update the lapsed time line."
3672 (let ((buffer (current-buffer)))
3676 (set-buffer (window-buffer w
))
3677 (when (derived-mode-p 'gnus-article-mode
)
3678 (let ((old-line (count-lines (point-min) (point)))
3679 (old-column (- (point) (line-beginning-position)))
3680 (window-start (window-start w
))
3683 (while (setq pos
(text-property-not-all pos
(point-max)
3684 'gnus-date-type nil
))
3685 (setq next
(or (next-single-property-change pos
3688 (setq type
(get-text-property pos
'gnus-date-type
))
3689 (when (memq type
'(lapsed combined-lapsed user-defined
))
3690 (article-date-ut type t pos
)
3691 (setq end
(or (next-single-property-change pos
3695 (if (/= window-start next
)
3696 (setq window-start nil
)
3697 (set-window-start w end
)))
3700 (goto-char (point-min))
3701 (when (> old-column
0)
3702 (setq old-line
(1- old-line
)))
3703 (forward-line old-line
)
3705 (when (> (current-column) old-column
)
3707 (forward-char old-column
)))))
3709 (set-buffer buffer
))))
3711 (defun gnus-start-date-timer (&optional n
)
3712 "Start a timer to update the Date headers in the article buffers.
3713 The numerical prefix says how frequently (in seconds) the function
3718 (gnus-stop-date-timer)
3719 (setq article-lapsed-timer
3720 (run-at-time 1 n
'article-update-date-lapsed
)))
3722 (defun gnus-stop-date-timer ()
3723 "Stop the Date timer."
3725 (when article-lapsed-timer
3726 (nnheader-cancel-timer article-lapsed-timer
)
3727 (setq article-lapsed-timer nil
)))
3729 (defun article-date-user (&optional highlight
)
3730 "Convert the current article date to the user-defined format.
3731 This format is defined by the `gnus-article-time-format' variable."
3732 (interactive (list t
))
3733 (article-date-ut 'user highlight
))
3735 (defun article-date-iso8601 (&optional highlight
)
3736 "Convert the current article date to ISO8601."
3737 (interactive (list t
))
3738 (article-date-ut 'iso8601 highlight
))
3740 (defmacro gnus-article-save-original-date
(&rest forms
)
3741 "Save the original date as a text property and evaluate FORMS."
3742 `(let* ((case-fold-search t
)
3744 (goto-char (point-min))
3745 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3748 (date (when (and start
3749 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3751 (buffer-substring-no-properties start
3752 (match-beginning 0)))))
3753 (goto-char (point-max))
3754 (skip-chars-backward "\n")
3755 (put-text-property (point-min) (point) 'original-date date
)
3757 (goto-char (point-max))
3758 (skip-chars-backward "\n")
3759 (put-text-property (point-min) (point) 'original-date date
)))
3761 ;; (defun article-show-all ()
3762 ;; "Show all hidden text in the article buffer."
3765 ;; (let ((inhibit-read-only t))
3766 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3768 (defun article-remove-leading-whitespace ()
3769 "Remove excessive whitespace from all headers."
3773 (let ((inhibit-read-only t
))
3774 (article-narrow-to-head)
3775 (goto-char (point-min))
3776 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3777 (delete-region (match-beginning 1) (match-end 1)))))))
3779 (defun article-emphasize (&optional arg
)
3780 "Emphasize text according to `gnus-emphasis-alist'."
3781 (interactive (gnus-article-hidden-arg))
3782 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3786 (with-current-buffer gnus-summary-buffer
3787 gnus-article-emphasis-alist
)
3789 gnus-emphasis-alist
))
3790 (inhibit-read-only t
)
3791 (props (append '(article-type emphasis
)
3792 gnus-hidden-properties
))
3793 regexp elem beg invisible visible face
)
3796 (while (setq elem
(pop alist
))
3798 (setq regexp
(car elem
)
3799 invisible
(nth 1 elem
)
3800 visible
(nth 2 elem
)
3802 (while (re-search-forward regexp nil t
)
3803 (when (and (match-beginning visible
) (match-beginning invisible
))
3804 (gnus-article-hide-text
3805 (match-beginning invisible
) (match-end invisible
) props
)
3806 (gnus-article-unhide-text-type
3807 (match-beginning visible
) (match-end visible
) 'emphasis
)
3808 (gnus-put-overlay-excluding-newlines
3809 (match-beginning visible
) (match-end visible
) 'face face
)
3810 (gnus-add-wash-type 'emphasis
)
3811 (goto-char (match-end invisible
)))))))))
3813 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3814 "Setup newsgroup emphasis alist."
3815 (unless gnus-article-emphasis-alist
3816 (let ((name (and gnus-newsgroup-name
3817 (gnus-group-real-name gnus-newsgroup-name
))))
3818 (make-local-variable 'gnus-article-emphasis-alist
)
3819 (setq gnus-article-emphasis-alist
3821 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3822 (while (setq elem
(pop alist
))
3823 (when (and name
(string-match (car elem
) name
))
3825 highlight
(copy-sequence (cdr elem
)))))
3827 (copy-sequence highlight-words
)
3828 (if gnus-newsgroup-name
3829 (copy-sequence (gnus-group-find-parameter
3830 gnus-newsgroup-name
'highlight-words t
)))
3831 gnus-emphasis-alist
)))))
3833 (defvar gnus-summary-article-menu
)
3834 (defvar gnus-summary-post-menu
)
3836 ;;; Saving functions.
3838 (defun gnus-article-save (save-buffer file
&optional num
)
3839 "Save the currently selected article."
3840 (when (or (get gnus-default-article-saver
:headers
)
3841 (not gnus-save-all-headers
))
3842 ;; Remove headers according to `gnus-saved-headers' or the value
3843 ;; of the `:headers' property that the saver function might have.
3844 (let ((gnus-visible-headers
3845 (or (symbol-value (get gnus-default-article-saver
:headers
))
3846 gnus-saved-headers gnus-visible-headers
))
3847 ;; Ignore group parameter. See `article-hide-headers'.
3848 (gnus-summary-buffer nil
))
3849 (with-current-buffer save-buffer
3850 (article-hide-headers 1 t
))))
3851 (save-window-excursion
3852 (if (not gnus-default-article-saver
)
3853 (error "No default saver is defined")
3854 ;; !!! Magic! The saving functions all save
3855 ;; `gnus-save-article-buffer' (or so they think), but we
3856 ;; bind that variable to our save-buffer.
3857 (set-buffer gnus-article-buffer
)
3858 (let* ((gnus-save-article-buffer save-buffer
)
3861 ((not gnus-prompt-before-saving
) 'default
)
3862 ((eq gnus-prompt-before-saving
'always
) nil
)
3864 (gnus-number-of-articles-to-be-saved
3865 (when (eq gnus-prompt-before-saving t
)
3867 (set-buffer gnus-article-current-summary
)
3868 (funcall gnus-default-article-saver filename
)))))
3870 (defun gnus-read-save-file-name (prompt &optional filename
3871 function group headers variable
3874 (funcall function group headers
(symbol-value variable
)))
3879 ((eq filename
'default
)
3885 (when (symbol-value dir-var
)
3886 (setq default-name
(expand-file-name
3887 (file-name-nondirectory default-name
)
3888 (symbol-value dir-var
))))
3889 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3892 (if (and gnus-number-of-articles-to-be-saved
3893 (> gnus-number-of-articles-to-be-saved
1))
3894 (format "these %d articles"
3895 gnus-number-of-articles-to-be-saved
)
3898 ;; Let the split methods have their say.
3900 ;; No split name was found.
3903 (concat prompt
" (default "
3904 (file-name-nondirectory default-name
) "): ")
3905 (file-name-directory default-name
)
3907 ;; A single group name is returned.
3908 ((stringp split-name
)
3910 (funcall function split-name headers
3911 (symbol-value variable
)))
3913 (concat prompt
" (default "
3914 (file-name-nondirectory default-name
) "): ")
3915 (file-name-directory default-name
)
3917 ;; A single split name was found
3918 ((= 1 (length split-name
))
3919 (let* ((name (expand-file-name
3921 gnus-article-save-directory
))
3922 (dir (cond ((file-directory-p name
)
3923 (file-name-as-directory name
))
3924 ((file-exists-p name
) name
)
3925 (t gnus-article-save-directory
))))
3927 (concat prompt
" (default " name
"): ")
3929 ;; A list of splits was found.
3931 (setq split-name
(nreverse split-name
))
3933 (let ((file-name-history
3934 (nconc split-name file-name-history
)))
3938 (concat prompt
" (`M-p' for defaults): ")
3939 gnus-article-save-directory
3941 gnus-article-save-directory
)))
3942 (car (push result file-name-history
)))))))
3943 ;; Create the directory.
3944 (gnus-make-directory (file-name-directory file
))
3945 ;; If we have read a directory, we append the default file name.
3946 (when (file-directory-p file
)
3947 (setq file
(expand-file-name (file-name-nondirectory
3949 (file-name-as-directory file
))))
3950 ;; Possibly translate some characters.
3951 (nnheader-translate-file-chars file
))))))
3952 (gnus-make-directory (file-name-directory result
))
3954 (set variable result
))
3956 (set dir-var
(file-name-directory result
)))
3959 (defun gnus-article-archive-name (_group)
3960 "Return the first instance of an \"Archive-name\" in the current buffer."
3961 (let ((case-fold-search t
))
3962 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3963 (nnheader-concat gnus-article-save-directory
3964 (match-string 1)))))
3966 (defun gnus-article-nndoc-name (group)
3967 "If GROUP is an nndoc group, return the name of the parent group."
3968 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3969 (gnus-group-get-parameter group
'save-article-group
)))
3971 (defun gnus-summary-save-in-rmail (&optional filename
)
3972 "Append this article to Rmail file.
3973 Optional argument FILENAME specifies file name.
3974 Directory to save to is default to `gnus-article-save-directory'."
3975 (setq filename
(gnus-read-save-file-name
3976 "Save %s in rmail file" filename
3977 gnus-rmail-save-name gnus-newsgroup-name
3978 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3979 (with-current-buffer gnus-save-article-buffer
3983 ;; Note that unlike gnus-summary-save-in-mail, there is no
3984 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3986 (gnus-output-to-rmail filename
))))
3989 (defun gnus-summary-save-in-mail (&optional filename
)
3990 "Append this article to Unix mail file.
3991 Optional argument FILENAME specifies file name.
3992 Directory to save to is default to `gnus-article-save-directory'."
3993 (setq filename
(gnus-read-save-file-name
3994 "Save %s in Unix mail file" filename
3995 gnus-mail-save-name gnus-newsgroup-name
3996 gnus-current-headers
'gnus-newsgroup-last-mail
))
3997 (with-current-buffer gnus-save-article-buffer
4001 (if (and (file-readable-p filename
)
4002 (file-regular-p filename
)
4003 (mail-file-babyl-p filename
))
4004 (gnus-output-to-rmail filename
)
4005 (gnus-output-to-mail filename
)))))
4008 (put 'gnus-summary-save-in-file
:decode t
)
4009 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4010 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4011 "Append this article to file.
4012 Optional argument FILENAME specifies file name.
4013 Directory to save to is default to `gnus-article-save-directory'."
4014 (setq filename
(gnus-read-save-file-name
4015 "Save %s in file" filename
4016 gnus-file-save-name gnus-newsgroup-name
4017 gnus-current-headers
'gnus-newsgroup-last-file
))
4018 (with-current-buffer gnus-save-article-buffer
4022 (when (and overwrite
4023 (file-exists-p filename
))
4024 (delete-file filename
))
4025 (gnus-output-to-file filename
))))
4028 (put 'gnus-summary-write-to-file
:decode t
)
4029 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4030 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4031 (defun gnus-summary-write-to-file (&optional filename
)
4032 "Write this article to a file, overwriting it if the file exists.
4033 Optional argument FILENAME specifies file name.
4034 The directory to save in defaults to `gnus-article-save-directory'."
4035 (setq filename
(gnus-read-save-file-name
4036 "Save %s in file" filename
4037 gnus-file-save-name gnus-newsgroup-name
4038 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4039 (gnus-summary-save-in-file filename t
))
4041 (put 'gnus-summary-save-body-in-file
:decode t
)
4042 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4043 "Append this article body to a file.
4044 Optional argument FILENAME specifies file name.
4045 The directory to save in defaults to `gnus-article-save-directory'."
4046 (setq filename
(gnus-read-save-file-name
4047 "Save %s body in file" filename
4048 gnus-file-save-name gnus-newsgroup-name
4049 gnus-current-headers
'gnus-newsgroup-last-file
))
4050 (with-current-buffer gnus-save-article-buffer
4054 (when (article-goto-body)
4055 (narrow-to-region (point) (point-max)))
4056 (when (and overwrite
4057 (file-exists-p filename
))
4058 (delete-file filename
))
4059 (gnus-output-to-file filename
))))
4062 (put 'gnus-summary-write-body-to-file
:decode t
)
4063 (put 'gnus-summary-write-body-to-file
4064 :function
'gnus-summary-save-body-in-file
)
4065 (defun gnus-summary-write-body-to-file (&optional filename
)
4066 "Write this article body to a file, overwriting it if the file exists.
4067 Optional argument FILENAME specifies file name.
4068 The directory to save in defaults to `gnus-article-save-directory'."
4069 (setq filename
(gnus-read-save-file-name
4070 "Save %s body in file" filename
4071 gnus-file-save-name gnus-newsgroup-name
4072 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4073 (gnus-summary-save-body-in-file filename t
))
4075 (put 'gnus-summary-save-in-pipe
:decode t
)
4076 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4077 (defun gnus-summary-save-in-pipe (&optional command raw
)
4078 "Pipe this article to subprocess COMMAND.
4079 Valid values for COMMAND include:
4081 The executable command name and possibly arguments.
4083 You will be prompted for the command in the minibuffer.
4084 the symbol `default'
4085 It will be replaced with the command which the variable
4086 `gnus-summary-pipe-output-default-command' holds or the command
4087 last used for saving.
4088 Non-nil value for RAW overrides `:decode' and `:headers' properties
4089 and the raw article including all headers will be piped."
4090 (let ((article (gnus-summary-article-number))
4092 (get 'gnus-summary-save-in-pipe
:decode
)))
4093 save-buffer default
)
4095 (if (vectorp (gnus-summary-article-header article
))
4096 (save-current-buffer
4097 (gnus-summary-select-article decode decode nil article
)
4098 (insert-buffer-substring
4102 gnus-original-article-buffer
)
4104 (nnheader-set-temp-buffer " *Gnus Save*"))))
4105 ;; Remove unwanted headers.
4106 (when (and (not raw
)
4107 (or (get 'gnus-summary-save-in-pipe
:headers
)
4108 (not gnus-save-all-headers
)))
4109 (let ((gnus-visible-headers
4110 (or (symbol-value (get 'gnus-summary-save-in-pipe
4112 gnus-saved-headers gnus-visible-headers
))
4113 (gnus-summary-buffer nil
))
4114 (article-hide-headers 1 t
))))
4115 (error "%d is not a real article" article
))
4116 (error "No article to pipe"))
4117 (setq default
(or gnus-summary-pipe-output-default-command
4118 gnus-last-shell-command
))
4119 (unless (stringp command
)
4121 (if (and (eq command
'default
) default
)
4123 (read-shell-command "Shell command on this article: " default
))))
4124 (when (string-equal command
"")
4126 (setq command default
)
4127 (error "A command is required")))
4128 (with-current-buffer save-buffer
4131 (shell-command-on-region (point-min) (point-max) command nil
)))
4132 (gnus-kill-buffer save-buffer
))
4133 (setq gnus-summary-pipe-output-default-command command
))
4135 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4136 "Pipe this article to muttprint."
4137 (unless (stringp command
)
4138 (setq command
(read-string
4139 "Print using command: " gnus-summary-muttprint-program
4140 nil gnus-summary-muttprint-program
)))
4141 (let ((gnus-summary-pipe-output-default-command
4142 gnus-summary-pipe-output-default-command
))
4143 (gnus-summary-save-in-pipe command
))
4144 (setq gnus-summary-muttprint-program command
))
4146 ;;; Article file names when saving.
4148 (defun gnus-capitalize-newsgroup (newsgroup)
4149 "Capitalize NEWSGROUP name."
4150 (when (not (zerop (length newsgroup
)))
4151 (concat (char-to-string (upcase (aref newsgroup
0)))
4152 (substring newsgroup
1))))
4154 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4155 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4156 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4157 Otherwise, it is like ~/News/news/group/num."
4160 (concat (if (gnus-use-long-file-name 'not-save
)
4161 (gnus-capitalize-newsgroup newsgroup
)
4162 (gnus-newsgroup-directory-form newsgroup
))
4163 "/" (int-to-string (mail-header-number headers
)))
4164 gnus-article-save-directory
)))
4166 (string-equal (file-name-directory default
)
4167 (file-name-directory last-file
))
4168 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4170 (or last-file default
))))
4172 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4173 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4174 If variable `gnus-use-long-file-name' is non-nil, it is
4175 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4178 (concat (if (gnus-use-long-file-name 'not-save
)
4180 (gnus-newsgroup-directory-form newsgroup
))
4181 "/" (int-to-string (mail-header-number headers
)))
4182 gnus-article-save-directory
)))
4184 (string-equal (file-name-directory default
)
4185 (file-name-directory last-file
))
4186 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4188 (or last-file default
))))
4190 (defun gnus-plain-save-name (newsgroup _headers
&optional last-file
)
4191 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4192 If variable `gnus-use-long-file-name' is non-nil, it is
4193 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4196 (if (gnus-use-long-file-name 'not-save
)
4199 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4201 gnus-article-save-directory
)))
4203 (defun gnus-sender-save-name (_newsgroup headers
&optional _last-file
)
4204 "Generate file name from sender."
4205 (let ((from (mail-header-from headers
)))
4207 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4208 (match-string 1 from
)
4210 gnus-article-save-directory
)))
4212 (defun article-verify-x-pgp-sig ()
4214 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4216 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4217 (let ((sig (with-current-buffer gnus-original-article-buffer
4218 (gnus-fetch-field "X-PGP-Sig")))
4222 (mml2015-clear-verify-function))
4224 (insert-buffer-substring gnus-original-article-buffer
)
4225 (setq items
(split-string sig
))
4226 (message-narrow-to-head)
4227 (let ((inhibit-point-motion-hooks t
)
4228 (case-fold-search t
))
4229 ;; Don't verify multiple headers.
4230 (setq headers
(mapconcat (lambda (header)
4232 (mail-fetch-field header
)
4234 (split-string (nth 1 items
) ",") "")))
4235 (delete-region (point-min) (point-max))
4236 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4237 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4242 (if (looking-at "^-")
4245 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4246 (insert "Version: " (car items
) "\n\n")
4247 (insert (mapconcat 'identity
(cddr items
) "\n"))
4248 (insert "\n-----END PGP SIGNATURE-----\n")
4249 (let ((mm-security-handle (list (format "multipart/signed"))))
4250 (mml2015-clean-buffer)
4251 (let ((coding-system-for-write (or gnus-newsgroup-charset
4253 (funcall (mml2015-clear-verify-function)))
4255 (or (mm-handle-multipart-ctl-parameter
4256 mm-security-handle
'gnus-details
)
4257 (mm-handle-multipart-ctl-parameter
4258 mm-security-handle
'gnus-info
)))))
4260 (let ((inhibit-read-only t
) bface eface
)
4262 (message-narrow-to-head)
4263 (goto-char (point-max))
4265 (setq bface
(get-text-property (point-at-bol) 'face
)
4266 eface
(get-text-property (1- (point-at-eol)) 'face
))
4267 (message-remove-header "X-Gnus-PGP-Verify")
4268 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4270 (goto-char (point-max)))
4271 (narrow-to-region (point) (point))
4272 (insert "X-Gnus-PGP-Verify: " info
"\n")
4273 (goto-char (point-min))
4276 (if (not (looking-at "^[ \t]"))
4280 (goto-char (point-min))
4281 (when (looking-at "\\([^:]+\\): *")
4282 (put-text-property (match-beginning 1) (1+ (match-end 1))
4284 (put-text-property (match-end 0) (point-max)
4285 'face eface
)))))))))
4287 (defun article-verify-cancel-lock ()
4288 "Verify Cancel-Lock header."
4290 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4291 (canlock-verify gnus-original-article-buffer
)))
4298 (setq afunc
(car func
)
4301 gfunc
(intern (format "gnus-%s" func
))))
4303 (when (fboundp afunc
)
4304 `(lambda (&optional interactive
&rest args
)
4305 ,(documentation afunc t
)
4306 (interactive (list t
))
4307 (with-current-buffer gnus-article-buffer
4309 (call-interactively ',afunc
)
4310 (apply ',afunc args
))))))))
4311 '(article-hide-headers
4312 article-verify-x-pgp-sig
4313 article-verify-cancel-lock
4314 article-hide-boring-headers
4315 article-treat-overstrike
4316 article-treat-ansi-sequences
4317 article-fill-long-lines
4318 article-capitalize-sentences
4320 article-remove-leading-whitespace
4321 article-display-x-face
4322 article-display-face
4323 article-de-quoted-unreadable
4324 article-de-base64-unreadable
4327 article-unsplit-urls
4328 article-hide-list-identifiers
4329 article-strip-banner
4332 article-hide-signature
4333 article-strip-headers-in-body
4334 article-remove-trailing-blank-lines
4335 article-strip-leading-blank-lines
4336 article-strip-multiple-blank-lines
4337 article-strip-leading-space
4338 article-strip-trailing-space
4339 article-strip-blank-lines
4340 article-strip-all-blank-lines
4342 article-date-english
4343 article-date-iso8601
4344 article-date-original
4347 article-decode-mime-words
4348 article-decode-charset
4349 article-decode-encoded-words
4352 article-date-combined-lapsed
4354 article-treat-dumbquotes
4355 article-treat-non-ascii
4356 article-normalize-headers
4357 ;;(article-show-all . gnus-article-show-all-headers)
4361 ;;; Gnus article mode
4364 (put 'gnus-article-mode
'mode-class
'special
)
4366 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4368 (gnus-define-keys gnus-article-mode-map
4369 " " gnus-article-goto-next-page
4370 [?\S-\
] gnus-article-goto-prev-page
4371 "\177" gnus-article-goto-prev-page
4372 [delete] gnus-article-goto-prev-page
4373 "\C-c^" gnus-article-refer-article
4374 "h" gnus-article-show-summary
4375 "s" gnus-article-show-summary
4376 "\C-c\C-m" gnus-article-mail
4377 "?" gnus-article-describe-briefly
4378 "<" beginning-of-buffer
4380 "\C-c\C-i" gnus-info-find-node
4382 "R" gnus-article-reply-with-original
4383 "F" gnus-article-followup-with-original
4384 "\C-hk" gnus-article-describe-key
4385 "\C-hc" gnus-article-describe-key-briefly
4386 "\C-hb" gnus-article-describe-bindings
4388 "e" gnus-article-read-summary-keys
4389 "\C-d" gnus-article-read-summary-keys
4390 "\M-*" gnus-article-read-summary-keys
4391 "\M-#" gnus-article-read-summary-keys
4392 "\M-^" gnus-article-read-summary-keys
4393 "\M-g" gnus-article-read-summary-keys)
4395 (substitute-key-definition
4396 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4398 (defvar gnus-article-send-map)
4399 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4400 "W" gnus-article-wide-reply-with-original
4401 [t] 'gnus-article-read-summary-send-keys)
4403 (defun gnus-article-make-menu-bar ()
4404 (unless (boundp 'gnus-article-commands-menu)
4405 (gnus-summary-make-menu-bar))
4406 (unless (boundp 'gnus-article-article-menu)
4408 gnus-article-article-menu gnus-article-mode-map ""
4410 ["Scroll forwards" gnus-article-goto-next-page t]
4411 ["Scroll backwards" gnus-article-goto-prev-page t]
4412 ["Show summary" gnus-article-show-summary t]
4413 ["Fetch Message-ID at point" gnus-article-refer-article t]
4414 ["Mail to address at point" gnus-article-mail t]
4415 ["Send a bug report" gnus-bug t]))
4418 gnus-article-treatment-menu gnus-article-mode-map ""
4419 ;; Fixme: this should use :active (and maybe :visible).
4421 ["Hide headers" gnus-article-hide-headers t]
4422 ["Hide signature" gnus-article-hide-signature t]
4423 ["Hide citation" gnus-article-hide-citation t]
4424 ["Treat overstrike" gnus-article-treat-overstrike t]
4425 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4426 ["Remove carriage return" gnus-article-remove-cr t]
4427 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4428 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4429 ["Remove base64" gnus-article-de-base64-unreadable t]
4430 ["Treat html" gnus-article-wash-html t]
4431 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4432 ["Decode HZ" gnus-article-decode-HZ t]))
4434 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4436 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4438 (gnus-run-hooks 'gnus-article-menu-hook)))
4440 (defvar bookmark-make-record-function)
4441 (defvar shr-put-image-function)
4443 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4444 "Major mode for displaying an article.
4446 All normal editing commands are switched off.
4448 The following commands are available in addition to all summary mode
4450 \\<gnus-article-mode-map>
4451 \\[gnus-article-next-page]\t Scroll the article one page forwards
4452 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4453 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4454 \\[gnus-article-show-summary]\t Display the summary buffer
4455 \\[gnus-article-mail]\t Send a reply to the address near point
4456 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4457 \\[gnus-info-find-node]\t Go to the Gnus info node"
4458 (gnus-simplify-mode-line)
4459 (make-local-variable 'minor-mode-alist)
4460 (when (gnus-visual-p 'article-menu 'menu)
4461 (gnus-article-make-menu-bar)
4462 (when gnus-summary-tool-bar-map
4463 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4464 (gnus-update-format-specifications nil 'article-mode)
4465 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4466 (set (make-local-variable 'gnus-page-broken) nil)
4467 (make-local-variable 'gnus-article-current-summary)
4468 (make-local-variable 'gnus-article-mime-handles)
4469 (make-local-variable 'gnus-article-decoded-p)
4470 (make-local-variable 'gnus-article-mime-handle-alist)
4471 (make-local-variable 'gnus-article-wash-types)
4472 (make-local-variable 'gnus-article-image-alist)
4473 (make-local-variable 'gnus-article-charset)
4474 (make-local-variable 'gnus-article-ignored-charsets)
4475 (set (make-local-variable 'bookmark-make-record-function)
4476 'gnus-summary-bookmark-make-record)
4477 ;; Prevent Emacs from displaying non-break space with
4478 ;; `nobreak-space' face.
4479 (set (make-local-variable 'nobreak-char-display) nil)
4480 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4481 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4482 (unless gnus-article-show-cursor
4483 (setq cursor-in-non-selected-windows nil))
4484 (gnus-set-default-directory)
4485 (buffer-disable-undo)
4486 (setq buffer-read-only t
4487 show-trailing-whitespace nil)
4488 (mm-enable-multibyte))
4490 (defun gnus-article-setup-buffer ()
4491 "Initialize the article buffer."
4492 (let* ((name (if gnus-single-article-buffer "*Article*"
4494 (gnus-group-decoded-name gnus-newsgroup-name)
4497 (progn (string-match "\\*Article" name)
4498 (concat " *Original Article"
4499 (substring name (match-end 0))))))
4500 (setq gnus-article-buffer name)
4501 (setq gnus-original-article-buffer original)
4502 (setq gnus-article-mime-handle-alist nil)
4503 (with-current-buffer gnus-summary-buffer
4504 ;; This might be a variable local to the summary buffer.
4505 (unless gnus-single-article-buffer
4506 (setq gnus-article-buffer name)
4507 (setq gnus-original-article-buffer original)
4508 (gnus-set-global-variables)))
4509 (gnus-article-setup-highlight-words)
4510 ;; Init original article buffer.
4511 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4512 (mm-enable-multibyte)
4513 (setq major-mode 'gnus-original-article-mode)
4514 (make-local-variable 'gnus-original-article))
4515 (if (and (get-buffer name)
4516 (with-current-buffer name
4517 (if gnus-article-edit-mode
4518 (if (y-or-n-p "Article mode edit in progress; discard? ")
4520 (set-buffer-modified-p nil)
4521 (gnus-kill-buffer name)
4524 (error "Action aborted"))
4526 (let ((summary gnus-summary-buffer))
4527 (with-current-buffer name
4528 (set (make-local-variable 'gnus-article-edit-mode) nil)
4529 (gnus-article-stop-animations)
4530 (when gnus-article-mime-handles
4531 (mm-destroy-parts gnus-article-mime-handles)
4532 (setq gnus-article-mime-handles nil))
4533 ;; Set it to nil in article-buffer!
4534 (setq gnus-article-mime-handle-alist nil)
4535 (buffer-disable-undo)
4536 (setq buffer-read-only t)
4537 (unless (derived-mode-p 'gnus-article-mode)
4538 (gnus-article-mode))
4539 (set (make-local-variable 'gnus-summary-buffer) summary)
4540 (setq truncate-lines gnus-article-truncate-lines)
4542 (let ((summary gnus-summary-buffer))
4543 (with-current-buffer (gnus-get-buffer-create name)
4545 (setq truncate-lines gnus-article-truncate-lines)
4546 (set (make-local-variable 'gnus-summary-buffer) summary)
4547 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4548 (when article-lapsed-timer
4549 (gnus-stop-date-timer))
4550 (when gnus-article-update-date-headers
4551 (gnus-start-date-timer gnus-article-update-date-headers))
4552 (current-buffer))))))
4554 (defun gnus-article-stop-animations ()
4555 (dolist (timer (and (boundp 'timer-list)
4557 (when (eq (timer--function timer) 'image-animate-timeout)
4558 (cancel-timer timer))))
4560 (defun gnus-stop-downloads ()
4561 (when (boundp 'url-queue)
4562 (set (intern "url-queue" obarray) nil)))
4564 ;; Set article window start at LINE, where LINE is the number of lines
4565 ;; from the head of the article.
4566 (defun gnus-article-set-window-start (&optional line)
4567 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4568 (when article-window
4571 (with-current-buffer gnus-article-buffer
4572 (goto-char (point-min))
4575 (gnus-message 6 "Moved to bookmark")
4576 (search-forward "\n\n" nil t)
4580 (defvar gnus-tmp-internal-hook)
4582 (defun gnus-article-prepare (article &optional all-headers _header)
4583 "Prepare ARTICLE in article mode buffer.
4584 ARTICLE should either be an article number or a Message-ID.
4585 If ARTICLE is an id, HEADER should be the article headers.
4586 If ALL-HEADERS is non-nil, no headers are hidden."
4587 (save-excursion ;FIXME: Shouldn't that be save-current-buffer?
4588 ;; Make sure we start in a summary buffer.
4589 (unless (derived-mode-p 'gnus-summary-mode)
4590 (set-buffer gnus-summary-buffer))
4591 (setq gnus-summary-buffer (current-buffer))
4592 (let* ((summary-buffer (current-buffer))
4593 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4594 (group gnus-newsgroup-name)
4597 (gnus-article-setup-buffer)
4598 (set-buffer gnus-article-buffer)
4599 ;; Deactivate active regions.
4600 (when transient-mark-mode
4601 (setq mark-active nil))
4602 (if (not (setq result (let ((inhibit-read-only t))
4603 (gnus-request-article-this-buffer
4605 ;; There is no such article.
4607 (when (and (numberp article)
4608 (not (memq article gnus-newsgroup-sparse)))
4609 (setq gnus-article-current
4610 (cons gnus-newsgroup-name article))
4611 (set-buffer gnus-summary-buffer)
4612 (setq gnus-current-article article)
4613 (if (and (memq article gnus-newsgroup-undownloaded)
4614 (not (gnus-online (gnus-find-method-for-group
4615 gnus-newsgroup-name))))
4617 (gnus-summary-set-agent-mark article)
4618 (message "Message marked for downloading"))
4619 (gnus-summary-mark-article article gnus-canceled-mark)
4620 (unless (memq article gnus-newsgroup-sparse)
4621 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4622 (if (or (eq result 'pseudo)
4623 (eq result 'nneething))
4625 (with-current-buffer summary-buffer
4626 (push article gnus-newsgroup-history)
4627 (setq gnus-last-article gnus-current-article
4628 gnus-current-article 0
4629 gnus-current-headers nil
4630 gnus-article-current nil)
4631 (if (eq result 'nneething)
4632 (gnus-configure-windows 'summary)
4633 (gnus-configure-windows 'article))
4634 (gnus-set-global-variables))
4635 (let ((gnus-article-mime-handle-alist-1
4636 gnus-article-mime-handle-alist))
4637 (gnus-set-mode-line 'article)))
4638 ;; The result from the `request' was an actual article -
4639 ;; or at least some text that is now displayed in the
4641 (when (and (numberp article)
4642 (not (eq article gnus-current-article)))
4643 ;; Seems like a new article has been selected.
4644 ;; `gnus-current-article' must be an article number.
4645 (with-current-buffer summary-buffer
4646 (push article gnus-newsgroup-history)
4647 (setq gnus-last-article gnus-current-article
4648 gnus-current-article article
4649 gnus-current-headers
4650 (gnus-summary-article-header gnus-current-article)
4651 gnus-article-current
4652 (cons gnus-newsgroup-name gnus-current-article))
4653 (unless (vectorp gnus-current-headers)
4654 (setq gnus-current-headers nil))
4655 (gnus-summary-goto-subject gnus-current-article)
4656 (when (gnus-summary-show-thread)
4657 ;; If the summary buffer really was folded, the
4658 ;; previous goto may not actually have gone to
4659 ;; the right article, but the thread root instead.
4661 (gnus-summary-goto-subject gnus-current-article))
4662 (gnus-run-hooks 'gnus-mark-article-hook)
4663 (gnus-set-mode-line 'summary)
4664 (when (gnus-visual-p 'article-highlight 'highlight)
4665 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4666 ;; Set the global newsgroup variables here.
4667 (gnus-set-global-variables)
4668 (setq gnus-have-all-headers
4669 (or all-headers gnus-show-all-headers))))
4671 (gnus-configure-windows 'article))
4672 (when (or (numberp article)
4674 (gnus-article-prepare-display)
4676 (goto-char (point-min))
4677 (when gnus-break-pages
4678 (gnus-narrow-to-page)))
4679 (let ((gnus-article-mime-handle-alist-1
4680 gnus-article-mime-handle-alist))
4681 (gnus-set-mode-line 'article))
4685 (set-window-point (get-buffer-window (current-buffer)) (point))
4686 (gnus-configure-windows 'article)
4687 (gnus-run-hooks 'gnus-article-prepare-hook)
4690 (defvar gnus-mime-display-attachment-buttons-in-header)
4693 (defun gnus-article-prepare-display ()
4694 "Make the current buffer look like a nice article."
4695 ;; Hooks for getting information from the article.
4696 ;; This hook must be called before being narrowed.
4697 (let ((gnus-article-buffer (current-buffer))
4699 (inhibit-read-only t))
4700 (unless (derived-mode-p 'gnus-article-mode)
4701 (gnus-article-mode))
4702 (setq buffer-read-only nil
4703 gnus-article-wash-types nil
4704 gnus-article-image-alist nil)
4705 (gnus-run-hooks 'gnus-tmp-internal-hook)
4706 (when gnus-display-mime-function
4707 (funcall gnus-display-mime-function))
4708 ;; Add attachment buttons to the header.
4709 (when gnus-mime-display-attachment-buttons-in-header
4710 (gnus-mime-buttonize-attachments-in-header))))
4713 ;;; Gnus Sticky Article Mode
4716 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4717 "Mode for sticky articles."
4718 ;; Release bindings that won't work.
4719 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4720 gnus-sticky-article-mode-map)
4721 (substitute-key-definition 'gnus-article-refer-article 'undefined
4722 gnus-sticky-article-mode-map)
4723 (dolist (k '("e" "h" "s" "F" "R"))
4724 (define-key gnus-sticky-article-mode-map k nil))
4725 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4726 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4727 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4728 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4730 (defun gnus-sticky-article (arg)
4731 "Make the current article sticky.
4732 If a prefix ARG is given, ask for a name for this sticky article buffer."
4734 (gnus-summary-show-thread)
4735 (gnus-summary-select-article nil nil 'pseudo)
4736 (let (new-art-buf-name)
4737 (gnus-eval-in-buffer-window gnus-article-buffer
4738 (setq new-art-buf-name
4742 (read-from-minibuffer "Sticky article buffer name: ")
4743 (gnus-with-article-headers
4744 (gnus-article-goto-header "subject")
4745 (setq new-art-buf-name
4746 (buffer-substring-no-properties
4747 (line-beginning-position) (line-end-position)))
4748 (goto-char (point-min))
4749 (gnus-article-goto-header "from")
4750 (setq new-art-buf-name
4752 new-art-buf-name ", "
4753 (buffer-substring-no-properties
4754 (line-beginning-position) (line-end-position))))
4755 (goto-char (point-min))
4756 (gnus-article-goto-header "date")
4757 (setq new-art-buf-name
4759 new-art-buf-name ", "
4760 (buffer-substring-no-properties
4761 (line-beginning-position) (line-end-position))))))
4763 (if (and (gnus-buffer-live-p new-art-buf-name)
4764 (with-current-buffer new-art-buf-name
4765 (derived-mode-p 'gnus-sticky-article-mode)))
4766 (switch-to-buffer new-art-buf-name)
4767 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4768 (gnus-sticky-article-mode))
4769 (setq gnus-article-buffer new-art-buf-name))
4770 (gnus-summary-recenter)
4771 (gnus-summary-position-point))
4773 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4774 "Kill the given sticky article BUFFER.
4775 If none is given, assume the current buffer and kill it if it has
4776 `gnus-sticky-article-mode'."
4779 (setq buffer (current-buffer)))
4780 (with-current-buffer buffer
4781 (when (derived-mode-p 'gnus-sticky-article-mode)
4782 (gnus-kill-buffer buffer))))
4784 (defun gnus-kill-sticky-article-buffers (arg)
4785 "Kill all sticky article buffers.
4786 If a prefix ARG is given, ask for confirmation."
4788 (dolist (buf (gnus-buffers))
4789 (with-current-buffer buf
4790 (when (derived-mode-p 'gnus-sticky-article-mode)
4792 (gnus-kill-buffer buf)
4793 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4794 (gnus-kill-buffer buf)))))))
4797 ;;; Gnus MIME viewing functions
4800 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4801 "Format of the MIME buttons.
4803 Valid specifiers include:
4805 %T MIME type, along with additional info
4806 %n The `name' parameter
4807 %d The description, if any
4808 %l The length of the encoded part
4809 %p The part identifier number
4810 %e Dots if the part isn't displayed
4812 General format specifiers can also be used. See Info node
4813 `(gnus)Formatting Variables'.")
4815 (defvar gnus-tmp-type)
4816 (defvar gnus-tmp-type-long)
4817 (defvar gnus-tmp-name)
4818 (defvar gnus-tmp-description)
4819 (defvar gnus-tmp-id)
4820 (defvar gnus-tmp-length)
4821 (defvar gnus-tmp-dots)
4822 (defvar gnus-tmp-info)
4823 (defvar gnus-tmp-pressed-details)
4825 (defvar gnus-mime-button-line-format-alist
4826 '((?t gnus-tmp-type ?s)
4827 (?T gnus-tmp-type-long ?s)
4828 (?n gnus-tmp-name ?s)
4829 (?d gnus-tmp-description ?s)
4831 (?l gnus-tmp-length ?d)
4832 (?e gnus-tmp-dots ?s)))
4834 (defvar gnus-mime-button-commands
4835 '((gnus-article-press-button "\r" "Toggle Display")
4836 (gnus-mime-view-part "v" "View Interactively...")
4837 (gnus-mime-view-part-as-type "t" "View As Type...")
4838 (gnus-mime-view-part-as-charset "C" "View As charset...")
4839 (gnus-mime-save-part "o" "Save...")
4840 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4841 (gnus-mime-replace-part "r" "Replace part")
4842 (gnus-mime-delete-part "d" "Delete part")
4843 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4844 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4845 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4846 (gnus-mime-view-part-externally "e" "View Externally")
4847 (gnus-mime-print-part "p" "Print")
4848 (gnus-mime-pipe-part "|" "Pipe To Command...")
4849 (gnus-mime-action-on-part "." "Take action on the part...")))
4851 (defun gnus-article-mime-part-status ()
4852 (if gnus-article-mime-handle-alist-1
4853 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4855 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4858 (defvar gnus-mime-button-map
4859 (let ((map (make-sparse-keymap)))
4860 (define-key map [mouse-2] 'gnus-article-push-button)
4861 (define-key map [down-mouse-3] 'gnus-mime-button-menu)
4862 (dolist (c gnus-mime-button-commands)
4863 (define-key map (cadr c) (car c)))
4867 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4869 ,@(mapcar (lambda (c)
4870 (vector (caddr c) (car c) :active t))
4871 gnus-mime-button-commands)))
4873 (defvar gnus-url-button-commands
4874 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4876 (defvar gnus-url-button-map
4877 (let ((map (make-sparse-keymap)))
4878 (dolist (c gnus-url-button-commands)
4879 (define-key map (cadr c) (car c)))
4883 gnus-url-button-menu gnus-url-button-map "URL button menu."
4885 ,@(mapcar (lambda (c)
4886 (vector (caddr c) (car c) :active t))
4887 gnus-url-button-commands)))
4889 (defmacro gnus-bind-mm-vars (&rest body)
4890 "Bind some mm-* variables and execute BODY."
4891 `(let (mm-html-inhibit-images
4892 mm-html-blocked-images
4893 (mm-w3m-safe-url-regexp mm-w3m-safe-url-regexp))
4894 (with-current-buffer
4895 (cond ((derived-mode-p 'gnus-article-mode)
4896 (if (gnus-buffer-live-p gnus-article-current-summary)
4897 gnus-article-current-summary
4898 ;; Maybe we're in a mml-preview buffer
4899 ;; and no group is selected.
4901 ((gnus-buffer-live-p gnus-summary-buffer)
4902 gnus-summary-buffer)
4903 (t (current-buffer)))
4904 (setq mm-html-inhibit-images gnus-inhibit-images
4905 mm-html-blocked-images (gnus-blocked-images))
4906 (when (or (not gnus-newsgroup-name)
4907 (and (stringp gnus-safe-html-newsgroups)
4908 (string-match gnus-safe-html-newsgroups
4909 gnus-newsgroup-name))
4910 (and (consp gnus-safe-html-newsgroups)
4911 (member gnus-newsgroup-name gnus-safe-html-newsgroups)))
4912 (setq mm-w3m-safe-url-regexp nil)))
4915 (defun gnus-mime-button-menu (event prefix)
4916 "Construct a context-sensitive menu of MIME commands."
4917 (interactive "e\nP")
4918 (save-window-excursion
4919 (let ((pos (event-start event)))
4920 (select-window (posn-window pos))
4921 (goto-char (posn-point pos))
4922 (gnus-article-check-buffer)
4923 (popup-menu gnus-mime-button-menu nil prefix))))
4925 (defun gnus-mime-view-all-parts (&optional handles)
4926 "View all the MIME parts."
4928 (with-current-buffer gnus-article-buffer
4929 (let ((handles (or handles gnus-article-mime-handles))
4930 (mail-parse-charset gnus-newsgroup-charset)
4931 (mail-parse-ignored-charsets
4932 (with-current-buffer gnus-summary-buffer
4933 gnus-newsgroup-ignored-charsets)))
4935 (mm-remove-parts handles)
4936 (goto-char (point-min))
4937 (or (search-forward "\n\n") (goto-char (point-max)))
4938 (let ((inhibit-read-only t))
4939 (delete-region (point) (point-max))
4940 (gnus-bind-mm-vars (mm-display-parts handles)))))))
4942 (defun gnus-article-jump-to-part (n)
4943 "Jump to MIME part N."
4945 (let ((parts (with-current-buffer gnus-article-buffer
4946 (length gnus-article-mime-handle-alist))))
4948 (error "No such part"))
4949 (pop-to-buffer gnus-article-buffer)
4951 (setq n (if (= parts 1)
4953 (read-number (format "Jump to part (1..%s): " parts)))))
4954 (unless (and (integerp n) (<= n parts) (>= n 1))
4957 (gnus-message 7 "Invalid part `%s', using %s instead."
4960 (gnus-message 9 "Jumping to part %s." n)
4961 (cond ((>= gnus-auto-select-part 1)
4962 (while (and (<= n parts)
4963 (not (gnus-article-goto-part n)))
4965 ((< gnus-auto-select-part 0)
4966 (while (and (>= n 1)
4967 (not (gnus-article-goto-part n)))
4970 (gnus-article-goto-part n)))))
4972 (defvar gnus-mime-buttonized-part-id nil
4973 "ID of a mime part that should be buttonized.
4974 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4977 (defsubst gnus-article-edit-part (handles &optional current-id)
4978 "Edit an article in order to delete a mime part.
4979 This function is exclusively used by `gnus-mime-save-part-and-strip'
4980 and `gnus-mime-delete-part', and not provided at run-time normally."
4981 (gnus-article-edit-article
4983 (buffer-disable-undo)
4984 (let ((mail-parse-charset (or gnus-article-charset
4985 ',gnus-newsgroup-charset))
4986 (mail-parse-ignored-charsets
4987 (or gnus-article-ignored-charsets
4988 ',gnus-newsgroup-ignored-charsets))
4989 (mbl mml-buffer-list))
4990 (setq mml-buffer-list nil)
4991 ;; A new text must be inserted before deleting existing ones
4992 ;; at the end so as not to move existing markers of which
4993 ;; the insertion type is t.
4997 (goto-char (point-max))
4998 (insert-buffer-substring gnus-original-article-buffer)))
4999 (mime-to-mml ',handles)
5000 (setq gnus-article-mime-handles nil)
5001 (let ((mbl1 mml-buffer-list))
5002 (setq mml-buffer-list mbl)
5003 (set (make-local-variable 'mml-buffer-list) mbl1))
5004 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5005 `(lambda (no-highlight)
5006 (let ((mail-parse-charset (or gnus-article-charset
5007 ',gnus-newsgroup-charset))
5008 (message-options message-options)
5009 (message-options-set-recipient)
5010 (mail-parse-ignored-charsets
5011 (or gnus-article-ignored-charsets
5012 ',gnus-newsgroup-ignored-charsets)))
5014 (mml-destroy-buffers)
5015 (remove-hook 'kill-buffer-hook
5016 'mml-destroy-buffers t)
5017 (kill-local-variable 'mml-buffer-list))
5018 (gnus-summary-edit-article-done
5019 ,(or (mail-header-references gnus-current-headers) "")
5020 ,(gnus-group-read-only-p)
5021 ,gnus-summary-buffer no-highlight))
5023 ;; Force buttonizing this part.
5024 (let ((gnus-mime-buttonized-part-id current-id))
5025 (gnus-article-edit-done))
5026 (gnus-configure-windows 'article)
5028 (when (and current-id (integerp gnus-auto-select-part))
5029 (gnus-article-jump-to-part
5030 (min (max (+ current-id gnus-auto-select-part) 1)
5031 (with-current-buffer gnus-article-buffer
5032 (length gnus-article-mime-handle-alist)))))))
5034 (defun gnus-mime-replace-part (file)
5035 "Replace MIME part under point with an external body."
5036 ;; Useful if file has already been saved to disk
5039 (read-file-name "Replace MIME part with file: "
5040 (or mm-default-directory default-directory)
5042 (gnus-mime-save-part-and-strip file))
5044 (defun gnus-mime-save-part-and-strip (&optional file)
5045 "Save the MIME part under point then replace it with an external body.
5046 If FILE is given, use it for the external part."
5048 (gnus-article-check-buffer)
5049 (when (gnus-group-read-only-p)
5050 (error "The current group does not support deleting of parts"))
5051 (when (mm-complicated-handles gnus-article-mime-handles)
5053 The current article has a complicated MIME structure, giving up..."))
5054 (let* ((data (get-text-property (point) 'gnus-data))
5055 (id (get-text-property (point) 'gnus-part))
5056 (handles gnus-article-mime-handles))
5059 (and data (mm-save-part data "Delete MIME part and save to: "))))
5061 (with-current-buffer (mm-handle-buffer data)
5063 (insert "Content-Type: " (mm-handle-media-type data))
5064 (mml-insert-parameter-string (cdr (mm-handle-type data))
5066 ;; Add a filename for the sake of saving the part again.
5067 (mml-insert-parameter
5068 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5070 (insert "Content-ID: " (message-make-message-id) "\n")
5071 (insert "Content-Transfer-Encoding: binary\n")
5074 (cdr (mm-make-handle nil
5075 `("message/external-body"
5076 (access-type . "LOCAL-FILE")
5078 ;; (set-buffer gnus-summary-buffer)
5079 (gnus-article-edit-part handles id))))
5081 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5082 ;; parts...>') but with stripping would be nice.
5084 (defun gnus-mime-delete-part ()
5085 "Delete the MIME part under point.
5086 Replace it with some information about the removed part."
5088 (gnus-article-check-buffer)
5089 (when (gnus-group-read-only-p)
5090 (error "The current group does not support deleting of parts"))
5091 (when (mm-complicated-handles gnus-article-mime-handles)
5093 The current article has a complicated MIME structure, giving up..."))
5094 (when (or gnus-expert-user
5095 (gnus-yes-or-no-p "\
5096 Deleting parts may malfunction or destroy the article; continue? "))
5097 (let* ((data (get-text-property (point) 'gnus-data))
5098 (id (get-text-property (point) 'gnus-part))
5099 (handles gnus-article-mime-handles)
5101 (let ((desc (mm-handle-description data)))
5103 (mail-decode-encoded-word-string desc))))
5104 (filename (or (mm-handle-filename data) "(none)"))
5105 (type (mm-handle-media-type data)))
5107 (error "No MIME part under point"))
5108 (with-current-buffer (mm-handle-buffer data)
5109 (let ((bsize (buffer-size)))
5114 "| The following attachment has been deleted:\n"
5116 "| Type: " type "\n"
5117 "| Filename: " filename "\n"
5118 "| Size (encoded): " (format "%s byte%s\n"
5119 bsize (if (= bsize 1)
5123 (concat "| Description: " description "\n"))
5126 (cdr (mm-make-handle
5127 nil `("text/plain" (charset . gnus-decoded)) nil nil
5129 (format "Deleted attachment (%s bytes)" bsize))))))
5130 ;; (set-buffer gnus-summary-buffer)
5131 (gnus-article-edit-part handles id))))
5133 (defun gnus-mime-save-part ()
5134 "Save the MIME part under point."
5136 (gnus-article-check-buffer)
5137 (let ((data (get-text-property (point) 'gnus-data)))
5139 (mm-save-part data))))
5141 (defun gnus-mime-pipe-part (&optional cmd)
5142 "Pipe the MIME part under point to a process.
5143 Use CMD as the process."
5145 (gnus-article-check-buffer)
5146 (let ((data (get-text-property (point) 'gnus-data)))
5148 (mm-pipe-part data cmd))))
5150 (defun gnus-mime-view-part ()
5151 "Interactively choose a viewing method for the MIME part under point."
5153 (gnus-article-check-buffer)
5154 (let ((data (get-text-property (point) 'gnus-data)))
5156 (setq gnus-article-mime-handles
5158 gnus-article-mime-handles (setq data (copy-sequence data))))
5159 (mm-interactively-view-part data))))
5161 (defun gnus-mime-view-part-as-type-internal ()
5162 (gnus-article-check-buffer)
5163 (let* ((handle (get-text-property (point) 'gnus-data))
5165 ;; Content-Type: foo/bar; name=...
5166 (mail-content-type-get (mm-handle-type handle) 'name)
5167 ;; Content-Disposition: attachment; filename=...
5168 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5169 (def-type (and name (mm-default-file-encoding name))))
5170 (or (and def-type (cons def-type 0))
5172 (equal (mm-handle-media-supertype handle) "text")
5173 '("text/plain" . 0))
5174 '("application/octet-stream" . 0))))
5176 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5177 "Choose a MIME media type, and view the part as such.
5178 If non-nil, PRED is a predicate to use during completion to limit the
5179 available media-types."
5183 (let ((default (gnus-mime-view-part-as-type-internal)))
5184 (gnus-completing-read
5187 (gnus-remove-if-not pred (mailcap-mime-types))
5188 (mailcap-mime-types))
5191 (gnus-article-check-buffer)
5192 (let ((handle (get-text-property (point) 'gnus-data)))
5194 (when (equal (mm-handle-media-type handle) "message/external-body")
5195 (unless (mm-handle-cache handle)
5196 (mm-extern-cache-contents handle))
5197 (setq handle (mm-handle-cache handle)))
5199 (mm-make-handle (mm-handle-buffer handle)
5200 (cons mime-type (cdr (mm-handle-type handle)))
5201 (mm-handle-encoding handle)
5202 (mm-handle-undisplayer handle)
5203 (mm-handle-disposition handle)
5204 (mm-handle-description handle)
5206 (mm-handle-id handle)))
5207 (setq gnus-article-mime-handles
5208 (mm-merge-handles gnus-article-mime-handles handle))
5209 (when (mm-handle-displayed-p handle)
5210 (mm-remove-part handle))
5211 (gnus-mm-display-part handle))))
5213 (defun gnus-mime-copy-part (&optional handle arg)
5214 "Put the MIME part under point into a new buffer.
5215 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5217 (interactive (list nil current-prefix-arg))
5218 (gnus-article-check-buffer)
5220 (setq handle (get-text-property (point) 'gnus-data)))
5222 (let ((filename (mm-handle-filename handle))
5223 contents dont-decode charset coding-system)
5224 (mm-with-unibyte-buffer
5225 (mm-insert-part handle)
5226 (setq contents (or (condition-case nil
5227 (mm-decompress-buffer filename nil 'sig)
5229 (setq dont-decode t)
5232 (setq filename (cond (filename (file-name-nondirectory filename))
5233 (dont-decode "*raw data*")
5238 (unless (setq charset (mail-content-type-get
5239 (mm-handle-type handle) 'charset))
5240 (unless (setq coding-system (mm-with-unibyte-buffer
5242 (mm-find-buffer-file-coding-system)))
5243 (setq charset gnus-newsgroup-charset))))
5245 (setq charset (or (cdr (assq arg
5246 gnus-summary-show-article-charset-alist))
5247 (read-coding-system "Charset: ")))))
5248 (switch-to-buffer (generate-new-buffer filename))
5249 (if (or coding-system
5251 (setq coding-system (mm-charset-to-coding-system
5253 (not (eq coding-system 'ascii))))
5255 (mm-enable-multibyte)
5256 (insert (decode-coding-string contents coding-system))
5257 (setq buffer-file-coding-system last-coding-system-used))
5258 (mm-disable-multibyte)
5260 (setq buffer-file-coding-system mm-binary-coding-system))
5261 ;; We do it this way to make `normal-mode' set the appropriate mode.
5264 (setq buffer-file-name (expand-file-name filename))
5266 (setq buffer-file-name nil))
5267 (goto-char (point-min)))))
5269 (defun gnus-mime-print-part (&optional handle filename)
5270 "Print the MIME part under point."
5271 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5272 (gnus-article-check-buffer)
5273 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5274 (contents (and handle (mm-get-part handle)))
5275 (file (make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5276 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5281 (mm-save-part-to-file handle file)
5282 (call-process shell-file-name nil
5283 (generate-new-buffer " *mm*")
5285 shell-command-switch
5287 printer file (mm-handle-type handle))))
5291 (gnus-print-buffer))
5292 (ps-despool filename)))))
5294 (defun gnus-mime-inline-part (&optional handle arg)
5295 "Insert the MIME part under point into the current buffer.
5296 Compressed files like .gz and .bz2 are decompressed."
5297 (interactive (list nil current-prefix-arg))
5298 (gnus-article-check-buffer)
5299 (let* ((inhibit-read-only t)
5301 (btn ;; position where the MIME button exists
5303 (if (eq handle (get-text-property b 'gnus-data))
5306 (or (text-property-any (point) (point-max) 'gnus-data handle)
5307 (text-property-any (point-min) (point) 'gnus-data handle)))
5308 (setq handle (get-text-property b 'gnus-data))
5314 (setq start (next-single-property-change btn 'gnus-data
5316 btn (previous-single-property-change start
5319 (if (and (not arg) (mm-handle-undisplayer handle))
5321 (setq b (copy-marker b)
5322 btn (copy-marker btn))
5323 (mm-remove-part handle))
5327 (if (mm-handle-undisplayer handle)
5328 (mm-remove-part handle)))
5329 ((mm-handle-undisplayer handle)
5330 (mm-remove-part handle)))
5333 ;; This is a header button.
5335 (mm-display-inline handle))
5336 ;; Toggle the button appearance between `[button]...' and `[button]'.
5338 (setq btn (prog1 (marker-position btn)
5339 (set-marker btn nil))))
5341 (let ((displayed-p (mm-handle-displayed-p handle)))
5342 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5346 (next-single-property-change (point) 'gnus-data nil (point-max)))
5347 (setq start (point))
5348 (if (search-backward "\n\n" nil t)
5351 (unless (or displayed-p (eolp))
5352 ;; Add extra newline.
5353 (insert (propertize (buffer-substring (1- start) start)
5354 'gnus-undeletable t))))
5355 ;; We're in the article header.
5357 (dolist (ovl (overlays-in btn (point)))
5358 (overlay-put ovl 'gnus-button-attachment-extra t)
5359 (overlay-put ovl 'face nil))
5361 (message-narrow-to-field)
5362 (let ((gnus-treatment-function-alist
5363 '((gnus-treat-highlight-headers
5364 gnus-article-highlight-headers))))
5365 (gnus-treat-article 'head)))))
5367 (setq b (prog1 (marker-position b)
5368 (set-marker b nil))))
5371 (defun gnus-mime-set-charset-parameters (handle charset)
5372 "Set CHARSET to parameters in HANDLE.
5373 CHARSET may either be a string or a symbol."
5374 (unless (stringp charset)
5375 (setq charset (symbol-name charset)))
5376 (if (stringp (car handle))
5377 (dolist (h (cdr handle))
5378 (gnus-mime-set-charset-parameters h charset))
5379 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5380 "message/external-body")
5382 (unless (mm-handle-cache handle)
5383 (mm-extern-cache-contents handle))
5384 (mm-handle-cache handle))
5386 (param (assq 'charset (cdr type))))
5388 (setcdr param charset)
5389 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5391 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5392 "Insert the MIME part under point into the current buffer using the
5394 (interactive (list nil current-prefix-arg))
5395 (gnus-article-check-buffer)
5396 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5397 (fun (get-text-property (point) 'gnus-callback))
5398 (gnus-newsgroup-ignored-charsets 'gnus-all)
5399 charset form preferred parts)
5406 gnus-summary-show-article-charset-alist))
5407 (read-coding-system "Charset: "))))
5408 (if (mm-handle-undisplayer handle)
5409 (mm-remove-part handle)))
5410 (gnus-mime-set-charset-parameters handle charset)
5411 (when (and (consp (setq form (cdr-safe fun)))
5412 (setq form (ignore-errors
5413 (assq 'gnus-mime-display-alternative form)))
5414 (setq preferred (caddr form))
5416 (when (eq (car preferred) 'quote)
5417 (setq preferred (cadr preferred)))
5418 (not (equal preferred
5419 (get-text-property (point) 'gnus-data))))
5420 (setq parts (get-text-property (point) 'gnus-part))
5421 (setq parts (cdr (assq parts
5422 gnus-article-mime-handle-alist)))
5423 (equal (mm-handle-media-type parts) "multipart/alternative")
5424 (setq parts (reverse (cdr parts))))
5426 (list 'quote (or (cadr (member preferred parts))
5428 (funcall fun handle)))))
5430 (defun gnus-mime-view-part-externally (&optional handle)
5431 "View the MIME part under point with an external viewer."
5433 (gnus-article-check-buffer)
5434 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5435 (mm-inlined-types nil)
5436 (mail-parse-charset gnus-newsgroup-charset)
5437 (mail-parse-ignored-charsets
5438 (with-current-buffer gnus-summary-buffer
5439 gnus-newsgroup-ignored-charsets))
5440 (type (mm-handle-media-type handle))
5441 (method (mailcap-mime-info type))
5442 (mm-enable-external t))
5443 (if (not (stringp method))
5444 (gnus-mime-view-part-as-type
5445 nil (lambda (type) (stringp (mailcap-mime-info type))))
5447 (mm-display-part handle nil t)))))
5449 (defun gnus-mime-view-part-internally (&optional handle)
5450 "View the MIME part under point with an internal viewer.
5451 If no internal viewer is available, use an external viewer."
5453 (gnus-article-check-buffer)
5454 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5455 (mm-inlined-types '(".*"))
5456 (mm-inline-large-images t)
5457 (mail-parse-charset gnus-newsgroup-charset)
5458 (mail-parse-ignored-charsets
5459 (with-current-buffer gnus-summary-buffer
5460 gnus-newsgroup-ignored-charsets))
5461 (inhibit-read-only t))
5462 (if (not (mm-inlinable-p handle))
5463 (gnus-mime-view-part-as-type
5464 nil (lambda (type) (mm-inlinable-p handle type)))
5466 (gnus-bind-mm-vars (mm-display-part handle nil t))))))
5468 (defun gnus-mime-action-on-part (&optional action)
5469 "Do something with the MIME attachment at (point)."
5471 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5472 (gnus-article-check-buffer)
5473 (let ((action-pair (assoc action gnus-mime-action-alist)))
5475 (funcall (cdr action-pair)))))
5477 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5478 "Call FUNCTION on MIME part N.
5479 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5480 If INTERACTIVE, call FUNCTION interactively."
5482 ;; Check whether the article is displayed.
5483 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5484 (setq window (get-buffer-window gnus-article-buffer t))
5485 (frame-visible-p (setq frame (window-frame window))))
5486 (error "No article is displayed"))
5487 (with-current-buffer gnus-article-buffer
5488 ;; Check whether the article displays the right contents.
5489 (unless (with-current-buffer gnus-summary-buffer
5490 (eq gnus-current-article (gnus-summary-article-number)))
5491 (error "You should select the right article first"))
5493 (setq n (prefix-numeric-value n))
5495 (setq n (or (get-text-property pt 'gnus-part)
5497 (get-text-property (1- pt) 'gnus-part))
5498 (get-text-property (prog2
5504 (or (and (setq pt (previous-single-property-change
5507 (next-single-property-change (point) 'gnus-part)
5511 ;; Check whether the specified part exists.
5512 (when (> n (length gnus-article-mime-handle-alist))
5513 (error "No such part")))
5516 ;; To select the window is needed so that the cursor
5517 ;; might be visible on the MIME button.
5518 (select-window (prog1
5520 (setq window (selected-window))
5521 ;; Article may be displayed in the other frame.
5522 (select-frame-set-input-focus
5525 (setq frame (selected-frame))))))
5526 (when (gnus-article-goto-part n)
5527 ;; We point the cursor and the arrow at the MIME button
5528 ;; when the `function' prompt the user for something.
5529 (unless (and (pos-visible-in-window-p)
5530 (> (count-lines (point) (window-end))
5531 (/ (1- (window-height)) 3)))
5532 (recenter (/ (1- (window-height)) 3)))
5533 (let ((cursor-in-non-selected-windows t)
5534 (overlay-arrow-string "=>")
5535 (overlay-arrow-position (point-marker)))
5538 ((and no-handle interactive)
5539 (call-interactively function))
5544 function (get-text-property (point) 'gnus-data)))
5547 (get-text-property (point) 'gnus-data))))
5548 (set-marker overlay-arrow-position nil)
5549 (unless gnus-auto-select-part
5550 (select-frame-set-input-focus frame)
5551 (select-window window))))
5553 (if gnus-inhibit-mime-unbuttonizing
5554 ;; This is the default though the program shouldn't reach here.
5555 (error "No such part")
5556 ;; The part which doesn't have the MIME button is selected.
5557 ;; So, we display all the buttons and redo it.
5558 (let ((gnus-inhibit-mime-unbuttonizing t))
5559 (gnus-summary-show-article)
5560 (gnus-article-part-wrapper n function no-handle))))))
5562 (defun gnus-article-pipe-part (n)
5563 "Pipe MIME part N, which is the numerical prefix."
5565 (gnus-article-part-wrapper n 'mm-pipe-part))
5567 (defun gnus-article-save-part (n)
5568 "Save MIME part N, which is the numerical prefix."
5570 (gnus-article-part-wrapper n 'mm-save-part))
5572 (defun gnus-article-interactively-view-part (n)
5573 "View MIME part N interactively, which is the numerical prefix."
5575 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5577 (defun gnus-article-copy-part (n)
5578 "Copy MIME part N, which is the numerical prefix."
5580 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5582 (defun gnus-article-view-part-as-charset (n)
5583 "View MIME part N using a specified charset.
5584 N is the numerical prefix."
5586 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5588 (defun gnus-article-view-part-externally (n)
5589 "View MIME part N externally, which is the numerical prefix."
5591 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5593 (defun gnus-article-inline-part (n)
5594 "Inline MIME part N, which is the numerical prefix."
5596 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5598 (defun gnus-article-save-part-and-strip (n)
5599 "Save MIME part N and replace it with an external body.
5600 N is the numerical prefix."
5602 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5604 (defun gnus-article-replace-part (n)
5605 "Replace MIME part N with an external body.
5606 N is the numerical prefix."
5608 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5610 (defun gnus-article-delete-part (n)
5611 "Delete MIME part N and add some information about the removed part.
5612 N is the numerical prefix."
5614 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5616 (defun gnus-article-view-part-as-type (n)
5617 "Choose a MIME media type, and view part N as such.
5618 N is the numerical prefix."
5620 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5622 (defun gnus-article-mime-match-handle-first (condition)
5625 (dolist (ihandle gnus-article-mime-handle-alist)
5627 ((functionp condition)
5628 (funcall condition (cdr ihandle)))
5629 ((eq condition 'undisplayed)
5630 (not (or (mm-handle-undisplayer (cdr ihandle))
5631 (equal (mm-handle-media-type (cdr ihandle))
5632 "multipart/alternative"))))
5633 ((eq condition 'undisplayed-alternative)
5634 (not (mm-handle-undisplayer (cdr ihandle))))
5636 (gnus-article-goto-part (car ihandle))
5637 (or (not n) (< (car ihandle) n)))
5638 (setq n (car ihandle))))
5642 (defun gnus-article-view-part (&optional n)
5643 "View MIME part N, which is the numerical prefix.
5644 If the part is already shown, hide the part. If N is nil, view
5647 (with-current-buffer gnus-article-buffer
5648 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5649 gnus-article-mime-match-handle-function)))
5650 (when (> n (length gnus-article-mime-handle-alist))
5651 (error "No such part"))
5652 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5653 (when (gnus-article-goto-part n)
5654 (if (equal (car handle) "multipart/alternative")
5656 (beginning-of-line) ;; Make it toggle subparts
5657 (gnus-article-press-button))
5658 (when (eq (gnus-mm-display-part handle) 'internal)
5659 (gnus-set-window-start)))))))
5661 (defsubst gnus-article-mime-total-parts ()
5662 (if (bufferp (car gnus-article-mime-handles))
5664 (1- (length gnus-article-mime-handles))))
5666 (defun gnus-mm-display-part (handle)
5667 "Display HANDLE and fix MIME button."
5668 (let ((id (get-text-property (point) 'gnus-part))
5670 (inhibit-read-only t)
5671 (window (selected-window))
5672 (mail-parse-charset gnus-newsgroup-charset)
5673 (mail-parse-ignored-charsets
5674 (if (gnus-buffer-live-p gnus-summary-buffer)
5675 (with-current-buffer gnus-summary-buffer
5676 gnus-newsgroup-ignored-charsets)
5681 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5685 (setq start (next-single-property-change point 'gnus-data
5687 point (previous-single-property-change start 'gnus-data))
5688 (if (mm-handle-displayed-p handle)
5689 ;; This will remove the part.
5690 (setq point (copy-marker point)
5691 retval (mm-display-part handle))
5692 (let ((part (or (and (mm-inlinable-p handle)
5693 (mm-inlined-p handle)
5697 (setq retval (mm-display-part handle)))
5698 (unless (zerop (buffer-size))
5699 (buffer-string))))))
5702 ;; This is a header button.
5704 (cond ((stringp part)
5706 (narrow-to-region (point)
5709 (unless (bolp) (insert "\n"))
5711 (gnus-treat-article nil id
5712 (gnus-article-mime-total-parts)
5713 (mm-handle-media-type handle))
5714 (mm-handle-set-undisplayer
5717 (let ((inhibit-read-only t))
5718 (delete-region ,(copy-marker (point-min) t)
5719 ,(point-max-marker)))))))
5721 (mm-display-inline handle))))))
5722 (when (markerp point)
5723 (setq point (prog1 (marker-position point)
5724 (set-marker point nil))))
5726 ;; Toggle the button appearance between `[button]...' and `[button]'.
5727 (let ((displayed-p (mm-handle-displayed-p handle)))
5728 (gnus-insert-mime-button handle id (list displayed-p))
5731 (next-single-property-change (point) 'gnus-data nil (point-max)))
5732 (setq start (point))
5733 (if (search-backward "\n\n" nil t)
5736 (unless (or displayed-p (eolp))
5737 ;; Add extra newline.
5738 (insert (propertize (buffer-substring (1- start) start)
5739 'gnus-undeletable t))))
5740 ;; We're in the article header.
5742 (dolist (ovl (overlays-in point (point)))
5743 (overlay-put ovl 'gnus-button-attachment-extra t)
5744 (overlay-put ovl 'face nil))
5746 (message-narrow-to-field)
5747 (let ((gnus-treatment-function-alist
5748 '((gnus-treat-highlight-headers
5749 gnus-article-highlight-headers))))
5750 (gnus-treat-article 'head)))))
5752 (if (window-live-p window)
5753 (select-window window)))
5756 (defun gnus-article-goto-part (n)
5757 "Go to MIME part N."
5758 (when gnus-break-pages
5762 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5763 ;; There may be header buttons.
5764 (text-property-any (point-min) (point) 'gnus-part n)))
5765 part handle end next handles)
5768 (if (setq handle (get-text-property start 'gnus-data))
5770 ;; Go to the displayed subpart, assuming this is
5771 ;; multipart/alternative.
5774 (while (and (not handle)
5777 (setq next (text-property-not-all part end
5780 handle (get-text-property part 'gnus-data))
5781 (push (cons handle part) handles)
5782 (unless (mm-handle-displayed-p handle)
5784 part (text-property-any part end 'gnus-data nil))))
5786 ;; No subpart is displayed, so we find preferred one.
5788 (cdr (assq (mm-preferred-alternative
5789 (nreverse (mapcar 'car handles)))
5792 (goto-char (1+ part))
5794 (when gnus-break-pages
5795 (gnus-narrow-to-page))))
5797 (defun gnus-insert-mime-button (handle id &optional displayed)
5798 (let ((gnus-tmp-name
5799 (or (mm-handle-filename handle)
5800 (mail-content-type-get (mm-handle-type handle) 'url)
5803 (gnus-tmp-type (mm-handle-media-type handle))
5804 (gnus-tmp-description (or (mm-handle-description handle) ""))
5806 (if (if displayed (car displayed)
5807 (mm-handle-displayed-p handle))
5809 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5811 gnus-tmp-type-long b e)
5812 (when (string-match ".*/" gnus-tmp-name)
5813 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5814 (setq gnus-tmp-type-long (concat gnus-tmp-type
5815 (and (not (equal gnus-tmp-name ""))
5816 (concat "; " gnus-tmp-name))))
5817 (unless (equal gnus-tmp-description "")
5818 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5821 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5822 `(keymap ,gnus-mime-button-map
5823 gnus-callback gnus-mm-display-part
5824 gnus-part ,gnus-tmp-id
5825 article-type annotation
5829 ;; Exclude a newline.
5832 (when gnus-article-button-face
5833 (overlay-put (make-overlay b e nil t)
5834 'face gnus-article-button-face))
5835 (widget-convert-button
5838 :action 'gnus-widget-press-button
5839 :button-keymap gnus-mime-button-map
5843 "%S: %s the MIME part; %S: more options"
5845 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5849 (defun gnus-widget-press-button (elems _el)
5850 (goto-char (widget-get elems :from))
5851 (gnus-article-press-button))
5853 (defvar gnus-displaying-mime nil)
5855 (defun gnus-display-mime (&optional ihandles)
5856 "Display the MIME parts."
5858 (save-selected-window
5859 (let ((window (get-buffer-window gnus-article-buffer))
5862 (select-window window)
5863 ;; We have to do this since selecting the window
5864 ;; may change the point. So we set the window point.
5865 (set-window-point window point)))
5866 (let ((handles ihandles)
5867 (inhibit-read-only t))
5869 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5870 (when gnus-article-emulate-mime
5871 (mm-uu-dissect-text-parts handles)))
5872 (gnus-article-emulate-mime
5873 (setq handles (mm-uu-dissect))))
5874 (when (and (not ihandles)
5875 (not gnus-displaying-mime))
5876 ;; Top-level call; we clean up.
5877 (when gnus-article-mime-handles
5878 (mm-destroy-parts gnus-article-mime-handles)
5879 (setq gnus-article-mime-handle-alist nil));; A trick.
5880 (setq gnus-article-mime-handles handles)
5881 ;; We allow users to glean info from the handles.
5882 (when gnus-article-mime-part-function
5883 (gnus-mime-part-function handles)))
5885 (or (not (stringp (car handles)))
5888 (when (and (not ihandles)
5889 (not gnus-displaying-mime))
5890 ;; Clean up for mime parts.
5892 (delete-region (point) (point-max)))
5893 (let ((gnus-displaying-mime t))
5894 (gnus-mime-display-part handles)))
5897 (narrow-to-region (point) (point-max))
5898 (gnus-treat-article nil 1 1 "text/plain")
5901 ;; Highlight the headers.
5905 (narrow-to-region (point-min) (point))
5906 (gnus-article-save-original-date
5907 (gnus-treat-article 'head)))))))
5908 ;; Cope with broken MIME messages.
5909 (goto-char (point-max))
5913 (defcustom gnus-mime-display-multipart-as-mixed nil
5914 "Display \"multipart\" parts as \"multipart/mixed\".
5916 If t, it overrides nil values of
5917 `gnus-mime-display-multipart-alternative-as-mixed' and
5918 `gnus-mime-display-multipart-related-as-mixed'."
5919 :group 'gnus-article-mime
5922 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5923 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5925 :group 'gnus-article-mime
5928 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5929 "Display \"multipart/related\" parts as \"multipart/mixed\".
5931 If displaying \"text/html\" is discouraged \(see
5932 `mm-discouraged-alternatives') images or other material inside a
5933 \"multipart/related\" part might be overlooked when this variable is nil."
5935 :group 'gnus-article-mime
5938 (defcustom gnus-mime-display-attachment-buttons-in-header t
5939 "Add attachment buttons in the end of the header of an article.
5940 Since MIME attachments tend to be put at the end of an article, we may
5941 overlook them if there is a huge body. This option offers you a copy
5942 of all non-inlinable MIME parts as buttons shown in front of an article.
5943 If nil, don't show those extra buttons."
5945 :group 'gnus-article-mime
5948 (defun gnus-mime-display-part (handle)
5950 ;; Maybe a broken MIME message.
5953 ((not (stringp (car handle)))
5954 (gnus-mime-display-single handle))
5955 ;; User-defined multipart
5956 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5957 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5959 ;; multipart/alternative
5960 ((and (equal (car handle) "multipart/alternative")
5961 (not (or gnus-mime-display-multipart-as-mixed
5962 gnus-mime-display-multipart-alternative-as-mixed)))
5963 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5964 (push (cons id handle) gnus-article-mime-handle-alist)
5965 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5966 ;; multipart/related
5967 ((and (equal (car handle) "multipart/related")
5968 (not (or gnus-mime-display-multipart-as-mixed
5969 gnus-mime-display-multipart-related-as-mixed)))
5970 (gnus-mime-display-part (cadr handle)))
5971 ((equal (car handle) "multipart/signed")
5972 (gnus-add-wash-type 'signed)
5973 (gnus-mime-display-security handle))
5974 ((equal (car handle) "multipart/encrypted")
5975 (gnus-add-wash-type 'encrypted)
5976 (gnus-mime-display-security handle))
5977 ;; Other multiparts are handled like multipart/mixed.
5979 (gnus-mime-display-mixed (cdr handle)))))
5981 (defun gnus-mime-part-function (handles)
5982 (if (stringp (car handles))
5983 (mapcar 'gnus-mime-part-function (cdr handles))
5984 (funcall gnus-article-mime-part-function handles)))
5986 (defun gnus-mime-display-mixed (handles)
5987 (mapcar 'gnus-mime-display-part handles))
5989 (defun gnus-mime-display-single (handle)
5990 (let ((type (mm-handle-media-type handle))
5991 (ignored gnus-ignored-mime-types)
5997 (when (string-match (pop ignored) type)
5998 (throw 'ignored nil)))
5999 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6000 (with-current-buffer gnus-summary-buffer
6001 gnus-inhibit-images)
6002 gnus-inhibit-images)
6003 (string-match "\\`image/" type)))
6004 (setq not-attachment
6005 (and (not (mm-inline-override-p handle))
6006 (or (not (mm-handle-disposition handle))
6007 (equal (car (mm-handle-disposition handle))
6009 (mm-attachment-override-p handle))))
6010 (mm-automatic-display-p handle)
6012 (mm-inlinable-p handle)
6013 (mm-inlined-p handle))
6014 (mm-automatic-external-display-p type)))
6016 (when (equal (mm-handle-media-supertype handle) "text")
6018 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6021 (setq id (1+ (length gnus-article-mime-handle-alist)))
6022 (push (cons id handle) gnus-article-mime-handle-alist))
6024 (equal (mm-handle-media-supertype handle) "message"))
6027 (cond ((not (bolp)) 2)
6028 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6030 (when (or (not display)
6031 (not (gnus-unbuttonized-mime-type-p type))
6032 (eq id gnus-mime-buttonized-part-id))
6033 (gnus-insert-mime-button
6034 handle id (list (or display (and not-attachment text)))))
6038 (let ((mail-parse-charset gnus-newsgroup-charset)
6039 (mail-parse-ignored-charsets
6040 (save-excursion (condition-case ()
6041 (set-buffer gnus-summary-buffer)
6043 gnus-newsgroup-ignored-charsets)))
6044 (gnus-bind-mm-vars (mm-display-part handle t))))
6045 ((and text not-attachment)
6046 (mm-display-inline handle)))
6047 (goto-char (point-max))
6048 (if (string-match "\\`image/" type)
6049 (gnus-article-insert-newline)
6051 (= (skip-chars-backward "\n") -1)
6052 (unless (eobp) (forward-char 1)))
6053 (gnus-article-insert-newline)
6054 (put-text-property (point) (point-max) 'gnus-undeletable t))
6055 (goto-char (point-max)))
6059 (narrow-to-region beg (point))
6060 (if (eq handle gnus-article-mime-handles)
6061 ;; The format=flowed case.
6062 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6063 ;; Don't count signature parts that are never displayed.
6064 ;; The part number should be re-calculated supposing this
6065 ;; might be a message/rfc822 part.
6067 (dolist (part gnus-article-mime-handles)
6068 (unless (or (stringp part)
6069 (equal (car (mm-handle-type part))
6070 "application/pgp-signature"))
6071 (push part handles)))
6073 nil (length (memq handle handles)) (length handles)
6074 (mm-handle-media-type handle)))))))))))
6076 (defun gnus-unbuttonized-mime-type-p (type)
6077 "Say whether TYPE is to be unbuttonized."
6078 (unless gnus-inhibit-mime-unbuttonizing
6080 (let ((types gnus-unbuttonized-mime-types))
6082 (when (string-match (pop types) type)
6083 (throw 'found t)))))
6085 (let ((types gnus-buttonized-mime-types))
6087 (when (string-match (pop types) type)
6088 (throw 'found t)))))))))
6090 (defun gnus-article-insert-newline ()
6091 "Insert a newline, but mark it as undeletable."
6092 (put-text-property (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6094 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6095 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6098 handle (inhibit-read-only t) from begend not-pref)
6099 (save-window-excursion
6102 (narrow-to-region (car ibegend)
6105 (goto-char (car ibegend))
6108 (delete-region (point-min) (point-max))
6109 (mm-remove-parts handles))
6110 (setq begend (list (point-marker)))
6112 (unless (setq not-pref (cadr (member preferred ihandles)))
6113 (setq not-pref (car ihandles)))
6116 (not (gnus-unbuttonized-mime-type-p
6117 "multipart/alternative")))
6118 (add-text-properties
6121 (insert (format "%d. " id))
6125 (unless ,(not ibegend)
6126 (setq gnus-article-mime-handle-alist
6127 ',gnus-article-mime-handle-alist))
6128 (gnus-mime-display-alternative
6129 ',ihandles ',not-pref ',begend ,id))
6130 keymap ,gnus-mime-button-map
6131 mouse-face ,gnus-article-mouse-face
6132 face ,gnus-article-button-face
6134 article-type multipart
6136 (widget-convert-button 'link from (point)
6137 :action 'gnus-widget-press-button)
6139 (while (setq handle (pop handles))
6140 (add-text-properties
6143 (insert (format "(%c) %-18s"
6144 (if (equal handle preferred) ?* ? )
6145 (mm-handle-media-type handle)))
6149 (unless ,(not ibegend)
6150 (setq gnus-article-mime-handle-alist
6151 ',gnus-article-mime-handle-alist))
6152 (gnus-mime-display-alternative
6153 ',ihandles ',handle ',begend ,id))
6154 keymap ,gnus-mime-button-map
6155 mouse-face ,gnus-article-mouse-face
6156 face ,gnus-article-button-face
6160 (widget-convert-button 'link from (point)
6161 :action 'gnus-widget-press-button)
6165 (if (stringp (car preferred))
6166 (gnus-display-mime preferred)
6167 (let ((mail-parse-charset gnus-newsgroup-charset)
6168 (mail-parse-ignored-charsets
6169 (with-current-buffer gnus-summary-buffer
6170 gnus-newsgroup-ignored-charsets)))
6171 (gnus-bind-mm-vars (mm-display-part preferred))
6175 (narrow-to-region (car begend) (point-max))
6177 nil (length gnus-article-mime-handle-alist)
6178 (gnus-article-mime-total-parts)
6179 (mm-handle-media-type preferred))))))
6180 (goto-char (point-max))
6181 (setcdr begend (point-marker)))))
6184 ;; Redraw attachment buttons in the header.
6185 (when gnus-mime-display-attachment-buttons-in-header
6186 (gnus-mime-buttonize-attachments-in-header)))
6188 (defconst gnus-article-wash-status-strings
6189 (let ((alist '((cite "c" "Possible hidden citation text"
6190 " " "All citation text visible")
6191 (headers "h" "Hidden headers"
6192 " " "All headers visible.")
6193 (pgp "p" "Encrypted or signed message status hidden"
6194 " " "No hidden encryption nor digital signature status")
6195 (signature "s" "Signature has been hidden"
6196 " " "Signature is visible")
6197 (overstrike "o" "Overstrike (^H) characters applied"
6198 " " "No overstrike characters applied")
6199 (emphasis "e" "/*_Emphasis_*/ characters applied"
6200 " " "No /*_emphasis_*/ characters applied")))
6202 (dolist (entry alist result)
6203 (let ((key (nth 0 entry))
6204 (on (copy-sequence (nth 1 entry)))
6205 (on-help (nth 2 entry))
6206 (off (copy-sequence (nth 3 entry)))
6207 (off-help (nth 4 entry)))
6208 (put-text-property 0 1 'help-echo on-help on)
6209 (put-text-property 0 1 'help-echo off-help off)
6210 (push (list key on off) result))))
6211 "Alist of strings describing wash status in the mode line.
6212 Each entry has the form (KEY ON OF), where the KEY is a symbol
6213 representing the particular washing function, ON is the string to use
6214 in the article mode line when the washing function is active, and OFF
6215 is the string to use when it is inactive.")
6217 (defun gnus-article-wash-status-entry (key value)
6218 (let ((entry (assoc key gnus-article-wash-status-strings)))
6219 (if value (nth 1 entry) (nth 2 entry))))
6221 (defun gnus-article-wash-status ()
6222 "Return a string which display status of article washing."
6223 (with-current-buffer gnus-article-buffer
6224 (let ((cite (memq 'cite gnus-article-wash-types))
6225 (headers (memq 'headers gnus-article-wash-types))
6226 (boring (memq 'boring-headers gnus-article-wash-types))
6227 (pgp (memq 'pgp gnus-article-wash-types))
6228 (pem (memq 'pem gnus-article-wash-types))
6229 (signed (memq 'signed gnus-article-wash-types))
6230 (encrypted (memq 'encrypted gnus-article-wash-types))
6231 (signature (memq 'signature gnus-article-wash-types))
6232 (overstrike (memq 'overstrike gnus-article-wash-types))
6233 (emphasis (memq 'emphasis gnus-article-wash-types)))
6235 (gnus-article-wash-status-entry 'cite cite)
6236 (gnus-article-wash-status-entry 'headers (or headers boring))
6237 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6238 (gnus-article-wash-status-entry 'signature signature)
6239 (gnus-article-wash-status-entry 'overstrike overstrike)
6240 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6242 (defun gnus-add-wash-type (type)
6243 "Add a washing of TYPE to the current status."
6244 (add-to-list 'gnus-article-wash-types type))
6246 (defun gnus-delete-wash-type (type)
6247 "Add a washing of TYPE to the current status."
6248 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6250 (defun gnus-add-image (category image)
6251 "Add IMAGE of CATEGORY to the list of displayed images."
6252 (let ((entry (assq category gnus-article-image-alist)))
6254 (setq entry (list category))
6255 (push entry gnus-article-image-alist))
6256 (nconc entry (list image))))
6258 (defun gnus-delete-images (category)
6259 "Delete all images in CATEGORY."
6260 (let ((entry (assq category gnus-article-image-alist)))
6261 (dolist (image (cdr entry))
6262 (gnus-remove-image image category))
6263 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6264 (gnus-delete-wash-type category)))
6266 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6268 (defun gnus-article-maybe-hide-headers ()
6269 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6270 Provided for backwards compatibility."
6271 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6272 (not (with-current-buffer gnus-summary-buffer
6273 gnus-have-all-headers)))
6274 (not gnus-inhibit-hiding))
6275 (article-hide-headers)))
6277 (declare-function shr-put-image "shr" (data alt &optional flags))
6279 (defun gnus-shr-put-image (data alt &optional flags)
6280 "Put image DATA with a string ALT. Enable image to be deleted."
6281 (let ((image (if flags
6282 (shr-put-image data (propertize (or alt "*")
6283 'gnus-image-category 'shr)
6285 ;; Old `shr-put-image' doesn't take the optional `flags'
6287 (shr-put-image data (propertize (or alt "*")
6288 'gnus-image-category 'shr)))))
6290 (gnus-add-image 'shr image))))
6292 (defun gnus-article-mime-handles (&optional alist id all)
6294 (let ((i 1) newid flat)
6295 (dolist (handle alist flat)
6296 (setq newid (append id (list i))
6298 (if (stringp (car handle))
6299 (setq flat (nconc flat (gnus-article-mime-handles
6300 (cdr handle) newid all)))
6301 (delq (rassq handle all) all)
6302 (setq flat (nconc flat (list (cons newid handle)))))))
6303 (let ((flat (list nil)))
6304 ;; Assume that elements of `gnus-article-mime-handle-alist'
6305 ;; are in the decreasing order, but unnumbered subsidiaries
6306 ;; in each element are in the increasing order.
6307 (dolist (handle (reverse gnus-article-mime-handle-alist))
6308 (if (stringp (cadr handle))
6309 (setq flat (nconc flat (gnus-article-mime-handles
6310 (cddr handle) (list (car handle)) flat)))
6311 (delq (rassq (cdr handle) flat) flat)
6312 (setq flat (nconc flat (list (cons (list (car handle))
6314 (setq flat (cdr flat))
6315 (mapc (lambda (handle)
6317 ;; This is a hidden (i.e. unnumbered) handle.
6320 (1+ (caar gnus-article-mime-handle-alist)))
6321 (push handle gnus-article-mime-handle-alist))
6322 (setcar handle (caar handle))))
6326 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6327 "Show attachments as buttons in the end of the header of an article.
6328 This function toggles the display when called interactively. Note that
6329 buttons to be added to the header are only the ones that aren't inlined
6330 in the body. Use `gnus-header-face-alist' to highlight buttons."
6331 (interactive (list t))
6332 (gnus-with-article-buffer
6333 (let ((case-fold-search t) buttons handle type st)
6337 (article-narrow-to-head)
6338 ;; Header buttons exist?
6339 (while (and (not buttons)
6340 (re-search-forward "^attachments?:[\n ]+" nil t))
6341 (when (get-char-property (match-end 0)
6342 'gnus-button-attachment-extra)
6343 (setq buttons (match-beginning 0))))
6346 ;; Delete header buttons.
6347 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6350 (unless (and interactive buttons)
6353 (dolist (button (gnus-article-mime-handles))
6354 (setq handle (cdr button)
6355 type (mm-handle-media-type handle))
6356 (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
6357 (with-current-buffer gnus-summary-buffer
6358 gnus-inhibit-images)
6359 gnus-inhibit-images)
6360 (string-match "\\`image/" type))
6361 (mm-inline-override-p handle)
6362 (and (mm-handle-disposition handle)
6363 (not (equal (car (mm-handle-disposition handle))
6365 (not (mm-attachment-override-p handle)))
6366 (not (mm-automatic-display-p handle))
6367 (not (or (and (mm-inlinable-p handle)
6368 (mm-inlined-p handle))
6369 (mm-automatic-external-display-p type))))
6370 (push button buttons)))
6372 ;; Add header buttons.
6375 (narrow-to-region (point) (point))
6376 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6377 (dolist (button (nreverse buttons))
6380 (mm-handle-set-undisplayer (setq handle (cdr button)) nil)
6381 (gnus-insert-mime-button handle (car button))
6382 (skip-chars-backward "\t\n ")
6383 (delete-region (point) (point-max))
6384 (when (> (current-column) (window-width))
6389 (dolist (ovl (overlays-in (point-min) (point)))
6390 (overlay-put ovl 'gnus-button-attachment-extra t)
6391 (overlay-put ovl 'face nil))
6392 (let ((gnus-treatment-function-alist
6393 '((gnus-treat-highlight-headers
6394 gnus-article-highlight-headers))))
6395 (gnus-treat-article 'head)))))))))
6399 (defun gnus-output-to-file (file-name)
6400 "Append the current article to a file named FILE-NAME.
6401 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6402 text and used as the value of the coding cookie which is added to the
6403 top of a file. Otherwise, this function saves a raw article without
6405 (let* ((artbuf (current-buffer))
6406 (file-name-coding-system nnmail-pathname-coding-system)
6407 (coding gnus-article-save-coding-system)
6408 (coding-system-for-read (if coding
6409 nil ;; Rely on the coding cookie.
6410 mm-text-coding-system))
6411 (coding-system-for-write (or coding
6412 mm-text-coding-system-for-write
6413 mm-text-coding-system))
6414 (exists (file-exists-p file-name)))
6417 (insert-file-contents file-name)
6418 (goto-char (point-min))
6419 ;; Remove the existing coding cookie.
6420 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6421 (delete-region (match-beginning 0) (match-end 0))))
6422 (goto-char (point-max))
6423 (insert-buffer-substring artbuf)
6424 ;; Append newline at end of the buffer as separator, and then
6426 (goto-char (point-max))
6429 ;; If the coding system is not suitable to encode the text,
6430 ;; ask a user for a proper one.
6431 (setq coding (coding-system-base
6432 (save-window-excursion
6433 (select-safe-coding-system (point-min) (point-max)
6435 (setq coding-system-for-write
6436 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6438 (goto-char (point-min))
6439 ;; Add the coding cookie.
6440 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6441 coding-system-for-write)))
6444 (write-region (point-min) (point-max) file-name nil 'no-message)
6445 (message "Appended to %s" file-name))
6446 (write-region (point-min) (point-max) file-name))))
6449 (defun gnus-narrow-to-page (&optional arg)
6450 "Narrow the article buffer to a page.
6451 If given a numerical ARG, move forward ARG pages."
6453 (setq arg (if arg (prefix-numeric-value arg) 0))
6454 (with-current-buffer gnus-article-buffer
6456 ;; Remove any old next/prev buttons.
6457 (when (gnus-visual-p 'page-marker)
6458 (let ((inhibit-read-only t))
6459 (gnus-remove-text-with-property 'gnus-prev)
6460 (gnus-remove-text-with-property 'gnus-next)))
6462 (when (save-excursion
6464 (if (re-search-backward page-delimiter nil 'move (abs arg))
6466 (setq nd (match-beginning 0)
6468 (when (re-search-backward page-delimiter nil t)
6469 (setq st (match-end 0))))
6470 (when (re-search-forward page-delimiter nil t)
6471 (setq nd (match-beginning 0)
6474 (if (re-search-forward page-delimiter nil 'move arg)
6476 (setq st (match-end 0)
6478 (when (re-search-forward page-delimiter nil t)
6479 (setq nd (match-beginning 0))))
6480 (when (re-search-backward page-delimiter nil t)
6481 (setq st (match-end 0)
6484 (when (re-search-backward page-delimiter nil t)
6485 (goto-char (setq st (match-end 0))))
6486 (when (re-search-forward page-delimiter nil t)
6487 (setq nd (match-beginning 0)))
6489 (setq gnus-page-broken t)
6490 (when pt (goto-char pt))
6491 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6492 (when (gnus-visual-p 'page-marker)
6496 (gnus-insert-next-page-button))
6499 (gnus-insert-prev-page-button))))))))
6501 ;; Article mode commands
6503 (defun gnus-article-goto-next-page ()
6504 "Show the next page of the article."
6506 (when (gnus-article-next-page)
6507 (goto-char (point-min))
6508 (gnus-article-read-summary-keys nil ?n)))
6511 (defun gnus-article-goto-prev-page ()
6512 "Show the previous page of the article."
6514 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6515 (gnus-article-read-summary-keys nil ?p)
6516 (gnus-article-prev-page nil)))
6518 ;; This is cleaner but currently breaks `gnus-pick-mode':
6520 ;; (defun gnus-article-goto-next-page ()
6521 ;; "Show the next page of the article."
6523 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6524 ;; (gnus-summary-next-page)))
6526 ;; (defun gnus-article-goto-prev-page ()
6527 ;; "Show the next page of the article."
6529 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6530 ;; (gnus-summary-prev-page)))
6532 (defun gnus-article-next-page (&optional lines)
6533 "Show the next page of the current article.
6534 If end of article, return non-nil. Otherwise return nil.
6535 Argument LINES specifies lines to be scrolled up."
6537 (move-to-window-line (- -1 scroll-margin))
6538 (if (and (not (and gnus-article-over-scroll
6539 (> (count-lines (window-start) (point-max))
6540 (+ (or lines (1- (window-height))) scroll-margin))))
6543 (and (pos-visible-in-window-p) ;Not continuation line.
6544 (>= (point) (point-max)))))
6545 ;; Nothing in this page.
6546 (if (or (not gnus-page-broken)
6551 (eobp)))) ;Real end-of-buffer?
6553 (when gnus-article-over-scroll
6554 (gnus-article-next-page-1 lines))
6556 (gnus-narrow-to-page 1) ;Go to next page.
6558 ;; More in this page.
6559 (gnus-article-next-page-1 lines)
6562 (defun gnus-article-beginning-of-window ()
6563 "Move point to the beginning of the window.
6564 The point is placed at the line number which `scroll-margin'
6566 ;; There is an obscure bug in Emacs that makes it impossible to
6567 ;; scroll past big pictures in the article buffer. Try to fix
6568 ;; this by adding a sanity check by counting the lines visible.
6569 (when (> (count-lines (window-start) (window-end)) 30)
6570 (move-to-window-line
6571 (min (max 0 scroll-margin)
6572 (max 1 (- (window-height)
6573 (if mode-line-format 1 0)
6574 (if header-line-format 1 0)
6577 (defvar scroll-in-place)
6579 (defun gnus-article-next-page-1 (lines)
6581 (let ((scroll-in-place nil)
6582 (auto-window-vscroll nil))
6585 ;; Long lines may cause an end-of-buffer error.
6586 (goto-char (point-max))))
6587 (gnus-article-beginning-of-window))
6589 (defun gnus-article-prev-page (&optional lines)
6590 "Show previous page of current article.
6591 Argument LINES specifies lines to be scrolled down."
6593 (move-to-window-line 0)
6594 (if (and gnus-page-broken
6596 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6598 (gnus-narrow-to-page -1) ;Go to previous page.
6599 (goto-char (point-max))
6600 (recenter (if gnus-article-over-scroll
6602 (max (+ lines scroll-margin) 3)
6603 (- (window-height) 2))
6607 (let ((scroll-in-place nil))
6608 (scroll-down lines))
6609 (beginning-of-buffer
6610 (goto-char (point-min))))
6611 (gnus-article-beginning-of-window))))
6613 (defun gnus-article-only-boring-p ()
6614 "Decide whether there is only boring text remaining in the article.
6615 Something \"interesting\" is a word of at least two letters that does
6616 not have a face in `gnus-article-boring-faces'."
6617 (when (and gnus-article-skip-boring
6618 (boundp 'gnus-article-boring-faces)
6619 (symbol-value 'gnus-article-boring-faces))
6621 (let ((inhibit-point-motion-hooks t))
6623 (while (re-search-forward "\\b\\w\\w" nil t)
6625 (when (not (gnus-intersection
6626 (gnus-faces-at (point))
6627 (symbol-value 'gnus-article-boring-faces)))
6628 (throw 'only-boring nil)))
6629 (throw 'only-boring t))))))
6631 (defun gnus-article-refer-article ()
6632 "Read article specified by message-id around point."
6635 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6636 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6637 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6638 (let ((msg-id (concat "<" (match-string 0) ">")))
6639 (set-buffer gnus-summary-buffer)
6640 (gnus-summary-refer-article msg-id))
6641 (error "No references around point"))))
6643 (defun gnus-article-show-summary ()
6644 "Reconfigure windows to show summary buffer."
6646 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6647 (error "There is no summary buffer for this article buffer")
6648 (gnus-article-set-globals)
6649 (gnus-configure-windows 'article)
6650 (gnus-summary-goto-subject gnus-current-article)
6651 (gnus-summary-position-point)))
6653 (defun gnus-article-describe-briefly ()
6654 "Describe article mode commands briefly."
6656 (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
6658 (defun gnus-article-check-buffer ()
6659 "Beep if not in an article buffer."
6660 (unless (derived-mode-p 'gnus-article-mode)
6661 (error "Command invoked outside of a Gnus article buffer")))
6663 (defvar gnus-pick-mode)
6665 (defun gnus-article-read-summary-keys (&optional _arg key not-restore-window)
6666 "Read a summary buffer key sequence and execute it from the article buffer."
6668 (gnus-article-check-buffer)
6670 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6671 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6672 "=" "^" "\M-^" "|"))
6674 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6675 "An" "Ap" [?A (meta return)] [?A delete]))
6679 (with-current-buffer gnus-article-current-summary
6680 (let (gnus-pick-mode)
6681 (setq unread-command-events (nconc unread-command-events
6682 (list (or key last-command-event)))
6683 keys (read-key-sequence nil t))))
6688 ((eq (aref keys (1- (length keys))) ?\C-h)
6689 (gnus-article-describe-bindings (substring keys 0 -1)))
6690 ((or (member keys nosaves)
6691 (member keys nosave-but-article)
6692 (member keys nosave-in-article))
6694 (save-window-excursion
6695 (pop-to-buffer gnus-article-current-summary)
6696 ;; We disable the pick minor mode commands.
6697 (let (gnus-pick-mode)
6698 (setq func (key-binding keys t))))
6702 (unless (member keys nosave-in-article)
6703 (set-buffer gnus-article-current-summary))
6704 (when (and (symbolp func)
6705 (get func 'disabled))
6706 (error "Function %s disabled" func))
6707 (call-interactively func)
6708 (setq new-sum-point (point)))
6709 (when (member keys nosave-but-article)
6710 (pop-to-buffer gnus-article-buffer))))
6712 ;; These commands should restore window configuration.
6713 (let ((obuf (current-buffer))
6714 (owin (current-window-configuration))
6715 win func in-buffer selected new-sum-start new-sum-hscroll err)
6716 (cond (not-restore-window
6717 (pop-to-buffer gnus-article-current-summary)
6718 (setq win (selected-window)))
6719 ((setq win (get-buffer-window gnus-article-current-summary))
6720 (select-window win))
6722 (let ((summary-buffer gnus-article-current-summary))
6723 (gnus-configure-windows 'article)
6724 (unless (setq win (get-buffer-window summary-buffer 'visible))
6725 (let ((gnus-buffer-configuration
6726 '((article ((vertical 1.0
6727 (summary 0.25 point)
6729 (gnus-configure-windows 'article))
6730 (setq win (get-buffer-window summary-buffer 'visible)))
6731 (select-frame-set-input-focus (window-frame win))
6732 (select-window win))))
6733 (setq in-buffer (current-buffer))
6734 ;; We disable the pick minor mode commands.
6735 (setq func (let (gnus-pick-mode)
6736 (key-binding keys t)))
6737 (when (get func 'disabled)
6738 (error "Function %s disabled" func))
6741 (condition-case code
6743 (call-interactively func)
6749 (when (eq win (selected-window))
6750 (setq new-sum-point (point)
6751 new-sum-start (window-start win)
6752 new-sum-hscroll (window-hscroll win)))
6753 (when (or (eq in-buffer (current-buffer))
6754 (when (eq obuf (current-buffer))
6755 (set-buffer in-buffer)
6757 (setq selected (ignore-errors (gnus-summary-select-article)))
6759 (unless not-restore-window
6760 (set-window-configuration owin))
6761 (when (and (eq selected 'old)
6763 (set-window-start (get-buffer-window (current-buffer))
6765 (set-window-point (get-buffer-window (current-buffer))
6766 (if (article-goto-body)
6769 (when (and (not not-restore-window)
6772 (with-current-buffer (window-buffer win)
6773 (derived-mode-p 'gnus-summary-mode)))
6774 (set-window-point win new-sum-point)
6775 (set-window-start win new-sum-start)
6776 (set-window-hscroll win new-sum-hscroll))))
6777 (set-window-configuration owin)
6779 (signal (car err) (cdr err))
6782 (defun gnus-article-read-summary-send-keys ()
6784 (let ((unread-command-events (list ?S)))
6785 (gnus-article-read-summary-keys)))
6787 (defun gnus-article-describe-key (key)
6788 "Display documentation of the function invoked by KEY.
6789 KEY is a string or a vector."
6790 (interactive (list (let ((cursor-in-echo-area t))
6791 (read-key-sequence "Describe key: "))))
6792 (gnus-article-check-buffer)
6793 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6794 gnus-article-read-summary-send-keys))
6795 (with-current-buffer gnus-article-current-summary
6796 (setq unread-command-events
6798 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6799 (list 'meta (- x 128))
6802 unread-command-events))
6803 (let ((cursor-in-echo-area t)
6805 (describe-key (read-key-sequence nil t))))
6806 (describe-key key)))
6808 (defun gnus-article-describe-key-briefly (key &optional insert)
6809 "Display documentation of the function invoked by KEY.
6810 KEY is a string or a vector."
6811 (interactive (list (let ((cursor-in-echo-area t))
6812 (read-key-sequence "Describe key: "))
6813 current-prefix-arg))
6814 (gnus-article-check-buffer)
6815 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6816 gnus-article-read-summary-send-keys))
6817 (with-current-buffer gnus-article-current-summary
6818 (setq unread-command-events
6820 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6821 (list 'meta (- x 128))
6824 unread-command-events))
6825 (let ((cursor-in-echo-area t)
6827 (describe-key-briefly (read-key-sequence nil t) insert)))
6828 (describe-key-briefly key insert)))
6830 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6831 (defvar gnus-agent-summary-mode)
6832 (defvar gnus-draft-mode)
6833 (defvar help-xref-stack-item)
6834 (defvar help-xref-following)
6836 (defun gnus-article-describe-bindings (&optional prefix)
6837 "Show a list of all defined keys, and their definitions.
6838 The optional argument PREFIX, if non-nil, should be a key sequence;
6839 then we display only bindings that start with that prefix."
6841 (gnus-article-check-buffer)
6842 (let ((keymap (copy-keymap gnus-article-mode-map))
6843 (map (copy-keymap gnus-article-send-map))
6844 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6846 (define-key keymap "S" map)
6847 (define-key map [t] nil)
6848 (with-current-buffer gnus-article-current-summary
6851 (if (setq parent (keymap-parent gnus-article-mode-map))
6853 (setq parent (copy-keymap parent))
6854 (set-keymap-parent parent (current-local-map)))
6855 (current-local-map)))
6856 (set-keymap-parent map (key-binding "S"))
6857 (let (key def gnus-pick-mode)
6859 (setq key (pop sumkeys))
6860 (cond ((and (vectorp key) (= (length key) 1)
6861 (consp (setq def (aref key 0)))
6862 (numberp (car def)) (numberp (cdr def)))
6863 (when (< (max (car def) (cdr def)) 128)
6867 (nreverse (gnus-uncompress-range def)))
6869 ((setq def (key-binding key))
6870 (unless (eq def 'undefined)
6871 (define-key keymap key def))))))
6872 (when (boundp 'gnus-agent-summary-mode)
6873 (setq agent gnus-agent-summary-mode))
6874 (when (boundp 'gnus-draft-mode)
6875 (setq draft gnus-draft-mode)))
6877 (use-local-map keymap)
6878 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6879 (set (make-local-variable 'gnus-draft-mode) draft)
6880 (describe-bindings prefix))
6881 (let ((item `((lambda (prefix)
6882 (with-current-buffer ,(current-buffer)
6883 (gnus-article-describe-bindings prefix)))
6885 ;; Loading `help-mode' here is necessary if `describe-bindings'
6886 ;; is replaced with something, e.g. `helm-descbinds'.
6887 (require 'help-mode)
6888 (with-current-buffer (let (help-xref-following) (help-buffer))
6889 (setq help-xref-stack-item item)))))
6891 (defun gnus-article-reply-with-original (&optional wide)
6892 "Start composing a reply mail to the current message.
6893 The text in the region will be yanked. If the region isn't active,
6894 the entire article will be yanked."
6896 (let ((article (cdr gnus-article-current))
6898 (if (not (and transient-mark-mode mark-active))
6899 (with-current-buffer gnus-summary-buffer
6900 (gnus-summary-reply (list (list article)) wide))
6901 (setq contents (buffer-substring (point) (mark t)))
6902 ;; Deactivate active regions.
6903 (when transient-mark-mode
6904 (setq mark-active nil))
6905 (with-current-buffer gnus-summary-buffer
6907 (list (list article contents)) wide)))))
6909 (defun gnus-article-wide-reply-with-original ()
6910 "Start composing a wide reply mail to the current message.
6911 The text in the region will be yanked. If the region isn't active,
6912 the entire article will be yanked."
6914 (gnus-article-reply-with-original t))
6916 (defun gnus-article-followup-with-original ()
6917 "Compose a followup to the current article.
6918 The text in the region will be yanked. If the region isn't active,
6919 the entire article will be yanked."
6921 (let ((article (cdr gnus-article-current))
6923 (if (not (and transient-mark-mode mark-active))
6924 (with-current-buffer gnus-summary-buffer
6925 (gnus-summary-followup (list (list article))))
6926 (setq contents (buffer-substring (point) (mark t)))
6927 ;; Deactivate active regions.
6928 (when transient-mark-mode
6929 (setq mark-active nil))
6930 (with-current-buffer gnus-summary-buffer
6931 (gnus-summary-followup
6932 (list (list article contents)))))))
6934 (defun gnus-article-hide (&optional arg force)
6935 "Hide all the gruft in the current article.
6936 This means that signatures, cited text and (some) headers will be
6938 If given a prefix, show the hidden text instead."
6939 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6940 (gnus-with-article-buffer
6941 (article-hide-headers arg)
6942 (article-hide-list-identifiers)
6943 (gnus-article-hide-citation-maybe arg force)
6944 (article-hide-signature arg)))
6946 (defun gnus-check-group-server ()
6947 ;; Make sure the connection to the server is alive.
6948 (unless (gnus-server-opened
6949 (gnus-find-method-for-group gnus-newsgroup-name))
6950 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6951 (gnus-request-group gnus-newsgroup-name t)))
6953 (declare-function nneething-get-file-name "nneething" (id))
6955 (defun gnus-request-article-this-buffer (article group)
6956 "Get an article and insert it into this buffer."
6957 (let (do-update-line sparse-header)
6961 (gnus-kill-all-overlays)
6962 (setq group (or group gnus-newsgroup-name))
6964 ;; Using `gnus-request-article' directly will insert the article into
6965 ;; `nntp-server-buffer' - so we'll save some time by not having to
6966 ;; copy it from the server buffer into the article buffer.
6968 ;; We only request an article by message-id when we do not have the
6969 ;; headers for it, so we'll have to get those.
6970 (when (stringp article)
6971 (gnus-read-header article))
6973 ;; If the article number is negative, that means that this article
6974 ;; doesn't belong in this newsgroup (possibly), so we find its
6975 ;; message-id and request it by id instead of number.
6976 (when (and (numberp article)
6978 (get-buffer gnus-summary-buffer)
6979 (gnus-buffer-exists-p gnus-summary-buffer))
6980 (with-current-buffer gnus-summary-buffer
6981 (let ((header (gnus-summary-article-header article)))
6984 ((memq article gnus-newsgroup-sparse)
6985 ;; This is a sparse gap article.
6986 (setq do-update-line article)
6987 (setq article (mail-header-id header))
6988 (setq sparse-header (gnus-read-header article))
6989 (setq gnus-newsgroup-sparse
6990 (delq article gnus-newsgroup-sparse)))
6992 ;; It's a real article.
6993 (setq article (mail-header-id header)))
6995 ;; It is an extracted pseudo-article.
6996 (setq article 'pseudo)
6997 (gnus-request-pseudo-article header))))
6999 (let ((method (gnus-find-method-for-group
7000 gnus-newsgroup-name)))
7001 (when (and (eq (car method) 'nneething)
7003 (let ((dir (nneething-get-file-name
7004 (mail-header-id header))))
7005 (when (and (stringp dir)
7006 (file-directory-p dir))
7007 (setq article 'nneething)
7008 (gnus-group-enter-directory dir))))))))
7011 ;; Refuse to select canceled articles.
7012 ((and (numberp article)
7014 (get-buffer gnus-summary-buffer)
7015 (gnus-buffer-exists-p gnus-summary-buffer)
7016 (eq (cdr (with-current-buffer gnus-summary-buffer
7017 (assq article gnus-newsgroup-reads)))
7018 gnus-canceled-mark))
7020 ;; We first check `gnus-original-article-buffer'.
7021 ((and (get-buffer gnus-original-article-buffer)
7023 (with-current-buffer gnus-original-article-buffer
7024 (and (equal (car gnus-original-article) group)
7025 (eq (cdr gnus-original-article) article))))
7026 ;; `insert-buffer-substring' would incorrectly use the
7027 ;; equivalent of string-make-multibyte which amount to decoding
7028 ;; with locale-coding-system, causing failure of
7029 ;; subsequent decoding.
7030 (insert (string-to-multibyte
7031 (with-current-buffer gnus-original-article-buffer
7032 (buffer-substring (point-min) (point-max)))))
7034 ;; Check the backlog.
7035 ((and gnus-keep-backlog
7036 (gnus-backlog-request-article group article (current-buffer)))
7038 ;; Check asynchronous pre-fetch.
7039 ((gnus-async-request-fetched-article group article (current-buffer))
7040 (gnus-async-prefetch-next group article gnus-summary-buffer)
7041 (when (and (numberp article) gnus-keep-backlog)
7042 (gnus-backlog-enter-article group article (current-buffer)))
7045 ((and gnus-use-cache
7047 (gnus-cache-request-article article group))
7049 ;; Check the agent cache.
7050 ((gnus-agent-request-article article group)
7052 ;; Get the article and put into the article buffer.
7053 ((or (stringp article)
7055 (let ((gnus-override-method gnus-override-method)
7056 (methods (and (stringp article)
7057 (with-current-buffer gnus-summary-buffer
7058 (gnus-refer-article-methods))))
7059 (backend (car (gnus-find-method-for-group
7060 gnus-newsgroup-name)))
7062 (inhibit-read-only t))
7063 (when (and (null gnus-override-method)
7065 (setq gnus-override-method (pop methods)))
7068 (gnus-kill-all-overlays)
7069 (let ((gnus-newsgroup-name group))
7070 (gnus-check-group-server))
7072 ((gnus-request-article article group (current-buffer))
7073 (when (numberp article)
7074 (gnus-async-prefetch-next group article
7075 gnus-summary-buffer)
7076 (when gnus-keep-backlog
7077 (gnus-backlog-enter-article
7078 group article (current-buffer)))
7079 (when (and gnus-agent
7080 (gnus-agent-group-covered-p group))
7081 (gnus-agent-store-article article group)))
7082 (setq result 'article))
7084 (setq gnus-override-method (pop methods)))
7085 ((not (string-match "^400 "
7086 (nnheader-get-report backend)))
7087 ;; If we get 400 server disconnect, reconnect and
7088 ;; retry; otherwise, assume the article has expired.
7089 (setq result 'done))))
7090 (and (eq result 'article) 'article)))
7094 ;; Associate this article with the current summary buffer.
7095 (setq gnus-article-current-summary gnus-summary-buffer)
7097 ;; Take the article from the original article buffer
7098 ;; and place it in the buffer it's supposed to be in.
7099 (when (and (get-buffer gnus-article-buffer)
7100 (equal (buffer-name (current-buffer))
7101 (buffer-name (get-buffer gnus-article-buffer))))
7103 (if (get-buffer gnus-original-article-buffer)
7104 (set-buffer gnus-original-article-buffer)
7105 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7106 (buffer-disable-undo)
7107 (setq major-mode 'gnus-original-article-mode)
7108 (setq buffer-read-only t))
7109 (let ((inhibit-read-only t))
7111 (insert-buffer-substring gnus-article-buffer))
7112 (setq gnus-original-article (cons group article)))
7115 (run-hooks 'gnus-article-decode-hook)
7116 ;; Mark article as decoded or not.
7117 (setq gnus-article-decoded-p gnus-article-decode-hook))
7119 ;; Update sparse articles.
7120 (when (and do-update-line
7121 (or (numberp article)
7123 (let ((buf (current-buffer)))
7124 (set-buffer gnus-summary-buffer)
7125 (gnus-summary-update-article do-update-line sparse-header)
7126 (gnus-summary-goto-subject do-update-line nil t)
7127 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7129 (set-buffer buf))))))
7131 (defun gnus-block-private-groups (group)
7132 "Allows images in newsgroups to be shown, blocks images in all
7134 (if (or (gnus-news-group-p group)
7135 (gnus-member-of-valid 'global group))
7136 ;; Block nothing in news groups.
7138 ;; Block everything anywhere else.
7141 (defun gnus-blocked-images ()
7142 (if (functionp gnus-blocked-images)
7143 (funcall gnus-blocked-images gnus-newsgroup-name)
7144 gnus-blocked-images))
7150 (defcustom gnus-article-edit-mode-hook nil
7151 "Hook run in article edit mode buffers."
7152 :group 'gnus-article-various
7155 (defvar gnus-article-edit-done-function nil)
7157 (defvar gnus-article-edit-mode-map nil)
7159 ;; Should we be using derived.el for this?
7160 (unless gnus-article-edit-mode-map
7161 (setq gnus-article-edit-mode-map (make-keymap))
7162 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7164 (gnus-define-keys gnus-article-edit-mode-map
7165 "\C-c?" describe-mode
7166 "\C-c\C-c" gnus-article-edit-done
7167 "\C-c\C-k" gnus-article-edit-exit
7168 "\C-c\C-f\C-t" message-goto-to
7169 "\C-c\C-f\C-o" message-goto-from
7170 "\C-c\C-f\C-b" message-goto-bcc
7171 ;;"\C-c\C-f\C-w" message-goto-fcc
7172 "\C-c\C-f\C-c" message-goto-cc
7173 "\C-c\C-f\C-s" message-goto-subject
7174 "\C-c\C-f\C-r" message-goto-reply-to
7175 "\C-c\C-f\C-n" message-goto-newsgroups
7176 "\C-c\C-f\C-d" message-goto-distribution
7177 "\C-c\C-f\C-f" message-goto-followup-to
7178 "\C-c\C-f\C-m" message-goto-mail-followup-to
7179 "\C-c\C-f\C-k" message-goto-keywords
7180 "\C-c\C-f\C-u" message-goto-summary
7181 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7182 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7183 "\C-c\C-b" message-goto-body
7184 "\C-c\C-i" message-goto-signature
7186 "\C-c\C-t" message-insert-to
7187 "\C-c\C-n" message-insert-newsgroups
7188 "\C-c\C-o" message-sort-headers
7189 "\C-c\C-e" message-elide-region
7190 "\C-c\C-v" message-delete-not-region
7191 "\C-c\C-z" message-kill-to-signature
7192 "\M-\r" message-newline-and-reformat
7193 "\C-c\C-a" mml-attach-file
7194 "\C-a" message-beginning-of-line
7196 "\M-;" comment-region)
7198 (gnus-define-keys (gnus-article-edit-wash-map
7199 "\C-c\C-w" gnus-article-edit-mode-map)
7200 "f" gnus-article-edit-full-stops))
7203 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7205 ["Fetch To" message-insert-to t]
7206 ["Fetch Newsgroups" message-insert-newsgroups t]
7208 ["To" message-goto-to t]
7209 ["From" message-goto-from t]
7210 ["Subject" message-goto-subject t]
7211 ["Cc" message-goto-cc t]
7212 ["Reply-To" message-goto-reply-to t]
7213 ["Summary" message-goto-summary t]
7214 ["Keywords" message-goto-keywords t]
7215 ["Newsgroups" message-goto-newsgroups t]
7216 ["Followup-To" message-goto-followup-to t]
7217 ["Mail-Followup-To" message-goto-mail-followup-to t]
7218 ["Distribution" message-goto-distribution t]
7219 ["Body" message-goto-body t]
7220 ["Signature" message-goto-signature t]))
7222 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7223 "Major mode for editing articles.
7224 This is an extended text-mode.
7226 \\{gnus-article-edit-mode-map}"
7227 (make-local-variable 'gnus-article-edit-done-function)
7228 (make-local-variable 'gnus-prev-winconf)
7229 (set (make-local-variable 'font-lock-defaults)
7230 '(message-font-lock-keywords t))
7231 (set (make-local-variable 'mail-header-separator) "")
7232 (set (make-local-variable 'gnus-article-edit-mode) t)
7233 (easy-menu-add message-mode-field-menu message-mode-map)
7235 (setq buffer-read-only nil)
7236 (buffer-enable-undo)
7239 (defun gnus-article-edit (&optional force)
7240 "Edit the current article.
7241 This will have permanent effect only in mail groups.
7242 If FORCE is non-nil, allow editing of articles even in read-only
7245 (when (and (not force)
7246 (gnus-group-read-only-p))
7247 (error "The current newsgroup does not support article editing"))
7248 (gnus-with-article-buffer
7249 (article-date-original))
7250 (gnus-article-edit-article
7252 `(lambda (no-highlight)
7254 (gnus-summary-edit-article-done
7255 ,(or (mail-header-references gnus-current-headers) "")
7256 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7258 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7259 "Start editing the contents of the current article buffer."
7260 (let ((winconf (current-window-configuration)))
7261 (set-buffer gnus-article-buffer)
7262 (let ((message-auto-save-directory
7263 ;; Don't associate the article buffer with a draft file.
7265 (gnus-article-edit-mode))
7266 (funcall start-func)
7267 (set-buffer-modified-p nil)
7268 (gnus-configure-windows 'edit-article)
7269 (setq gnus-article-edit-done-function exit-func)
7270 (setq gnus-prev-winconf winconf)
7272 (gnus-message 6 "C-c C-c to end edits"))))
7274 (defun gnus-article-edit-done (&optional arg)
7275 "Update the article edits and exit."
7277 (let ((func gnus-article-edit-done-function)
7278 (buf (current-buffer))
7279 (start (window-start))
7280 (winconf gnus-prev-winconf))
7281 (widen) ;; Widen it in case that users narrowed the buffer.
7284 ;; The cache and backlog have to be flushed somewhat.
7285 (when gnus-keep-backlog
7286 (gnus-backlog-remove-article
7287 (car gnus-article-current) (cdr gnus-article-current)))
7288 ;; Flush original article as well.
7289 (gnus-flush-original-article-buffer)
7290 (when gnus-use-cache
7291 (gnus-cache-update-article
7292 (car gnus-article-current) (cdr gnus-article-current)))
7293 ;; We remove all text props from the article buffer.
7294 (kill-all-local-variables)
7295 (set-text-properties (point-min) (point-max) nil)
7297 (set-window-configuration winconf)
7299 (set-window-start (get-buffer-window buf) start)
7300 (set-window-point (get-buffer-window buf) (point)))
7301 (gnus-summary-show-article))
7303 (defun gnus-flush-original-article-buffer ()
7304 (when (get-buffer gnus-original-article-buffer)
7305 (with-current-buffer gnus-original-article-buffer
7306 (setq gnus-original-article nil))))
7308 (defun gnus-article-edit-exit ()
7309 "Exit the article editing without updating."
7311 (when (or (not (buffer-modified-p))
7312 (yes-or-no-p "Article modified; kill anyway? "))
7313 (let ((curbuf (current-buffer))
7315 (window-start (window-start)))
7317 (if (gnus-buffer-live-p gnus-original-article-buffer)
7318 (insert-buffer-substring gnus-original-article-buffer))
7319 (let ((winconf gnus-prev-winconf))
7320 (kill-all-local-variables)
7322 (set-window-configuration winconf)
7323 ;; Tippy-toe some to make sure that point remains where it was.
7324 (save-current-buffer
7326 (set-window-start (get-buffer-window (current-buffer)) window-start)
7328 (gnus-summary-show-article)))
7330 (defun gnus-article-edit-full-stops ()
7331 "Interactively repair spacing at end of sentences."
7334 (goto-char (point-min))
7335 (search-forward-regexp "^$" nil t)
7336 (let ((case-fold-search nil))
7337 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7340 ;;; Article highlights
7343 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7345 ;;; Internal Variables:
7347 (defcustom gnus-button-url-regexp
7349 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7350 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7351 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7352 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7356 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7357 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7358 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7359 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7361 "[" chars punct "]+" "[" chars "]"
7364 "Regular expression that matches URLs."
7366 :group 'gnus-article-buttons
7369 (defcustom gnus-button-valid-fqdn-regexp "\\([-A-Za-z0-9]+\\.\\)+[A-Za-z]+"
7370 "Regular expression that matches a valid FQDN."
7372 :group 'gnus-article-buttons
7375 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7376 (defcustom gnus-button-valid-localpart-regexp
7377 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7378 "Regular expression that matches a localpart of mail addresses or MIDs."
7380 :group 'gnus-article-buttons
7383 (defcustom gnus-button-man-handler 'manual-entry
7384 "Function to use for displaying man pages.
7385 The function must take at least one argument with a string naming the
7388 :type '(choice (function-item :tag "Man" manual-entry)
7389 (function-item :tag "Woman" woman)
7390 (function :tag "Other"))
7391 :group 'gnus-article-buttons)
7393 (defcustom gnus-button-mid-or-mail-regexp
7394 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7395 gnus-button-valid-fqdn-regexp
7397 "Regular expression that matches a message ID or a mail address."
7399 :group 'gnus-article-buttons
7402 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7403 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7404 Strings like this can be either a message ID or a mail address. If it is one
7405 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7406 message ID or a mail address, respectively. If this variable is set to the
7407 symbol `ask', always query the user what do do. If it is a function, this
7408 function will be called with the string as its only argument. The function
7409 must return `mid', `mail', `invalid' or `ask'."
7411 :group 'gnus-article-buttons
7412 :type '(choice (function-item :tag "Heuristic function"
7413 gnus-button-mid-or-mail-heuristic)
7418 (defcustom gnus-button-mid-or-mail-heuristic-alist
7419 '((-10.0 . ".+\\$.+@")
7422 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7423 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7424 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7425 (-1.0 . "^[^a-z]+@")
7427 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7428 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7429 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7430 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7433 (-1.0 . "^[0-9][0-9]")
7435 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7436 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7437 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7438 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7440 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7441 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7444 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7446 ;; compensation for TDMA dated mail addresses:
7447 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7449 (-20.0 . "\\.fsf@") ;; Gnus
7452 (-20.0 . "^alpine\\.")
7453 (-20.0 . "_-_") ;; Subject change in thread
7455 (-20.0 . "\\.ln@") ;; leafnode
7456 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7457 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7459 ;; (5.0 . "") ;; $local_part_len <= 7
7460 (10.0 . "^[^0-9]+@")
7461 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7462 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7465 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7467 (0.5 . "^[A-Z][a-z]")
7468 (0.5 . "^[A-Z][a-z][a-z]")
7469 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7470 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7471 "An alist of (RATE . REGEXP) pairs for `gnus-button-mid-or-mail-heuristic'.
7473 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7474 address. The REGEXP is processed with `case-fold-search' set to nil."
7476 :group 'gnus-article-buttons
7477 :type '(repeat (cons (number :tag "Rate")
7478 (regexp :tag "Regexp"))))
7480 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7481 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7482 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7483 address, `ask' if unsure and `invalid' if the string is invalid."
7484 (let ((case-fold-search nil)
7485 (list gnus-button-mid-or-mail-heuristic-alist)
7486 (result 0) rate regexp lpartlen elem)
7488 (length (replace-regexp-in-string "^\\(.*\\)@.*$" "\\1" mid-or-mail)))
7489 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7490 ;; Certain special cases...
7493 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7494 "^[0-9]+\\.[0-9]+@compuserve\\|"
7495 "@public\\.gmane\\.org")
7497 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7498 (setq result 'mail))
7499 (when (string-match "@.*@\\| " mid-or-mail)
7500 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7501 (setq result 'invalid))
7502 ;; Nothing more to do, if result is not a number here...
7503 (when (numberp result)
7505 (setq elem (car list)
7509 (when (string-match regexp mid-or-mail)
7510 (setq result (+ result rate))
7512 9 "`%s' matched `%s', rate `%s', result `%s'."
7513 mid-or-mail regexp rate result)))
7514 (when (<= lpartlen 7)
7515 (setq result (+ result 5.0))
7516 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7517 mid-or-mail result))
7518 (when (>= lpartlen 12)
7519 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7521 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7522 ;; Long local part should contain realname if e-mail address,
7523 ;; too many digits: message-id.
7524 ;; $score -= 5.0 + 0.1 * $local_part_len;
7525 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7526 (setq result (+ result rate))
7528 9 "Many digits in `%s', rate `%s', result `%s'."
7529 mid-or-mail rate result))
7530 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*@"
7532 ;; Too few vowels [^aeiouy]{4,}.*@
7533 (setq result (+ result -5.0))
7535 9 "Few vowels in `%s', rate `%s', result `%s'."
7536 mid-or-mail -5.0 result))
7538 (setq result (+ result 5.0))
7540 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7541 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7542 ;; Maybe we should make this a customizable alist: (condition . 'result)
7544 ((symbolp result) result)
7545 ;; Now convert number into proper results:
7546 ((< result -10.0) 'mid)
7547 ((> result 10.0) 'mail)
7550 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7551 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7552 (url-mid (concat "news" ":" mid-or-mail))
7553 (url-mailto (concat "mailto" ":" mid-or-mail)))
7554 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7555 (when (fboundp pref)
7557 ;; get rid of surrounding angles...
7559 (replace-regexp-in-string "^<\\|>$" "" mid-or-mail)))
7560 (if (or (eq 'mid guessed) (eq 'mail guessed))
7564 (save-window-excursion
7565 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7568 (cond ((eq pref 'mid)
7569 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7570 (gnus-button-handle-news url-mid))
7572 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7573 (gnus-url-mailto url-mailto))
7574 (t (gnus-message 3 "Invalid string.")))))
7576 (defun gnus-button-handle-custom (fun arg)
7577 "Call function FUN on argument ARG.
7578 Both FUN and ARG are supposed to be strings. ARG will be passed
7579 as a symbol to FUN."
7580 (funcall (intern fun)
7581 (if (string-match "^customize-apropos" fun)
7585 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7587 (defun gnus-button-handle-describe-function (url)
7588 "Call `describe-function' when pushing the corresponding URL button."
7591 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))))
7593 (defun gnus-button-handle-describe-variable (url)
7594 "Call `describe-variable' when pushing the corresponding URL button."
7597 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))))
7599 (defun gnus-button-handle-symbol (url)
7600 "Display help on variable or function.
7601 Calls `describe-variable' or `describe-function'."
7602 (let ((sym (intern url)))
7604 ((fboundp sym) (describe-function sym))
7605 ((boundp sym) (describe-variable sym))
7606 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7608 (defun gnus-button-handle-describe-key (url)
7609 "Call `describe-key' when pushing the corresponding URL button."
7611 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))
7612 (keys (ignore-errors (eval `(kbd ,key-string)))))
7615 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7617 (defun gnus-button-handle-apropos (url)
7618 "Call `apropos' when pushing the corresponding URL button."
7619 (apropos (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7621 (defun gnus-button-handle-apropos-command (url)
7622 "Call `apropos' when pushing the corresponding URL button."
7624 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7626 (defun gnus-button-handle-apropos-variable (url)
7627 "Call `apropos' when pushing the corresponding URL button."
7629 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7631 (defun gnus-button-handle-apropos-documentation (url)
7632 "Call `apropos' when pushing the corresponding URL button."
7633 (apropos-documentation
7634 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7636 (defun gnus-button-handle-library (url)
7637 "Call `locate-library' when pushing the corresponding URL button."
7638 (gnus-message 9 "url=`%s'" url)
7639 (let* ((lib (locate-library url))
7640 (file (replace-regexp-in-string "\\.elc" ".el" (or lib ""))))
7642 (gnus-message 1 "Cannot locale library `%s'." url)
7643 (find-file-read-only file))))
7645 (defcustom gnus-button-man-level 5
7646 "*Integer that says how many man-related buttons Gnus will show.
7647 The higher the number, the more buttons will appear and the more false
7648 positives are possible. Note that you can set this variable local to
7649 specific groups. Setting it higher in Unix groups is probably a good idea.
7650 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7651 how to set variables in specific groups."
7653 :group 'gnus-article-buttons
7654 :link '(custom-manual "(gnus)Group Parameters")
7657 (defcustom gnus-button-emacs-level 5
7658 "*Integer that says how many emacs-related buttons Gnus will show.
7659 The higher the number, the more buttons will appear and the more false
7660 positives are possible. Note that you can set this variable local to
7661 specific groups. Setting it higher in Emacs or Gnus related groups is
7662 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7663 `gnus-parameters' on how to set variables in specific groups."
7665 :group 'gnus-article-buttons
7666 :link '(custom-manual "(gnus)Group Parameters")
7669 (defcustom gnus-button-message-level 5
7670 "*Integer that says how many buttons for news or mail messages will appear.
7671 The higher the number, the more buttons will appear and the more false
7672 positives are possible."
7673 ;; mail addresses, MIDs, URLs for news, ...
7675 :group 'gnus-article-buttons
7678 (defcustom gnus-button-browse-level 5
7679 "*Integer that says how many buttons for browsing will appear.
7680 The higher the number, the more buttons will appear and the more false
7681 positives are possible."
7682 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7684 :group 'gnus-article-buttons
7687 (defcustom gnus-button-alist
7688 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7689 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7690 ((concat "\\b\\(nntp\\|news\\):\\("
7691 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7692 0 t gnus-button-handle-news 2)
7693 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7694 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7695 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7696 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7697 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7698 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7699 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7700 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7701 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7702 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7703 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7704 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7705 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7706 ;; RFC 2368 (The mailto URL scheme)
7707 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7708 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7709 ("\\bmailto:\\([^ \n\t]+\\)"
7710 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7711 ;; Info Konqueror style <info:/foo/bar baz>.
7712 ;; Must come before " Gnus home-grown style".
7713 ("\\binfo://?\\([^'\">\n\t]+\\)"
7714 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7715 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7716 ("\\binfo://\\([^'\">\n\t ]+\\)"
7717 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7718 ;; Info GNOME style <info:foo#bar_baz>
7719 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7720 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7721 ;; Info KDE style <info:(foo)bar baz>
7722 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7723 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7724 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7725 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7726 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n,]*\\)\\)?"
7727 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7728 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7730 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7731 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7732 ;; Emacs help commands
7733 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7734 ;; regexp doesn't match arguments containing ` '.
7735 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7736 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7737 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7738 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7739 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7740 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7741 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7742 ;; The following entries may lead to many false positives so don't enable
7743 ;; them by default (use a high button level).
7744 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7745 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7746 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7747 ("['`‘]\\([a-z][-a-z0-9]+\\.el\\)['’]"
7748 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7749 ("['`‘]\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)['’]"
7750 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7751 ("['`‘]\\([a-z][a-z0-9]+-[a-z]+\\)['’]"
7752 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7753 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7754 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7755 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7756 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7757 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7758 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7759 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7760 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7761 ("['`‘]\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^'’]+\\)\\)['’]"
7762 ;; Unlike the other regexps we really have to require quoting
7763 ;; here to determine where it ends.
7764 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7765 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7766 ("<URL: *\\([^\n<>]*\\)>"
7767 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7768 ;; RFC 2396 (2.4.3., delims) ...
7769 ("\"URL: *\\([^\n\"]*\\)\""
7770 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7772 (gnus-button-url-regexp
7773 0 (>= gnus-button-browse-level 0) browse-url 0)
7775 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7776 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7777 gnus-button-handle-man 1)
7778 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7779 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7780 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7781 gnus-button-handle-man 1)
7782 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7783 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7784 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7785 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7786 ;; Recognizing patches to .el files. This is somewhat obscure,
7787 ;; but considering the percentage of Gnus users who hack Emacs
7789 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7790 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7791 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7792 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7793 ;; MID or mail: To avoid too many false positives we don't try to catch
7794 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7795 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7796 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7797 ;; so that non-ambiguous entries (see above) match first.
7798 (gnus-button-mid-or-mail-regexp
7799 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7800 "*Alist of regexps matching buttons in article bodies.
7802 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7803 REGEXP: is the string (case insensitive) matching text around the button (can
7804 also be Lisp expression evaluating to a string),
7805 BUTTON: is the number of the regexp grouping actually matching the button,
7806 FORM: is a Lisp expression which must eval to true for the button to
7808 CALLBACK: is the function to call when the user push this button, and each
7809 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7811 CALLBACK can also be a variable, in that case the value of that
7812 variable it the real callback function."
7813 :group 'gnus-article-buttons
7814 :type '(repeat (list (choice regexp variable sexp)
7815 (integer :tag "Button")
7817 (function :tag "Callback")
7820 (integer :tag "Regexp group")))))
7821 (put 'gnus-button-alist 'risky-local-variable t)
7823 (defcustom gnus-header-button-alist
7824 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7825 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7826 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7827 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7828 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7829 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7830 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7831 0 (>= gnus-button-browse-level 0) browse-url 0)
7832 ("^Subject:" gnus-button-url-regexp
7833 0 (>= gnus-button-browse-level 0) browse-url 0)
7834 ("^[^:]+:" gnus-button-url-regexp
7835 0 (>= gnus-button-browse-level 0) browse-url 0)
7836 ("^OpenPGP:.*url=" gnus-button-url-regexp
7837 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7838 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7839 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7840 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7841 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7842 "*Alist of headers and regexps to match buttons in article heads.
7844 This alist is very similar to `gnus-button-alist', except that each
7845 alist has an additional HEADER element first in each entry:
7847 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7849 HEADER is a regexp to match a header. For a fuller explanation, see
7850 `gnus-button-alist'."
7851 :group 'gnus-article-buttons
7852 :group 'gnus-article-headers
7853 :type '(repeat (list (regexp :tag "Header")
7854 (choice regexp variable)
7855 (integer :tag "Button")
7857 (function :tag "Callback")
7860 (integer :tag "Regexp group")))))
7861 (put 'gnus-header-button-alist 'risky-local-variable t)
7865 (defun gnus-article-push-button (event)
7866 "Check text under the mouse pointer for a callback function.
7867 If the text under the mouse pointer has a `gnus-callback' property,
7868 call it with the value of the `gnus-data' text property."
7870 (set-buffer (window-buffer (posn-window (event-start event))))
7871 (let* ((pos (posn-point (event-start event)))
7872 (data (get-text-property pos 'gnus-data))
7873 (fun (get-text-property pos 'gnus-callback)))
7876 (funcall fun data))))
7878 (defun gnus-article-press-button ()
7879 "Check text at point for a callback function.
7880 If the text at point has a `gnus-callback' property,
7881 call it with the value of the `gnus-data' text property."
7883 (let ((data (get-text-property (point) 'gnus-data))
7884 (fun (get-text-property (point) 'gnus-callback)))
7886 (funcall fun data))))
7888 (defun gnus-article-highlight (&optional force)
7889 "Highlight current article.
7890 This function calls `gnus-article-highlight-headers',
7891 `gnus-article-highlight-citation',
7892 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7893 do the highlighting. See the documentation for those functions."
7894 (interactive (list 'force))
7895 (gnus-article-highlight-headers)
7896 (gnus-article-highlight-citation force)
7897 (gnus-article-highlight-signature)
7898 (gnus-article-add-buttons)
7899 (gnus-article-add-buttons-to-head))
7901 (defun gnus-article-highlight-some (&optional _force)
7902 "Highlight current article.
7903 This function calls `gnus-article-highlight-headers',
7904 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7905 do the highlighting. See the documentation for those functions."
7906 (interactive (list 'force))
7907 (gnus-article-highlight-headers)
7908 (gnus-article-highlight-signature)
7909 (gnus-article-add-buttons))
7911 (defun gnus-article-highlight-headers ()
7912 "Highlight article headers as specified by `gnus-header-face-alist'."
7914 (gnus-with-article-headers
7915 (let (regexp header-face field-face from hpoints fpoints)
7916 (dolist (entry gnus-header-face-alist)
7917 (goto-char (point-min))
7918 (setq regexp (concat "^\\("
7919 (if (string-equal "" (nth 0 entry))
7923 header-face (nth 1 entry)
7924 field-face (nth 2 entry))
7925 (while (and (re-search-forward regexp nil t)
7929 (unless (search-forward ":" nil t)
7931 (when (and header-face
7932 (not (memq (point) hpoints)))
7933 (push (point) hpoints)
7934 (put-text-property from (point) 'face header-face))
7935 (when (and field-face
7936 (not (memq (setq from (point)) fpoints)))
7938 (if (re-search-forward "^[^ \t]" nil t)
7940 (goto-char (point-max)))
7941 (put-text-property from (point) 'face field-face)))))))
7943 (defun gnus-article-highlight-signature ()
7944 "Highlight the signature in an article.
7945 It does this by highlighting everything after
7946 `gnus-signature-separator' using the face `gnus-signature'."
7948 (gnus-with-article-buffer
7949 (let ((inhibit-point-motion-hooks t))
7951 (when (and gnus-signature-face
7952 (gnus-article-narrow-to-signature))
7953 (overlay-put (make-overlay (point-min) (point-max) nil t)
7954 'face gnus-signature-face)
7956 (gnus-article-search-signature)
7957 (let ((start (match-beginning 0))
7958 (end (set-marker (make-marker) (1+ (match-end 0)))))
7959 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7962 (defun gnus-button-in-region-p (b e prop)
7963 "Say whether PROP exists in the region."
7964 (text-property-not-all b e prop nil))
7966 (defun gnus-article-add-buttons ()
7967 "Find external references in the article and make buttons of them.
7968 \"External references\" are things like Message-IDs and URLs, as
7969 specified by `gnus-button-alist'."
7971 (gnus-with-article-buffer
7972 (let ((inhibit-point-motion-hooks t)
7973 (case-fold-search t)
7974 (alist gnus-button-alist)
7976 ;; We skip the headers.
7979 (while (setq entry (pop alist))
7980 (setq regexp (eval (car entry)))
7982 (while (re-search-forward regexp nil t)
7983 (let ((start (match-beginning (nth 1 entry)))
7984 (end (match-end (nth 1 entry)))
7985 (from (match-beginning 0)))
7986 (when (and (eval (nth 2 entry))
7987 (not (gnus-button-in-region-p
7988 start end 'gnus-callback)))
7989 ;; That optional form returned non-nil, so we add the
7991 (setq from (set-marker (make-marker) from))
7992 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7993 (gnus-article-extend-url-button from start end))
7994 (gnus-article-add-button start end
7995 'gnus-button-push (list from entry))
7998 'gnus-string (buffer-substring-no-properties
8001 (defun gnus-article-extend-url-button (beg start end)
8002 "Extend url button if url is folded into two or more lines.
8003 Return non-nil if button is extended. BEG is a marker that points to
8004 the beginning position of a text containing url. START and END are
8005 the endpoints of a url button before it is extended. The concatenated
8006 url is put as the `gnus-button-url' overlay property on the button."
8007 (let ((opoint (point))
8008 (points (list start end))
8013 (not (looking-at "[\t ]*[\">]")))
8017 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8018 (buffer-substring (point-at-bol) start)))
8020 (setq url (list (buffer-substring start end))
8021 delim (if (match-beginning 1) ">" "\""))
8023 (setq regexp (concat
8024 (when (and (looking-at
8025 message-cite-prefix-regexp)
8026 (< (match-end 0) start))
8027 (regexp-quote (match-string 0)))
8029 [\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8033 (and (looking-at regexp)
8036 (push (or (match-string 2)
8039 (push (setq end (or (match-end 2)
8042 (push (or (match-beginning 2)
8043 (match-beginning 1))
8045 (match-beginning 2)))
8046 (let (gnus-article-mouse-face widget-mouse-face)
8048 (gnus-article-add-button (pop points) (pop points)
8050 (list beg (assq 'gnus-button-url-regexp
8051 gnus-button-alist)))))
8052 (let ((overlay (make-overlay start end)))
8053 (overlay-put overlay 'evaporate t)
8054 (overlay-put overlay 'gnus-button-url
8055 (list (mapconcat 'identity (nreverse url) "")))
8056 (when gnus-article-mouse-face
8057 (overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8059 (goto-char opoint))))
8061 ;; Add buttons to the head of an article.
8062 (defun gnus-article-add-buttons-to-head ()
8063 "Add buttons to the head of the article."
8065 (gnus-with-article-headers
8067 (dolist (entry gnus-header-button-alist)
8068 ;; Each alist entry.
8069 (goto-char (point-min))
8070 (while (re-search-forward (car entry) nil t)
8071 ;; Each header matching the entry.
8072 (setq beg (match-beginning 0))
8073 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8074 (match-beginning 0))
8077 (while (re-search-forward (eval (nth 1 entry)) end t)
8078 ;; Each match within a header.
8079 (let* ((entry (cdr entry))
8080 (start (match-beginning (nth 1 entry)))
8081 (end (match-end (nth 1 entry)))
8082 (form (nth 2 entry)))
8083 (goto-char (match-end 0))
8085 (gnus-article-add-button
8086 start end (nth 3 entry)
8087 (buffer-substring (match-beginning (nth 4 entry))
8088 (match-end (nth 4 entry)))))))
8089 (goto-char end))))))
8091 ;;; External functions:
8093 (defun gnus-article-add-button (from to fun &optional data text)
8094 "Create a button between FROM and TO with callback FUN and data DATA."
8095 (when gnus-article-button-face
8096 (overlay-put (make-overlay from to nil t)
8097 'face gnus-article-button-face))
8098 (add-text-properties
8100 (nconc (and gnus-article-mouse-face
8101 (list 'mouse-face gnus-article-mouse-face))
8102 (list 'gnus-callback fun)
8103 (and data (list 'gnus-data data))))
8104 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8105 :help-echo (or text "Follow the link")
8106 :keymap gnus-url-button-map))
8108 (defun gnus-article-copy-string ()
8109 "Copy the string in the button to the kill ring."
8111 (gnus-article-check-buffer)
8112 (let ((data (get-text-property (point) 'gnus-string)))
8116 (copy-region-as-kill (point-min) (point-max))
8117 (message "Copied %s" data)))))
8119 ;;; Internal functions:
8121 (defun gnus-article-set-globals ()
8122 (with-current-buffer gnus-summary-buffer
8123 (gnus-set-global-variables)))
8125 (defun gnus-signature-toggle (end)
8126 (gnus-with-article-buffer
8127 (let ((inhibit-point-motion-hooks t))
8128 (if (text-property-any end (point-max) 'article-type 'signature)
8130 (gnus-delete-wash-type 'signature)
8131 (gnus-remove-text-properties-when
8132 'article-type 'signature end (point-max)
8133 (cons 'article-type (cons 'signature
8134 gnus-hidden-properties))))
8135 (gnus-add-wash-type 'signature)
8136 (gnus-add-text-properties-when
8137 'article-type nil end (point-max)
8138 (cons 'article-type (cons 'signature
8139 gnus-hidden-properties)))))
8140 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8141 (gnus-set-mode-line 'article))))
8143 (defun gnus-button-push (marker-and-entry)
8144 ;; Push button starting at MARKER.
8146 (let* ((marker (car marker-and-entry))
8147 (entry (cadr marker-and-entry))
8148 (regexp (car entry))
8149 (inhibit-point-motion-hooks t))
8151 ;; This is obviously true, or something bad is happening :)
8152 ;; But we need it to have the match-data
8153 (when (looking-at (or (if (symbolp regexp)
8154 (symbol-value regexp)
8156 (let ((fun (nth 3 entry))
8157 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8158 (get-char-property marker 'gnus-button-url))
8159 (mapcar (lambda (group)
8160 (let ((string (match-string group)))
8161 (set-text-properties
8162 0 (length string) nil string)
8164 (nthcdr 4 entry)))))
8170 (fboundp (symbol-value fun)))
8171 (apply (symbol-value fun) args))
8173 (gnus-message 1 "You must define `%S' to use this button"
8174 (cons fun args)))))))))
8176 (defun gnus-parse-news-url (url)
8177 (let (scheme server port group message-id articles)
8180 (goto-char (point-min))
8181 (when (looking-at "\\([A-Za-z]+\\):")
8182 (setq scheme (match-string 1))
8183 (goto-char (match-end 0)))
8184 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8185 (setq server (match-string 1))
8186 (setq port (if (stringp (match-string 3))
8187 (string-to-number (match-string 3))
8189 (goto-char (match-end 0)))
8192 ((looking-at "\\(.*@.*\\)")
8193 (setq message-id (match-string 1)))
8194 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8195 (setq group (match-string 1)
8196 articles (split-string (match-string 2) "-")))
8197 ((looking-at "\\([^/]+\\)/?")
8198 (setq group (match-string 1)))
8200 (error "Unknown news URL syntax"))))
8201 (list scheme server port group message-id articles)))
8203 (defvar nntp-port-number)
8205 (defun gnus-button-handle-news (url)
8207 (destructuring-bind (_scheme server port group message-id _articles)
8208 (gnus-parse-news-url url)
8211 (with-current-buffer gnus-summary-buffer
8213 (let ((gnus-refer-article-method
8214 (nconc (list (list 'nntp server))
8215 gnus-refer-article-method))
8216 (nntp-port-number (or port "nntp")))
8217 (gnus-message 7 "Fetching %s with %s"
8218 message-id gnus-refer-article-method)
8219 (gnus-summary-refer-article message-id))
8220 (gnus-summary-refer-article message-id))))
8222 (gnus-button-fetch-group url)))))
8224 (defun gnus-button-patch (library line)
8225 "Visit an Emacs Lisp library LIBRARY on line LINE."
8227 (let ((file (locate-library (file-name-nondirectory library))))
8229 (error "Couldn't find library %s" library))
8231 (goto-char (point-min))
8232 (forward-line (1- (string-to-number line)))))
8234 (defun gnus-button-handle-man (url)
8236 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8237 (when (eq gnus-button-man-handler 'woman)
8238 (setq url (replace-regexp-in-string "([1-9][X1a-z]*).*\\'" "" url)))
8239 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8240 (funcall gnus-button-man-handler url))
8242 (defun gnus-button-handle-info-url (url)
8243 "Fetch an info URL."
8244 (setq url (subst-char-in-string ?+ ?\ url))
8246 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8247 (gnus-info-find-node
8248 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8250 ")" (gnus-url-unhex-string (match-string 2 url)))))
8251 ((string-match "([^)\"]+)[^\"]+" url)
8253 (replace-regexp-in-string
8254 "\"" "" (replace-regexp-in-string "[\n\t ]+" " " url)))
8255 (gnus-info-find-node url))
8256 (t (error "Can't parse %s" url))))
8258 (defun gnus-button-handle-info-url-gnome (url)
8259 "Fetch GNOME style info URL."
8260 (setq url (subst-char-in-string ?_ ?\ url))
8261 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8262 (gnus-info-find-node
8264 (gnus-url-unhex-string
8265 (match-string 1 url))
8267 (or (gnus-url-unhex-string
8268 (match-string 2 url))
8270 (error "Can't parse %s" url)))
8272 (defun gnus-button-handle-info-url-kde (url)
8273 "Fetch KDE style info URL."
8274 (gnus-info-find-node (gnus-url-unhex-string url)))
8276 ;; (info) will autoload info.el
8277 (declare-function Info-menu "info" (menu-item &optional fork))
8278 (declare-function Info-index-next "info" (num))
8280 (defun gnus-button-handle-info-keystrokes (url)
8281 "Call `info' when pushing the corresponding URL button."
8282 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8283 (let (node indx comma)
8285 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8286 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8287 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8288 "\\(?:[ \t\n,]*\\)\\)?")
8290 (setq node (match-string 2 url)
8291 indx (match-string 3 url))
8292 (error "Can't parse %s" url))
8296 (when (> (length indx) 0)
8297 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8300 (setq comma (match-string 2 indx))
8301 (setq indx (match-string 1 indx))
8304 (dotimes (i (with-temp-buffer
8306 ;; Note: the XEmacs version of `how-many' takes
8307 ;; no optional argument.
8308 (goto-char (point-min))
8310 (Info-index-next 1)))
8313 (autoload 'pgg-snarf-keys-region "pgg")
8314 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8315 (declare-function pgg-display-output-buffer "pgg" (start end status))
8317 (defun gnus-button-openpgp (url)
8318 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8320 (mm-url-insert-file-contents-external url)
8321 (pgg-snarf-keys-region (point-min) (point-max))
8322 (pgg-display-output-buffer nil nil nil)))
8324 (defun gnus-button-message-id (message-id)
8326 (with-current-buffer gnus-summary-buffer
8327 (gnus-summary-refer-article message-id)))
8329 (defun gnus-button-fetch-group (address &rest _ignore)
8330 "Fetch GROUP specified by ADDRESS."
8331 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8333 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8334 ;; for nntp:// and news://
8335 (setq address (match-string 3 address)))
8336 (if (not (string-match "[:/]" address))
8337 ;; This is just a simple group url.
8338 (gnus-group-read-ephemeral-group address gnus-select-method)
8341 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8343 (error "Can't parse %s" address)
8344 (gnus-group-read-ephemeral-group
8345 (match-string 4 address)
8346 `(nntp ,(match-string 1 address)
8347 (nntp-address ,(match-string 1 address))
8348 (nntp-port-number ,(if (match-end 3)
8349 (match-string 3 address)
8352 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8354 (defun gnus-url-parse-query-string (query &optional downcase)
8355 (let (retval pairs cur key val)
8356 (setq pairs (split-string query "&"))
8358 (setq cur (car pairs)
8360 (if (not (string-match "=" cur))
8362 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8363 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8365 (setq key (downcase key)))
8366 (setq cur (assoc key retval))
8368 (setcdr cur (cons val (cdr cur)))
8369 (setq retval (cons (list key val) retval)))))
8372 (defun gnus-url-mailto (url)
8373 ;; Send mail to someone
8374 (setq url (replace-regexp-in-string "\n" " " url))
8375 (when (string-match "mailto:/*\\(.*\\)" url)
8376 (setq url (substring url (match-beginning 1) nil)))
8377 (let* ((args (gnus-url-parse-query-string
8378 (if (string-match "^\\?" url)
8380 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8381 (concat "to=" (match-string 1 url) "&"
8382 (match-string 2 url))
8383 (concat "to=" url)))))
8384 (subject (cdr-safe (assoc "subject" args)))
8388 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8391 (message-position-on-field (caar args)))
8392 (insert (replace-regexp-in-string
8394 (mapconcat 'identity (reverse (cdar args)) ", ") nil t))
8395 (setq args (cdr args)))
8398 (message-goto-subject))))
8400 (defun gnus-button-embedded-url (address)
8401 "Activate ADDRESS with `browse-url'."
8402 (browse-url (gnus-strip-whitespace address)))
8404 ;;; Next/prev buttons in the article buffer.
8406 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8407 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8409 (defvar gnus-prev-page-map
8410 (let ((map (make-sparse-keymap)))
8411 (define-key map [mouse-2] 'gnus-button-prev-page)
8412 (define-key map "\r" 'gnus-button-prev-page)
8415 (defvar gnus-next-page-map
8416 (let ((map (make-sparse-keymap)))
8417 (define-key map [mouse-2] 'gnus-button-next-page)
8418 (define-key map "\r" 'gnus-button-next-page)
8421 (defun gnus-insert-prev-page-button ()
8423 (inhibit-read-only t))
8425 gnus-prev-page-line-format nil
8426 `(keymap ,gnus-prev-page-map
8428 gnus-callback gnus-article-button-prev-page
8429 article-type annotation))
8431 ;; Exclude a newline.
8434 (when gnus-article-button-face
8435 (overlay-put (make-overlay b e nil t)
8436 'face gnus-article-button-face))
8437 (widget-convert-button
8439 :action 'gnus-button-prev-page
8440 :button-keymap gnus-prev-page-map)))
8442 (defun gnus-button-next-page (&optional _args _more-args)
8443 "Go to the next page."
8445 (let ((win (selected-window)))
8446 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8447 (gnus-article-next-page)
8448 (select-window win)))
8450 (defun gnus-button-prev-page (&optional _args _more-args)
8451 "Go to the prev page."
8453 (let ((win (selected-window)))
8454 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8455 (gnus-article-prev-page)
8456 (select-window win)))
8458 (defun gnus-insert-next-page-button ()
8460 (inhibit-read-only t))
8461 (gnus-eval-format gnus-next-page-line-format nil
8462 `(keymap ,gnus-next-page-map
8464 gnus-callback gnus-article-button-next-page
8465 article-type annotation))
8467 ;; Exclude a newline.
8470 (when gnus-article-button-face
8471 (overlay-put (make-overlay b e nil t)
8472 'face gnus-article-button-face))
8473 (widget-convert-button
8475 :action 'gnus-button-next-page
8476 :button-keymap gnus-next-page-map)))
8478 (defun gnus-article-button-next-page (_arg)
8479 "Go to the next page."
8481 (let ((win (selected-window)))
8482 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8483 (gnus-article-next-page)
8484 (select-window win)))
8486 (defun gnus-article-button-prev-page (_arg)
8487 "Go to the prev page."
8489 (let ((win (selected-window)))
8490 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8491 (gnus-article-prev-page)
8492 (select-window win)))
8494 (defvar gnus-decode-header-methods
8495 '(mail-decode-encoded-word-region)
8496 "List of methods used to decode headers.
8498 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8499 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8500 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8501 whose names match REGEXP.
8504 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8505 mail-decode-encoded-word-region
8506 (\"chinese\" . rfc1843-decode-region))
8509 (defvar gnus-decode-header-methods-cache nil)
8511 (defun gnus-multi-decode-header (start end)
8512 "Apply the functions from `gnus-encoded-word-methods' that match."
8513 (unless (and gnus-decode-header-methods-cache
8514 (eq gnus-newsgroup-name
8515 (car gnus-decode-header-methods-cache)))
8516 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8517 (dolist (x gnus-decode-header-methods)
8519 (nconc gnus-decode-header-methods-cache (list x))
8520 (if (and gnus-newsgroup-name
8521 (string-match (car x) gnus-newsgroup-name))
8522 (nconc gnus-decode-header-methods-cache
8524 (let ((xlist gnus-decode-header-methods-cache))
8527 (narrow-to-region start end)
8529 (funcall (pop xlist) (point-min) (point-max))))))
8532 ;;; Treatment top-level handling.
8535 (defvar gnus-inhibit-article-treatments nil)
8537 ;; Dynamic variables.
8538 (defvar part-number) ;FIXME: Lacks a "gnus-" prefix.
8539 (defvar total-parts) ;FIXME: Lacks a "gnus-" prefix.
8540 (defvar gnus-treat-type)
8541 (defvar gnus-treat-condition)
8542 (defvar gnus-treat-length)
8544 (defun gnus-treat-article (condition
8545 &optional part-num total type)
8546 (let ((gnus-treat-condition condition)
8547 (part-number part-num)
8549 (gnus-treat-type type)
8550 (gnus-treat-length (- (point-max) (point-min)))
8551 (alist gnus-treatment-function-alist)
8552 (article-goto-body-goes-to-point-min-p t)
8556 (let ((list gnus-article-treat-types))
8558 (when (string-match (pop list) type)
8559 (throw 'found t)))))))
8560 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8562 (gnus-run-hooks 'gnus-part-display-hook)
8563 (dolist (elem alist)
8566 (when (gnus-buffer-live-p gnus-summary-buffer)
8567 (set-buffer gnus-summary-buffer))
8568 (symbol-value (car elem))))
8569 (when (and (or (consp val)
8571 (or (not gnus-inhibit-article-treatments)
8572 (eq gnus-treat-condition 'head))
8573 (gnus-treat-predicate val)
8574 (or (not (get (car elem) 'highlight))
8577 (funcall (cadr elem)))))))
8579 (defun gnus-treat-predicate (val)
8583 (gnus-treat-condition
8584 (eq gnus-treat-condition val))
8586 (stringp (car val)))
8587 (apply 'gnus-or (mapcar `(lambda (s)
8588 (string-match s ,(or gnus-newsgroup-name "")))
8591 (let ((pred (pop val)))
8594 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8596 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8598 (not (gnus-treat-predicate (car val))))
8600 (equal (car val) gnus-treat-type))
8604 (error "%S is not a valid predicate" pred)))))
8612 (eq part-number total-parts))
8614 (< gnus-treat-length val))
8616 (error "%S is not a valid value" val))))
8618 (defun gnus-article-encrypt-body (protocol &optional n)
8619 "Encrypt the article body."
8622 (or gnus-article-encrypt-protocol
8623 (gnus-completing-read "Encrypt protocol"
8624 (mapcar 'car gnus-article-encrypt-protocol-alist)
8626 current-prefix-arg))
8627 ;; User might hit `K E' instead of `K e', so prompt once.
8628 (when (and gnus-article-encrypt-protocol
8630 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8631 (error "Encrypt aborted")))
8632 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8634 (error "Can't find the encrypt protocol %s" protocol))
8635 (if (member gnus-newsgroup-name '("nndraft:delayed"
8638 (error "Can't encrypt the article in group %s"
8639 gnus-newsgroup-name))
8640 (gnus-summary-iterate n
8641 (with-current-buffer gnus-summary-buffer
8642 (let ((mail-parse-charset gnus-newsgroup-charset)
8643 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8644 (summary-buffer gnus-summary-buffer)
8646 (gnus-set-global-variables)
8647 (when (gnus-group-read-only-p)
8648 (error "The current newsgroup does not support article encrypt"))
8649 (gnus-summary-show-article t)
8651 (or (mail-header-references gnus-current-headers) ""))
8652 (set-buffer gnus-article-buffer)
8653 (let* ((inhibit-read-only t)
8655 (mapcar (lambda (field)
8656 (and (save-restriction
8657 (message-narrow-to-head)
8658 (goto-char (point-min))
8659 (search-forward field nil t))
8661 (message-narrow-to-field)
8663 (delete-region (point-min) (point-max))
8665 '("Content-Type:" "Content-Transfer-Encoding:"
8666 "Content-Disposition:"))))
8667 (message-narrow-to-head)
8668 (message-remove-header "MIME-Version")
8669 (goto-char (point-max))
8670 (setq point (point))
8671 (insert (apply 'concat headers))
8673 (narrow-to-region point (point-max))
8674 (let ((message-options message-options))
8675 (message-options-set 'message-sender user-mail-address)
8676 (message-options-set 'message-recipients user-mail-address)
8677 (message-options-set 'message-sign-encrypt 'not)
8679 (goto-char (point-min))
8680 (insert "MIME-Version: 1.0\n")
8682 (gnus-summary-edit-article-done
8683 references nil summary-buffer t))
8684 (when gnus-keep-backlog
8685 (gnus-backlog-remove-article
8686 (car gnus-article-current) (cdr gnus-article-current)))
8687 (gnus-flush-original-article-buffer)
8688 (when gnus-use-cache
8689 (gnus-cache-update-article
8690 (car gnus-article-current) (cdr gnus-article-current))))))))
8692 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8693 "The following specs can be used:
8694 %t The security MIME type
8697 %D Details if button is pressed")
8699 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8700 "The following specs can be used:
8701 %t The security MIME type
8704 %D Details if button is pressed")
8706 (defvar gnus-mime-security-button-line-format-alist
8707 '((?t gnus-tmp-type ?s)
8708 (?i gnus-tmp-info ?s)
8709 (?d gnus-tmp-details ?s)
8710 (?D gnus-tmp-pressed-details ?s)))
8712 (defvar gnus-mime-security-button-commands
8713 '((gnus-article-press-button "\r" "Show Detail")
8717 (gnus-mime-security-save-part "o" "Save...")
8726 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8729 (defvar gnus-mime-security-button-map
8730 (let ((map (make-sparse-keymap)))
8731 (define-key map [mouse-2] 'gnus-article-push-button)
8732 (define-key map [down-mouse-3] 'gnus-mime-security-button-menu)
8733 (dolist (c gnus-mime-security-button-commands)
8734 (define-key map (cadr c) (car c)))
8738 gnus-mime-security-button-menu gnus-mime-security-button-map
8739 "Security button menu."
8743 (unless (eq (car c) 'undefined)
8744 (vector (caddr c) (car c) :active t)))
8745 gnus-mime-security-button-commands))))
8747 (defun gnus-mime-security-button-menu (event prefix)
8748 "Construct a context-sensitive menu of security commands."
8749 (interactive "e\nP")
8750 (save-window-excursion
8751 (let ((pos (event-start event)))
8752 (select-window (posn-window pos))
8753 (goto-char (posn-point pos))
8754 (gnus-article-check-buffer)
8755 (popup-menu gnus-mime-security-button-menu nil prefix))))
8757 (defvar gnus-mime-security-details-buffer nil)
8759 (defvar gnus-mime-security-button-pressed nil)
8761 (defvar gnus-mime-security-show-details-inline t
8762 "If non-nil, show details in the article buffer.")
8764 (defun gnus-mime-security-verify-or-decrypt (handle)
8765 (mm-remove-parts (cdr handle))
8766 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8767 point (inhibit-read-only t))
8769 (goto-char (car region)))
8770 (setq point (point))
8771 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8772 (let* ((mm-verify-option 'known)
8773 (mm-decrypt-option 'known)
8774 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8775 (unless (eq nparts (cdr handle))
8776 (mm-destroy-parts (cdr handle))
8777 (setcdr handle nparts))))
8778 (gnus-mime-display-security handle)
8780 (delete-region (point) (cdr region))
8781 (set-marker (car region) nil)
8782 (set-marker (cdr region) nil))
8785 (defun gnus-mime-security-show-details (handle)
8786 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8788 (gnus-message 5 "No details.")
8789 (if gnus-mime-security-show-details-inline
8790 (let ((gnus-mime-security-button-pressed
8791 (not (get-text-property (point) 'gnus-mime-details)))
8792 (gnus-mime-security-button-line-format
8793 (get-text-property (point) 'gnus-line-format))
8794 (inhibit-read-only t))
8796 (while (eq (get-text-property (point) 'gnus-line-format)
8797 gnus-mime-security-button-line-format)
8801 (narrow-to-region (point) (point))
8802 (gnus-insert-mime-security-button handle))
8803 (delete-region (point)
8804 (or (text-property-not-all
8807 gnus-mime-security-button-line-format)
8810 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8811 (with-current-buffer gnus-mime-security-details-buffer
8814 (setq gnus-mime-security-details-buffer
8815 (gnus-get-buffer-create "*MIME Security Details*")))
8816 (with-current-buffer gnus-mime-security-details-buffer
8818 (goto-char (point-min)))
8819 (pop-to-buffer gnus-mime-security-details-buffer)))))
8821 (defun gnus-mime-security-press-button (handle)
8823 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8824 (gnus-mime-security-show-details handle)
8825 (gnus-mime-security-verify-or-decrypt handle))))
8827 (defun gnus-insert-mime-security-button (handle &optional _displayed)
8828 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8831 (or (nth 2 (assoc protocol mm-verify-function-alist))
8832 (nth 2 (assoc protocol mm-decrypt-function-alist))
8834 (if (equal (car handle) "multipart/signed")
8835 " Signed" " Encrypted")
8838 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8841 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8842 gnus-tmp-pressed-details
8844 (setq gnus-tmp-details
8845 (if gnus-tmp-details
8846 (concat "\n" gnus-tmp-details)
8848 (setq gnus-tmp-pressed-details
8849 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8854 gnus-mime-security-button-line-format
8855 gnus-mime-security-button-line-format-alist
8856 `(keymap ,gnus-mime-security-button-map
8857 gnus-callback gnus-mime-security-press-button
8858 gnus-line-format ,gnus-mime-security-button-line-format
8859 gnus-mime-details ,gnus-mime-security-button-pressed
8860 article-type annotation
8863 ;; Exclude a newline.
8866 (when gnus-article-button-face
8867 (overlay-put (make-overlay b e nil t)
8868 'face gnus-article-button-face))
8869 (widget-convert-button
8872 :action 'gnus-widget-press-button
8873 :button-keymap gnus-mime-security-button-map
8877 "%S: show detail; %S: more options"
8881 (defun gnus-mime-display-security (handle)
8883 (narrow-to-region (point) (point))
8884 (unless (gnus-unbuttonized-mime-type-p (car handle))
8885 (gnus-insert-mime-security-button handle))
8886 (gnus-mime-display-part (cadr handle))
8889 (unless (gnus-unbuttonized-mime-type-p (car handle))
8890 (let ((gnus-mime-security-button-line-format
8891 gnus-mime-security-button-end-line-format))
8892 (gnus-insert-mime-security-button handle)))
8893 (mm-set-handle-multipart-parameter
8894 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8895 (goto-char (point-max))))
8897 (defun gnus-mime-security-run-function (function)
8898 "Run FUNCTION with the security part under point."
8899 (gnus-article-check-buffer)
8900 (let ((data (get-text-property (point) 'gnus-data))
8902 (when (and (stringp (car-safe data))
8903 (setq buffer (mm-handle-multipart-original-buffer data))
8904 (setq handle (cadr data)))
8905 (if (bufferp (mm-handle-buffer handle))
8907 (setq handle (cons buffer (copy-sequence (cdr handle))))
8908 (mm-handle-set-undisplayer handle nil))
8909 (setq handle (mm-make-handle
8911 (mm-handle-multipart-ctl-parameter handle 'protocol)
8912 nil nil nil nil nil nil)))
8913 (funcall function handle))))
8915 (defun gnus-mime-security-save-part ()
8916 "Save the security part under point."
8918 (gnus-mime-security-run-function 'mm-save-part))
8920 (defun gnus-mime-security-pipe-part ()
8921 "Pipe the security part under point to a process."
8923 (gnus-mime-security-run-function 'mm-pipe-part))
8927 (run-hooks 'gnus-art-load-hook)
8929 ;;; gnus-art.el ends here