| 1 | ;;; gnus-art.el --- article mode commands for Gnus |
| 2 | |
| 3 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 4 | ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
| 5 | |
| 6 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 7 | ;; Keywords: news |
| 8 | |
| 9 | ;; This file is part of GNU Emacs. |
| 10 | |
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 12 | ;; it under the terms of the GNU General Public License as published by |
| 13 | ;; the Free Software Foundation, either version 3 of the License, or |
| 14 | ;; (at your option) any later version. |
| 15 | |
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | ;; GNU General Public License for more details. |
| 20 | |
| 21 | ;; You should have received a copy of the GNU General Public License |
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 23 | |
| 24 | ;;; Commentary: |
| 25 | |
| 26 | ;;; Code: |
| 27 | |
| 28 | ;; For Emacs < 22.2. |
| 29 | (eval-and-compile |
| 30 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
| 31 | (eval-when-compile |
| 32 | (require 'cl)) |
| 33 | (defvar tool-bar-map) |
| 34 | (defvar w3m-minor-mode-map) |
| 35 | |
| 36 | (require 'gnus) |
| 37 | (require 'gnus-sum) |
| 38 | (require 'gnus-spec) |
| 39 | (require 'gnus-int) |
| 40 | (require 'gnus-win) |
| 41 | (require 'mm-bodies) |
| 42 | (require 'mail-parse) |
| 43 | (require 'mm-decode) |
| 44 | (require 'mm-view) |
| 45 | (require 'wid-edit) |
| 46 | (require 'mm-uu) |
| 47 | (require 'message) |
| 48 | |
| 49 | (autoload 'gnus-msg-mail "gnus-msg" nil t) |
| 50 | (autoload 'gnus-button-mailto "gnus-msg") |
| 51 | (autoload 'gnus-button-reply "gnus-msg" nil t) |
| 52 | (autoload 'parse-time-string "parse-time" nil nil) |
| 53 | (autoload 'ansi-color-apply-on-region "ansi-color") |
| 54 | (autoload 'mm-url-insert-file-contents-external "mm-url") |
| 55 | (autoload 'mm-extern-cache-contents "mm-extern") |
| 56 | |
| 57 | (defgroup gnus-article nil |
| 58 | "Article display." |
| 59 | :link '(custom-manual "(gnus)Article Buffer") |
| 60 | :group 'gnus) |
| 61 | |
| 62 | (defgroup gnus-article-treat nil |
| 63 | "Treating article parts." |
| 64 | :link '(custom-manual "(gnus)Article Hiding") |
| 65 | :group 'gnus-article) |
| 66 | |
| 67 | (defgroup gnus-article-hiding nil |
| 68 | "Hiding article parts." |
| 69 | :link '(custom-manual "(gnus)Article Hiding") |
| 70 | :group 'gnus-article) |
| 71 | |
| 72 | (defgroup gnus-article-highlight nil |
| 73 | "Article highlighting." |
| 74 | :link '(custom-manual "(gnus)Article Highlighting") |
| 75 | :group 'gnus-article |
| 76 | :group 'gnus-visual) |
| 77 | |
| 78 | (defgroup gnus-article-signature nil |
| 79 | "Article signatures." |
| 80 | :link '(custom-manual "(gnus)Article Signature") |
| 81 | :group 'gnus-article) |
| 82 | |
| 83 | (defgroup gnus-article-headers nil |
| 84 | "Article headers." |
| 85 | :link '(custom-manual "(gnus)Hiding Headers") |
| 86 | :group 'gnus-article) |
| 87 | |
| 88 | (defgroup gnus-article-washing nil |
| 89 | "Special commands on articles." |
| 90 | :link '(custom-manual "(gnus)Article Washing") |
| 91 | :group 'gnus-article) |
| 92 | |
| 93 | (defgroup gnus-article-emphasis nil |
| 94 | "Fontisizing articles." |
| 95 | :link '(custom-manual "(gnus)Article Fontisizing") |
| 96 | :group 'gnus-article) |
| 97 | |
| 98 | (defgroup gnus-article-saving nil |
| 99 | "Saving articles." |
| 100 | :link '(custom-manual "(gnus)Saving Articles") |
| 101 | :group 'gnus-article) |
| 102 | |
| 103 | (defgroup gnus-article-mime nil |
| 104 | "Worshiping the MIME wonder." |
| 105 | :link '(custom-manual "(gnus)Using MIME") |
| 106 | :group 'gnus-article) |
| 107 | |
| 108 | (defgroup gnus-article-buttons nil |
| 109 | "Pushable buttons in the article buffer." |
| 110 | :link '(custom-manual "(gnus)Article Buttons") |
| 111 | :group 'gnus-article) |
| 112 | |
| 113 | (defgroup gnus-article-various nil |
| 114 | "Other article options." |
| 115 | :link '(custom-manual "(gnus)Misc Article") |
| 116 | :group 'gnus-article) |
| 117 | |
| 118 | (defcustom gnus-ignored-headers |
| 119 | (mapcar |
| 120 | (lambda (header) |
| 121 | (concat "^" header ":")) |
| 122 | '("Path" "Expires" "Date-Received" "References" "Xref" "Lines" |
| 123 | "Relay-Version" "Message-ID" "Approved" "Sender" "Received" |
| 124 | "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To" |
| 125 | "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature" |
| 126 | "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop" |
| 127 | "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face" |
| 128 | "X-Attribution" "X-Originating-IP" "Delivered-To" |
| 129 | "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace" |
| 130 | "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*" |
| 131 | "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date" |
| 132 | "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache" |
| 133 | "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time" |
| 134 | "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List" |
| 135 | "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt" |
| 136 | "Old-Received" "X-Pgp" "X-Auth" "X-From-Line" |
| 137 | "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender" |
| 138 | "MBOX-Line" "Priority" "X400-[-A-Za-z]+" |
| 139 | "Status" "X-Gnus-Mail-Source" "Cancel-Lock" |
| 140 | "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance" |
| 141 | "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3" |
| 142 | "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT" |
| 143 | "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin" |
| 144 | "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender" |
| 145 | "List-[A-Za-z]+" "X-Listprocessor-Version" |
| 146 | "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks" |
| 147 | "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway" |
| 148 | "X-Received" "Content-length" "X-precedence" |
| 149 | "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info" |
| 150 | "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup" |
| 151 | "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To" |
| 152 | "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post" |
| 153 | "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive" |
| 154 | "X-Content-length" "X-Posting-Agent" "Original-Received" |
| 155 | "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom" |
| 156 | "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway" |
| 157 | "X-Local-Origin" "X-Local-Destination" "X-UserInfo1" |
| 158 | "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications" |
| 159 | "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer" |
| 160 | "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane" |
| 161 | "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At" |
| 162 | "Envelope-Sender" "Envelope-Recipients")) |
| 163 | "*All headers that start with this regexp will be hidden. |
| 164 | This variable can also be a list of regexps of headers to be ignored. |
| 165 | If `gnus-visible-headers' is non-nil, this variable will be ignored." |
| 166 | :type '(choice :custom-show nil |
| 167 | regexp |
| 168 | (repeat regexp)) |
| 169 | :group 'gnus-article-hiding) |
| 170 | |
| 171 | (defcustom gnus-visible-headers |
| 172 | "^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:\\|^X-Sent:" |
| 173 | "*All headers that do not match this regexp will be hidden. |
| 174 | This variable can also be a list of regexp of headers to remain visible. |
| 175 | If this variable is non-nil, `gnus-ignored-headers' will be ignored." |
| 176 | :type '(choice |
| 177 | (repeat :value-to-internal (lambda (widget value) |
| 178 | (custom-split-regexp-maybe value)) |
| 179 | :match (lambda (widget value) |
| 180 | (or (stringp value) |
| 181 | (widget-editable-list-match widget value))) |
| 182 | regexp) |
| 183 | (const :tag "Use gnus-ignored-headers" nil) |
| 184 | regexp) |
| 185 | :group 'gnus-article-hiding) |
| 186 | |
| 187 | (defcustom gnus-sorted-header-list |
| 188 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" |
| 189 | "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:") |
| 190 | "*This variable is a list of regular expressions. |
| 191 | If it is non-nil, headers that match the regular expressions will |
| 192 | be placed first in the article buffer in the sequence specified by |
| 193 | this list." |
| 194 | :type '(repeat regexp) |
| 195 | :group 'gnus-article-hiding) |
| 196 | |
| 197 | (defcustom gnus-boring-article-headers '(empty followup-to reply-to) |
| 198 | "Headers that are only to be displayed if they have interesting data. |
| 199 | Possible values in this list are: |
| 200 | |
| 201 | 'empty Headers with no content. |
| 202 | 'newsgroups Newsgroup identical to Gnus group. |
| 203 | 'to-address To identical to To-address. |
| 204 | 'to-list To identical to To-list. |
| 205 | 'cc-list CC identical to To-list. |
| 206 | 'followup-to Followup-to identical to Newsgroups. |
| 207 | 'reply-to Reply-to identical to From. |
| 208 | 'date Date less than four days old. |
| 209 | 'long-to To and/or Cc longer than 1024 characters. |
| 210 | 'many-to Multiple To and/or Cc." |
| 211 | :type '(set (const :tag "Headers with no content." empty) |
| 212 | (const :tag "Newsgroups identical to Gnus group." newsgroups) |
| 213 | (const :tag "To identical to To-address." to-address) |
| 214 | (const :tag "To identical to To-list." to-list) |
| 215 | (const :tag "CC identical to To-list." cc-list) |
| 216 | (const :tag "Followup-to identical to Newsgroups." followup-to) |
| 217 | (const :tag "Reply-to identical to From." reply-to) |
| 218 | (const :tag "Date less than four days old." date) |
| 219 | (const :tag "To and/or Cc longer than 1024 characters." long-to) |
| 220 | (const :tag "Multiple To and/or Cc headers." many-to)) |
| 221 | :group 'gnus-article-hiding) |
| 222 | |
| 223 | (defcustom gnus-article-skip-boring nil |
| 224 | "Skip over text that is not worth reading. |
| 225 | By default, if you set this t, then Gnus will display citations and |
| 226 | signatures, but will never scroll down to show you a page consisting |
| 227 | only of boring text. Boring text is controlled by |
| 228 | `gnus-article-boring-faces'." |
| 229 | :version "22.1" |
| 230 | :type 'boolean |
| 231 | :group 'gnus-article-hiding) |
| 232 | |
| 233 | (defcustom gnus-signature-separator '("^-- $" "^-- *$") |
| 234 | "Regexp matching signature separator. |
| 235 | This can also be a list of regexps. In that case, it will be checked |
| 236 | from head to tail looking for a separator. Searches will be done from |
| 237 | the end of the buffer." |
| 238 | :type '(choice :format "%{%t%}: %[Value Menu%]\n%v" |
| 239 | (regexp) |
| 240 | (repeat :tag "List of regexp" regexp)) |
| 241 | :group 'gnus-article-signature) |
| 242 | |
| 243 | (defcustom gnus-signature-limit nil |
| 244 | "Provide a limit to what is considered a signature. |
| 245 | If it is a number, no signature may not be longer (in characters) than |
| 246 | that number. If it is a floating point number, no signature may be |
| 247 | longer (in lines) than that number. If it is a function, the function |
| 248 | will be called without any parameters, and if it returns nil, there is |
| 249 | no signature in the buffer. If it is a string, it will be used as a |
| 250 | regexp. If it matches, the text in question is not a signature. |
| 251 | |
| 252 | This can also be a list of the above values." |
| 253 | :type '(choice (const nil) |
| 254 | (integer :value 200) |
| 255 | (number :value 4.0) |
| 256 | function |
| 257 | (regexp :value ".*")) |
| 258 | :group 'gnus-article-signature) |
| 259 | |
| 260 | (defcustom gnus-hidden-properties '(invisible t intangible t) |
| 261 | "Property list to use for hiding text." |
| 262 | :type 'sexp |
| 263 | :group 'gnus-article-hiding) |
| 264 | |
| 265 | ;; Fixme: This isn't the right thing for mixed graphical and non-graphical |
| 266 | ;; frames in a session. |
| 267 | (defcustom gnus-article-x-face-command |
| 268 | (if (featurep 'xemacs) |
| 269 | (if (or (gnus-image-type-available-p 'xface) |
| 270 | (gnus-image-type-available-p 'pbm)) |
| 271 | 'gnus-display-x-face-in-from |
| 272 | "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -") |
| 273 | (if (gnus-image-type-available-p 'pbm) |
| 274 | 'gnus-display-x-face-in-from |
| 275 | "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \ |
| 276 | display -")) |
| 277 | "*String or function to be executed to display an X-Face header. |
| 278 | If it is a string, the command will be executed in a sub-shell |
| 279 | asynchronously. The compressed face will be piped to this command." |
| 280 | :type `(choice string |
| 281 | (function-item gnus-display-x-face-in-from) |
| 282 | function) |
| 283 | :version "21.1" |
| 284 | :group 'gnus-picon |
| 285 | :group 'gnus-article-washing) |
| 286 | |
| 287 | (defcustom gnus-article-x-face-too-ugly nil |
| 288 | "Regexp matching posters whose face shouldn't be shown automatically." |
| 289 | :type '(choice regexp (const nil)) |
| 290 | :group 'gnus-article-washing) |
| 291 | |
| 292 | (defcustom gnus-article-banner-alist nil |
| 293 | "Banner alist for stripping. |
| 294 | For example, |
| 295 | ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))" |
| 296 | :version "21.1" |
| 297 | :type '(repeat (cons symbol regexp)) |
| 298 | :group 'gnus-article-washing) |
| 299 | |
| 300 | (gnus-define-group-parameter |
| 301 | banner |
| 302 | :variable-document |
| 303 | "Alist of regexps (to match group names) and banner." |
| 304 | :variable-group gnus-article-washing |
| 305 | :parameter-type |
| 306 | '(choice :tag "Banner" |
| 307 | :value nil |
| 308 | (const :tag "Remove signature" signature) |
| 309 | (symbol :tag "Item in `gnus-article-banner-alist'" none) |
| 310 | regexp |
| 311 | (const :tag "None" nil)) |
| 312 | :parameter-document |
| 313 | "If non-nil, specify how to remove `banners' from articles. |
| 314 | |
| 315 | Symbol `signature' means to remove signatures delimited by |
| 316 | `gnus-signature-separator'. Any other symbol is used to look up a |
| 317 | regular expression to match the banner in `gnus-article-banner-alist'. |
| 318 | A string is used as a regular expression to match the banner |
| 319 | directly.") |
| 320 | |
| 321 | (defcustom gnus-article-address-banner-alist nil |
| 322 | "Alist of mail addresses and banners. |
| 323 | Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp |
| 324 | to match a mail address in the From: header, BANNER is one of a symbol |
| 325 | `signature', an item in `gnus-article-banner-alist', a regexp and nil. |
| 326 | If ADDRESS matches author's mail address, it will remove things like |
| 327 | advertisements. For example: |
| 328 | |
| 329 | \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\")) |
| 330 | " |
| 331 | :type '(repeat |
| 332 | (cons |
| 333 | (regexp :tag "Address") |
| 334 | (choice :tag "Banner" :value nil |
| 335 | (const :tag "Remove signature" signature) |
| 336 | (symbol :tag "Item in `gnus-article-banner-alist'" none) |
| 337 | regexp |
| 338 | (const :tag "None" nil)))) |
| 339 | :version "22.1" |
| 340 | :group 'gnus-article-washing) |
| 341 | |
| 342 | (defmacro gnus-emphasis-custom-with-format (&rest body) |
| 343 | `(let ((format "\ |
| 344 | \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\ |
| 345 | \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")) |
| 346 | ,@body)) |
| 347 | |
| 348 | (defun gnus-emphasis-custom-value-to-external (value) |
| 349 | (gnus-emphasis-custom-with-format |
| 350 | (if (consp (car value)) |
| 351 | (list (format format (car (car value)) (cdr (car value))) |
| 352 | 2 |
| 353 | (if (nth 1 value) 2 3) |
| 354 | (nth 2 value)) |
| 355 | value))) |
| 356 | |
| 357 | (defun gnus-emphasis-custom-value-to-internal (value) |
| 358 | (gnus-emphasis-custom-with-format |
| 359 | (let ((regexp (concat "\\`" |
| 360 | (format (regexp-quote format) |
| 361 | "\\([^()]+\\)" "\\([^()]+\\)") |
| 362 | "\\'")) |
| 363 | pattern) |
| 364 | (if (string-match regexp (setq pattern (car value))) |
| 365 | (list (cons (match-string 1 pattern) (match-string 2 pattern)) |
| 366 | (= (nth 2 value) 2) |
| 367 | (nth 3 value)) |
| 368 | value)))) |
| 369 | |
| 370 | (defcustom gnus-emphasis-alist |
| 371 | (let ((types |
| 372 | '(("\\*" "\\*" bold nil 2) |
| 373 | ("_" "_" underline) |
| 374 | ("/" "/" italic) |
| 375 | ("_/" "/_" underline-italic) |
| 376 | ("_\\*" "\\*_" underline-bold) |
| 377 | ("\\*/" "/\\*" bold-italic) |
| 378 | ("_\\*/" "/\\*_" underline-bold-italic)))) |
| 379 | (nconc |
| 380 | (gnus-emphasis-custom-with-format |
| 381 | (mapcar (lambda (spec) |
| 382 | (list (format format (car spec) (cadr spec)) |
| 383 | (or (nth 3 spec) 2) |
| 384 | (or (nth 4 spec) 3) |
| 385 | (intern (format "gnus-emphasis-%s" (nth 2 spec))))) |
| 386 | types)) |
| 387 | '(;; I've never seen anyone use this strikethru convention whereas I've |
| 388 | ;; several times seen it triggered by normal text. --Stef |
| 389 | ;; Miles suggests that this form is sometimes used but for italics, |
| 390 | ;; so maybe we should map it to `italic'. |
| 391 | ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)" |
| 392 | ;; 2 3 gnus-emphasis-strikethru) |
| 393 | ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)" |
| 394 | 2 3 gnus-emphasis-underline)))) |
| 395 | "*Alist that says how to fontify certain phrases. |
| 396 | Each item looks like this: |
| 397 | |
| 398 | (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline) |
| 399 | |
| 400 | The first element is a regular expression to be matched. The second |
| 401 | is a number that says what regular expression grouping used to find |
| 402 | the entire emphasized word. The third is a number that says what |
| 403 | regexp grouping should be displayed and highlighted. The fourth |
| 404 | is the face used for highlighting." |
| 405 | :type |
| 406 | '(repeat |
| 407 | (menu-choice |
| 408 | :format "%[Customizing Style%]\n%v" |
| 409 | :indent 2 |
| 410 | (group :tag "Default" |
| 411 | :value ("" 0 0 default) |
| 412 | :value-create |
| 413 | (lambda (widget) |
| 414 | (let ((value (widget-get |
| 415 | (cadr (widget-get (widget-get widget :parent) |
| 416 | :args)) |
| 417 | :value))) |
| 418 | (if (not (eq (nth 2 value) 'default)) |
| 419 | (widget-put |
| 420 | widget |
| 421 | :value |
| 422 | (gnus-emphasis-custom-value-to-external value)))) |
| 423 | (widget-group-value-create widget)) |
| 424 | regexp |
| 425 | (integer :format "Match group: %v") |
| 426 | (integer :format "Emphasize group: %v") |
| 427 | face) |
| 428 | (group :tag "Simple" |
| 429 | :value (("_" . "_") nil default) |
| 430 | (cons :format "%v" |
| 431 | (regexp :format "Start regexp: %v") |
| 432 | (regexp :format "End regexp: %v")) |
| 433 | (boolean :format "Show start and end patterns: %[%v%]\n" |
| 434 | :on " On " :off " Off ") |
| 435 | face))) |
| 436 | :get (lambda (symbol) |
| 437 | (mapcar 'gnus-emphasis-custom-value-to-internal |
| 438 | (default-value symbol))) |
| 439 | :set (lambda (symbol value) |
| 440 | (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external |
| 441 | value))) |
| 442 | :group 'gnus-article-emphasis) |
| 443 | |
| 444 | (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n" |
| 445 | "A regexp to describe whitespace which should not be emphasized. |
| 446 | Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\". |
| 447 | The former avoids underlining of leading and trailing whitespace, |
| 448 | and the latter avoids underlining any whitespace at all." |
| 449 | :version "21.1" |
| 450 | :group 'gnus-article-emphasis |
| 451 | :type 'regexp) |
| 452 | |
| 453 | (defface gnus-emphasis-bold '((t (:bold t))) |
| 454 | "Face used for displaying strong emphasized text (*word*)." |
| 455 | :group 'gnus-article-emphasis) |
| 456 | |
| 457 | (defface gnus-emphasis-italic '((t (:italic t))) |
| 458 | "Face used for displaying italic emphasized text (/word/)." |
| 459 | :group 'gnus-article-emphasis) |
| 460 | |
| 461 | (defface gnus-emphasis-underline '((t (:underline t))) |
| 462 | "Face used for displaying underlined emphasized text (_word_)." |
| 463 | :group 'gnus-article-emphasis) |
| 464 | |
| 465 | (defface gnus-emphasis-underline-bold '((t (:bold t :underline t))) |
| 466 | "Face used for displaying underlined bold emphasized text (_*word*_)." |
| 467 | :group 'gnus-article-emphasis) |
| 468 | |
| 469 | (defface gnus-emphasis-underline-italic '((t (:italic t :underline t))) |
| 470 | "Face used for displaying underlined italic emphasized text (_/word/_)." |
| 471 | :group 'gnus-article-emphasis) |
| 472 | |
| 473 | (defface gnus-emphasis-bold-italic '((t (:bold t :italic t))) |
| 474 | "Face used for displaying bold italic emphasized text (/*word*/)." |
| 475 | :group 'gnus-article-emphasis) |
| 476 | |
| 477 | (defface gnus-emphasis-underline-bold-italic |
| 478 | '((t (:bold t :italic t :underline t))) |
| 479 | "Face used for displaying underlined bold italic emphasized text. |
| 480 | Example: (_/*word*/_)." |
| 481 | :group 'gnus-article-emphasis) |
| 482 | |
| 483 | (defface gnus-emphasis-strikethru (if (featurep 'xemacs) |
| 484 | '((t (:strikethru t))) |
| 485 | '((t (:strike-through t)))) |
| 486 | "Face used for displaying strike-through text (-word-)." |
| 487 | :group 'gnus-article-emphasis) |
| 488 | |
| 489 | (defface gnus-emphasis-highlight-words |
| 490 | '((t (:background "black" :foreground "yellow"))) |
| 491 | "Face used for displaying highlighted words." |
| 492 | :group 'gnus-article-emphasis) |
| 493 | |
| 494 | (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z" |
| 495 | "Format for display of Date headers in article bodies. |
| 496 | See `format-time-string' for the possible values. |
| 497 | |
| 498 | The variable can also be function, which should return a complete Date |
| 499 | header. The function is called with one argument, the time, which can |
| 500 | be fed to `format-time-string'." |
| 501 | :type '(choice string function) |
| 502 | :link '(custom-manual "(gnus)Article Date") |
| 503 | :group 'gnus-article-washing) |
| 504 | |
| 505 | (defcustom gnus-save-all-headers t |
| 506 | "*If non-nil, don't remove any headers before saving. |
| 507 | This will be overridden by the `:headers' property that the symbol of |
| 508 | the saver function, which is specified by `gnus-default-article-saver', |
| 509 | might have." |
| 510 | :group 'gnus-article-saving |
| 511 | :type 'boolean) |
| 512 | |
| 513 | (defcustom gnus-prompt-before-saving 'always |
| 514 | "*This variable says how much prompting is to be done when saving articles. |
| 515 | If it is nil, no prompting will be done, and the articles will be |
| 516 | saved to the default files. If this variable is `always', each and |
| 517 | every article that is saved will be preceded by a prompt, even when |
| 518 | saving large batches of articles. If this variable is neither nil not |
| 519 | `always', there the user will be prompted once for a file name for |
| 520 | each invocation of the saving commands." |
| 521 | :group 'gnus-article-saving |
| 522 | :type '(choice (item always) |
| 523 | (item :tag "never" nil) |
| 524 | (sexp :tag "once" :format "%t\n" :value t))) |
| 525 | |
| 526 | (defcustom gnus-saved-headers gnus-visible-headers |
| 527 | "Headers to keep if `gnus-save-all-headers' is nil. |
| 528 | If `gnus-save-all-headers' is non-nil, this variable will be ignored. |
| 529 | If that variable is nil, however, all headers that match this regexp |
| 530 | will be kept while the rest will be deleted before saving. This and |
| 531 | `gnus-save-all-headers' will be overridden by the `:headers' property |
| 532 | that the symbol of the saver function, which is specified by |
| 533 | `gnus-default-article-saver', might have." |
| 534 | :group 'gnus-article-saving |
| 535 | :type 'regexp) |
| 536 | |
| 537 | ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before. |
| 538 | (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail |
| 539 | "A function to save articles in your favourite format. |
| 540 | The function will be called by way of the `gnus-summary-save-article' |
| 541 | command, and friends such as `gnus-summary-save-article-rmail'. |
| 542 | |
| 543 | Gnus provides the following functions: |
| 544 | |
| 545 | * gnus-summary-save-in-rmail (Rmail format) |
| 546 | * gnus-summary-save-in-mail (Unix mail format) |
| 547 | * gnus-summary-save-in-folder (MH folder) |
| 548 | * gnus-summary-save-in-file (article format) |
| 549 | * gnus-summary-save-body-in-file (article body) |
| 550 | * gnus-summary-save-in-vm (use VM's folder format) |
| 551 | * gnus-summary-write-to-file (article format -- overwrite) |
| 552 | * gnus-summary-write-body-to-file (article body -- overwrite) |
| 553 | * gnus-summary-save-in-pipe (article format) |
| 554 | |
| 555 | The symbol of each function may have the following properties: |
| 556 | |
| 557 | * :decode |
| 558 | The value non-nil means save decoded articles. This is meaningful |
| 559 | only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file', |
| 560 | `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and |
| 561 | `gnus-summary-save-in-pipe'. |
| 562 | |
| 563 | * :function |
| 564 | The value specifies an alternative function which appends, not |
| 565 | overwrites, articles to a file. This implies that when saving many |
| 566 | articles at a time, `gnus-prompt-before-saving' is bound to t and all |
| 567 | articles are saved in a single file. This is meaningful only with |
| 568 | `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'. |
| 569 | |
| 570 | * :headers |
| 571 | The value specifies the symbol of a variable of which the value |
| 572 | specifies headers to be saved. If it is omitted, |
| 573 | `gnus-save-all-headers' and `gnus-saved-headers' control what |
| 574 | headers should be saved." |
| 575 | :group 'gnus-article-saving |
| 576 | :type '(radio (function-item gnus-summary-save-in-rmail) |
| 577 | (function-item gnus-summary-save-in-mail) |
| 578 | (function-item gnus-summary-save-in-folder) |
| 579 | (function-item gnus-summary-save-in-file) |
| 580 | (function-item gnus-summary-save-body-in-file) |
| 581 | (function-item gnus-summary-save-in-vm) |
| 582 | (function-item gnus-summary-write-to-file) |
| 583 | (function-item gnus-summary-write-body-to-file) |
| 584 | (function-item gnus-summary-save-in-pipe) |
| 585 | (function))) |
| 586 | |
| 587 | (defcustom gnus-article-save-coding-system |
| 588 | (or (and (mm-coding-system-p 'utf-8) 'utf-8) |
| 589 | (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit) |
| 590 | (and (mm-coding-system-p 'emacs-mule) 'emacs-mule) |
| 591 | (and (mm-coding-system-p 'escape-quoted) 'escape-quoted)) |
| 592 | "Coding system used to save decoded articles to a file. |
| 593 | |
| 594 | The recommended coding systems are `utf-8', `iso-2022-7bit' and so on, |
| 595 | which can safely encode any characters in text. This is used by the |
| 596 | commands including: |
| 597 | |
| 598 | * gnus-summary-save-article-file |
| 599 | * gnus-summary-save-article-body-file |
| 600 | * gnus-summary-write-article-file |
| 601 | * gnus-summary-write-article-body-file |
| 602 | |
| 603 | and the functions to which you may set `gnus-default-article-saver': |
| 604 | |
| 605 | * gnus-summary-save-in-file |
| 606 | * gnus-summary-save-body-in-file |
| 607 | * gnus-summary-write-to-file |
| 608 | * gnus-summary-write-body-to-file |
| 609 | |
| 610 | Those commands and functions save just text displayed in the article |
| 611 | buffer to a file if the value of this variable is non-nil. Note that |
| 612 | buttonized MIME parts will be lost in a saved file in that case. |
| 613 | Otherwise, raw articles will be saved." |
| 614 | :group 'gnus-article-saving |
| 615 | :type `(choice |
| 616 | :format "%{%t%}:\n %[Value Menu%] %v" |
| 617 | (const :tag "Save raw articles" nil) |
| 618 | ,@(delq nil |
| 619 | (mapcar |
| 620 | (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg)) |
| 621 | '((const :tag "UTF-8" utf-8) |
| 622 | (const :tag "iso-2022-7bit" iso-2022-7bit) |
| 623 | (const :tag "Emacs internal" emacs-mule) |
| 624 | (const :tag "escape-quoted" escape-quoted)))) |
| 625 | (symbol :tag "Coding system"))) |
| 626 | |
| 627 | (defcustom gnus-rmail-save-name 'gnus-plain-save-name |
| 628 | "A function generating a file name to save articles in Rmail format. |
| 629 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." |
| 630 | :group 'gnus-article-saving |
| 631 | :type 'function) |
| 632 | |
| 633 | (defcustom gnus-mail-save-name 'gnus-plain-save-name |
| 634 | "A function generating a file name to save articles in Unix mail format. |
| 635 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." |
| 636 | :group 'gnus-article-saving |
| 637 | :type 'function) |
| 638 | |
| 639 | (defcustom gnus-folder-save-name 'gnus-folder-save-name |
| 640 | "A function generating a file name to save articles in MH folder. |
| 641 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER." |
| 642 | :group 'gnus-article-saving |
| 643 | :type 'function) |
| 644 | |
| 645 | (defcustom gnus-file-save-name 'gnus-numeric-save-name |
| 646 | "A function generating a file name to save articles in article format. |
| 647 | The function is called with NEWSGROUP, HEADERS, and optional |
| 648 | LAST-FILE." |
| 649 | :group 'gnus-article-saving |
| 650 | :type 'function) |
| 651 | |
| 652 | (defcustom gnus-split-methods |
| 653 | '((gnus-article-archive-name) |
| 654 | (gnus-article-nndoc-name)) |
| 655 | "*Variable used to suggest where articles are to be saved. |
| 656 | For instance, if you would like to save articles related to Gnus in |
| 657 | the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", |
| 658 | you could set this variable to something like: |
| 659 | |
| 660 | '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") |
| 661 | (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) |
| 662 | |
| 663 | This variable is an alist where the key is the match and the |
| 664 | value is a list of possible files to save in if the match is |
| 665 | non-nil. |
| 666 | |
| 667 | If the match is a string, it is used as a regexp match on the |
| 668 | article. If the match is a symbol, that symbol will be funcalled |
| 669 | from the buffer of the article to be saved with the newsgroup as the |
| 670 | parameter. If it is a list, it will be evaled in the same buffer. |
| 671 | |
| 672 | If this form or function returns a string, this string will be used as a |
| 673 | possible file name; and if it returns a non-nil list, that list will be |
| 674 | used as possible file names." |
| 675 | :group 'gnus-article-saving |
| 676 | :type '(repeat (choice (list :value (fun) function) |
| 677 | (cons :value ("" "") regexp (repeat string)) |
| 678 | (sexp :value nil)))) |
| 679 | |
| 680 | (defcustom gnus-page-delimiter "^\^L" |
| 681 | "*Regexp describing what to use as article page delimiters. |
| 682 | The default value is \"^\^L\", which is a form linefeed at the |
| 683 | beginning of a line." |
| 684 | :type 'regexp |
| 685 | :group 'gnus-article-various) |
| 686 | |
| 687 | (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m" |
| 688 | "*The format specification for the article mode line. |
| 689 | See `gnus-summary-mode-line-format' for a closer description. |
| 690 | |
| 691 | The following additional specs are available: |
| 692 | |
| 693 | %w The article washing status. |
| 694 | %m The number of MIME parts in the article." |
| 695 | :type 'string |
| 696 | :group 'gnus-article-various) |
| 697 | |
| 698 | (defcustom gnus-article-mode-hook nil |
| 699 | "*A hook for Gnus article mode." |
| 700 | :type 'hook |
| 701 | :group 'gnus-article-various) |
| 702 | |
| 703 | (when (featurep 'xemacs) |
| 704 | ;; Extracted from gnus-xmas-define in order to preserve user settings |
| 705 | (when (fboundp 'turn-off-scroll-in-place) |
| 706 | (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place)) |
| 707 | ;; Extracted from gnus-xmas-redefine in order to preserve user settings |
| 708 | (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)) |
| 709 | |
| 710 | (defcustom gnus-article-menu-hook nil |
| 711 | "*Hook run after the creation of the article mode menu." |
| 712 | :type 'hook |
| 713 | :group 'gnus-article-various) |
| 714 | |
| 715 | (defcustom gnus-article-prepare-hook nil |
| 716 | "*A hook called after an article has been prepared in the article buffer." |
| 717 | :type 'hook |
| 718 | :group 'gnus-article-various) |
| 719 | |
| 720 | (defcustom gnus-copy-article-ignored-headers nil |
| 721 | "List of headers to be removed when copying an article. |
| 722 | Each element is a regular expression." |
| 723 | :version "23.1" ;; No Gnus |
| 724 | :type '(repeat regexp) |
| 725 | :group 'gnus-article-various) |
| 726 | |
| 727 | (make-obsolete-variable 'gnus-article-hide-pgp-hook nil |
| 728 | "Gnus 5.10 (Emacs-22.1)") |
| 729 | |
| 730 | (defface gnus-button |
| 731 | '((t (:weight bold))) |
| 732 | "Face used for highlighting a button in the article buffer." |
| 733 | :group 'gnus-article-buttons) |
| 734 | |
| 735 | (defcustom gnus-article-button-face 'gnus-button |
| 736 | "Face used for highlighting buttons in the article buffer. |
| 737 | |
| 738 | An article button is a piece of text that you can activate by pressing |
| 739 | `RET' or `mouse-2' above it." |
| 740 | :type 'face |
| 741 | :group 'gnus-article-buttons) |
| 742 | |
| 743 | (defcustom gnus-article-mouse-face 'highlight |
| 744 | "Face used for mouse highlighting in the article buffer. |
| 745 | |
| 746 | Article buttons will be displayed in this face when the cursor is |
| 747 | above them." |
| 748 | :type 'face |
| 749 | :group 'gnus-article-buttons) |
| 750 | |
| 751 | (defcustom gnus-signature-face 'gnus-signature |
| 752 | "Face used for highlighting a signature in the article buffer. |
| 753 | Obsolete; use the face `gnus-signature' for customizations instead." |
| 754 | :type 'face |
| 755 | :group 'gnus-article-highlight |
| 756 | :group 'gnus-article-signature) |
| 757 | |
| 758 | (defface gnus-signature |
| 759 | '((t |
| 760 | (:italic t))) |
| 761 | "Face used for highlighting a signature in the article buffer." |
| 762 | :group 'gnus-article-highlight |
| 763 | :group 'gnus-article-signature) |
| 764 | ;; backward-compatibility alias |
| 765 | (put 'gnus-signature-face 'face-alias 'gnus-signature) |
| 766 | (put 'gnus-signature-face 'obsolete-face "22.1") |
| 767 | |
| 768 | (defface gnus-header-from |
| 769 | '((((class color) |
| 770 | (background dark)) |
| 771 | (:foreground "PaleGreen1")) |
| 772 | (((class color) |
| 773 | (background light)) |
| 774 | (:foreground "red3")) |
| 775 | (t |
| 776 | (:italic t))) |
| 777 | "Face used for displaying from headers." |
| 778 | :group 'gnus-article-headers |
| 779 | :group 'gnus-article-highlight) |
| 780 | ;; backward-compatibility alias |
| 781 | (put 'gnus-header-from-face 'face-alias 'gnus-header-from) |
| 782 | (put 'gnus-header-from-face 'obsolete-face "22.1") |
| 783 | |
| 784 | (defface gnus-header-subject |
| 785 | '((((class color) |
| 786 | (background dark)) |
| 787 | (:foreground "SeaGreen1")) |
| 788 | (((class color) |
| 789 | (background light)) |
| 790 | (:foreground "red4")) |
| 791 | (t |
| 792 | (:bold t :italic t))) |
| 793 | "Face used for displaying subject headers." |
| 794 | :group 'gnus-article-headers |
| 795 | :group 'gnus-article-highlight) |
| 796 | ;; backward-compatibility alias |
| 797 | (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject) |
| 798 | (put 'gnus-header-subject-face 'obsolete-face "22.1") |
| 799 | |
| 800 | (defface gnus-header-newsgroups |
| 801 | '((((class color) |
| 802 | (background dark)) |
| 803 | (:foreground "yellow" :italic t)) |
| 804 | (((class color) |
| 805 | (background light)) |
| 806 | (:foreground "MidnightBlue" :italic t)) |
| 807 | (t |
| 808 | (:italic t))) |
| 809 | "Face used for displaying newsgroups headers. |
| 810 | In the default setup this face is only used for crossposted |
| 811 | articles." |
| 812 | :group 'gnus-article-headers |
| 813 | :group 'gnus-article-highlight) |
| 814 | ;; backward-compatibility alias |
| 815 | (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups) |
| 816 | (put 'gnus-header-newsgroups-face 'obsolete-face "22.1") |
| 817 | |
| 818 | (defface gnus-header-name |
| 819 | '((((class color) |
| 820 | (background dark)) |
| 821 | (:foreground "SpringGreen2")) |
| 822 | (((class color) |
| 823 | (background light)) |
| 824 | (:foreground "maroon")) |
| 825 | (t |
| 826 | (:bold t))) |
| 827 | "Face used for displaying header names." |
| 828 | :group 'gnus-article-headers |
| 829 | :group 'gnus-article-highlight) |
| 830 | ;; backward-compatibility alias |
| 831 | (put 'gnus-header-name-face 'face-alias 'gnus-header-name) |
| 832 | (put 'gnus-header-name-face 'obsolete-face "22.1") |
| 833 | |
| 834 | (defface gnus-header-content |
| 835 | '((((class color) |
| 836 | (background dark)) |
| 837 | (:foreground "SpringGreen1" :italic t)) |
| 838 | (((class color) |
| 839 | (background light)) |
| 840 | (:foreground "indianred4" :italic t)) |
| 841 | (t |
| 842 | (:italic t))) "Face used for displaying header content." |
| 843 | :group 'gnus-article-headers |
| 844 | :group 'gnus-article-highlight) |
| 845 | ;; backward-compatibility alias |
| 846 | (put 'gnus-header-content-face 'face-alias 'gnus-header-content) |
| 847 | (put 'gnus-header-content-face 'obsolete-face "22.1") |
| 848 | |
| 849 | (defcustom gnus-header-face-alist |
| 850 | '(("From" nil gnus-header-from) |
| 851 | ("Subject" nil gnus-header-subject) |
| 852 | ("Newsgroups:.*," nil gnus-header-newsgroups) |
| 853 | ("" gnus-header-name gnus-header-content)) |
| 854 | "*Controls highlighting of article headers. |
| 855 | |
| 856 | An alist of the form (HEADER NAME CONTENT). |
| 857 | |
| 858 | HEADER is a regular expression which should match the name of a |
| 859 | header and NAME and CONTENT are either face names or nil. |
| 860 | |
| 861 | The name of each header field will be displayed using the face |
| 862 | specified by the first element in the list where HEADER matches |
| 863 | the header name and NAME is non-nil. Similarly, the content will |
| 864 | be displayed by the first non-nil matching CONTENT face." |
| 865 | :group 'gnus-article-headers |
| 866 | :group 'gnus-article-highlight |
| 867 | :type '(repeat (list (regexp :tag "Header") |
| 868 | (choice :tag "Name" |
| 869 | (item :tag "skip" nil) |
| 870 | (face :value default)) |
| 871 | (choice :tag "Content" |
| 872 | (item :tag "skip" nil) |
| 873 | (face :value default))))) |
| 874 | |
| 875 | (defcustom gnus-face-properties-alist (if (featurep 'xemacs) |
| 876 | '((xface . (:face gnus-x-face))) |
| 877 | '((pbm . (:face gnus-x-face)) |
| 878 | (png . nil))) |
| 879 | "Alist of image types and properties applied to Face and X-Face images. |
| 880 | Here are examples: |
| 881 | |
| 882 | ;; Specify the altitude of Face images in the From header. |
| 883 | \(setq gnus-face-properties-alist |
| 884 | '((pbm . (:face gnus-x-face :ascent 80)) |
| 885 | (png . (:ascent 80)))) |
| 886 | |
| 887 | ;; Show Face images as pressed buttons. |
| 888 | \(setq gnus-face-properties-alist |
| 889 | '((pbm . (:face gnus-x-face :relief -2)) |
| 890 | (png . (:relief -2)))) |
| 891 | |
| 892 | See the manual for the valid properties for various image types. |
| 893 | Currently, `pbm' is used for X-Face images and `png' is used for Face |
| 894 | images in Emacs. Only the `:face' property is effective on the `xface' |
| 895 | image type in XEmacs if it is built with the libcompface library." |
| 896 | :version "23.1" ;; No Gnus |
| 897 | :group 'gnus-article-headers |
| 898 | :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist))) |
| 899 | |
| 900 | (defcustom gnus-article-decode-hook |
| 901 | '(article-decode-charset article-decode-encoded-words |
| 902 | article-decode-group-name article-decode-idna-rhs) |
| 903 | "*Hook run to decode charsets in articles." |
| 904 | :group 'gnus-article-headers |
| 905 | :type 'hook) |
| 906 | |
| 907 | (defcustom gnus-display-mime-function 'gnus-display-mime |
| 908 | "Function to display MIME articles." |
| 909 | :group 'gnus-article-mime |
| 910 | :type 'function) |
| 911 | |
| 912 | (defvar gnus-decode-header-function 'mail-decode-encoded-word-region |
| 913 | "Function used to decode headers.") |
| 914 | |
| 915 | (defvar gnus-decode-address-function 'mail-decode-encoded-address-region |
| 916 | "Function used to decode addresses.") |
| 917 | |
| 918 | (defvar gnus-article-dumbquotes-map |
| 919 | '(("\200" "EUR") |
| 920 | ("\202" ",") |
| 921 | ("\203" "f") |
| 922 | ("\204" ",,") |
| 923 | ("\205" "...") |
| 924 | ("\213" "<") |
| 925 | ("\214" "OE") |
| 926 | ("\221" "`") |
| 927 | ("\222" "'") |
| 928 | ("\223" "``") |
| 929 | ("\224" "\"") |
| 930 | ("\225" "*") |
| 931 | ("\226" "-") |
| 932 | ("\227" "--") |
| 933 | ("\230" "~") |
| 934 | ("\231" "(TM)") |
| 935 | ("\233" ">") |
| 936 | ("\234" "oe") |
| 937 | ("\264" "'")) |
| 938 | "Table for MS-to-Latin1 translation.") |
| 939 | |
| 940 | (defcustom gnus-ignored-mime-types nil |
| 941 | "List of MIME types that should be ignored by Gnus." |
| 942 | :version "21.1" |
| 943 | :group 'gnus-article-mime |
| 944 | :type '(repeat regexp)) |
| 945 | |
| 946 | (defcustom gnus-unbuttonized-mime-types '(".*/.*") |
| 947 | "List of MIME types that should not be given buttons when rendered inline. |
| 948 | See also `gnus-buttonized-mime-types' which may override this variable. |
| 949 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." |
| 950 | :version "21.1" |
| 951 | :group 'gnus-article-mime |
| 952 | :type '(repeat regexp)) |
| 953 | |
| 954 | (defcustom gnus-buttonized-mime-types nil |
| 955 | "List of MIME types that should be given buttons when rendered inline. |
| 956 | If set, this variable overrides `gnus-unbuttonized-mime-types'. |
| 957 | To see e.g. security buttons you could set this to |
| 958 | `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to |
| 959 | this list to display radio buttons that allow you to choose one of two |
| 960 | media types those mails include. See also `mm-discouraged-alternatives'. |
| 961 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." |
| 962 | :version "22.1" |
| 963 | :group 'gnus-article-mime |
| 964 | :type '(repeat regexp)) |
| 965 | |
| 966 | (defcustom gnus-inhibit-mime-unbuttonizing nil |
| 967 | "If non-nil, all MIME parts get buttons. |
| 968 | When nil (the default value), then some MIME parts do not get buttons, |
| 969 | as described by the variables `gnus-buttonized-mime-types' and |
| 970 | `gnus-unbuttonized-mime-types'." |
| 971 | :version "22.1" |
| 972 | :group 'gnus-article-mime |
| 973 | :type 'boolean) |
| 974 | |
| 975 | (defcustom gnus-body-boundary-delimiter "_" |
| 976 | "String used to delimit header and body. |
| 977 | This variable is used by `gnus-article-treat-body-boundary' which can |
| 978 | be controlled by `gnus-treat-body-boundary'." |
| 979 | :version "22.1" |
| 980 | :group 'gnus-article-various |
| 981 | :type '(choice (item :tag "None" :value nil) |
| 982 | string)) |
| 983 | |
| 984 | (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces" |
| 985 | "/usr/share/picons") |
| 986 | "Defines the location of the faces database. |
| 987 | For information on obtaining this database of pretty pictures, please |
| 988 | see http://www.cs.indiana.edu/picons/ftp/index.html" |
| 989 | :version "22.1" |
| 990 | :type '(repeat directory) |
| 991 | :link '(url-link :tag "download" |
| 992 | "http://www.cs.indiana.edu/picons/ftp/index.html") |
| 993 | :link '(custom-manual "(gnus)Picons") |
| 994 | :group 'gnus-picon) |
| 995 | |
| 996 | (defun gnus-picons-installed-p () |
| 997 | "Say whether picons are installed on your machine." |
| 998 | (let ((installed nil)) |
| 999 | (dolist (database gnus-picon-databases) |
| 1000 | (when (file-exists-p database) |
| 1001 | (setq installed t))) |
| 1002 | installed)) |
| 1003 | |
| 1004 | (defcustom gnus-article-mime-part-function nil |
| 1005 | "Function called with a MIME handle as the argument. |
| 1006 | This is meant for people who want to do something automatic based |
| 1007 | on parts -- for instance, adding Vcard info to a database." |
| 1008 | :group 'gnus-article-mime |
| 1009 | :type '(choice (const nil) |
| 1010 | function)) |
| 1011 | |
| 1012 | (defcustom gnus-mime-multipart-functions nil |
| 1013 | "An alist of MIME types to functions to display them." |
| 1014 | :version "21.1" |
| 1015 | :group 'gnus-article-mime |
| 1016 | :type '(repeat (cons :format "%v" (string :tag "MIME type") function))) |
| 1017 | |
| 1018 | (defcustom gnus-article-date-lapsed-new-header nil |
| 1019 | "Whether the X-Sent and Date headers can coexist. |
| 1020 | When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will |
| 1021 | either replace the old \"Date:\" header (if this variable is nil), or |
| 1022 | be added below it (otherwise)." |
| 1023 | :version "21.1" |
| 1024 | :group 'gnus-article-headers |
| 1025 | :type 'boolean) |
| 1026 | |
| 1027 | (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative |
| 1028 | "Function called with a MIME handle as the argument. |
| 1029 | This is meant for people who want to view first matched part. |
| 1030 | For `undisplayed-alternative' (default), the first undisplayed |
| 1031 | part or alternative part is used. For `undisplayed', the first |
| 1032 | undisplayed part is used. For a function, the first part which |
| 1033 | the function return t is used. For nil, the first part is |
| 1034 | used." |
| 1035 | :version "21.1" |
| 1036 | :group 'gnus-article-mime |
| 1037 | :type '(choice |
| 1038 | (item :tag "first" :value nil) |
| 1039 | (item :tag "undisplayed" :value undisplayed) |
| 1040 | (item :tag "undisplayed or alternative" |
| 1041 | :value undisplayed-alternative) |
| 1042 | (function))) |
| 1043 | |
| 1044 | (defcustom gnus-mime-action-alist |
| 1045 | '(("save to file" . gnus-mime-save-part) |
| 1046 | ("save and strip" . gnus-mime-save-part-and-strip) |
| 1047 | ("replace with file" . gnus-mime-replace-part) |
| 1048 | ("delete part" . gnus-mime-delete-part) |
| 1049 | ("display as text" . gnus-mime-inline-part) |
| 1050 | ("view the part" . gnus-mime-view-part) |
| 1051 | ("pipe to command" . gnus-mime-pipe-part) |
| 1052 | ("toggle display" . gnus-article-press-button) |
| 1053 | ("toggle display" . gnus-article-view-part-as-charset) |
| 1054 | ("view as type" . gnus-mime-view-part-as-type) |
| 1055 | ("view internally" . gnus-mime-view-part-internally) |
| 1056 | ("view externally" . gnus-mime-view-part-externally)) |
| 1057 | "An alist of actions that run on the MIME attachment." |
| 1058 | :group 'gnus-article-mime |
| 1059 | :type '(repeat (cons (string :tag "name") |
| 1060 | (function)))) |
| 1061 | |
| 1062 | (defcustom gnus-auto-select-part 1 |
| 1063 | "Advance to next MIME part when deleting or stripping parts. |
| 1064 | |
| 1065 | When 0, point will be placed on the same part as before. When |
| 1066 | positive (negative), move point forward (backwards) this many |
| 1067 | parts. When nil, redisplay article." |
| 1068 | :version "23.1" ;; No Gnus |
| 1069 | :group 'gnus-article-mime |
| 1070 | :type '(choice (const nil :tag "Redisplay article.") |
| 1071 | (const 1 :tag "Next part.") |
| 1072 | (const 0 :tag "Current part.") |
| 1073 | integer)) |
| 1074 | |
| 1075 | ;;; |
| 1076 | ;;; The treatment variables |
| 1077 | ;;; |
| 1078 | |
| 1079 | (defvar gnus-part-display-hook nil |
| 1080 | "Hook called on parts that are to receive treatment.") |
| 1081 | |
| 1082 | (defvar gnus-article-treat-custom |
| 1083 | '(choice (const :tag "Off" nil) |
| 1084 | (const :tag "On" t) |
| 1085 | (const :tag "Header" head) |
| 1086 | (const :tag "First" first) |
| 1087 | (const :tag "Last" last) |
| 1088 | (integer :tag "Less") |
| 1089 | (repeat :tag "Groups" regexp) |
| 1090 | (sexp :tag "Predicate"))) |
| 1091 | |
| 1092 | (defvar gnus-article-treat-head-custom |
| 1093 | '(choice (const :tag "Off" nil) |
| 1094 | (const :tag "Header" head))) |
| 1095 | |
| 1096 | (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim" |
| 1097 | "text/x-patch") |
| 1098 | "Parts to treat.") |
| 1099 | |
| 1100 | (defvar gnus-inhibit-treatment nil |
| 1101 | "Whether to inhibit treatment.") |
| 1102 | |
| 1103 | (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard")) |
| 1104 | "Highlight the signature. |
| 1105 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1106 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1107 | :group 'gnus-article-treat |
| 1108 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1109 | :type gnus-article-treat-custom) |
| 1110 | (put 'gnus-treat-highlight-signature 'highlight t) |
| 1111 | |
| 1112 | (defcustom gnus-treat-buttonize 100000 |
| 1113 | "Add buttons. |
| 1114 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1115 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1116 | :group 'gnus-article-treat |
| 1117 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1118 | :type gnus-article-treat-custom) |
| 1119 | (put 'gnus-treat-buttonize 'highlight t) |
| 1120 | |
| 1121 | (defcustom gnus-treat-buttonize-head 'head |
| 1122 | "Add buttons to the head. |
| 1123 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1124 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1125 | :group 'gnus-article-treat |
| 1126 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1127 | :type gnus-article-treat-head-custom) |
| 1128 | (put 'gnus-treat-buttonize-head 'highlight t) |
| 1129 | |
| 1130 | (defcustom gnus-treat-emphasize 50000 |
| 1131 | "Emphasize text. |
| 1132 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1133 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1134 | :group 'gnus-article-treat |
| 1135 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1136 | :type gnus-article-treat-custom) |
| 1137 | (put 'gnus-treat-emphasize 'highlight t) |
| 1138 | |
| 1139 | (defcustom gnus-treat-strip-cr nil |
| 1140 | "Remove carriage returns. |
| 1141 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1142 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1143 | :version "22.1" |
| 1144 | :group 'gnus-article-treat |
| 1145 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1146 | :type gnus-article-treat-custom) |
| 1147 | |
| 1148 | (defcustom gnus-treat-unsplit-urls nil |
| 1149 | "Remove newlines from within URLs. |
| 1150 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1151 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1152 | :version "22.1" |
| 1153 | :group 'gnus-article-treat |
| 1154 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1155 | :type gnus-article-treat-custom) |
| 1156 | |
| 1157 | (defcustom gnus-treat-leading-whitespace nil |
| 1158 | "Remove leading whitespace in headers. |
| 1159 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1160 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1161 | :version "22.1" |
| 1162 | :group 'gnus-article-treat |
| 1163 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1164 | :type gnus-article-treat-custom) |
| 1165 | |
| 1166 | (defcustom gnus-treat-hide-headers 'head |
| 1167 | "Hide headers. |
| 1168 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1169 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1170 | :group 'gnus-article-treat |
| 1171 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1172 | :type gnus-article-treat-head-custom) |
| 1173 | |
| 1174 | (defcustom gnus-treat-hide-boring-headers nil |
| 1175 | "Hide boring headers. |
| 1176 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1177 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1178 | :group 'gnus-article-treat |
| 1179 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1180 | :type gnus-article-treat-head-custom) |
| 1181 | |
| 1182 | (defcustom gnus-treat-hide-signature nil |
| 1183 | "Hide the signature. |
| 1184 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1185 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1186 | :group 'gnus-article-treat |
| 1187 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1188 | :type gnus-article-treat-custom) |
| 1189 | |
| 1190 | (defcustom gnus-treat-fill-article nil |
| 1191 | "Fill the article. |
| 1192 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1193 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1194 | :group 'gnus-article-treat |
| 1195 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1196 | :type gnus-article-treat-custom) |
| 1197 | |
| 1198 | (defcustom gnus-treat-hide-citation nil |
| 1199 | "Hide cited text. |
| 1200 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1201 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1202 | :group 'gnus-article-treat |
| 1203 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1204 | :type gnus-article-treat-custom) |
| 1205 | |
| 1206 | (defcustom gnus-treat-hide-citation-maybe nil |
| 1207 | "Hide cited text. |
| 1208 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1209 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1210 | :group 'gnus-article-treat |
| 1211 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1212 | :type gnus-article-treat-custom) |
| 1213 | |
| 1214 | (defcustom gnus-treat-strip-list-identifiers 'head |
| 1215 | "Strip list identifiers from `gnus-list-identifiers`. |
| 1216 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1217 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1218 | :version "21.1" |
| 1219 | :group 'gnus-article-treat |
| 1220 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1221 | :type gnus-article-treat-custom) |
| 1222 | |
| 1223 | (make-obsolete-variable 'gnus-treat-strip-pgp nil |
| 1224 | "Gnus 5.10 (Emacs 22.1)") |
| 1225 | |
| 1226 | (defcustom gnus-treat-strip-pem nil |
| 1227 | "Strip PEM signatures. |
| 1228 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1229 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1230 | :group 'gnus-article-treat |
| 1231 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1232 | :type gnus-article-treat-custom) |
| 1233 | |
| 1234 | (defcustom gnus-treat-strip-banner t |
| 1235 | "Strip banners from articles. |
| 1236 | The banner to be stripped is specified in the `banner' group parameter. |
| 1237 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1238 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1239 | :group 'gnus-article-treat |
| 1240 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1241 | :type gnus-article-treat-custom) |
| 1242 | |
| 1243 | (defcustom gnus-treat-highlight-headers 'head |
| 1244 | "Highlight the headers. |
| 1245 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1246 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1247 | :group 'gnus-article-treat |
| 1248 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1249 | :type gnus-article-treat-head-custom) |
| 1250 | (put 'gnus-treat-highlight-headers 'highlight t) |
| 1251 | |
| 1252 | (defcustom gnus-treat-highlight-citation t |
| 1253 | "Highlight cited text. |
| 1254 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1255 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1256 | :group 'gnus-article-treat |
| 1257 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1258 | :type gnus-article-treat-custom) |
| 1259 | (put 'gnus-treat-highlight-citation 'highlight t) |
| 1260 | |
| 1261 | (defcustom gnus-treat-date-ut nil |
| 1262 | "Display the Date in UT (GMT). |
| 1263 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1264 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1265 | :group 'gnus-article-treat |
| 1266 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1267 | :type gnus-article-treat-head-custom) |
| 1268 | |
| 1269 | (defcustom gnus-treat-date-local nil |
| 1270 | "Display the Date in the local timezone. |
| 1271 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1272 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1273 | :group 'gnus-article-treat |
| 1274 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1275 | :type gnus-article-treat-head-custom) |
| 1276 | |
| 1277 | (defcustom gnus-treat-date-english nil |
| 1278 | "Display the Date in a format that can be read aloud in English. |
| 1279 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1280 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1281 | :version "22.1" |
| 1282 | :group 'gnus-article-treat |
| 1283 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1284 | :type gnus-article-treat-head-custom) |
| 1285 | |
| 1286 | (defcustom gnus-treat-date-lapsed nil |
| 1287 | "Display the Date header in a way that says how much time has elapsed. |
| 1288 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1289 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1290 | :group 'gnus-article-treat |
| 1291 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1292 | :type gnus-article-treat-head-custom) |
| 1293 | |
| 1294 | (defcustom gnus-treat-date-original nil |
| 1295 | "Display the date in the original timezone. |
| 1296 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1297 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1298 | :group 'gnus-article-treat |
| 1299 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1300 | :type gnus-article-treat-head-custom) |
| 1301 | |
| 1302 | (defcustom gnus-treat-date-iso8601 nil |
| 1303 | "Display the date in the ISO8601 format. |
| 1304 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1305 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1306 | :version "21.1" |
| 1307 | :group 'gnus-article-treat |
| 1308 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1309 | :type gnus-article-treat-head-custom) |
| 1310 | |
| 1311 | (defcustom gnus-treat-date-user-defined nil |
| 1312 | "Display the date in a user-defined format. |
| 1313 | The format is defined by the `gnus-article-time-format' variable. |
| 1314 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1315 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1316 | :group 'gnus-article-treat |
| 1317 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1318 | :type gnus-article-treat-head-custom) |
| 1319 | |
| 1320 | (defcustom gnus-treat-strip-headers-in-body t |
| 1321 | "Strip the X-No-Archive header line from the beginning of the body. |
| 1322 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1323 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1324 | :version "21.1" |
| 1325 | :group 'gnus-article-treat |
| 1326 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1327 | :type gnus-article-treat-custom) |
| 1328 | |
| 1329 | (defcustom gnus-treat-strip-trailing-blank-lines nil |
| 1330 | "Strip trailing blank lines. |
| 1331 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1332 | predicate. See Info node `(gnus)Customizing Articles'. |
| 1333 | |
| 1334 | When set to t, it also strips trailing blanks in all MIME parts. |
| 1335 | Consider to use `last' instead." |
| 1336 | :group 'gnus-article-treat |
| 1337 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1338 | :type gnus-article-treat-custom) |
| 1339 | |
| 1340 | (defcustom gnus-treat-strip-leading-blank-lines nil |
| 1341 | "Strip leading blank lines. |
| 1342 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1343 | predicate. See Info node `(gnus)Customizing Articles'. |
| 1344 | |
| 1345 | When set to t, it also strips trailing blanks in all MIME parts." |
| 1346 | :group 'gnus-article-treat |
| 1347 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1348 | :type gnus-article-treat-custom) |
| 1349 | |
| 1350 | (defcustom gnus-treat-strip-multiple-blank-lines nil |
| 1351 | "Strip multiple blank lines. |
| 1352 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1353 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1354 | :group 'gnus-article-treat |
| 1355 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1356 | :type gnus-article-treat-custom) |
| 1357 | |
| 1358 | (defcustom gnus-treat-unfold-headers 'head |
| 1359 | "Unfold folded header lines. |
| 1360 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1361 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1362 | :version "22.1" |
| 1363 | :group 'gnus-article-treat |
| 1364 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1365 | :type gnus-article-treat-custom) |
| 1366 | |
| 1367 | (defcustom gnus-article-unfold-long-headers nil |
| 1368 | "If non-nil, allow unfolding headers even if the header is long. |
| 1369 | If it is a regexp, only long headers matching this regexp are unfolded. |
| 1370 | If it is t, all long headers are unfolded. |
| 1371 | |
| 1372 | This variable has no effect if `gnus-treat-unfold-headers' is nil." |
| 1373 | :version "23.1" ;; No Gnus |
| 1374 | :group 'gnus-article-treat |
| 1375 | :type '(choice (const nil) |
| 1376 | (const :tag "all" t) |
| 1377 | (regexp))) |
| 1378 | |
| 1379 | (defcustom gnus-treat-fold-headers nil |
| 1380 | "Fold headers. |
| 1381 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1382 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1383 | :version "22.1" |
| 1384 | :group 'gnus-article-treat |
| 1385 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1386 | :type gnus-article-treat-custom) |
| 1387 | |
| 1388 | (defcustom gnus-treat-fold-newsgroups 'head |
| 1389 | "Fold the Newsgroups and Followup-To headers. |
| 1390 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1391 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1392 | :version "22.1" |
| 1393 | :group 'gnus-article-treat |
| 1394 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1395 | :type gnus-article-treat-custom) |
| 1396 | |
| 1397 | (defcustom gnus-treat-overstrike t |
| 1398 | "Treat overstrike highlighting. |
| 1399 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1400 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1401 | :group 'gnus-article-treat |
| 1402 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1403 | :type gnus-article-treat-custom) |
| 1404 | (put 'gnus-treat-overstrike 'highlight t) |
| 1405 | |
| 1406 | (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t) |
| 1407 | "Treat ANSI SGR control sequences. |
| 1408 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1409 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1410 | :group 'gnus-article-treat |
| 1411 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1412 | :type gnus-article-treat-custom) |
| 1413 | |
| 1414 | (make-obsolete-variable 'gnus-treat-display-xface |
| 1415 | 'gnus-treat-display-x-face "22.1") |
| 1416 | |
| 1417 | (defcustom gnus-treat-display-x-face |
| 1418 | (and (not noninteractive) |
| 1419 | (gnus-image-type-available-p 'xbm) |
| 1420 | (if (featurep 'xemacs) |
| 1421 | (featurep 'xface) |
| 1422 | (condition-case nil |
| 1423 | (and (string-match "^0x" (shell-command-to-string "uncompface")) |
| 1424 | (executable-find "icontopbm")) |
| 1425 | ;; shell-command-to-string may signal an error, e.g. if |
| 1426 | ;; shell-file-name is not found. |
| 1427 | (error nil))) |
| 1428 | 'head) |
| 1429 | "Display X-Face headers. |
| 1430 | Valid values are nil and `head'. |
| 1431 | See Info node `(gnus)Customizing Articles' and Info node |
| 1432 | `(gnus)X-Face' for details." |
| 1433 | :group 'gnus-article-treat |
| 1434 | :version "21.1" |
| 1435 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1436 | :link '(custom-manual "(gnus)X-Face") |
| 1437 | :type gnus-article-treat-head-custom |
| 1438 | :set (lambda (symbol value) |
| 1439 | (set-default |
| 1440 | symbol |
| 1441 | (cond ((or (boundp symbol) (get symbol 'saved-value)) |
| 1442 | value) |
| 1443 | ((boundp 'gnus-treat-display-xface) |
| 1444 | (message "\ |
| 1445 | ** gnus-treat-display-xface is an obsolete variable;\ |
| 1446 | use gnus-treat-display-x-face instead") |
| 1447 | (default-value 'gnus-treat-display-xface)) |
| 1448 | ((get 'gnus-treat-display-xface 'saved-value) |
| 1449 | (message "\ |
| 1450 | ** gnus-treat-display-xface is an obsolete variable;\ |
| 1451 | use gnus-treat-display-x-face instead") |
| 1452 | (eval (car (get 'gnus-treat-display-xface 'saved-value)))) |
| 1453 | (t |
| 1454 | value))))) |
| 1455 | (put 'gnus-treat-display-x-face 'highlight t) |
| 1456 | |
| 1457 | (defcustom gnus-treat-display-face |
| 1458 | (and (not noninteractive) |
| 1459 | (gnus-image-type-available-p 'png) |
| 1460 | 'head) |
| 1461 | "Display Face headers. |
| 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)Face' for details." |
| 1465 | :group 'gnus-article-treat |
| 1466 | :version "22.1" |
| 1467 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1468 | :link '(custom-manual "(gnus)X-Face") |
| 1469 | :type gnus-article-treat-head-custom) |
| 1470 | (put 'gnus-treat-display-face 'highlight t) |
| 1471 | |
| 1472 | (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm) |
| 1473 | "Display smileys. |
| 1474 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1475 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1476 | node `(gnus)Smileys' for details." |
| 1477 | :group 'gnus-article-treat |
| 1478 | :version "21.1" |
| 1479 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1480 | :link '(custom-manual "(gnus)Smileys") |
| 1481 | :type gnus-article-treat-custom) |
| 1482 | (put 'gnus-treat-display-smileys 'highlight t) |
| 1483 | |
| 1484 | (defcustom gnus-treat-from-picon |
| 1485 | (if (and (gnus-image-type-available-p 'xpm) |
| 1486 | (gnus-picons-installed-p)) |
| 1487 | 'head nil) |
| 1488 | "Display picons in the From header. |
| 1489 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1490 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1491 | node `(gnus)Picons' for details." |
| 1492 | :version "22.1" |
| 1493 | :group 'gnus-article-treat |
| 1494 | :group 'gnus-picon |
| 1495 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1496 | :link '(custom-manual "(gnus)Picons") |
| 1497 | :type gnus-article-treat-head-custom) |
| 1498 | (put 'gnus-treat-from-picon 'highlight t) |
| 1499 | |
| 1500 | (defcustom gnus-treat-mail-picon |
| 1501 | (if (and (gnus-image-type-available-p 'xpm) |
| 1502 | (gnus-picons-installed-p)) |
| 1503 | 'head nil) |
| 1504 | "Display picons in To and Cc headers. |
| 1505 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1506 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1507 | node `(gnus)Picons' for details." |
| 1508 | :version "22.1" |
| 1509 | :group 'gnus-article-treat |
| 1510 | :group 'gnus-picon |
| 1511 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1512 | :link '(custom-manual "(gnus)Picons") |
| 1513 | :type gnus-article-treat-head-custom) |
| 1514 | (put 'gnus-treat-mail-picon 'highlight t) |
| 1515 | |
| 1516 | (defcustom gnus-treat-newsgroups-picon |
| 1517 | (if (and (gnus-image-type-available-p 'xpm) |
| 1518 | (gnus-picons-installed-p)) |
| 1519 | 'head nil) |
| 1520 | "Display picons in the Newsgroups and Followup-To headers. |
| 1521 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1522 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1523 | node `(gnus)Picons' for details." |
| 1524 | :version "22.1" |
| 1525 | :group 'gnus-article-treat |
| 1526 | :group 'gnus-picon |
| 1527 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1528 | :link '(custom-manual "(gnus)Picons") |
| 1529 | :type gnus-article-treat-head-custom) |
| 1530 | (put 'gnus-treat-newsgroups-picon 'highlight t) |
| 1531 | |
| 1532 | (defcustom gnus-treat-from-gravatar nil |
| 1533 | "Display gravatars in the From header. |
| 1534 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1535 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1536 | node `(gnus)Gravatars' for details." |
| 1537 | :version "24.1" |
| 1538 | :group 'gnus-article-treat |
| 1539 | :group 'gnus-gravatar |
| 1540 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1541 | :link '(custom-manual "(gnus)Gravatars") |
| 1542 | :type gnus-article-treat-head-custom) |
| 1543 | (put 'gnus-treat-from-gravatar 'highlight t) |
| 1544 | |
| 1545 | (defcustom gnus-treat-mail-gravatar nil |
| 1546 | "Display gravatars in To and Cc headers. |
| 1547 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1548 | predicate. See Info node `(gnus)Customizing Articles' and Info |
| 1549 | node `(gnus)Gravatars' for details." |
| 1550 | :version "24.1" |
| 1551 | :group 'gnus-article-treat |
| 1552 | :group 'gnus-gravatar |
| 1553 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1554 | :link '(custom-manual "(gnus)Gravatars") |
| 1555 | :type gnus-article-treat-head-custom) |
| 1556 | (put 'gnus-treat-mail-gravatar 'highlight t) |
| 1557 | |
| 1558 | (defcustom gnus-treat-body-boundary |
| 1559 | (if (or gnus-treat-newsgroups-picon |
| 1560 | gnus-treat-mail-picon |
| 1561 | gnus-treat-from-picon |
| 1562 | gnus-treat-from-gravatar |
| 1563 | gnus-treat-mail-gravatar) |
| 1564 | ;; If there's much decoration, the user might prefer a boundery. |
| 1565 | 'head |
| 1566 | nil) |
| 1567 | "Draw a boundary at the end of the headers. |
| 1568 | Valid values are nil and `head'. |
| 1569 | See Info node `(gnus)Customizing Articles' for details." |
| 1570 | :version "22.1" |
| 1571 | :group 'gnus-article-treat |
| 1572 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1573 | :type gnus-article-treat-head-custom) |
| 1574 | |
| 1575 | (defcustom gnus-treat-capitalize-sentences nil |
| 1576 | "Capitalize sentence-starting words. |
| 1577 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1578 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1579 | :version "21.1" |
| 1580 | :group 'gnus-article-treat |
| 1581 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1582 | :type gnus-article-treat-custom) |
| 1583 | |
| 1584 | (defcustom gnus-treat-wash-html nil |
| 1585 | "Format as HTML. |
| 1586 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1587 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1588 | :version "22.1" |
| 1589 | :group 'gnus-article-treat |
| 1590 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1591 | :type gnus-article-treat-custom) |
| 1592 | |
| 1593 | (defcustom gnus-treat-fill-long-lines nil |
| 1594 | "Fill long lines. |
| 1595 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1596 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1597 | :group 'gnus-article-treat |
| 1598 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1599 | :type gnus-article-treat-custom) |
| 1600 | |
| 1601 | (defcustom gnus-treat-x-pgp-sig nil |
| 1602 | "Verify X-PGP-Sig. |
| 1603 | To automatically treat X-PGP-Sig, set it to head. |
| 1604 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 1605 | predicate. See Info node `(gnus)Customizing Articles'." |
| 1606 | :version "22.1" |
| 1607 | :group 'gnus-article-treat |
| 1608 | :group 'mime-security |
| 1609 | :link '(custom-manual "(gnus)Customizing Articles") |
| 1610 | :type gnus-article-treat-custom) |
| 1611 | |
| 1612 | (defvar gnus-article-encrypt-protocol-alist |
| 1613 | '(("PGP" . mml2015-self-encrypt))) |
| 1614 | |
| 1615 | ;; Set to nil if more than one protocol added to |
| 1616 | ;; gnus-article-encrypt-protocol-alist. |
| 1617 | (defcustom gnus-article-encrypt-protocol "PGP" |
| 1618 | "The protocol used for encrypt articles. |
| 1619 | It is a string, such as \"PGP\". If nil, ask user." |
| 1620 | :version "22.1" |
| 1621 | :type 'string |
| 1622 | :group 'mime-security) |
| 1623 | |
| 1624 | (defvar gnus-article-wash-function nil |
| 1625 | "Function used for converting HTML into text.") |
| 1626 | |
| 1627 | (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error)) |
| 1628 | (mm-coding-system-p 'utf-8) |
| 1629 | (executable-find idna-program)) |
| 1630 | "Whether IDNA decoding of headers is used when viewing messages. |
| 1631 | This requires GNU Libidn, and by default only enabled if it is found." |
| 1632 | :version "22.1" |
| 1633 | :group 'gnus-article-headers |
| 1634 | :type 'boolean) |
| 1635 | |
| 1636 | (defcustom gnus-article-over-scroll nil |
| 1637 | "If non-nil, allow scrolling the article buffer even when there no more text." |
| 1638 | :version "22.1" |
| 1639 | :group 'gnus-article |
| 1640 | :type 'boolean) |
| 1641 | |
| 1642 | ;;; Internal variables |
| 1643 | |
| 1644 | (defvar gnus-english-month-names |
| 1645 | '("January" "February" "March" "April" "May" "June" "July" "August" |
| 1646 | "September" "October" "November" "December")) |
| 1647 | |
| 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) |
| 1652 | |
| 1653 | (defvar gnus-article-mime-handle-alist-1 nil) |
| 1654 | (defvar gnus-treatment-function-alist |
| 1655 | '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig) |
| 1656 | (gnus-treat-strip-banner gnus-article-strip-banner) |
| 1657 | (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body) |
| 1658 | (gnus-treat-highlight-signature gnus-article-highlight-signature) |
| 1659 | (gnus-treat-buttonize gnus-article-add-buttons) |
| 1660 | (gnus-treat-fill-article gnus-article-fill-cited-article) |
| 1661 | (gnus-treat-fill-long-lines gnus-article-fill-long-lines) |
| 1662 | (gnus-treat-strip-cr gnus-article-remove-cr) |
| 1663 | (gnus-treat-unsplit-urls gnus-article-unsplit-urls) |
| 1664 | (gnus-treat-date-ut gnus-article-date-ut) |
| 1665 | (gnus-treat-date-local gnus-article-date-local) |
| 1666 | (gnus-treat-date-english gnus-article-date-english) |
| 1667 | (gnus-treat-date-original gnus-article-date-original) |
| 1668 | (gnus-treat-date-user-defined gnus-article-date-user) |
| 1669 | (gnus-treat-date-iso8601 gnus-article-date-iso8601) |
| 1670 | (gnus-treat-date-lapsed gnus-article-date-lapsed) |
| 1671 | (gnus-treat-display-x-face gnus-article-display-x-face) |
| 1672 | (gnus-treat-display-face gnus-article-display-face) |
| 1673 | (gnus-treat-hide-headers gnus-article-maybe-hide-headers) |
| 1674 | (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers) |
| 1675 | (gnus-treat-hide-signature gnus-article-hide-signature) |
| 1676 | (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers) |
| 1677 | (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace) |
| 1678 | (gnus-treat-from-picon gnus-treat-from-picon) |
| 1679 | (gnus-treat-mail-picon gnus-treat-mail-picon) |
| 1680 | (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon) |
| 1681 | (gnus-treat-strip-pem gnus-article-hide-pem) |
| 1682 | (gnus-treat-from-gravatar gnus-treat-from-gravatar) |
| 1683 | (gnus-treat-mail-gravatar gnus-treat-mail-gravatar) |
| 1684 | (gnus-treat-highlight-headers gnus-article-highlight-headers) |
| 1685 | (gnus-treat-highlight-signature gnus-article-highlight-signature) |
| 1686 | (gnus-treat-strip-trailing-blank-lines |
| 1687 | gnus-article-remove-trailing-blank-lines) |
| 1688 | (gnus-treat-strip-leading-blank-lines |
| 1689 | gnus-article-strip-leading-blank-lines) |
| 1690 | (gnus-treat-strip-multiple-blank-lines |
| 1691 | gnus-article-strip-multiple-blank-lines) |
| 1692 | (gnus-treat-overstrike gnus-article-treat-overstrike) |
| 1693 | (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences) |
| 1694 | (gnus-treat-unfold-headers gnus-article-treat-unfold-headers) |
| 1695 | (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups) |
| 1696 | (gnus-treat-fold-headers gnus-article-treat-fold-headers) |
| 1697 | (gnus-treat-buttonize-head gnus-article-add-buttons-to-head) |
| 1698 | (gnus-treat-display-smileys gnus-treat-smiley) |
| 1699 | (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences) |
| 1700 | (gnus-treat-wash-html gnus-article-wash-html) |
| 1701 | (gnus-treat-emphasize gnus-article-emphasize) |
| 1702 | (gnus-treat-hide-citation gnus-article-hide-citation) |
| 1703 | (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe) |
| 1704 | (gnus-treat-highlight-citation gnus-article-highlight-citation) |
| 1705 | (gnus-treat-body-boundary gnus-article-treat-body-boundary))) |
| 1706 | |
| 1707 | (defvar gnus-article-mime-handle-alist nil) |
| 1708 | (defvar article-lapsed-timer nil) |
| 1709 | (defvar gnus-article-current-summary nil) |
| 1710 | |
| 1711 | (defvar gnus-article-mode-syntax-table |
| 1712 | (let ((table (copy-syntax-table text-mode-syntax-table))) |
| 1713 | ;; This causes the citation match run O(2^n). |
| 1714 | ;; (modify-syntax-entry ?- "w" table) |
| 1715 | (modify-syntax-entry ?> ")<" table) |
| 1716 | (modify-syntax-entry ?< "(>" table) |
| 1717 | ;; make M-. in article buffers work for `foo' strings |
| 1718 | (modify-syntax-entry ?' " " table) |
| 1719 | (modify-syntax-entry ?` " " table) |
| 1720 | table) |
| 1721 | "Syntax table used in article mode buffers. |
| 1722 | Initialized from `text-mode-syntax-table.") |
| 1723 | |
| 1724 | (defvar gnus-save-article-buffer nil) |
| 1725 | |
| 1726 | (defvar gnus-number-of-articles-to-be-saved nil) |
| 1727 | |
| 1728 | (defvar gnus-inhibit-hiding nil) |
| 1729 | |
| 1730 | (defvar gnus-article-edit-mode nil) |
| 1731 | |
| 1732 | ;;; Macros for dealing with the article buffer. |
| 1733 | |
| 1734 | (defmacro gnus-with-article-headers (&rest forms) |
| 1735 | `(with-current-buffer gnus-article-buffer |
| 1736 | (save-restriction |
| 1737 | (let ((inhibit-read-only t) |
| 1738 | (inhibit-point-motion-hooks t) |
| 1739 | (case-fold-search t)) |
| 1740 | (article-narrow-to-head) |
| 1741 | ,@forms)))) |
| 1742 | |
| 1743 | (put 'gnus-with-article-headers 'lisp-indent-function 0) |
| 1744 | (put 'gnus-with-article-headers 'edebug-form-spec '(body)) |
| 1745 | |
| 1746 | (defmacro gnus-with-article-buffer (&rest forms) |
| 1747 | `(with-current-buffer gnus-article-buffer |
| 1748 | (let ((inhibit-read-only t)) |
| 1749 | ,@forms))) |
| 1750 | |
| 1751 | (put 'gnus-with-article-buffer 'lisp-indent-function 0) |
| 1752 | (put 'gnus-with-article-buffer 'edebug-form-spec '(body)) |
| 1753 | |
| 1754 | (defun gnus-article-goto-header (header) |
| 1755 | "Go to HEADER, which is a regular expression." |
| 1756 | (re-search-forward (concat "^\\(" header "\\):") nil t)) |
| 1757 | |
| 1758 | (defsubst gnus-article-hide-text (b e props) |
| 1759 | "Set text PROPS on the B to E region, extending `intangible' 1 past B." |
| 1760 | (gnus-add-text-properties-when 'article-type nil b e props) |
| 1761 | (when (memq 'intangible props) |
| 1762 | (put-text-property |
| 1763 | (max (1- b) (point-min)) |
| 1764 | b 'intangible (cddr (memq 'intangible props))))) |
| 1765 | |
| 1766 | (defsubst gnus-article-unhide-text (b e) |
| 1767 | "Remove hidden text properties from region between B and E." |
| 1768 | (remove-text-properties b e gnus-hidden-properties) |
| 1769 | (when (memq 'intangible gnus-hidden-properties) |
| 1770 | (put-text-property (max (1- b) (point-min)) |
| 1771 | b 'intangible nil))) |
| 1772 | |
| 1773 | (defun gnus-article-hide-text-type (b e type) |
| 1774 | "Hide text of TYPE between B and E." |
| 1775 | (gnus-add-wash-type type) |
| 1776 | (gnus-article-hide-text |
| 1777 | b e (cons 'article-type (cons type gnus-hidden-properties)))) |
| 1778 | |
| 1779 | (defun gnus-article-unhide-text-type (b e type) |
| 1780 | "Unhide text of TYPE between B and E." |
| 1781 | (gnus-delete-wash-type type) |
| 1782 | (remove-text-properties |
| 1783 | b e (cons 'article-type (cons type gnus-hidden-properties))) |
| 1784 | (when (memq 'intangible gnus-hidden-properties) |
| 1785 | (put-text-property (max (1- b) (point-min)) |
| 1786 | b 'intangible nil))) |
| 1787 | |
| 1788 | (defun gnus-article-hide-text-of-type (type) |
| 1789 | "Hide text of TYPE in the current buffer." |
| 1790 | (save-excursion |
| 1791 | (let ((b (point-min)) |
| 1792 | (e (point-max))) |
| 1793 | (while (setq b (text-property-any b e 'article-type type)) |
| 1794 | (add-text-properties b (incf b) gnus-hidden-properties))))) |
| 1795 | |
| 1796 | (defun gnus-article-delete-text-of-type (type) |
| 1797 | "Delete text of TYPE in the current buffer." |
| 1798 | (save-excursion |
| 1799 | (let ((b (point-min))) |
| 1800 | (if (eq type 'multipart) |
| 1801 | ;; Remove MIME buttons associated with multipart/alternative parts. |
| 1802 | (progn |
| 1803 | (goto-char b) |
| 1804 | (while (if (get-text-property (point) 'gnus-part) |
| 1805 | (setq b (point)) |
| 1806 | (when (setq b (next-single-property-change (point) |
| 1807 | 'gnus-part)) |
| 1808 | (goto-char b) |
| 1809 | t)) |
| 1810 | (end-of-line) |
| 1811 | (skip-chars-forward "\n") |
| 1812 | (when (eq (get-text-property b 'article-type) 'multipart) |
| 1813 | (delete-region b (point))))) |
| 1814 | (while (setq b (text-property-any b (point-max) 'article-type type)) |
| 1815 | (delete-region |
| 1816 | b (or (text-property-not-all b (point-max) 'article-type type) |
| 1817 | (point-max)))))))) |
| 1818 | |
| 1819 | (defun gnus-article-delete-invisible-text () |
| 1820 | "Delete all invisible text in the current buffer." |
| 1821 | (save-excursion |
| 1822 | (let ((b (point-min))) |
| 1823 | (while (setq b (text-property-any b (point-max) 'invisible t)) |
| 1824 | (delete-region |
| 1825 | b (or (text-property-not-all b (point-max) 'invisible t) |
| 1826 | (point-max))))))) |
| 1827 | |
| 1828 | (defun gnus-article-text-type-exists-p (type) |
| 1829 | "Say whether any text of type TYPE exists in the buffer." |
| 1830 | (text-property-any (point-min) (point-max) 'article-type type)) |
| 1831 | |
| 1832 | (defsubst gnus-article-header-rank () |
| 1833 | "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." |
| 1834 | (let ((list gnus-sorted-header-list) |
| 1835 | (i 1)) |
| 1836 | (while list |
| 1837 | (if (looking-at (car list)) |
| 1838 | (setq list nil) |
| 1839 | (setq list (cdr list)) |
| 1840 | (incf i))) |
| 1841 | i)) |
| 1842 | |
| 1843 | (defun article-hide-headers (&optional arg delete) |
| 1844 | "Hide unwanted headers and possibly sort them as well." |
| 1845 | (interactive) |
| 1846 | ;; This function might be inhibited. |
| 1847 | (unless gnus-inhibit-hiding |
| 1848 | (let ((inhibit-read-only t) |
| 1849 | (case-fold-search t) |
| 1850 | (max (1+ (length gnus-sorted-header-list))) |
| 1851 | (inhibit-point-motion-hooks t) |
| 1852 | (cur (current-buffer)) |
| 1853 | ignored visible beg) |
| 1854 | (save-excursion |
| 1855 | ;; `gnus-ignored-headers' and `gnus-visible-headers' may be |
| 1856 | ;; group parameters, so we should go to the summary buffer. |
| 1857 | (when (prog1 |
| 1858 | (condition-case nil |
| 1859 | (progn (set-buffer gnus-summary-buffer) t) |
| 1860 | (error nil)) |
| 1861 | (setq ignored (when (not gnus-visible-headers) |
| 1862 | (cond ((stringp gnus-ignored-headers) |
| 1863 | gnus-ignored-headers) |
| 1864 | ((listp gnus-ignored-headers) |
| 1865 | (mapconcat 'identity |
| 1866 | gnus-ignored-headers |
| 1867 | "\\|")))) |
| 1868 | visible (cond ((stringp gnus-visible-headers) |
| 1869 | gnus-visible-headers) |
| 1870 | ((and gnus-visible-headers |
| 1871 | (listp gnus-visible-headers)) |
| 1872 | (mapconcat 'identity |
| 1873 | gnus-visible-headers |
| 1874 | "\\|"))))) |
| 1875 | (set-buffer cur)) |
| 1876 | (save-restriction |
| 1877 | ;; First we narrow to just the headers. |
| 1878 | (article-narrow-to-head) |
| 1879 | ;; Hide any "From " lines at the beginning of (mail) articles. |
| 1880 | (while (looking-at "From ") |
| 1881 | (forward-line 1)) |
| 1882 | (unless (bobp) |
| 1883 | (delete-region (point-min) (point))) |
| 1884 | ;; Then treat the rest of the header lines. |
| 1885 | ;; Then we use the two regular expressions |
| 1886 | ;; `gnus-ignored-headers' and `gnus-visible-headers' to |
| 1887 | ;; select which header lines is to remain visible in the |
| 1888 | ;; article buffer. |
| 1889 | (while (re-search-forward "^[^ \t:]*:" nil t) |
| 1890 | (beginning-of-line) |
| 1891 | ;; Mark the rank of the header. |
| 1892 | (put-text-property |
| 1893 | (point) (1+ (point)) 'message-rank |
| 1894 | (if (or (and visible (looking-at visible)) |
| 1895 | (and ignored |
| 1896 | (not (looking-at ignored)))) |
| 1897 | (gnus-article-header-rank) |
| 1898 | (+ 2 max))) |
| 1899 | (forward-line 1)) |
| 1900 | (message-sort-headers-1) |
| 1901 | (when (setq beg (text-property-any |
| 1902 | (point-min) (point-max) 'message-rank (+ 2 max))) |
| 1903 | ;; We delete the unwanted headers. |
| 1904 | (gnus-add-wash-type 'headers) |
| 1905 | (add-text-properties (point-min) (+ 5 (point-min)) |
| 1906 | '(article-type headers dummy-invisible t)) |
| 1907 | (delete-region beg (point-max)))))))) |
| 1908 | |
| 1909 | (defun article-hide-boring-headers (&optional arg) |
| 1910 | "Toggle hiding of headers that aren't very interesting. |
| 1911 | If given a negative prefix, always show; if given a positive prefix, |
| 1912 | always hide." |
| 1913 | (interactive (gnus-article-hidden-arg)) |
| 1914 | (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) |
| 1915 | (not gnus-show-all-headers)) |
| 1916 | (save-excursion |
| 1917 | (save-restriction |
| 1918 | (let ((inhibit-read-only t) |
| 1919 | (inhibit-point-motion-hooks t)) |
| 1920 | (article-narrow-to-head) |
| 1921 | (dolist (elem gnus-boring-article-headers) |
| 1922 | (goto-char (point-min)) |
| 1923 | (cond |
| 1924 | ;; Hide empty headers. |
| 1925 | ((eq elem 'empty) |
| 1926 | (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t) |
| 1927 | (forward-line -1) |
| 1928 | (gnus-article-hide-text-type |
| 1929 | (point-at-bol) |
| 1930 | (progn |
| 1931 | (end-of-line) |
| 1932 | (if (re-search-forward "^[^ \t]" nil t) |
| 1933 | (match-beginning 0) |
| 1934 | (point-max))) |
| 1935 | 'boring-headers))) |
| 1936 | ;; Hide boring Newsgroups header. |
| 1937 | ((eq elem 'newsgroups) |
| 1938 | (when (gnus-string-equal |
| 1939 | (gnus-fetch-field "newsgroups") |
| 1940 | (gnus-group-real-name |
| 1941 | (if (boundp 'gnus-newsgroup-name) |
| 1942 | gnus-newsgroup-name |
| 1943 | ""))) |
| 1944 | (gnus-article-hide-header "newsgroups"))) |
| 1945 | ((eq elem 'to-address) |
| 1946 | (let ((to (message-fetch-field "to")) |
| 1947 | (to-address |
| 1948 | (gnus-parameter-to-address |
| 1949 | (if (boundp 'gnus-newsgroup-name) |
| 1950 | gnus-newsgroup-name "")))) |
| 1951 | (when (and to to-address |
| 1952 | (ignore-errors |
| 1953 | (gnus-string-equal |
| 1954 | ;; only one address in To |
| 1955 | (nth 1 (mail-extract-address-components to)) |
| 1956 | to-address))) |
| 1957 | (gnus-article-hide-header "to")))) |
| 1958 | ((eq elem 'to-list) |
| 1959 | (let ((to (message-fetch-field "to")) |
| 1960 | (to-list |
| 1961 | (gnus-parameter-to-list |
| 1962 | (if (boundp 'gnus-newsgroup-name) |
| 1963 | gnus-newsgroup-name "")))) |
| 1964 | (when (and to to-list |
| 1965 | (ignore-errors |
| 1966 | (gnus-string-equal |
| 1967 | ;; only one address in To |
| 1968 | (nth 1 (mail-extract-address-components to)) |
| 1969 | to-list))) |
| 1970 | (gnus-article-hide-header "to")))) |
| 1971 | ((eq elem 'cc-list) |
| 1972 | (let ((cc (message-fetch-field "cc")) |
| 1973 | (to-list |
| 1974 | (gnus-parameter-to-list |
| 1975 | (if (boundp 'gnus-newsgroup-name) |
| 1976 | gnus-newsgroup-name "")))) |
| 1977 | (when (and cc to-list |
| 1978 | (ignore-errors |
| 1979 | (gnus-string-equal |
| 1980 | ;; only one address in CC |
| 1981 | (nth 1 (mail-extract-address-components cc)) |
| 1982 | to-list))) |
| 1983 | (gnus-article-hide-header "cc")))) |
| 1984 | ((eq elem 'followup-to) |
| 1985 | (when (gnus-string-equal |
| 1986 | (message-fetch-field "followup-to") |
| 1987 | (message-fetch-field "newsgroups")) |
| 1988 | (gnus-article-hide-header "followup-to"))) |
| 1989 | ((eq elem 'reply-to) |
| 1990 | (if (gnus-group-find-parameter |
| 1991 | gnus-newsgroup-name 'broken-reply-to) |
| 1992 | (gnus-article-hide-header "reply-to") |
| 1993 | (let ((from (message-fetch-field "from")) |
| 1994 | (reply-to (message-fetch-field "reply-to"))) |
| 1995 | (when |
| 1996 | (and |
| 1997 | from reply-to |
| 1998 | (ignore-errors |
| 1999 | (equal |
| 2000 | (sort (mapcar |
| 2001 | (lambda (x) (downcase (cadr x))) |
| 2002 | (mail-extract-address-components from t)) |
| 2003 | 'string<) |
| 2004 | (sort (mapcar |
| 2005 | (lambda (x) (downcase (cadr x))) |
| 2006 | (mail-extract-address-components reply-to t)) |
| 2007 | 'string<)))) |
| 2008 | (gnus-article-hide-header "reply-to"))))) |
| 2009 | ((eq elem 'date) |
| 2010 | (let ((date (with-current-buffer gnus-original-article-buffer |
| 2011 | ;; If date in `gnus-article-buffer' is localized |
| 2012 | ;; (`gnus-treat-date-user-defined'), |
| 2013 | ;; `days-between' might fail. |
| 2014 | (message-fetch-field "date")))) |
| 2015 | (when (and date |
| 2016 | (< (days-between (current-time-string) date) |
| 2017 | 4)) |
| 2018 | (gnus-article-hide-header "date")))) |
| 2019 | ((eq elem 'long-to) |
| 2020 | (let ((to (message-fetch-field "to")) |
| 2021 | (cc (message-fetch-field "cc"))) |
| 2022 | (when (> (length to) 1024) |
| 2023 | (gnus-article-hide-header "to")) |
| 2024 | (when (> (length cc) 1024) |
| 2025 | (gnus-article-hide-header "cc")))) |
| 2026 | ((eq elem 'many-to) |
| 2027 | (let ((to-count 0) |
| 2028 | (cc-count 0)) |
| 2029 | (goto-char (point-min)) |
| 2030 | (while (re-search-forward "^to:" nil t) |
| 2031 | (setq to-count (1+ to-count))) |
| 2032 | (when (> to-count 1) |
| 2033 | (while (> to-count 0) |
| 2034 | (goto-char (point-min)) |
| 2035 | (save-restriction |
| 2036 | (re-search-forward "^to:" nil nil to-count) |
| 2037 | (forward-line -1) |
| 2038 | (narrow-to-region (point) (point-max)) |
| 2039 | (gnus-article-hide-header "to")) |
| 2040 | (setq to-count (1- to-count)))) |
| 2041 | (goto-char (point-min)) |
| 2042 | (while (re-search-forward "^cc:" nil t) |
| 2043 | (setq cc-count (1+ cc-count))) |
| 2044 | (when (> cc-count 1) |
| 2045 | (while (> cc-count 0) |
| 2046 | (goto-char (point-min)) |
| 2047 | (save-restriction |
| 2048 | (re-search-forward "^cc:" nil nil cc-count) |
| 2049 | (forward-line -1) |
| 2050 | (narrow-to-region (point) (point-max)) |
| 2051 | (gnus-article-hide-header "cc")) |
| 2052 | (setq cc-count (1- cc-count))))))))))))) |
| 2053 | |
| 2054 | (defun gnus-article-hide-header (header) |
| 2055 | (save-excursion |
| 2056 | (goto-char (point-min)) |
| 2057 | (when (re-search-forward (concat "^" header ":") nil t) |
| 2058 | (gnus-article-hide-text-type |
| 2059 | (point-at-bol) |
| 2060 | (progn |
| 2061 | (end-of-line) |
| 2062 | (if (re-search-forward "^[^ \t]" nil t) |
| 2063 | (match-beginning 0) |
| 2064 | (point-max))) |
| 2065 | 'boring-headers)))) |
| 2066 | |
| 2067 | (defvar gnus-article-normalized-header-length 40 |
| 2068 | "Length of normalized headers.") |
| 2069 | |
| 2070 | (defun article-normalize-headers () |
| 2071 | "Make all header lines 40 characters long." |
| 2072 | (interactive) |
| 2073 | (let ((inhibit-read-only t) |
| 2074 | column) |
| 2075 | (save-excursion |
| 2076 | (save-restriction |
| 2077 | (article-narrow-to-head) |
| 2078 | (while (not (eobp)) |
| 2079 | (cond |
| 2080 | ((< (setq column (- (point-at-eol) (point))) |
| 2081 | gnus-article-normalized-header-length) |
| 2082 | (end-of-line) |
| 2083 | (insert (make-string |
| 2084 | (- gnus-article-normalized-header-length column) |
| 2085 | ? ))) |
| 2086 | ((> column gnus-article-normalized-header-length) |
| 2087 | (gnus-put-text-property |
| 2088 | (progn |
| 2089 | (forward-char gnus-article-normalized-header-length) |
| 2090 | (point)) |
| 2091 | (point-at-eol) |
| 2092 | 'invisible t)) |
| 2093 | (t |
| 2094 | ;; Do nothing. |
| 2095 | )) |
| 2096 | (forward-line 1)))))) |
| 2097 | |
| 2098 | (defun article-treat-dumbquotes () |
| 2099 | "Translate M****s*** sm*rtq**t*s and other symbols into proper text. |
| 2100 | Note that this function guesses whether a character is a sm*rtq**t* or |
| 2101 | not, so it should only be used interactively. |
| 2102 | |
| 2103 | Sm*rtq**t*s are M****s***'s unilateral extension to the |
| 2104 | iso-8859-1 character map in an attempt to provide more quoting |
| 2105 | characters. If you see something like \\222 or \\264 where |
| 2106 | you're expecting some kind of apostrophe or quotation mark, then |
| 2107 | try this wash." |
| 2108 | (interactive) |
| 2109 | (article-translate-strings gnus-article-dumbquotes-map)) |
| 2110 | |
| 2111 | (defun article-translate-characters (from to) |
| 2112 | "Translate all characters in the body of the article according to FROM and TO. |
| 2113 | FROM is a string of characters to translate from; to is a string of |
| 2114 | characters to translate to." |
| 2115 | (save-excursion |
| 2116 | (when (article-goto-body) |
| 2117 | (let ((inhibit-read-only t) |
| 2118 | (x (make-string 225 ?x)) |
| 2119 | (i -1)) |
| 2120 | (while (< (incf i) (length x)) |
| 2121 | (aset x i i)) |
| 2122 | (setq i 0) |
| 2123 | (while (< i (length from)) |
| 2124 | (aset x (aref from i) (aref to i)) |
| 2125 | (incf i)) |
| 2126 | (translate-region (point) (point-max) x))))) |
| 2127 | |
| 2128 | (defun article-translate-strings (map) |
| 2129 | "Translate all string in the body of the article according to MAP. |
| 2130 | MAP is an alist where the elements are on the form (\"from\" \"to\")." |
| 2131 | (save-excursion |
| 2132 | (when (article-goto-body) |
| 2133 | (let ((inhibit-read-only t)) |
| 2134 | (dolist (elem map) |
| 2135 | (save-excursion |
| 2136 | (while (search-forward (car elem) nil t) |
| 2137 | (replace-match (cadr elem))))))))) |
| 2138 | |
| 2139 | (defun article-treat-overstrike () |
| 2140 | "Translate overstrikes into bold text." |
| 2141 | (interactive) |
| 2142 | (save-excursion |
| 2143 | (when (article-goto-body) |
| 2144 | (let ((inhibit-read-only t)) |
| 2145 | (while (search-forward "\b" nil t) |
| 2146 | (let ((next (char-after)) |
| 2147 | (previous (char-after (- (point) 2)))) |
| 2148 | ;; We do the boldification/underlining by hiding the |
| 2149 | ;; overstrikes and putting the proper text property |
| 2150 | ;; on the letters. |
| 2151 | (cond |
| 2152 | ((eq next previous) |
| 2153 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) |
| 2154 | (put-text-property (point) (1+ (point)) 'face 'bold)) |
| 2155 | ((eq next ?_) |
| 2156 | (gnus-article-hide-text-type |
| 2157 | (1- (point)) (1+ (point)) 'overstrike) |
| 2158 | (put-text-property |
| 2159 | (- (point) 2) (1- (point)) 'face 'underline)) |
| 2160 | ((eq previous ?_) |
| 2161 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) |
| 2162 | (put-text-property |
| 2163 | (point) (1+ (point)) 'face 'underline))))))))) |
| 2164 | |
| 2165 | (defun article-treat-ansi-sequences () |
| 2166 | "Translate ANSI SGR control sequences into overlays or extents." |
| 2167 | (interactive) |
| 2168 | (save-excursion |
| 2169 | (when (article-goto-body) |
| 2170 | (let ((inhibit-read-only t)) |
| 2171 | (ansi-color-apply-on-region (point) (point-max)))))) |
| 2172 | |
| 2173 | (defun gnus-article-treat-unfold-headers () |
| 2174 | "Unfold folded message headers. |
| 2175 | Only the headers that fit into the current window width will be |
| 2176 | unfolded." |
| 2177 | (interactive) |
| 2178 | (gnus-with-article-headers |
| 2179 | (let (length) |
| 2180 | (while (not (eobp)) |
| 2181 | (save-restriction |
| 2182 | (mail-header-narrow-to-field) |
| 2183 | (let* ((header (buffer-string)) |
| 2184 | (unfoldable |
| 2185 | (or (equal gnus-article-unfold-long-headers t) |
| 2186 | (and (stringp gnus-article-unfold-long-headers) |
| 2187 | (string-match gnus-article-unfold-long-headers header))))) |
| 2188 | (with-temp-buffer |
| 2189 | (insert header) |
| 2190 | (goto-char (point-min)) |
| 2191 | (while (re-search-forward "\n[\t ]" nil t) |
| 2192 | (replace-match " " t t))) |
| 2193 | (setq length (- (point-max) (point-min) 1)) |
| 2194 | (when (or unfoldable |
| 2195 | (< length (window-width))) |
| 2196 | (while (re-search-forward "\n[\t ]" nil t) |
| 2197 | (replace-match " " t t)))) |
| 2198 | (goto-char (point-max))))))) |
| 2199 | |
| 2200 | (defun gnus-article-treat-fold-headers () |
| 2201 | "Fold message headers." |
| 2202 | (interactive) |
| 2203 | (gnus-with-article-headers |
| 2204 | (while (not (eobp)) |
| 2205 | (save-restriction |
| 2206 | (mail-header-narrow-to-field) |
| 2207 | (mail-header-fold-field) |
| 2208 | (goto-char (point-max)))))) |
| 2209 | |
| 2210 | (defun gnus-treat-smiley () |
| 2211 | "Toggle display of textual emoticons (\"smileys\") as small graphical icons." |
| 2212 | (interactive) |
| 2213 | (gnus-with-article-buffer |
| 2214 | (if (memq 'smiley gnus-article-wash-types) |
| 2215 | (gnus-delete-images 'smiley) |
| 2216 | (article-goto-body) |
| 2217 | (let ((images (smiley-region (point) (point-max)))) |
| 2218 | (when images |
| 2219 | (gnus-add-wash-type 'smiley) |
| 2220 | (dolist (image images) |
| 2221 | (gnus-add-image 'smiley image))))))) |
| 2222 | |
| 2223 | (defun gnus-article-remove-images () |
| 2224 | "Remove all images from the article buffer." |
| 2225 | (interactive) |
| 2226 | (gnus-with-article-buffer |
| 2227 | (dolist (elem gnus-article-image-alist) |
| 2228 | (gnus-delete-images (car elem))))) |
| 2229 | |
| 2230 | (defun gnus-article-treat-fold-newsgroups () |
| 2231 | "Unfold folded message headers. |
| 2232 | Only the headers that fit into the current window width will be |
| 2233 | unfolded." |
| 2234 | (interactive) |
| 2235 | (gnus-with-article-headers |
| 2236 | (while (gnus-article-goto-header "newsgroups\\|followup-to") |
| 2237 | (save-restriction |
| 2238 | (mail-header-narrow-to-field) |
| 2239 | (while (re-search-forward ", *" nil t) |
| 2240 | (replace-match ", " t t)) |
| 2241 | (mail-header-fold-field) |
| 2242 | (goto-char (point-max)))))) |
| 2243 | |
| 2244 | (defcustom gnus-article-truncate-lines (default-value 'truncate-lines) |
| 2245 | "Value of `truncate-lines' in Gnus Article buffer. |
| 2246 | Valid values are nil, t, `head', `first', `last', an integer or a |
| 2247 | predicate. See Info node `(gnus)Customizing Articles'." |
| 2248 | :version "23.1" ;; No Gnus |
| 2249 | :group 'gnus-article |
| 2250 | ;; :link '(custom-manual "(gnus)Customizing Articles") |
| 2251 | :type 'boolean) |
| 2252 | |
| 2253 | (defun gnus-article-toggle-truncate-lines (&optional arg) |
| 2254 | "Toggle whether to fold or truncate long lines in article the buffer. |
| 2255 | If ARG is non-nil and not a number, toggle |
| 2256 | `gnus-article-truncate-lines' too. If ARG is a number, truncate |
| 2257 | long lines if and only if arg is positive." |
| 2258 | (interactive "P") |
| 2259 | (cond |
| 2260 | ((and (numberp arg) (> arg 0)) |
| 2261 | (setq gnus-article-truncate-lines t)) |
| 2262 | ((numberp arg) |
| 2263 | (setq gnus-article-truncate-lines nil)) |
| 2264 | (arg |
| 2265 | (setq gnus-article-truncate-lines |
| 2266 | (not gnus-article-truncate-lines)))) |
| 2267 | (gnus-with-article-buffer |
| 2268 | (cond |
| 2269 | ((and (numberp arg) (> arg 0)) |
| 2270 | (setq truncate-lines nil)) |
| 2271 | ((numberp arg) |
| 2272 | (setq truncate-lines t))) |
| 2273 | ;; In versions of Emacs 22 (CVS) before 2006-05-26, |
| 2274 | ;; `toggle-truncate-lines' needs an argument. |
| 2275 | (toggle-truncate-lines))) |
| 2276 | |
| 2277 | (defun gnus-article-treat-body-boundary () |
| 2278 | "Place a boundary line at the end of the headers." |
| 2279 | (interactive) |
| 2280 | (when (and gnus-body-boundary-delimiter |
| 2281 | (> (length gnus-body-boundary-delimiter) 0)) |
| 2282 | (gnus-with-article-headers |
| 2283 | (goto-char (point-max)) |
| 2284 | (let ((start (point))) |
| 2285 | (insert "X-Boundary: ") |
| 2286 | (gnus-add-text-properties start (point) '(invisible t intangible t)) |
| 2287 | (insert (let (str) |
| 2288 | (while (>= (window-width) (length str)) |
| 2289 | (setq str (concat str gnus-body-boundary-delimiter))) |
| 2290 | (substring str 0 (window-width))) |
| 2291 | "\n") |
| 2292 | (gnus-put-text-property start (point) 'gnus-decoration 'header))))) |
| 2293 | |
| 2294 | (defun article-fill-long-lines () |
| 2295 | "Fill lines that are wider than the window width." |
| 2296 | (interactive) |
| 2297 | (save-excursion |
| 2298 | (let ((inhibit-read-only t) |
| 2299 | (width (window-width (get-buffer-window (current-buffer))))) |
| 2300 | (save-restriction |
| 2301 | (article-goto-body) |
| 2302 | (let ((adaptive-fill-mode nil)) ;Why? -sm |
| 2303 | (while (not (eobp)) |
| 2304 | (end-of-line) |
| 2305 | (when (>= (current-column) (min fill-column width)) |
| 2306 | (narrow-to-region (min (1+ (point)) (point-max)) |
| 2307 | (point-at-bol)) |
| 2308 | (let ((goback (point-marker))) |
| 2309 | (fill-paragraph nil) |
| 2310 | (goto-char (marker-position goback))) |
| 2311 | (widen)) |
| 2312 | (forward-line 1))))))) |
| 2313 | |
| 2314 | (defun article-capitalize-sentences () |
| 2315 | "Capitalize the first word in each sentence." |
| 2316 | (interactive) |
| 2317 | (save-excursion |
| 2318 | (let ((inhibit-read-only t) |
| 2319 | (paragraph-start "^[\n\^L]")) |
| 2320 | (article-goto-body) |
| 2321 | (while (not (eobp)) |
| 2322 | (capitalize-word 1) |
| 2323 | (forward-sentence))))) |
| 2324 | |
| 2325 | (defun article-remove-cr () |
| 2326 | "Remove trailing CRs and then translate remaining CRs into LFs." |
| 2327 | (interactive) |
| 2328 | (save-excursion |
| 2329 | (let ((inhibit-read-only t)) |
| 2330 | (goto-char (point-min)) |
| 2331 | (while (re-search-forward "\r+$" nil t) |
| 2332 | (replace-match "" t t)) |
| 2333 | (goto-char (point-min)) |
| 2334 | (while (search-forward "\r" nil t) |
| 2335 | (replace-match "\n" t t))))) |
| 2336 | |
| 2337 | (defun article-remove-trailing-blank-lines () |
| 2338 | "Remove all trailing blank lines from the article." |
| 2339 | (interactive) |
| 2340 | (save-excursion |
| 2341 | (let ((inhibit-read-only t)) |
| 2342 | (goto-char (point-max)) |
| 2343 | (delete-region |
| 2344 | (point) |
| 2345 | (progn |
| 2346 | (while (and (not (bobp)) |
| 2347 | (looking-at "^[ \t]*$") |
| 2348 | (not (gnus-annotation-in-region-p |
| 2349 | (point) (point-at-eol)))) |
| 2350 | (forward-line -1)) |
| 2351 | (forward-line 1) |
| 2352 | (point)))))) |
| 2353 | |
| 2354 | (defvar gnus-face-properties-alist) |
| 2355 | |
| 2356 | (defun article-display-face (&optional force) |
| 2357 | "Display any Face headers in the header." |
| 2358 | (interactive (list 'force)) |
| 2359 | (let ((wash-face-p buffer-read-only)) |
| 2360 | (gnus-with-article-headers |
| 2361 | ;; When displaying parts, this function can be called several times on |
| 2362 | ;; the same article, without any intended toggle semantic (as typing `W |
| 2363 | ;; D d' would have). So face deletion must occur only when we come from |
| 2364 | ;; an interactive command, that is when the *Article* buffer is |
| 2365 | ;; read-only. |
| 2366 | (if (and wash-face-p (memq 'face gnus-article-wash-types)) |
| 2367 | (gnus-delete-images 'face) |
| 2368 | (let ((from (message-fetch-field "from")) |
| 2369 | face faces) |
| 2370 | (save-current-buffer |
| 2371 | (when (and wash-face-p |
| 2372 | (gnus-buffer-live-p gnus-original-article-buffer) |
| 2373 | (not (re-search-forward "^Face:[\t ]*" nil t))) |
| 2374 | (set-buffer gnus-original-article-buffer)) |
| 2375 | (save-restriction |
| 2376 | (mail-narrow-to-head) |
| 2377 | (when (or force |
| 2378 | ;; Check whether this face is censored. |
| 2379 | (not (and gnus-article-x-face-too-ugly |
| 2380 | (or from |
| 2381 | (setq from (message-fetch-field "from"))) |
| 2382 | (string-match gnus-article-x-face-too-ugly |
| 2383 | from)))) |
| 2384 | (while (gnus-article-goto-header "Face") |
| 2385 | (push (mail-header-field-value) faces))))) |
| 2386 | (when faces |
| 2387 | (goto-char (point-min)) |
| 2388 | (let (png image) |
| 2389 | (unless (setq from (gnus-article-goto-header "from")) |
| 2390 | (insert "From:") |
| 2391 | (setq from (point)) |
| 2392 | (insert " [no `from' set]\n")) |
| 2393 | (while faces |
| 2394 | (when (setq png (gnus-convert-face-to-png (pop faces))) |
| 2395 | (setq image |
| 2396 | (apply 'gnus-create-image png 'png t |
| 2397 | (cdr (assq 'png gnus-face-properties-alist)))) |
| 2398 | (goto-char from) |
| 2399 | (gnus-add-wash-type 'face) |
| 2400 | (gnus-add-image 'face image) |
| 2401 | (gnus-put-image image nil 'face)))))))))) |
| 2402 | |
| 2403 | (defun article-display-x-face (&optional force) |
| 2404 | "Look for an X-Face header and display it if present." |
| 2405 | (interactive (list 'force)) |
| 2406 | (let ((wash-face-p buffer-read-only)) ;; When type `W f' |
| 2407 | (gnus-with-article-headers |
| 2408 | ;; Delete the old process, if any. |
| 2409 | (when (process-status "article-x-face") |
| 2410 | (delete-process "article-x-face")) |
| 2411 | ;; See the comment in `article-display-face'. |
| 2412 | (if (and wash-face-p (memq 'xface gnus-article-wash-types)) |
| 2413 | ;; We have already displayed X-Faces, so we remove them |
| 2414 | ;; instead. |
| 2415 | (gnus-delete-images 'xface) |
| 2416 | ;; Display X-Faces. |
| 2417 | (let ((from (message-fetch-field "from")) |
| 2418 | x-faces face) |
| 2419 | (save-current-buffer |
| 2420 | (when (and wash-face-p |
| 2421 | (gnus-buffer-live-p gnus-original-article-buffer) |
| 2422 | (not (re-search-forward "^X-Face:[\t ]*" nil t))) |
| 2423 | ;; If type `W f', use gnus-original-article-buffer, |
| 2424 | ;; otherwise use the current buffer because displaying |
| 2425 | ;; RFC822 parts calls this function too. |
| 2426 | (set-buffer gnus-original-article-buffer)) |
| 2427 | (save-restriction |
| 2428 | (mail-narrow-to-head) |
| 2429 | (and gnus-article-x-face-command |
| 2430 | (or force |
| 2431 | ;; Check whether this face is censored. |
| 2432 | (not (and gnus-article-x-face-too-ugly |
| 2433 | (or from |
| 2434 | (setq from (message-fetch-field "from"))) |
| 2435 | (string-match gnus-article-x-face-too-ugly |
| 2436 | from)))) |
| 2437 | (while (gnus-article-goto-header "X-Face") |
| 2438 | (push (mail-header-field-value) x-faces))))) |
| 2439 | (when x-faces |
| 2440 | ;; We display the face. |
| 2441 | (cond ((functionp gnus-article-x-face-command) |
| 2442 | ;; The command is a lisp function, so we call it. |
| 2443 | (mapc gnus-article-x-face-command x-faces)) |
| 2444 | ((stringp gnus-article-x-face-command) |
| 2445 | ;; The command is a string, so we interpret the command |
| 2446 | ;; as a, well, command, and fork it off. |
| 2447 | (let ((process-connection-type nil)) |
| 2448 | (gnus-set-process-query-on-exit-flag |
| 2449 | (start-process |
| 2450 | "article-x-face" nil shell-file-name |
| 2451 | shell-command-switch gnus-article-x-face-command) |
| 2452 | nil) |
| 2453 | ;; Sending multiple EOFs to xv doesn't work, |
| 2454 | ;; so we only do a single external face. |
| 2455 | (with-temp-buffer |
| 2456 | (insert (car x-faces)) |
| 2457 | (process-send-region "article-x-face" |
| 2458 | (point-min) (point-max))) |
| 2459 | (process-send-eof "article-x-face"))) |
| 2460 | (t |
| 2461 | (error "`%s' set to `%s' is not a function" |
| 2462 | gnus-article-x-face-command |
| 2463 | 'gnus-article-x-face-command))))))))) |
| 2464 | |
| 2465 | (defun article-decode-mime-words () |
| 2466 | "Decode all MIME-encoded words in the article." |
| 2467 | (interactive) |
| 2468 | (gnus-with-article-buffer |
| 2469 | (let ((inhibit-point-motion-hooks t) |
| 2470 | (mail-parse-charset gnus-newsgroup-charset) |
| 2471 | (mail-parse-ignored-charsets |
| 2472 | (with-current-buffer gnus-summary-buffer |
| 2473 | gnus-newsgroup-ignored-charsets))) |
| 2474 | (mail-decode-encoded-word-region (point-min) (point-max))))) |
| 2475 | |
| 2476 | (defun article-decode-charset (&optional prompt) |
| 2477 | "Decode charset-encoded text in the article. |
| 2478 | If PROMPT (the prefix), prompt for a coding system to use." |
| 2479 | (interactive "P") |
| 2480 | (let ((inhibit-point-motion-hooks t) (case-fold-search t) |
| 2481 | (inhibit-read-only t) |
| 2482 | (mail-parse-charset gnus-newsgroup-charset) |
| 2483 | (mail-parse-ignored-charsets |
| 2484 | (save-excursion (condition-case nil |
| 2485 | (set-buffer gnus-summary-buffer) |
| 2486 | (error)) |
| 2487 | gnus-newsgroup-ignored-charsets)) |
| 2488 | ct cte ctl charset format) |
| 2489 | (save-excursion |
| 2490 | (save-restriction |
| 2491 | (article-narrow-to-head) |
| 2492 | (setq ct (message-fetch-field "Content-Type" t) |
| 2493 | cte (message-fetch-field "Content-Transfer-Encoding" t) |
| 2494 | ctl (and ct (mail-header-parse-content-type ct)) |
| 2495 | charset (cond |
| 2496 | (prompt |
| 2497 | (mm-read-coding-system "Charset to decode: ")) |
| 2498 | (ctl |
| 2499 | (mail-content-type-get ctl 'charset))) |
| 2500 | format (and ctl (mail-content-type-get ctl 'format))) |
| 2501 | (when cte |
| 2502 | (setq cte (mail-header-strip cte))) |
| 2503 | (if (and ctl (not (string-match "/" (car ctl)))) |
| 2504 | (setq ctl nil)) |
| 2505 | (goto-char (point-max))) |
| 2506 | (forward-line 1) |
| 2507 | (save-restriction |
| 2508 | (narrow-to-region (point) (point-max)) |
| 2509 | (when (and (eq mail-parse-charset 'gnus-decoded) |
| 2510 | (eq (mm-body-7-or-8) '8bit)) |
| 2511 | ;; The text code could have been decoded. |
| 2512 | (setq charset mail-parse-charset)) |
| 2513 | (when (and (or (not ctl) |
| 2514 | (equal (car ctl) "text/plain")) |
| 2515 | (not format)) ;; article with format will decode later. |
| 2516 | (mm-decode-body |
| 2517 | charset (and cte (intern (downcase |
| 2518 | (gnus-strip-whitespace cte)))) |
| 2519 | (car ctl))))))) |
| 2520 | |
| 2521 | (defun article-decode-encoded-words () |
| 2522 | "Remove encoded-word encoding from headers." |
| 2523 | (let ((inhibit-point-motion-hooks t) |
| 2524 | (mail-parse-charset gnus-newsgroup-charset) |
| 2525 | (mail-parse-ignored-charsets |
| 2526 | (save-excursion (condition-case nil |
| 2527 | (set-buffer gnus-summary-buffer) |
| 2528 | (error)) |
| 2529 | gnus-newsgroup-ignored-charsets)) |
| 2530 | (inhibit-read-only t) |
| 2531 | end start) |
| 2532 | (goto-char (point-min)) |
| 2533 | (when (search-forward "\n\n" nil 'move) |
| 2534 | (forward-line -1)) |
| 2535 | (setq end (point)) |
| 2536 | (while (not (bobp)) |
| 2537 | (while (progn |
| 2538 | (forward-line -1) |
| 2539 | (and (not (bobp)) |
| 2540 | (memq (char-after) '(?\t ? ))))) |
| 2541 | (setq start (point)) |
| 2542 | (if (looking-at "\ |
| 2543 | \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\ |
| 2544 | \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):") |
| 2545 | (funcall gnus-decode-address-function start end) |
| 2546 | (funcall gnus-decode-header-function start end)) |
| 2547 | (goto-char (setq end start))))) |
| 2548 | |
| 2549 | (defun article-decode-group-name () |
| 2550 | "Decode group names in Newsgroups, Followup-To and Xref headers." |
| 2551 | (let ((inhibit-point-motion-hooks t) |
| 2552 | (inhibit-read-only t) |
| 2553 | (method (gnus-find-method-for-group gnus-newsgroup-name)) |
| 2554 | regexp) |
| 2555 | (when (and (or gnus-group-name-charset-method-alist |
| 2556 | gnus-group-name-charset-group-alist) |
| 2557 | (gnus-buffer-live-p gnus-original-article-buffer)) |
| 2558 | (save-restriction |
| 2559 | (article-narrow-to-head) |
| 2560 | (dolist (header '("Newsgroups" "Followup-To" "Xref")) |
| 2561 | (with-current-buffer gnus-original-article-buffer |
| 2562 | (goto-char (point-min))) |
| 2563 | (setq regexp (concat "^" header |
| 2564 | ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n")) |
| 2565 | (while (re-search-forward regexp nil t) |
| 2566 | (replace-match (save-match-data |
| 2567 | (gnus-decode-newsgroups |
| 2568 | ;; XXX how to use data in article buffer? |
| 2569 | (with-current-buffer gnus-original-article-buffer |
| 2570 | (re-search-forward regexp nil t) |
| 2571 | (match-string 1)) |
| 2572 | gnus-newsgroup-name method)) |
| 2573 | t t nil 1)) |
| 2574 | (goto-char (point-min))))))) |
| 2575 | |
| 2576 | (autoload 'idna-to-unicode "idna") |
| 2577 | |
| 2578 | (defun article-decode-idna-rhs () |
| 2579 | "Decode IDNA strings in RHS in various headers in current buffer. |
| 2580 | The following headers are decoded: From:, To:, Cc:, Reply-To:, |
| 2581 | Mail-Reply-To: and Mail-Followup-To:." |
| 2582 | (when gnus-use-idna |
| 2583 | (save-restriction |
| 2584 | (let ((inhibit-point-motion-hooks t) |
| 2585 | (inhibit-read-only t)) |
| 2586 | (article-narrow-to-head) |
| 2587 | (goto-char (point-min)) |
| 2588 | (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t) |
| 2589 | (let (ace unicode) |
| 2590 | (when (save-match-data |
| 2591 | (and (setq ace (match-string 1)) |
| 2592 | (save-excursion |
| 2593 | (and (re-search-backward "^[^ \t]" nil t) |
| 2594 | (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To"))) |
| 2595 | (setq unicode (idna-to-unicode ace)))) |
| 2596 | (unless (string= ace unicode) |
| 2597 | (replace-match unicode nil nil nil 1))))))))) |
| 2598 | |
| 2599 | (defun article-de-quoted-unreadable (&optional force read-charset) |
| 2600 | "Translate a quoted-printable-encoded article. |
| 2601 | If FORCE, decode the article whether it is marked as quoted-printable |
| 2602 | or not. |
| 2603 | If READ-CHARSET, ask for a coding system." |
| 2604 | (interactive (list 'force current-prefix-arg)) |
| 2605 | (save-excursion |
| 2606 | (let ((inhibit-read-only t) type charset) |
| 2607 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
| 2608 | (with-current-buffer gnus-original-article-buffer |
| 2609 | (setq type |
| 2610 | (gnus-fetch-field "content-transfer-encoding")) |
| 2611 | (let* ((ct (gnus-fetch-field "content-type")) |
| 2612 | (ctl (and ct (mail-header-parse-content-type ct)))) |
| 2613 | (setq charset (and ctl |
| 2614 | (mail-content-type-get ctl 'charset))) |
| 2615 | (if (stringp charset) |
| 2616 | (setq charset (intern (downcase charset))))))) |
| 2617 | (if read-charset |
| 2618 | (setq charset (mm-read-coding-system "Charset: " charset))) |
| 2619 | (unless charset |
| 2620 | (setq charset gnus-newsgroup-charset)) |
| 2621 | (when (or force |
| 2622 | (and type (let ((case-fold-search t)) |
| 2623 | (string-match "quoted-printable" type)))) |
| 2624 | (article-goto-body) |
| 2625 | (quoted-printable-decode-region |
| 2626 | (point) (point-max) (mm-charset-to-coding-system charset)))))) |
| 2627 | |
| 2628 | (defun article-de-base64-unreadable (&optional force read-charset) |
| 2629 | "Translate a base64 article. |
| 2630 | If FORCE, decode the article whether it is marked as base64 not. |
| 2631 | If READ-CHARSET, ask for a coding system." |
| 2632 | (interactive (list 'force current-prefix-arg)) |
| 2633 | (save-excursion |
| 2634 | (let ((inhibit-read-only t) type charset) |
| 2635 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
| 2636 | (with-current-buffer gnus-original-article-buffer |
| 2637 | (setq type |
| 2638 | (gnus-fetch-field "content-transfer-encoding")) |
| 2639 | (let* ((ct (gnus-fetch-field "content-type")) |
| 2640 | (ctl (and ct (mail-header-parse-content-type ct)))) |
| 2641 | (setq charset (and ctl |
| 2642 | (mail-content-type-get ctl 'charset))) |
| 2643 | (if (stringp charset) |
| 2644 | (setq charset (intern (downcase charset))))))) |
| 2645 | (if read-charset |
| 2646 | (setq charset (mm-read-coding-system "Charset: " charset))) |
| 2647 | (unless charset |
| 2648 | (setq charset gnus-newsgroup-charset)) |
| 2649 | (when (or force |
| 2650 | (and type (let ((case-fold-search t)) |
| 2651 | (string-match "base64" type)))) |
| 2652 | (article-goto-body) |
| 2653 | (save-restriction |
| 2654 | (narrow-to-region (point) (point-max)) |
| 2655 | (base64-decode-region (point-min) (point-max)) |
| 2656 | (mm-decode-coding-region |
| 2657 | (point-min) (point-max) (mm-charset-to-coding-system charset))))))) |
| 2658 | |
| 2659 | (eval-when-compile |
| 2660 | (require 'rfc1843)) |
| 2661 | |
| 2662 | (defun article-decode-HZ () |
| 2663 | "Translate a HZ-encoded article." |
| 2664 | (interactive) |
| 2665 | (require 'rfc1843) |
| 2666 | (save-excursion |
| 2667 | (let ((inhibit-read-only t)) |
| 2668 | (rfc1843-decode-region (point-min) (point-max))))) |
| 2669 | |
| 2670 | (defun article-unsplit-urls () |
| 2671 | "Remove the newlines that some other mailers insert into URLs." |
| 2672 | (interactive) |
| 2673 | (save-excursion |
| 2674 | (let ((inhibit-read-only t)) |
| 2675 | (goto-char (point-min)) |
| 2676 | (while (re-search-forward |
| 2677 | "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t) |
| 2678 | (replace-match "\\1\\3" t))) |
| 2679 | (when (interactive-p) |
| 2680 | (gnus-treat-article nil)))) |
| 2681 | |
| 2682 | |
| 2683 | (defun article-wash-html (&optional read-charset) |
| 2684 | "Format an HTML article. |
| 2685 | If READ-CHARSET, ask for a coding system. If it is a number, the |
| 2686 | charset defined in `gnus-summary-show-article-charset-alist' is used." |
| 2687 | (interactive "P") |
| 2688 | (save-excursion |
| 2689 | (let ((inhibit-read-only t) |
| 2690 | charset) |
| 2691 | (if read-charset |
| 2692 | (if (or (and (numberp read-charset) |
| 2693 | (setq charset |
| 2694 | (cdr |
| 2695 | (assq read-charset |
| 2696 | gnus-summary-show-article-charset-alist)))) |
| 2697 | (setq charset (mm-read-coding-system "Charset: "))) |
| 2698 | (let ((gnus-summary-show-article-charset-alist |
| 2699 | (list (cons 1 charset)))) |
| 2700 | (with-current-buffer gnus-summary-buffer |
| 2701 | (gnus-summary-show-article 1))) |
| 2702 | (error "No charset is given")) |
| 2703 | (when (gnus-buffer-live-p gnus-original-article-buffer) |
| 2704 | (with-current-buffer gnus-original-article-buffer |
| 2705 | (let* ((ct (gnus-fetch-field "content-type")) |
| 2706 | (ctl (and ct (mail-header-parse-content-type ct)))) |
| 2707 | (setq charset (and ctl |
| 2708 | (mail-content-type-get ctl 'charset))) |
| 2709 | (when (stringp charset) |
| 2710 | (setq charset (intern (downcase charset))))))) |
| 2711 | (unless charset |
| 2712 | (setq charset gnus-newsgroup-charset))) |
| 2713 | (article-goto-body) |
| 2714 | (save-window-excursion |
| 2715 | (save-restriction |
| 2716 | (narrow-to-region (point) (point-max)) |
| 2717 | (let* ((func (or gnus-article-wash-function mm-text-html-renderer)) |
| 2718 | (entry (assq func mm-text-html-washer-alist))) |
| 2719 | (when entry |
| 2720 | (setq func (cdr entry))) |
| 2721 | (cond |
| 2722 | ((functionp func) |
| 2723 | (funcall func)) |
| 2724 | (t |
| 2725 | (apply (car func) (cdr func)))))))))) |
| 2726 | |
| 2727 | ;; External. |
| 2728 | (declare-function w3-region "ext:w3-display" (st nd)) |
| 2729 | |
| 2730 | (defun gnus-article-wash-html-with-w3 () |
| 2731 | "Wash the current buffer with w3." |
| 2732 | (mm-setup-w3) |
| 2733 | (let ((w3-strict-width (window-width)) |
| 2734 | (url-standalone-mode t) |
| 2735 | (url-gateway-unplugged t) |
| 2736 | (w3-honor-stylesheets nil)) |
| 2737 | (condition-case () |
| 2738 | (w3-region (point-min) (point-max)) |
| 2739 | (error)))) |
| 2740 | |
| 2741 | ;; External. |
| 2742 | (declare-function w3m-region "ext:w3m" (start end &optional url charset)) |
| 2743 | |
| 2744 | (defun gnus-article-wash-html-with-w3m () |
| 2745 | "Wash the current buffer with emacs-w3m." |
| 2746 | (mm-setup-w3m) |
| 2747 | (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp) |
| 2748 | w3m-force-redisplay) |
| 2749 | (w3m-region (point-min) (point-max))) |
| 2750 | ;; Put the mark meaning this part was rendered by emacs-w3m. |
| 2751 | (put-text-property (point-min) (point-max) 'mm-inline-text-html-with-w3m t) |
| 2752 | (when (and mm-inline-text-html-with-w3m-keymap |
| 2753 | (boundp 'w3m-minor-mode-map) |
| 2754 | w3m-minor-mode-map) |
| 2755 | (if (and (boundp 'w3m-link-map) |
| 2756 | w3m-link-map) |
| 2757 | (let* ((start (point-min)) |
| 2758 | (end (point-max)) |
| 2759 | (on (get-text-property start 'w3m-href-anchor)) |
| 2760 | (map (copy-keymap w3m-link-map)) |
| 2761 | next) |
| 2762 | (set-keymap-parent map w3m-minor-mode-map) |
| 2763 | (while (< start end) |
| 2764 | (if on |
| 2765 | (progn |
| 2766 | (setq next (or (text-property-any start end |
| 2767 | 'w3m-href-anchor nil) |
| 2768 | end)) |
| 2769 | (put-text-property start next 'keymap map)) |
| 2770 | (setq next (or (text-property-not-all start end |
| 2771 | 'w3m-href-anchor nil) |
| 2772 | end)) |
| 2773 | (put-text-property start next 'keymap w3m-minor-mode-map)) |
| 2774 | (setq start next |
| 2775 | on (not on)))) |
| 2776 | (put-text-property (point-min) (point-max) 'keymap w3m-minor-mode-map)))) |
| 2777 | |
| 2778 | (defvar charset) ;; Bound by `article-wash-html'. |
| 2779 | |
| 2780 | (defun gnus-article-wash-html-with-w3m-standalone () |
| 2781 | "Wash the current buffer with w3m." |
| 2782 | (if (mm-w3m-standalone-supports-m17n-p) |
| 2783 | (progn |
| 2784 | (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'. |
| 2785 | ;; The default. |
| 2786 | (setq charset 'iso-8859-1)) |
| 2787 | (let ((coding-system-for-write charset) |
| 2788 | (coding-system-for-read charset)) |
| 2789 | (call-process-region |
| 2790 | (point-min) (point-max) |
| 2791 | "w3m" t t nil "-dump" "-T" "text/html" |
| 2792 | "-I" (symbol-name charset) "-O" (symbol-name charset)))) |
| 2793 | (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html"))) |
| 2794 | |
| 2795 | (defvar gnus-article-browse-html-temp-list nil |
| 2796 | "List of temporary files created by `gnus-article-browse-html-parts'. |
| 2797 | Internal variable.") |
| 2798 | |
| 2799 | (defcustom gnus-article-browse-delete-temp 'ask |
| 2800 | "What to do with temporary files from `gnus-article-browse-html-parts'. |
| 2801 | If nil, don't delete temporary files. If it is t, delete them on |
| 2802 | exit from the summary buffer. If it is the symbol `file', query |
| 2803 | on each file, if it is `ask' ask once when exiting from the |
| 2804 | summary buffer." |
| 2805 | :group 'gnus-article |
| 2806 | :version "23.1" ;; No Gnus |
| 2807 | :type '(choice (const :tag "Don't delete" nil) |
| 2808 | (const :tag "Don't ask" t) |
| 2809 | (const :tag "Ask" ask) |
| 2810 | (const :tag "Ask for each file" file))) |
| 2811 | |
| 2812 | ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list. |
| 2813 | |
| 2814 | (defun gnus-article-browse-delete-temp-files (&optional how) |
| 2815 | "Delete temp-files created by `gnus-article-browse-html-parts'." |
| 2816 | (when (and gnus-article-browse-html-temp-list |
| 2817 | (progn |
| 2818 | (or how (setq how gnus-article-browse-delete-temp)) |
| 2819 | (if (eq how 'ask) |
| 2820 | (let ((files (length gnus-article-browse-html-temp-list))) |
| 2821 | (gnus-y-or-n-p (format |
| 2822 | "Delete all %s temporary HTML file%s? " |
| 2823 | files |
| 2824 | (if (> files 1) "s" "")))) |
| 2825 | how))) |
| 2826 | (dolist (file gnus-article-browse-html-temp-list) |
| 2827 | (cond ((file-directory-p file) |
| 2828 | (when (or (not (eq how 'file)) |
| 2829 | (gnus-y-or-n-p |
| 2830 | (format |
| 2831 | "Delete temporary HTML file(s) in directory `%s'? " |
| 2832 | (file-name-as-directory file)))) |
| 2833 | (gnus-delete-directory file))) |
| 2834 | ((file-exists-p file) |
| 2835 | (when (or (not (eq how 'file)) |
| 2836 | (gnus-y-or-n-p |
| 2837 | (format "Delete temporary HTML file `%s'? " file))) |
| 2838 | (delete-file file))))) |
| 2839 | ;; Also remove file from the list when not deleted or if file doesn't |
| 2840 | ;; exist anymore. |
| 2841 | (setq gnus-article-browse-html-temp-list nil)) |
| 2842 | gnus-article-browse-html-temp-list) |
| 2843 | |
| 2844 | (defun gnus-article-browse-html-save-cid-content (cid handles directory) |
| 2845 | "Find CID content in HANDLES and save it in a file in DIRECTORY. |
| 2846 | Return file name." |
| 2847 | (save-match-data |
| 2848 | (let (file type) |
| 2849 | (catch 'found |
| 2850 | (dolist (handle handles) |
| 2851 | (cond |
| 2852 | ((not (listp handle))) |
| 2853 | ((equal (mm-handle-media-supertype handle) "multipart") |
| 2854 | (when (setq file (gnus-article-browse-html-save-cid-content |
| 2855 | cid handle directory)) |
| 2856 | (throw 'found file))) |
| 2857 | ((equal (concat "<" cid ">") (mm-handle-id handle)) |
| 2858 | (setq file |
| 2859 | (expand-file-name |
| 2860 | (or (mail-content-type-get |
| 2861 | (mm-handle-disposition handle) 'filename) |
| 2862 | (mail-content-type-get |
| 2863 | (setq type (mm-handle-type handle)) 'name) |
| 2864 | (concat |
| 2865 | (make-temp-name "cid") |
| 2866 | (car (rassoc (car type) mailcap-mime-extensions)))) |
| 2867 | directory)) |
| 2868 | (mm-save-part-to-file handle file) |
| 2869 | (throw 'found file)))))))) |
| 2870 | |
| 2871 | (defun gnus-article-browse-html-parts (list &optional header) |
| 2872 | "View all \"text/html\" parts from LIST. |
| 2873 | Recurse into multiparts. The optional HEADER that should be a decoded |
| 2874 | message header will be added to the bodies of the \"text/html\" parts." |
| 2875 | ;; Internal function used by `gnus-article-browse-html-article'. |
| 2876 | (let (type file charset content cid-dir tmp-file showed) |
| 2877 | ;; Find and show the html-parts. |
| 2878 | (dolist (handle list) |
| 2879 | ;; If HTML, show it: |
| 2880 | (cond ((not (listp handle))) |
| 2881 | ((or (equal (car (setq type (mm-handle-type handle))) "text/html") |
| 2882 | (and (equal (car type) "message/external-body") |
| 2883 | (or header |
| 2884 | (setq file (or (mail-content-type-get type 'name) |
| 2885 | (mail-content-type-get |
| 2886 | (mm-handle-disposition handle) |
| 2887 | 'filename)))) |
| 2888 | (or (mm-handle-cache handle) |
| 2889 | (condition-case code |
| 2890 | (progn (mm-extern-cache-contents handle) t) |
| 2891 | (error |
| 2892 | (gnus-message 3 "%s" (error-message-string code)) |
| 2893 | (when (>= gnus-verbose 3) (sit-for 2)) |
| 2894 | nil))) |
| 2895 | (progn |
| 2896 | (setq handle (mm-handle-cache handle) |
| 2897 | type (mm-handle-type handle)) |
| 2898 | (equal (car type) "text/html")))) |
| 2899 | (setq charset (mail-content-type-get type 'charset) |
| 2900 | content (mm-get-part handle)) |
| 2901 | (with-temp-buffer |
| 2902 | (if (eq charset 'gnus-decoded) |
| 2903 | (mm-enable-multibyte) |
| 2904 | (mm-disable-multibyte)) |
| 2905 | (insert content) |
| 2906 | ;; resolve cid contents |
| 2907 | (let ((case-fold-search t) |
| 2908 | cid-file) |
| 2909 | (goto-char (point-min)) |
| 2910 | (while (re-search-forward "\ |
| 2911 | <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\"" |
| 2912 | nil t) |
| 2913 | (unless cid-dir |
| 2914 | (setq cid-dir (mm-make-temp-file "cid" t)) |
| 2915 | (add-to-list 'gnus-article-browse-html-temp-list cid-dir)) |
| 2916 | (setq file nil |
| 2917 | content nil) |
| 2918 | (when (setq cid-file |
| 2919 | (gnus-article-browse-html-save-cid-content |
| 2920 | (match-string 2) |
| 2921 | (with-current-buffer gnus-article-buffer |
| 2922 | gnus-article-mime-handles) |
| 2923 | cid-dir)) |
| 2924 | (replace-match (concat "file://" cid-file) |
| 2925 | nil nil nil 1)))) |
| 2926 | (unless content (setq content (buffer-string)))) |
| 2927 | (when (or charset header (not file)) |
| 2928 | (setq tmp-file (mm-make-temp-file |
| 2929 | ;; Do we need to care for 8.3 filenames? |
| 2930 | "mm-" nil ".html"))) |
| 2931 | ;; Add a meta html tag to specify charset and a header. |
| 2932 | (cond |
| 2933 | (header |
| 2934 | (let (title eheader body hcharset coding force-charset) |
| 2935 | (with-temp-buffer |
| 2936 | (mm-enable-multibyte) |
| 2937 | (setq case-fold-search t) |
| 2938 | (insert header "\n") |
| 2939 | (setq title (message-fetch-field "subject")) |
| 2940 | (goto-char (point-min)) |
| 2941 | (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t) |
| 2942 | (replace-match (cond ((match-beginning 1) "<") |
| 2943 | ((match-beginning 2) ">") |
| 2944 | (t "&")))) |
| 2945 | (goto-char (point-min)) |
| 2946 | (insert "<pre>\n") |
| 2947 | (goto-char (point-max)) |
| 2948 | (insert "</pre>\n<hr>\n") |
| 2949 | ;; We have to examine charset one by one since |
| 2950 | ;; charset specified in parts might be different. |
| 2951 | (if (eq charset 'gnus-decoded) |
| 2952 | (setq charset 'utf-8 |
| 2953 | eheader (mm-encode-coding-string (buffer-string) |
| 2954 | charset) |
| 2955 | title (when title |
| 2956 | (mm-encode-coding-string title charset)) |
| 2957 | body (mm-encode-coding-string content charset) |
| 2958 | force-charset t) |
| 2959 | (setq hcharset (mm-find-mime-charset-region (point-min) |
| 2960 | (point-max))) |
| 2961 | (cond ((= (length hcharset) 1) |
| 2962 | (setq hcharset (car hcharset) |
| 2963 | coding (mm-charset-to-coding-system |
| 2964 | hcharset))) |
| 2965 | ((> (length hcharset) 1) |
| 2966 | (setq hcharset 'utf-8 |
| 2967 | coding hcharset))) |
| 2968 | (if coding |
| 2969 | (if charset |
| 2970 | (progn |
| 2971 | (setq body |
| 2972 | (mm-charset-to-coding-system charset)) |
| 2973 | (if (eq coding body) |
| 2974 | (setq eheader (mm-encode-coding-string |
| 2975 | (buffer-string) coding) |
| 2976 | title (when title |
| 2977 | (mm-encode-coding-string |
| 2978 | title coding)) |
| 2979 | body content) |
| 2980 | (setq charset 'utf-8 |
| 2981 | eheader (mm-encode-coding-string |
| 2982 | (buffer-string) charset) |
| 2983 | title (when title |
| 2984 | (mm-encode-coding-string |
| 2985 | title charset)) |
| 2986 | body (mm-encode-coding-string |
| 2987 | (mm-decode-coding-string |
| 2988 | content body) |
| 2989 | charset) |
| 2990 | force-charset t))) |
| 2991 | (setq charset hcharset |
| 2992 | eheader (mm-encode-coding-string |
| 2993 | (buffer-string) coding) |
| 2994 | title (when title |
| 2995 | (mm-encode-coding-string |
| 2996 | title coding)) |
| 2997 | body content)) |
| 2998 | (setq eheader (mm-string-as-unibyte (buffer-string)) |
| 2999 | body content))) |
| 3000 | (erase-buffer) |
| 3001 | (mm-disable-multibyte) |
| 3002 | (insert body) |
| 3003 | (when charset |
| 3004 | (mm-add-meta-html-tag handle charset force-charset)) |
| 3005 | (when title |
| 3006 | (goto-char (point-min)) |
| 3007 | (unless (search-forward "<title>" nil t) |
| 3008 | (re-search-forward "<head>\\s-*" nil t) |
| 3009 | (insert "<title>" title "</title>\n"))) |
| 3010 | (goto-char (point-min)) |
| 3011 | (or (re-search-forward |
| 3012 | "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t) |
| 3013 | (re-search-forward |
| 3014 | "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)) |
| 3015 | (insert eheader) |
| 3016 | (mm-write-region (point-min) (point-max) |
| 3017 | tmp-file nil nil nil 'binary t)))) |
| 3018 | (charset |
| 3019 | (mm-with-unibyte-buffer |
| 3020 | (insert (if (eq charset 'gnus-decoded) |
| 3021 | (mm-encode-coding-string content |
| 3022 | (setq charset 'utf-8)) |
| 3023 | content)) |
| 3024 | (if (or (mm-add-meta-html-tag handle charset) |
| 3025 | (not file)) |
| 3026 | (mm-write-region (point-min) (point-max) |
| 3027 | tmp-file nil nil nil 'binary t) |
| 3028 | (setq tmp-file nil)))) |
| 3029 | (tmp-file |
| 3030 | (mm-save-part-to-file handle tmp-file))) |
| 3031 | (when tmp-file |
| 3032 | (add-to-list 'gnus-article-browse-html-temp-list tmp-file)) |
| 3033 | (add-hook 'gnus-summary-prepare-exit-hook |
| 3034 | 'gnus-article-browse-delete-temp-files) |
| 3035 | (add-hook 'gnus-exit-gnus-hook |
| 3036 | (lambda () |
| 3037 | (gnus-article-browse-delete-temp-files t))) |
| 3038 | ;; FIXME: Warn if there's an <img> tag? |
| 3039 | (browse-url-of-file (or tmp-file (expand-file-name file))) |
| 3040 | (setq showed t)) |
| 3041 | ;; If multipart, recurse |
| 3042 | ((equal (mm-handle-media-supertype handle) "multipart") |
| 3043 | (when (gnus-article-browse-html-parts handle header) |
| 3044 | (setq showed t))) |
| 3045 | ((equal (mm-handle-media-type handle) "message/rfc822") |
| 3046 | (mm-with-multibyte-buffer |
| 3047 | (mm-insert-part handle) |
| 3048 | (setq handle (mm-dissect-buffer t t)) |
| 3049 | (when (and (bufferp (car handle)) |
| 3050 | (stringp (car (mm-handle-type handle)))) |
| 3051 | (setq handle (list handle))) |
| 3052 | (when header |
| 3053 | (article-decode-encoded-words) |
| 3054 | (let ((gnus-visible-headers |
| 3055 | (or (get 'gnus-visible-headers 'standard-value) |
| 3056 | gnus-visible-headers))) |
| 3057 | (article-hide-headers)) |
| 3058 | (goto-char (point-min)) |
| 3059 | (search-forward "\n\n" nil 'move) |
| 3060 | (skip-chars-backward "\t\n ") |
| 3061 | (setq header (buffer-substring (point-min) (point))))) |
| 3062 | (when (prog1 |
| 3063 | (gnus-article-browse-html-parts handle header) |
| 3064 | (mm-destroy-parts handle)) |
| 3065 | (setq showed t))))) |
| 3066 | showed)) |
| 3067 | |
| 3068 | (defun gnus-article-browse-html-article (&optional arg) |
| 3069 | "View \"text/html\" parts of the current article with a WWW browser. |
| 3070 | Inline images embedded in a message using the cid scheme, as they are |
| 3071 | generally considered to be safe, will be processed properly. |
| 3072 | The message header is added to the beginning of every html part unless |
| 3073 | the prefix argument ARG is given. |
| 3074 | |
| 3075 | Warning: Spammers use links to images (using the http scheme) in HTML |
| 3076 | articles to verify whether you have read the message. As |
| 3077 | `gnus-article-browse-html-article' passes the HTML content to the |
| 3078 | browser without eliminating these \"web bugs\" you should only |
| 3079 | use it for mails from trusted senders. |
| 3080 | |
| 3081 | If you always want to display HTML parts in the browser, set |
| 3082 | `mm-text-html-renderer' to nil. |
| 3083 | |
| 3084 | This command creates temporary files to pass HTML contents including |
| 3085 | images if any to the browser, and deletes them when exiting the group |
| 3086 | \(if you want)." |
| 3087 | ;; Cf. `mm-w3m-safe-url-regexp' |
| 3088 | (interactive "P") |
| 3089 | (if arg |
| 3090 | (gnus-summary-show-article) |
| 3091 | (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value) |
| 3092 | gnus-visible-headers)) |
| 3093 | ;; As we insert a <hr>, there's no need for the body boundary. |
| 3094 | (gnus-treat-body-boundary nil)) |
| 3095 | (gnus-summary-show-article))) |
| 3096 | (with-current-buffer gnus-article-buffer |
| 3097 | (let ((header (unless arg |
| 3098 | (save-restriction |
| 3099 | (widen) |
| 3100 | (buffer-substring-no-properties |
| 3101 | (goto-char (point-min)) |
| 3102 | (if (search-forward "\n\n" nil t) |
| 3103 | (match-beginning 0) |
| 3104 | (goto-char (point-max)) |
| 3105 | (skip-chars-backward "\t\n ") |
| 3106 | (point)))))) |
| 3107 | parts) |
| 3108 | (set-buffer gnus-original-article-buffer) |
| 3109 | (setq parts (mm-dissect-buffer t t)) |
| 3110 | ;; If singlepart, enforce a list. |
| 3111 | (when (and (bufferp (car parts)) |
| 3112 | (stringp (car (mm-handle-type parts)))) |
| 3113 | (setq parts (list parts))) |
| 3114 | ;; Process the list |
| 3115 | (unless (gnus-article-browse-html-parts parts header) |
| 3116 | (gnus-error 3 "Mail doesn't contain a \"text/html\" part!")) |
| 3117 | (mm-destroy-parts parts) |
| 3118 | (unless arg |
| 3119 | (gnus-summary-show-article))))) |
| 3120 | |
| 3121 | (defun article-hide-list-identifiers () |
| 3122 | "Remove list identifies from the Subject header. |
| 3123 | The `gnus-list-identifiers' variable specifies what to do." |
| 3124 | (interactive) |
| 3125 | (let ((inhibit-point-motion-hooks t) |
| 3126 | (regexp (if (consp gnus-list-identifiers) |
| 3127 | (mapconcat 'identity gnus-list-identifiers " *\\|") |
| 3128 | gnus-list-identifiers)) |
| 3129 | (inhibit-read-only t)) |
| 3130 | (when regexp |
| 3131 | (save-excursion |
| 3132 | (save-restriction |
| 3133 | (article-narrow-to-head) |
| 3134 | (goto-char (point-min)) |
| 3135 | (while (re-search-forward |
| 3136 | (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)") |
| 3137 | nil t) |
| 3138 | (delete-region (match-beginning 2) (match-end 0)) |
| 3139 | (beginning-of-line)) |
| 3140 | (when (re-search-forward |
| 3141 | "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t) |
| 3142 | (delete-region (match-beginning 1) (match-end 1)))))))) |
| 3143 | |
| 3144 | (defun article-hide-pem (&optional arg) |
| 3145 | "Toggle hiding of any PEM headers and signatures in the current article. |
| 3146 | If given a negative prefix, always show; if given a positive prefix, |
| 3147 | always hide." |
| 3148 | (interactive (gnus-article-hidden-arg)) |
| 3149 | (unless (gnus-article-check-hidden-text 'pem arg) |
| 3150 | (save-excursion |
| 3151 | (let ((inhibit-read-only t) end) |
| 3152 | (goto-char (point-min)) |
| 3153 | ;; Hide the horrendously ugly "header". |
| 3154 | (when (and (search-forward |
| 3155 | "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" |
| 3156 | nil t) |
| 3157 | (setq end (1+ (match-beginning 0)))) |
| 3158 | (gnus-add-wash-type 'pem) |
| 3159 | (gnus-article-hide-text-type |
| 3160 | end |
| 3161 | (if (search-forward "\n\n" nil t) |
| 3162 | (match-end 0) |
| 3163 | (point-max)) |
| 3164 | 'pem) |
| 3165 | ;; Hide the trailer as well |
| 3166 | (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" |
| 3167 | nil t) |
| 3168 | (gnus-article-hide-text-type |
| 3169 | (match-beginning 0) (match-end 0) 'pem))))))) |
| 3170 | |
| 3171 | (defun article-strip-banner () |
| 3172 | "Strip the banners specified by the `banner' group parameter and by |
| 3173 | `gnus-article-address-banner-alist'." |
| 3174 | (interactive) |
| 3175 | (save-excursion |
| 3176 | (save-restriction |
| 3177 | (let ((inhibit-point-motion-hooks t)) |
| 3178 | (when (gnus-parameter-banner gnus-newsgroup-name) |
| 3179 | (article-really-strip-banner |
| 3180 | (gnus-parameter-banner gnus-newsgroup-name))) |
| 3181 | (when gnus-article-address-banner-alist |
| 3182 | ;; Note that the From header is decoded here, so it is |
| 3183 | ;; required that the *-extract-address-components function |
| 3184 | ;; supports non-ASCII text. |
| 3185 | (let ((from (save-restriction |
| 3186 | (widen) |
| 3187 | (article-narrow-to-head) |
| 3188 | (mail-fetch-field "from")))) |
| 3189 | (when (and from |
| 3190 | (setq from |
| 3191 | (cadr (funcall gnus-extract-address-components |
| 3192 | from)))) |
| 3193 | (catch 'found |
| 3194 | (dolist (pair gnus-article-address-banner-alist) |
| 3195 | (when (string-match (car pair) from) |
| 3196 | (throw 'found |
| 3197 | (article-really-strip-banner (cdr pair))))))))))))) |
| 3198 | |
| 3199 | (defun article-really-strip-banner (banner) |
| 3200 | "Strip the banner specified by the argument." |
| 3201 | (save-excursion |
| 3202 | (save-restriction |
| 3203 | (let ((inhibit-point-motion-hooks t) |
| 3204 | (gnus-signature-limit nil) |
| 3205 | (inhibit-read-only t)) |
| 3206 | (article-goto-body) |
| 3207 | (cond |
| 3208 | ((eq banner 'signature) |
| 3209 | (when (gnus-article-narrow-to-signature) |
| 3210 | (widen) |
| 3211 | (forward-line -1) |
| 3212 | (delete-region (point) (point-max)))) |
| 3213 | ((symbolp banner) |
| 3214 | (if (setq banner (cdr (assq banner gnus-article-banner-alist))) |
| 3215 | (while (re-search-forward banner nil t) |
| 3216 | (delete-region (match-beginning 0) (match-end 0))))) |
| 3217 | ((stringp banner) |
| 3218 | (while (re-search-forward banner nil t) |
| 3219 | (delete-region (match-beginning 0) (match-end 0))))))))) |
| 3220 | |
| 3221 | (defun article-babel () |
| 3222 | "Translate article using an online translation service." |
| 3223 | (interactive) |
| 3224 | (require 'babel) |
| 3225 | (gnus-with-article-buffer |
| 3226 | (when (article-goto-body) |
| 3227 | (let* ((start (point)) |
| 3228 | (end (point-max)) |
| 3229 | (orig (buffer-substring start end)) |
| 3230 | (trans (babel-as-string orig))) |
| 3231 | (save-restriction |
| 3232 | (narrow-to-region start end) |
| 3233 | (delete-region start end) |
| 3234 | (insert trans)))))) |
| 3235 | |
| 3236 | (defun article-hide-signature (&optional arg) |
| 3237 | "Hide the signature in the current article. |
| 3238 | If given a negative prefix, always show; if given a positive prefix, |
| 3239 | always hide." |
| 3240 | (interactive (gnus-article-hidden-arg)) |
| 3241 | (unless (gnus-article-check-hidden-text 'signature arg) |
| 3242 | (save-excursion |
| 3243 | (save-restriction |
| 3244 | (let ((inhibit-read-only t)) |
| 3245 | (when (gnus-article-narrow-to-signature) |
| 3246 | (gnus-article-hide-text-type |
| 3247 | (point-min) (point-max) 'signature)))))) |
| 3248 | (gnus-set-mode-line 'article)) |
| 3249 | |
| 3250 | (defun article-strip-headers-in-body () |
| 3251 | "Strip offensive headers from bodies." |
| 3252 | (interactive) |
| 3253 | (save-excursion |
| 3254 | (article-goto-body) |
| 3255 | (let ((case-fold-search t)) |
| 3256 | (when (looking-at "x-no-archive:") |
| 3257 | (gnus-delete-line))))) |
| 3258 | |
| 3259 | (defun article-strip-leading-blank-lines () |
| 3260 | "Remove all blank lines from the beginning of the article." |
| 3261 | (interactive) |
| 3262 | (save-excursion |
| 3263 | (let ((inhibit-point-motion-hooks t) |
| 3264 | (inhibit-read-only t)) |
| 3265 | (when (article-goto-body) |
| 3266 | (while (and (not (eobp)) |
| 3267 | (looking-at "[ \t]*$")) |
| 3268 | (gnus-delete-line)))))) |
| 3269 | |
| 3270 | (defun article-narrow-to-head () |
| 3271 | "Narrow the buffer to the head of the message. |
| 3272 | Point is left at the beginning of the narrowed-to region." |
| 3273 | (narrow-to-region |
| 3274 | (goto-char (point-min)) |
| 3275 | (if (search-forward "\n\n" nil 1) |
| 3276 | (1- (point)) |
| 3277 | (point-max))) |
| 3278 | (goto-char (point-min))) |
| 3279 | |
| 3280 | (defun article-goto-body () |
| 3281 | "Place point at the start of the body." |
| 3282 | (goto-char (point-min)) |
| 3283 | (cond |
| 3284 | ;; This variable is only bound when dealing with separate |
| 3285 | ;; MIME body parts. |
| 3286 | (article-goto-body-goes-to-point-min-p |
| 3287 | t) |
| 3288 | ((search-forward "\n\n" nil t) |
| 3289 | t) |
| 3290 | (t |
| 3291 | (goto-char (point-max)) |
| 3292 | nil))) |
| 3293 | |
| 3294 | (defun article-strip-multiple-blank-lines () |
| 3295 | "Replace consecutive blank lines with one empty line." |
| 3296 | (interactive) |
| 3297 | (save-excursion |
| 3298 | (let ((inhibit-point-motion-hooks t) |
| 3299 | (inhibit-read-only t)) |
| 3300 | ;; First make all blank lines empty. |
| 3301 | (article-goto-body) |
| 3302 | (while (re-search-forward "^[ \t]+$" nil t) |
| 3303 | (unless (gnus-annotation-in-region-p |
| 3304 | (match-beginning 0) (match-end 0)) |
| 3305 | (replace-match "" nil t))) |
| 3306 | ;; Then replace multiple empty lines with a single empty line. |
| 3307 | (article-goto-body) |
| 3308 | (while (re-search-forward "\n\n\\(\n+\\)" nil t) |
| 3309 | (unless (gnus-annotation-in-region-p |
| 3310 | (match-beginning 0) (match-end 0)) |
| 3311 | (delete-region (match-beginning 1) (match-end 1))))))) |
| 3312 | |
| 3313 | (defun article-strip-leading-space () |
| 3314 | "Remove all white space from the beginning of the lines in the article." |
| 3315 | (interactive) |
| 3316 | (save-excursion |
| 3317 | (let ((inhibit-point-motion-hooks t) |
| 3318 | (inhibit-read-only t)) |
| 3319 | (article-goto-body) |
| 3320 | (while (re-search-forward "^[ \t]+" nil t) |
| 3321 | (replace-match "" t t))))) |
| 3322 | |
| 3323 | (defun article-strip-trailing-space () |
| 3324 | "Remove all white space from the end of the lines in the article." |
| 3325 | (interactive) |
| 3326 | (save-excursion |
| 3327 | (let ((inhibit-point-motion-hooks t) |
| 3328 | (inhibit-read-only t)) |
| 3329 | (article-goto-body) |
| 3330 | (while (re-search-forward "[ \t]+$" nil t) |
| 3331 | (replace-match "" t t))))) |
| 3332 | |
| 3333 | (defun article-strip-blank-lines () |
| 3334 | "Strip leading, trailing and multiple blank lines." |
| 3335 | (interactive) |
| 3336 | (article-strip-leading-blank-lines) |
| 3337 | (article-remove-trailing-blank-lines) |
| 3338 | (article-strip-multiple-blank-lines)) |
| 3339 | |
| 3340 | (defun article-strip-all-blank-lines () |
| 3341 | "Strip all blank lines." |
| 3342 | (interactive) |
| 3343 | (save-excursion |
| 3344 | (let ((inhibit-point-motion-hooks t) |
| 3345 | (inhibit-read-only t)) |
| 3346 | (article-goto-body) |
| 3347 | (while (re-search-forward "^[ \t]*\n" nil t) |
| 3348 | (replace-match "" t t))))) |
| 3349 | |
| 3350 | (defun gnus-article-narrow-to-signature () |
| 3351 | "Narrow to the signature; return t if a signature is found, else nil." |
| 3352 | (let ((inhibit-point-motion-hooks t)) |
| 3353 | (when (gnus-article-search-signature) |
| 3354 | (forward-line 1) |
| 3355 | ;; Check whether we have some limits to what we consider |
| 3356 | ;; to be a signature. |
| 3357 | (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit |
| 3358 | (list gnus-signature-limit))) |
| 3359 | limit limited) |
| 3360 | (while (setq limit (pop limits)) |
| 3361 | (if (or (and (integerp limit) |
| 3362 | (< (- (point-max) (point)) limit)) |
| 3363 | (and (floatp limit) |
| 3364 | (< (count-lines (point) (point-max)) limit)) |
| 3365 | (and (functionp limit) |
| 3366 | (funcall limit)) |
| 3367 | (and (stringp limit) |
| 3368 | (not (re-search-forward limit nil t)))) |
| 3369 | () ; This limit did not succeed. |
| 3370 | (setq limited t |
| 3371 | limits nil))) |
| 3372 | (unless limited |
| 3373 | (narrow-to-region (point) (point-max)) |
| 3374 | t))))) |
| 3375 | |
| 3376 | (defun gnus-article-search-signature () |
| 3377 | "Search the current buffer for the signature separator. |
| 3378 | Put point at the beginning of the signature separator." |
| 3379 | (let ((cur (point))) |
| 3380 | (goto-char (point-max)) |
| 3381 | (if (if (stringp gnus-signature-separator) |
| 3382 | (re-search-backward gnus-signature-separator nil t) |
| 3383 | (let ((seps gnus-signature-separator)) |
| 3384 | (while (and seps |
| 3385 | (not (re-search-backward (car seps) nil t))) |
| 3386 | (pop seps)) |
| 3387 | seps)) |
| 3388 | t |
| 3389 | (goto-char cur) |
| 3390 | nil))) |
| 3391 | |
| 3392 | (defun gnus-article-hidden-arg () |
| 3393 | "Return the current prefix arg as a number, or 0 if no prefix." |
| 3394 | (list (if current-prefix-arg |
| 3395 | (prefix-numeric-value current-prefix-arg) |
| 3396 | 0))) |
| 3397 | |
| 3398 | (defun gnus-article-check-hidden-text (type arg) |
| 3399 | "Return nil if hiding is necessary. |
| 3400 | Arg can be nil or a number. nil and positive means hide, negative |
| 3401 | means show, 0 means toggle." |
| 3402 | (save-excursion |
| 3403 | (save-restriction |
| 3404 | (let ((hide (gnus-article-hidden-text-p type))) |
| 3405 | (cond |
| 3406 | ((or (null arg) |
| 3407 | (> arg 0)) |
| 3408 | nil) |
| 3409 | ((< arg 0) |
| 3410 | (gnus-article-show-hidden-text type) |
| 3411 | t) |
| 3412 | (t |
| 3413 | (if (eq hide 'hidden) |
| 3414 | (progn |
| 3415 | (gnus-article-show-hidden-text type) |
| 3416 | t) |
| 3417 | nil))))))) |
| 3418 | |
| 3419 | (defun gnus-article-hidden-text-p (type) |
| 3420 | "Say whether the current buffer contains hidden text of type TYPE." |
| 3421 | (let ((pos (text-property-any (point-min) (point-max) 'article-type type))) |
| 3422 | (while (and pos |
| 3423 | (not (get-text-property pos 'invisible)) |
| 3424 | (not (get-text-property pos 'dummy-invisible))) |
| 3425 | (setq pos |
| 3426 | (text-property-any (1+ pos) (point-max) 'article-type type))) |
| 3427 | (if pos |
| 3428 | 'hidden |
| 3429 | nil))) |
| 3430 | |
| 3431 | (defun gnus-article-show-hidden-text (type &optional dummy) |
| 3432 | "Show all hidden text of type TYPE. |
| 3433 | Originally it is hide instead of DUMMY." |
| 3434 | (let ((inhibit-read-only t) |
| 3435 | (inhibit-point-motion-hooks t)) |
| 3436 | (gnus-remove-text-properties-when |
| 3437 | 'article-type type |
| 3438 | (point-min) (point-max) |
| 3439 | (cons 'article-type (cons type |
| 3440 | gnus-hidden-properties))) |
| 3441 | (gnus-delete-wash-type type))) |
| 3442 | |
| 3443 | (defconst article-time-units |
| 3444 | `((year . ,(* 365.25 24 60 60)) |
| 3445 | (week . ,(* 7 24 60 60)) |
| 3446 | (day . ,(* 24 60 60)) |
| 3447 | (hour . ,(* 60 60)) |
| 3448 | (minute . 60) |
| 3449 | (second . 1)) |
| 3450 | "Mapping from time units to seconds.") |
| 3451 | |
| 3452 | (defun gnus-article-forward-header () |
| 3453 | "Move point to the start of the next header. |
| 3454 | If the current header is a continuation header, this can be several |
| 3455 | lines forward." |
| 3456 | (let ((ended nil)) |
| 3457 | (while (not ended) |
| 3458 | (forward-line 1) |
| 3459 | (if (looking-at "[ \t]+[^ \t]") |
| 3460 | (forward-line 1) |
| 3461 | (setq ended t))))) |
| 3462 | |
| 3463 | (defun article-date-ut (&optional type highlight) |
| 3464 | "Convert DATE date to universal time in the current article. |
| 3465 | If TYPE is `local', convert to local time; if it is `lapsed', output |
| 3466 | how much time has lapsed since DATE. For `lapsed', the value of |
| 3467 | `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header |
| 3468 | should replace the \"Date:\" one, or should be added below it." |
| 3469 | (interactive (list 'ut t)) |
| 3470 | (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") |
| 3471 | (date-regexp (cond ((not gnus-article-date-lapsed-new-header) |
| 3472 | tdate-regexp) |
| 3473 | ((eq type 'lapsed) |
| 3474 | "^X-Sent:[ \t]") |
| 3475 | (article-lapsed-timer |
| 3476 | "^Date:[ \t]") |
| 3477 | (t |
| 3478 | tdate-regexp))) |
| 3479 | (case-fold-search t) |
| 3480 | (inhibit-read-only t) |
| 3481 | (inhibit-point-motion-hooks t) |
| 3482 | pos date bface eface) |
| 3483 | (save-excursion |
| 3484 | (save-restriction |
| 3485 | (widen) |
| 3486 | (goto-char (point-min)) |
| 3487 | (while (or (setq date (get-text-property (setq pos (point)) |
| 3488 | 'original-date)) |
| 3489 | (when (setq pos (next-single-property-change |
| 3490 | (point) 'original-date)) |
| 3491 | (setq date (get-text-property pos 'original-date)) |
| 3492 | t)) |
| 3493 | (narrow-to-region |
| 3494 | pos (if (setq pos (text-property-any pos (point-max) |
| 3495 | 'original-date nil)) |
| 3496 | (progn |
| 3497 | (goto-char pos) |
| 3498 | (if (or (bolp) (eobp)) |
| 3499 | (point) |
| 3500 | (1+ (point)))) |
| 3501 | (point-max))) |
| 3502 | (goto-char (point-min)) |
| 3503 | (when (re-search-forward tdate-regexp nil t) |
| 3504 | (setq bface (get-text-property (point-at-bol) 'face) |
| 3505 | eface (get-text-property (1- (point-at-eol)) 'face))) |
| 3506 | (goto-char (point-min)) |
| 3507 | (setq pos nil) |
| 3508 | ;; Delete any old Date headers. |
| 3509 | (while (re-search-forward date-regexp nil t) |
| 3510 | (if pos |
| 3511 | (delete-region (point-at-bol) (progn |
| 3512 | (gnus-article-forward-header) |
| 3513 | (point))) |
| 3514 | (delete-region (point-at-bol) (progn |
| 3515 | (gnus-article-forward-header) |
| 3516 | (forward-char -1) |
| 3517 | (point))) |
| 3518 | (setq pos (point)))) |
| 3519 | (when (and (not pos) |
| 3520 | (re-search-forward tdate-regexp nil t)) |
| 3521 | (forward-line 1)) |
| 3522 | (gnus-goto-char pos) |
| 3523 | (insert (article-make-date-line date (or type 'ut))) |
| 3524 | (unless pos |
| 3525 | (insert "\n") |
| 3526 | (forward-line -1)) |
| 3527 | ;; Do highlighting. |
| 3528 | (beginning-of-line) |
| 3529 | (when (looking-at "\\([^:]+\\): *\\(.*\\)$") |
| 3530 | (put-text-property (match-beginning 1) (1+ (match-end 1)) |
| 3531 | 'face bface) |
| 3532 | (put-text-property (match-beginning 2) (match-end 2) |
| 3533 | 'face eface)) |
| 3534 | (put-text-property (point-min) (1- (point-max)) 'original-date date) |
| 3535 | (goto-char (point-max)) |
| 3536 | (widen)))))) |
| 3537 | |
| 3538 | (defun article-make-date-line (date type) |
| 3539 | "Return a DATE line of TYPE." |
| 3540 | (unless (memq type '(local ut original user iso8601 lapsed english)) |
| 3541 | (error "Unknown conversion type: %s" type)) |
| 3542 | (condition-case () |
| 3543 | (let ((time (date-to-time date))) |
| 3544 | (cond |
| 3545 | ;; Convert to the local timezone. |
| 3546 | ((eq type 'local) |
| 3547 | (concat "Date: " (message-make-date time))) |
| 3548 | ;; Convert to Universal Time. |
| 3549 | ((eq type 'ut) |
| 3550 | (concat "Date: " |
| 3551 | (substring |
| 3552 | (message-make-date |
| 3553 | (let* ((e (parse-time-string date)) |
| 3554 | (tm (apply 'encode-time e)) |
| 3555 | (ms (car tm)) |
| 3556 | (ls (- (cadr tm) (car (current-time-zone time))))) |
| 3557 | (cond ((< ls 0) (list (1- ms) (+ ls 65536))) |
| 3558 | ((> ls 65535) (list (1+ ms) (- ls 65536))) |
| 3559 | (t (list ms ls))))) |
| 3560 | 0 -5) |
| 3561 | "UT")) |
| 3562 | ;; Get the original date from the article. |
| 3563 | ((eq type 'original) |
| 3564 | (concat "Date: " (if (string-match "\n+$" date) |
| 3565 | (substring date 0 (match-beginning 0)) |
| 3566 | date))) |
| 3567 | ;; Let the user define the format. |
| 3568 | ((eq type 'user) |
| 3569 | (let ((format (or (condition-case nil |
| 3570 | (with-current-buffer gnus-summary-buffer |
| 3571 | gnus-article-time-format) |
| 3572 | (error nil)) |
| 3573 | gnus-article-time-format))) |
| 3574 | (if (functionp format) |
| 3575 | (funcall format time) |
| 3576 | (concat "Date: " (format-time-string format time))))) |
| 3577 | ;; ISO 8601. |
| 3578 | ((eq type 'iso8601) |
| 3579 | (let ((tz (car (current-time-zone time)))) |
| 3580 | (concat |
| 3581 | "Date: " |
| 3582 | (format-time-string "%Y%m%dT%H%M%S" time) |
| 3583 | (format "%s%02d%02d" |
| 3584 | (if (> tz 0) "+" "-") (/ (abs tz) 3600) |
| 3585 | (/ (% (abs tz) 3600) 60))))) |
| 3586 | ;; Do an X-Sent lapsed format. |
| 3587 | ((eq type 'lapsed) |
| 3588 | ;; If the date is seriously mangled, the timezone functions are |
| 3589 | ;; liable to bug out, so we ignore all errors. |
| 3590 | (let* ((now (current-time)) |
| 3591 | (real-time (subtract-time now time)) |
| 3592 | (real-sec (and real-time |
| 3593 | (+ (* (float (car real-time)) 65536) |
| 3594 | (cadr real-time)))) |
| 3595 | (sec (and real-time (abs real-sec))) |
| 3596 | num prev) |
| 3597 | (cond |
| 3598 | ((null real-time) |
| 3599 | "X-Sent: Unknown") |
| 3600 | ((zerop sec) |
| 3601 | "X-Sent: Now") |
| 3602 | (t |
| 3603 | (concat |
| 3604 | "X-Sent: " |
| 3605 | ;; This is a bit convoluted, but basically we go |
| 3606 | ;; through the time units for years, weeks, etc, |
| 3607 | ;; and divide things to see whether that results |
| 3608 | ;; in positive answers. |
| 3609 | (mapconcat |
| 3610 | (lambda (unit) |
| 3611 | (if (zerop (setq num (ffloor (/ sec (cdr unit))))) |
| 3612 | ;; The (remaining) seconds are too few to |
| 3613 | ;; be divided into this time unit. |
| 3614 | "" |
| 3615 | ;; It's big enough, so we output it. |
| 3616 | (setq sec (- sec (* num (cdr unit)))) |
| 3617 | (prog1 |
| 3618 | (concat (if prev ", " "") (int-to-string |
| 3619 | (floor num)) |
| 3620 | " " (symbol-name (car unit)) |
| 3621 | (if (> num 1) "s" "")) |
| 3622 | (setq prev t)))) |
| 3623 | article-time-units "") |
| 3624 | ;; If dates are odd, then it might appear like the |
| 3625 | ;; article was sent in the future. |
| 3626 | (if (> real-sec 0) |
| 3627 | " ago" |
| 3628 | " in the future")))))) |
| 3629 | ;; Display the date in proper English |
| 3630 | ((eq type 'english) |
| 3631 | (let ((dtime (decode-time time))) |
| 3632 | (concat |
| 3633 | "Date: the " |
| 3634 | (number-to-string (nth 3 dtime)) |
| 3635 | (let ((digit (% (nth 3 dtime) 10))) |
| 3636 | (cond |
| 3637 | ((memq (nth 3 dtime) '(11 12 13)) "th") |
| 3638 | ((= digit 1) "st") |
| 3639 | ((= digit 2) "nd") |
| 3640 | ((= digit 3) "rd") |
| 3641 | (t "th"))) |
| 3642 | " of " |
| 3643 | (nth (1- (nth 4 dtime)) gnus-english-month-names) |
| 3644 | " " |
| 3645 | (number-to-string (nth 5 dtime)) |
| 3646 | " at " |
| 3647 | (format "%02d" (nth 2 dtime)) |
| 3648 | ":" |
| 3649 | (format "%02d" (nth 1 dtime))))))) |
| 3650 | (error |
| 3651 | (format "Date: %s (from Gnus)" date)))) |
| 3652 | |
| 3653 | (defun article-date-local (&optional highlight) |
| 3654 | "Convert the current article date to the local timezone." |
| 3655 | (interactive (list t)) |
| 3656 | (article-date-ut 'local highlight)) |
| 3657 | |
| 3658 | (defun article-date-english (&optional highlight) |
| 3659 | "Convert the current article date to something that is proper English." |
| 3660 | (interactive (list t)) |
| 3661 | (article-date-ut 'english highlight)) |
| 3662 | |
| 3663 | (defun article-date-original (&optional highlight) |
| 3664 | "Convert the current article date to what it was originally. |
| 3665 | This is only useful if you have used some other date conversion |
| 3666 | function and want to see what the date was before converting." |
| 3667 | (interactive (list t)) |
| 3668 | (article-date-ut 'original highlight)) |
| 3669 | |
| 3670 | (defun article-date-lapsed (&optional highlight) |
| 3671 | "Convert the current article date to time lapsed since it was sent." |
| 3672 | (interactive (list t)) |
| 3673 | (article-date-ut 'lapsed highlight)) |
| 3674 | |
| 3675 | (defun article-update-date-lapsed () |
| 3676 | "Function to be run from a timer to update the lapsed time line." |
| 3677 | (save-match-data |
| 3678 | (let (deactivate-mark) |
| 3679 | (save-excursion |
| 3680 | (ignore-errors |
| 3681 | (walk-windows |
| 3682 | (lambda (w) |
| 3683 | (set-buffer (window-buffer w)) |
| 3684 | (when (eq major-mode 'gnus-article-mode) |
| 3685 | (let ((mark (point-marker))) |
| 3686 | (goto-char (point-min)) |
| 3687 | (when (re-search-forward "^X-Sent:" nil t) |
| 3688 | (article-date-lapsed t)) |
| 3689 | (goto-char (marker-position mark)) |
| 3690 | (move-marker mark nil)))) |
| 3691 | nil 'visible)))))) |
| 3692 | |
| 3693 | (defun gnus-start-date-timer (&optional n) |
| 3694 | "Start a timer to update the X-Sent header in the article buffers. |
| 3695 | The numerical prefix says how frequently (in seconds) the function |
| 3696 | is to run." |
| 3697 | (interactive "p") |
| 3698 | (unless n |
| 3699 | (setq n 1)) |
| 3700 | (gnus-stop-date-timer) |
| 3701 | (setq article-lapsed-timer |
| 3702 | (run-at-time 1 n 'article-update-date-lapsed))) |
| 3703 | |
| 3704 | (defun gnus-stop-date-timer () |
| 3705 | "Stop the X-Sent timer." |
| 3706 | (interactive) |
| 3707 | (when article-lapsed-timer |
| 3708 | (nnheader-cancel-timer article-lapsed-timer) |
| 3709 | (setq article-lapsed-timer nil))) |
| 3710 | |
| 3711 | (defun article-date-user (&optional highlight) |
| 3712 | "Convert the current article date to the user-defined format. |
| 3713 | This format is defined by the `gnus-article-time-format' variable." |
| 3714 | (interactive (list t)) |
| 3715 | (article-date-ut 'user highlight)) |
| 3716 | |
| 3717 | (defun article-date-iso8601 (&optional highlight) |
| 3718 | "Convert the current article date to ISO8601." |
| 3719 | (interactive (list t)) |
| 3720 | (article-date-ut 'iso8601 highlight)) |
| 3721 | |
| 3722 | (defmacro gnus-article-save-original-date (&rest forms) |
| 3723 | "Save the original date as a text property and evaluate FORMS." |
| 3724 | `(let* ((case-fold-search t) |
| 3725 | (start (progn |
| 3726 | (goto-char (point-min)) |
| 3727 | (when (and (re-search-forward "^date:[\t\n ]+" nil t) |
| 3728 | (not (bolp))) |
| 3729 | (match-end 0)))) |
| 3730 | (date (when (and start |
| 3731 | (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)" |
| 3732 | nil t)) |
| 3733 | (buffer-substring-no-properties start |
| 3734 | (match-beginning 0))))) |
| 3735 | (goto-char (point-max)) |
| 3736 | (skip-chars-backward "\n") |
| 3737 | (put-text-property (point-min) (point) 'original-date date) |
| 3738 | ,@forms |
| 3739 | (goto-char (point-max)) |
| 3740 | (skip-chars-backward "\n") |
| 3741 | (put-text-property (point-min) (point) 'original-date date))) |
| 3742 | |
| 3743 | ;; (defun article-show-all () |
| 3744 | ;; "Show all hidden text in the article buffer." |
| 3745 | ;; (interactive) |
| 3746 | ;; (save-excursion |
| 3747 | ;; (let ((inhibit-read-only t)) |
| 3748 | ;; (gnus-article-unhide-text (point-min) (point-max))))) |
| 3749 | |
| 3750 | (defun article-remove-leading-whitespace () |
| 3751 | "Remove excessive whitespace from all headers." |
| 3752 | (interactive) |
| 3753 | (save-excursion |
| 3754 | (save-restriction |
| 3755 | (let ((inhibit-read-only t)) |
| 3756 | (article-narrow-to-head) |
| 3757 | (goto-char (point-min)) |
| 3758 | (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t) |
| 3759 | (delete-region (match-beginning 1) (match-end 1))))))) |
| 3760 | |
| 3761 | (defun article-emphasize (&optional arg) |
| 3762 | "Emphasize text according to `gnus-emphasis-alist'." |
| 3763 | (interactive (gnus-article-hidden-arg)) |
| 3764 | (unless (gnus-article-check-hidden-text 'emphasis arg) |
| 3765 | (save-excursion |
| 3766 | (let ((alist (or |
| 3767 | (condition-case nil |
| 3768 | (with-current-buffer gnus-summary-buffer |
| 3769 | gnus-article-emphasis-alist) |
| 3770 | (error)) |
| 3771 | gnus-emphasis-alist)) |
| 3772 | (inhibit-read-only t) |
| 3773 | (props (append '(article-type emphasis) |
| 3774 | gnus-hidden-properties)) |
| 3775 | regexp elem beg invisible visible face) |
| 3776 | (article-goto-body) |
| 3777 | (setq beg (point)) |
| 3778 | (while (setq elem (pop alist)) |
| 3779 | (goto-char beg) |
| 3780 | (setq regexp (car elem) |
| 3781 | invisible (nth 1 elem) |
| 3782 | visible (nth 2 elem) |
| 3783 | face (nth 3 elem)) |
| 3784 | (while (re-search-forward regexp nil t) |
| 3785 | (when (and (match-beginning visible) (match-beginning invisible)) |
| 3786 | (gnus-article-hide-text |
| 3787 | (match-beginning invisible) (match-end invisible) props) |
| 3788 | (gnus-article-unhide-text-type |
| 3789 | (match-beginning visible) (match-end visible) 'emphasis) |
| 3790 | (gnus-put-overlay-excluding-newlines |
| 3791 | (match-beginning visible) (match-end visible) 'face face) |
| 3792 | (gnus-add-wash-type 'emphasis) |
| 3793 | (goto-char (match-end invisible))))))))) |
| 3794 | |
| 3795 | (defun gnus-article-setup-highlight-words (&optional highlight-words) |
| 3796 | "Setup newsgroup emphasis alist." |
| 3797 | (unless gnus-article-emphasis-alist |
| 3798 | (let ((name (and gnus-newsgroup-name |
| 3799 | (gnus-group-real-name gnus-newsgroup-name)))) |
| 3800 | (make-local-variable 'gnus-article-emphasis-alist) |
| 3801 | (setq gnus-article-emphasis-alist |
| 3802 | (nconc |
| 3803 | (let ((alist gnus-group-highlight-words-alist) elem highlight) |
| 3804 | (while (setq elem (pop alist)) |
| 3805 | (when (and name (string-match (car elem) name)) |
| 3806 | (setq alist nil |
| 3807 | highlight (copy-sequence (cdr elem))))) |
| 3808 | highlight) |
| 3809 | (copy-sequence highlight-words) |
| 3810 | (if gnus-newsgroup-name |
| 3811 | (copy-sequence (gnus-group-find-parameter |
| 3812 | gnus-newsgroup-name 'highlight-words t))) |
| 3813 | gnus-emphasis-alist))))) |
| 3814 | |
| 3815 | (defvar gnus-summary-article-menu) |
| 3816 | (defvar gnus-summary-post-menu) |
| 3817 | |
| 3818 | ;;; Saving functions. |
| 3819 | |
| 3820 | (defun gnus-article-save (save-buffer file &optional num) |
| 3821 | "Save the currently selected article." |
| 3822 | (when (or (get gnus-default-article-saver :headers) |
| 3823 | (not gnus-save-all-headers)) |
| 3824 | ;; Remove headers according to `gnus-saved-headers' or the value |
| 3825 | ;; of the `:headers' property that the saver function might have. |
| 3826 | (let ((gnus-visible-headers |
| 3827 | (or (symbol-value (get gnus-default-article-saver :headers)) |
| 3828 | gnus-saved-headers gnus-visible-headers)) |
| 3829 | ;; Ignore group parameter. See `article-hide-headers'. |
| 3830 | (gnus-summary-buffer nil)) |
| 3831 | (with-current-buffer save-buffer |
| 3832 | (article-hide-headers 1 t)))) |
| 3833 | (save-window-excursion |
| 3834 | (if (not gnus-default-article-saver) |
| 3835 | (error "No default saver is defined") |
| 3836 | ;; !!! Magic! The saving functions all save |
| 3837 | ;; `gnus-save-article-buffer' (or so they think), but we |
| 3838 | ;; bind that variable to our save-buffer. |
| 3839 | (set-buffer gnus-article-buffer) |
| 3840 | (let* ((gnus-save-article-buffer save-buffer) |
| 3841 | (filename |
| 3842 | (cond |
| 3843 | ((not gnus-prompt-before-saving) 'default) |
| 3844 | ((eq gnus-prompt-before-saving 'always) nil) |
| 3845 | (t file))) |
| 3846 | (gnus-number-of-articles-to-be-saved |
| 3847 | (when (eq gnus-prompt-before-saving t) |
| 3848 | num))) ; Magic |
| 3849 | (set-buffer gnus-article-current-summary) |
| 3850 | (funcall gnus-default-article-saver filename))))) |
| 3851 | |
| 3852 | (defun gnus-read-save-file-name (prompt &optional filename |
| 3853 | function group headers variable |
| 3854 | dir-var) |
| 3855 | (let ((default-name |
| 3856 | (funcall function group headers (symbol-value variable))) |
| 3857 | result) |
| 3858 | (setq result |
| 3859 | (expand-file-name |
| 3860 | (cond |
| 3861 | ((eq filename 'default) |
| 3862 | default-name) |
| 3863 | ((eq filename t) |
| 3864 | default-name) |
| 3865 | (filename filename) |
| 3866 | (t |
| 3867 | (when (symbol-value dir-var) |
| 3868 | (setq default-name (expand-file-name |
| 3869 | (file-name-nondirectory default-name) |
| 3870 | (symbol-value dir-var)))) |
| 3871 | (let* ((split-name (gnus-get-split-value gnus-split-methods)) |
| 3872 | (prompt |
| 3873 | (format prompt |
| 3874 | (if (and gnus-number-of-articles-to-be-saved |
| 3875 | (> gnus-number-of-articles-to-be-saved 1)) |
| 3876 | (format "these %d articles" |
| 3877 | gnus-number-of-articles-to-be-saved) |
| 3878 | "this article"))) |
| 3879 | (file |
| 3880 | ;; Let the split methods have their say. |
| 3881 | (cond |
| 3882 | ;; No split name was found. |
| 3883 | ((null split-name) |
| 3884 | (read-file-name |
| 3885 | (concat prompt " (default " |
| 3886 | (file-name-nondirectory default-name) "): ") |
| 3887 | (file-name-directory default-name) |
| 3888 | default-name)) |
| 3889 | ;; A single group name is returned. |
| 3890 | ((stringp split-name) |
| 3891 | (setq default-name |
| 3892 | (funcall function split-name headers |
| 3893 | (symbol-value variable))) |
| 3894 | (read-file-name |
| 3895 | (concat prompt " (default " |
| 3896 | (file-name-nondirectory default-name) "): ") |
| 3897 | (file-name-directory default-name) |
| 3898 | default-name)) |
| 3899 | ;; A single split name was found |
| 3900 | ((= 1 (length split-name)) |
| 3901 | (let* ((name (expand-file-name |
| 3902 | (car split-name) |
| 3903 | gnus-article-save-directory)) |
| 3904 | (dir (cond ((file-directory-p name) |
| 3905 | (file-name-as-directory name)) |
| 3906 | ((file-exists-p name) name) |
| 3907 | (t gnus-article-save-directory)))) |
| 3908 | (read-file-name |
| 3909 | (concat prompt " (default " name "): ") |
| 3910 | dir name))) |
| 3911 | ;; A list of splits was found. |
| 3912 | (t |
| 3913 | (setq split-name (nreverse split-name)) |
| 3914 | (let (result) |
| 3915 | (let ((file-name-history |
| 3916 | (nconc split-name file-name-history))) |
| 3917 | (setq result |
| 3918 | (expand-file-name |
| 3919 | (read-file-name |
| 3920 | (concat prompt " (`M-p' for defaults): ") |
| 3921 | gnus-article-save-directory |
| 3922 | (car split-name)) |
| 3923 | gnus-article-save-directory))) |
| 3924 | (car (push result file-name-history))))))) |
| 3925 | ;; Create the directory. |
| 3926 | (gnus-make-directory (file-name-directory file)) |
| 3927 | ;; If we have read a directory, we append the default file name. |
| 3928 | (when (file-directory-p file) |
| 3929 | (setq file (expand-file-name (file-name-nondirectory |
| 3930 | default-name) |
| 3931 | (file-name-as-directory file)))) |
| 3932 | ;; Possibly translate some characters. |
| 3933 | (nnheader-translate-file-chars file)))))) |
| 3934 | (gnus-make-directory (file-name-directory result)) |
| 3935 | (when variable |
| 3936 | (set variable result)) |
| 3937 | (when dir-var |
| 3938 | (set dir-var (file-name-directory result))) |
| 3939 | result)) |
| 3940 | |
| 3941 | (defun gnus-article-archive-name (group) |
| 3942 | "Return the first instance of an \"Archive-name\" in the current buffer." |
| 3943 | (let ((case-fold-search t)) |
| 3944 | (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) |
| 3945 | (nnheader-concat gnus-article-save-directory |
| 3946 | (match-string 1))))) |
| 3947 | |
| 3948 | (defun gnus-article-nndoc-name (group) |
| 3949 | "If GROUP is an nndoc group, return the name of the parent group." |
| 3950 | (when (eq (car (gnus-find-method-for-group group)) 'nndoc) |
| 3951 | (gnus-group-get-parameter group 'save-article-group))) |
| 3952 | |
| 3953 | (defun gnus-summary-save-in-rmail (&optional filename) |
| 3954 | "Append this article to Rmail file. |
| 3955 | Optional argument FILENAME specifies file name. |
| 3956 | Directory to save to is default to `gnus-article-save-directory'." |
| 3957 | (setq filename (gnus-read-save-file-name |
| 3958 | "Save %s in rmail file" filename |
| 3959 | gnus-rmail-save-name gnus-newsgroup-name |
| 3960 | gnus-current-headers 'gnus-newsgroup-last-rmail)) |
| 3961 | (gnus-eval-in-buffer-window gnus-save-article-buffer |
| 3962 | (save-excursion |
| 3963 | (save-restriction |
| 3964 | (widen) |
| 3965 | ;; Note that unlike gnus-summary-save-in-mail, there is no |
| 3966 | ;; check to see if filename is Babyl. Rmail in Emacs 23 does |
| 3967 | ;; not use Babyl. |
| 3968 | (gnus-output-to-rmail filename)))) |
| 3969 | filename) |
| 3970 | |
| 3971 | (defun gnus-summary-save-in-mail (&optional filename) |
| 3972 | "Append this article to Unix mail 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 Unix mail file" filename |
| 3977 | gnus-mail-save-name gnus-newsgroup-name |
| 3978 | gnus-current-headers 'gnus-newsgroup-last-mail)) |
| 3979 | (gnus-eval-in-buffer-window gnus-save-article-buffer |
| 3980 | (save-excursion |
| 3981 | (save-restriction |
| 3982 | (widen) |
| 3983 | (if (and (file-readable-p filename) |
| 3984 | (file-regular-p filename) |
| 3985 | (mail-file-babyl-p filename)) |
| 3986 | (gnus-output-to-rmail filename) |
| 3987 | (gnus-output-to-mail filename))))) |
| 3988 | filename) |
| 3989 | |
| 3990 | (put 'gnus-summary-save-in-file :decode t) |
| 3991 | (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers) |
| 3992 | (defun gnus-summary-save-in-file (&optional filename overwrite) |
| 3993 | "Append this article to file. |
| 3994 | Optional argument FILENAME specifies file name. |
| 3995 | Directory to save to is default to `gnus-article-save-directory'." |
| 3996 | (setq filename (gnus-read-save-file-name |
| 3997 | "Save %s in file" filename |
| 3998 | gnus-file-save-name gnus-newsgroup-name |
| 3999 | gnus-current-headers 'gnus-newsgroup-last-file)) |
| 4000 | (gnus-eval-in-buffer-window gnus-save-article-buffer |
| 4001 | (save-excursion |
| 4002 | (save-restriction |
| 4003 | (widen) |
| 4004 | (when (and overwrite |
| 4005 | (file-exists-p filename)) |
| 4006 | (delete-file filename)) |
| 4007 | (gnus-output-to-file filename)))) |
| 4008 | filename) |
| 4009 | |
| 4010 | (put 'gnus-summary-write-to-file :decode t) |
| 4011 | (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file) |
| 4012 | (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers) |
| 4013 | (defun gnus-summary-write-to-file (&optional filename) |
| 4014 | "Write this article to a file, overwriting it if the file exists. |
| 4015 | Optional argument FILENAME specifies file name. |
| 4016 | The directory to save in defaults to `gnus-article-save-directory'." |
| 4017 | (setq filename (gnus-read-save-file-name |
| 4018 | "Save %s in file" filename |
| 4019 | gnus-file-save-name gnus-newsgroup-name |
| 4020 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) |
| 4021 | (gnus-summary-save-in-file filename t)) |
| 4022 | |
| 4023 | (put 'gnus-summary-save-body-in-file :decode t) |
| 4024 | (defun gnus-summary-save-body-in-file (&optional filename overwrite) |
| 4025 | "Append this article body to a file. |
| 4026 | Optional argument FILENAME specifies file name. |
| 4027 | The directory to save in defaults to `gnus-article-save-directory'." |
| 4028 | (setq filename (gnus-read-save-file-name |
| 4029 | "Save %s body in file" filename |
| 4030 | gnus-file-save-name gnus-newsgroup-name |
| 4031 | gnus-current-headers 'gnus-newsgroup-last-file)) |
| 4032 | (gnus-eval-in-buffer-window gnus-save-article-buffer |
| 4033 | (save-excursion |
| 4034 | (save-restriction |
| 4035 | (widen) |
| 4036 | (when (article-goto-body) |
| 4037 | (narrow-to-region (point) (point-max))) |
| 4038 | (when (and overwrite |
| 4039 | (file-exists-p filename)) |
| 4040 | (delete-file filename)) |
| 4041 | (gnus-output-to-file filename)))) |
| 4042 | filename) |
| 4043 | |
| 4044 | (put 'gnus-summary-write-body-to-file :decode t) |
| 4045 | (put 'gnus-summary-write-body-to-file |
| 4046 | :function 'gnus-summary-save-body-in-file) |
| 4047 | (defun gnus-summary-write-body-to-file (&optional filename) |
| 4048 | "Write this article body to a file, overwriting it if the file exists. |
| 4049 | Optional argument FILENAME specifies file name. |
| 4050 | The directory to save in defaults to `gnus-article-save-directory'." |
| 4051 | (setq filename (gnus-read-save-file-name |
| 4052 | "Save %s body in file" filename |
| 4053 | gnus-file-save-name gnus-newsgroup-name |
| 4054 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) |
| 4055 | (gnus-summary-save-body-in-file filename t)) |
| 4056 | |
| 4057 | (put 'gnus-summary-save-in-pipe :decode t) |
| 4058 | (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers) |
| 4059 | (defun gnus-summary-save-in-pipe (&optional command raw) |
| 4060 | "Pipe this article to subprocess COMMAND. |
| 4061 | Valid values for COMMAND include: |
| 4062 | a string |
| 4063 | The executable command name and possibly arguments. |
| 4064 | nil |
| 4065 | You will be prompted for the command in the minibuffer. |
| 4066 | the symbol `default' |
| 4067 | It will be replaced with the command which the variable |
| 4068 | `gnus-summary-pipe-output-default-command' holds or the command |
| 4069 | last used for saving. |
| 4070 | Non-nil value for RAW overrides `:decode' and `:headers' properties |
| 4071 | and the raw article including all headers will be piped." |
| 4072 | (let ((article (gnus-summary-article-number)) |
| 4073 | (decode (unless raw |
| 4074 | (get 'gnus-summary-save-in-pipe :decode))) |
| 4075 | save-buffer default) |
| 4076 | (if article |
| 4077 | (if (vectorp (gnus-summary-article-header article)) |
| 4078 | (save-current-buffer |
| 4079 | (gnus-summary-select-article decode decode nil article) |
| 4080 | (insert-buffer-substring |
| 4081 | (prog1 |
| 4082 | (if decode |
| 4083 | gnus-article-buffer |
| 4084 | gnus-original-article-buffer) |
| 4085 | (setq save-buffer |
| 4086 | (nnheader-set-temp-buffer " *Gnus Save*")))) |
| 4087 | ;; Remove unwanted headers. |
| 4088 | (when (and (not raw) |
| 4089 | (or (get 'gnus-summary-save-in-pipe :headers) |
| 4090 | (not gnus-save-all-headers))) |
| 4091 | (let ((gnus-visible-headers |
| 4092 | (or (symbol-value (get 'gnus-summary-save-in-pipe |
| 4093 | :headers)) |
| 4094 | gnus-saved-headers gnus-visible-headers)) |
| 4095 | (gnus-summary-buffer nil)) |
| 4096 | (article-hide-headers 1 t)))) |
| 4097 | (error "%d is not a real article" article)) |
| 4098 | (error "No article to pipe")) |
| 4099 | (setq default (or gnus-summary-pipe-output-default-command |
| 4100 | gnus-last-shell-command)) |
| 4101 | (unless (stringp command) |
| 4102 | (setq command |
| 4103 | (if (and (eq command 'default) default) |
| 4104 | default |
| 4105 | (gnus-read-shell-command "Shell command on this article: " |
| 4106 | default)))) |
| 4107 | (when (string-equal command "") |
| 4108 | (if default |
| 4109 | (setq command default) |
| 4110 | (error "A command is required"))) |
| 4111 | (gnus-eval-in-buffer-window save-buffer |
| 4112 | (save-restriction |
| 4113 | (widen) |
| 4114 | (shell-command-on-region (point-min) (point-max) command nil))) |
| 4115 | (gnus-kill-buffer save-buffer)) |
| 4116 | (setq gnus-summary-pipe-output-default-command command)) |
| 4117 | |
| 4118 | (defun gnus-summary-pipe-to-muttprint (&optional command) |
| 4119 | "Pipe this article to muttprint." |
| 4120 | (unless (stringp command) |
| 4121 | (setq command (read-string |
| 4122 | "Print using command: " gnus-summary-muttprint-program |
| 4123 | nil gnus-summary-muttprint-program))) |
| 4124 | (let ((gnus-summary-pipe-output-default-command |
| 4125 | gnus-summary-pipe-output-default-command)) |
| 4126 | (gnus-summary-save-in-pipe command)) |
| 4127 | (setq gnus-summary-muttprint-program command)) |
| 4128 | |
| 4129 | ;;; Article file names when saving. |
| 4130 | |
| 4131 | (defun gnus-capitalize-newsgroup (newsgroup) |
| 4132 | "Capitalize NEWSGROUP name." |
| 4133 | (when (not (zerop (length newsgroup))) |
| 4134 | (concat (char-to-string (upcase (aref newsgroup 0))) |
| 4135 | (substring newsgroup 1)))) |
| 4136 | |
| 4137 | (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) |
| 4138 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. |
| 4139 | If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num. |
| 4140 | Otherwise, it is like ~/News/news/group/num." |
| 4141 | (let ((default |
| 4142 | (expand-file-name |
| 4143 | (concat (if (gnus-use-long-file-name 'not-save) |
| 4144 | (gnus-capitalize-newsgroup newsgroup) |
| 4145 | (gnus-newsgroup-directory-form newsgroup)) |
| 4146 | "/" (int-to-string (mail-header-number headers))) |
| 4147 | gnus-article-save-directory))) |
| 4148 | (if (and last-file |
| 4149 | (string-equal (file-name-directory default) |
| 4150 | (file-name-directory last-file)) |
| 4151 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) |
| 4152 | default |
| 4153 | (or last-file default)))) |
| 4154 | |
| 4155 | (defun gnus-numeric-save-name (newsgroup headers &optional last-file) |
| 4156 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. |
| 4157 | If variable `gnus-use-long-file-name' is non-nil, it is |
| 4158 | ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." |
| 4159 | (let ((default |
| 4160 | (expand-file-name |
| 4161 | (concat (if (gnus-use-long-file-name 'not-save) |
| 4162 | newsgroup |
| 4163 | (gnus-newsgroup-directory-form newsgroup)) |
| 4164 | "/" (int-to-string (mail-header-number headers))) |
| 4165 | gnus-article-save-directory))) |
| 4166 | (if (and last-file |
| 4167 | (string-equal (file-name-directory default) |
| 4168 | (file-name-directory last-file)) |
| 4169 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) |
| 4170 | default |
| 4171 | (or last-file default)))) |
| 4172 | |
| 4173 | (defun gnus-plain-save-name (newsgroup headers &optional last-file) |
| 4174 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. |
| 4175 | If variable `gnus-use-long-file-name' is non-nil, it is |
| 4176 | ~/News/news.group. Otherwise, it is like ~/News/news/group/news." |
| 4177 | (or last-file |
| 4178 | (expand-file-name |
| 4179 | (if (gnus-use-long-file-name 'not-save) |
| 4180 | newsgroup |
| 4181 | (file-relative-name |
| 4182 | (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)) |
| 4183 | default-directory)) |
| 4184 | gnus-article-save-directory))) |
| 4185 | |
| 4186 | (defun gnus-sender-save-name (newsgroup headers &optional last-file) |
| 4187 | "Generate file name from sender." |
| 4188 | (let ((from (mail-header-from headers))) |
| 4189 | (expand-file-name |
| 4190 | (if (and from (string-match "\\([^ <]+\\)@" from)) |
| 4191 | (match-string 1 from) |
| 4192 | "nobody") |
| 4193 | gnus-article-save-directory))) |
| 4194 | |
| 4195 | (defun article-verify-x-pgp-sig () |
| 4196 | "Verify X-PGP-Sig." |
| 4197 | ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT> |
| 4198 | (interactive) |
| 4199 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
| 4200 | (let ((sig (with-current-buffer gnus-original-article-buffer |
| 4201 | (gnus-fetch-field "X-PGP-Sig"))) |
| 4202 | items info headers) |
| 4203 | (when (and sig |
| 4204 | mml2015-use |
| 4205 | (mml2015-clear-verify-function)) |
| 4206 | (with-temp-buffer |
| 4207 | (insert-buffer-substring gnus-original-article-buffer) |
| 4208 | (setq items (split-string sig)) |
| 4209 | (message-narrow-to-head) |
| 4210 | (let ((inhibit-point-motion-hooks t) |
| 4211 | (case-fold-search t)) |
| 4212 | ;; Don't verify multiple headers. |
| 4213 | (setq headers (mapconcat (lambda (header) |
| 4214 | (concat header ": " |
| 4215 | (mail-fetch-field header) |
| 4216 | "\n")) |
| 4217 | (split-string (nth 1 items) ",") ""))) |
| 4218 | (delete-region (point-min) (point-max)) |
| 4219 | (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n") |
| 4220 | (insert "X-Signed-Headers: " (nth 1 items) "\n") |
| 4221 | (insert headers) |
| 4222 | (widen) |
| 4223 | (forward-line) |
| 4224 | (while (not (eobp)) |
| 4225 | (if (looking-at "^-") |
| 4226 | (insert "- ")) |
| 4227 | (forward-line)) |
| 4228 | (insert "\n-----BEGIN PGP SIGNATURE-----\n") |
| 4229 | (insert "Version: " (car items) "\n\n") |
| 4230 | (insert (mapconcat 'identity (cddr items) "\n")) |
| 4231 | (insert "\n-----END PGP SIGNATURE-----\n") |
| 4232 | (let ((mm-security-handle (list (format "multipart/signed")))) |
| 4233 | (mml2015-clean-buffer) |
| 4234 | (let ((coding-system-for-write (or gnus-newsgroup-charset |
| 4235 | 'iso-8859-1))) |
| 4236 | (funcall (mml2015-clear-verify-function))) |
| 4237 | (setq info |
| 4238 | (or (mm-handle-multipart-ctl-parameter |
| 4239 | mm-security-handle 'gnus-details) |
| 4240 | (mm-handle-multipart-ctl-parameter |
| 4241 | mm-security-handle 'gnus-info))))) |
| 4242 | (when info |
| 4243 | (let ((inhibit-read-only t) bface eface) |
| 4244 | (save-restriction |
| 4245 | (message-narrow-to-head) |
| 4246 | (goto-char (point-max)) |
| 4247 | (forward-line -1) |
| 4248 | (setq bface (get-text-property (point-at-bol) 'face) |
| 4249 | eface (get-text-property (1- (point-at-eol)) 'face)) |
| 4250 | (message-remove-header "X-Gnus-PGP-Verify") |
| 4251 | (if (re-search-forward "^X-PGP-Sig:" nil t) |
| 4252 | (forward-line) |
| 4253 | (goto-char (point-max))) |
| 4254 | (narrow-to-region (point) (point)) |
| 4255 | (insert "X-Gnus-PGP-Verify: " info "\n") |
| 4256 | (goto-char (point-min)) |
| 4257 | (forward-line) |
| 4258 | (while (not (eobp)) |
| 4259 | (if (not (looking-at "^[ \t]")) |
| 4260 | (insert " ")) |
| 4261 | (forward-line)) |
| 4262 | ;; Do highlighting. |
| 4263 | (goto-char (point-min)) |
| 4264 | (when (looking-at "\\([^:]+\\): *") |
| 4265 | (put-text-property (match-beginning 1) (1+ (match-end 1)) |
| 4266 | 'face bface) |
| 4267 | (put-text-property (match-end 0) (point-max) |
| 4268 | 'face eface))))))))) |
| 4269 | |
| 4270 | (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs. |
| 4271 | |
| 4272 | (defun article-verify-cancel-lock () |
| 4273 | "Verify Cancel-Lock header." |
| 4274 | (interactive) |
| 4275 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
| 4276 | (canlock-verify gnus-original-article-buffer))) |
| 4277 | |
| 4278 | (eval-and-compile |
| 4279 | (mapc |
| 4280 | (lambda (func) |
| 4281 | (let (afunc gfunc) |
| 4282 | (if (consp func) |
| 4283 | (setq afunc (car func) |
| 4284 | gfunc (cdr func)) |
| 4285 | (setq afunc func |
| 4286 | gfunc (intern (format "gnus-%s" func)))) |
| 4287 | (defalias gfunc |
| 4288 | (when (fboundp afunc) |
| 4289 | `(lambda (&optional interactive &rest args) |
| 4290 | ,(documentation afunc t) |
| 4291 | (interactive (list t)) |
| 4292 | (with-current-buffer gnus-article-buffer |
| 4293 | (if interactive |
| 4294 | (call-interactively ',afunc) |
| 4295 | (apply ',afunc args)))))))) |
| 4296 | '(article-hide-headers |
| 4297 | article-verify-x-pgp-sig |
| 4298 | article-verify-cancel-lock |
| 4299 | article-hide-boring-headers |
| 4300 | article-treat-overstrike |
| 4301 | article-treat-ansi-sequences |
| 4302 | article-fill-long-lines |
| 4303 | article-capitalize-sentences |
| 4304 | article-remove-cr |
| 4305 | article-remove-leading-whitespace |
| 4306 | article-display-x-face |
| 4307 | article-display-face |
| 4308 | article-de-quoted-unreadable |
| 4309 | article-de-base64-unreadable |
| 4310 | article-decode-HZ |
| 4311 | article-wash-html |
| 4312 | article-unsplit-urls |
| 4313 | article-hide-list-identifiers |
| 4314 | article-strip-banner |
| 4315 | article-babel |
| 4316 | article-hide-pem |
| 4317 | article-hide-signature |
| 4318 | article-strip-headers-in-body |
| 4319 | article-remove-trailing-blank-lines |
| 4320 | article-strip-leading-blank-lines |
| 4321 | article-strip-multiple-blank-lines |
| 4322 | article-strip-leading-space |
| 4323 | article-strip-trailing-space |
| 4324 | article-strip-blank-lines |
| 4325 | article-strip-all-blank-lines |
| 4326 | article-date-local |
| 4327 | article-date-english |
| 4328 | article-date-iso8601 |
| 4329 | article-date-original |
| 4330 | article-date-ut |
| 4331 | article-decode-mime-words |
| 4332 | article-decode-charset |
| 4333 | article-decode-encoded-words |
| 4334 | article-date-user |
| 4335 | article-date-lapsed |
| 4336 | article-emphasize |
| 4337 | article-treat-dumbquotes |
| 4338 | article-normalize-headers |
| 4339 | ;;(article-show-all . gnus-article-show-all-headers) |
| 4340 | ))) |
| 4341 | \f |
| 4342 | ;;; |
| 4343 | ;;; Gnus article mode |
| 4344 | ;;; |
| 4345 | |
| 4346 | (put 'gnus-article-mode 'mode-class 'special) |
| 4347 | |
| 4348 | (set-keymap-parent gnus-article-mode-map widget-keymap) |
| 4349 | |
| 4350 | (gnus-define-keys gnus-article-mode-map |
| 4351 | " " gnus-article-goto-next-page |
| 4352 | "\177" gnus-article-goto-prev-page |
| 4353 | [delete] gnus-article-goto-prev-page |
| 4354 | [backspace] gnus-article-goto-prev-page |
| 4355 | "\C-c^" gnus-article-refer-article |
| 4356 | "h" gnus-article-show-summary |
| 4357 | "s" gnus-article-show-summary |
| 4358 | "\C-c\C-m" gnus-article-mail |
| 4359 | "?" gnus-article-describe-briefly |
| 4360 | "<" beginning-of-buffer |
| 4361 | ">" end-of-buffer |
| 4362 | "\C-c\C-i" gnus-info-find-node |
| 4363 | "\C-c\C-b" gnus-bug |
| 4364 | "R" gnus-article-reply-with-original |
| 4365 | "F" gnus-article-followup-with-original |
| 4366 | "\C-hk" gnus-article-describe-key |
| 4367 | "\C-hc" gnus-article-describe-key-briefly |
| 4368 | "\C-hb" gnus-article-describe-bindings |
| 4369 | |
| 4370 | "e" gnus-article-read-summary-keys |
| 4371 | "\C-d" gnus-article-read-summary-keys |
| 4372 | "\M-*" gnus-article-read-summary-keys |
| 4373 | "\M-#" gnus-article-read-summary-keys |
| 4374 | "\M-^" gnus-article-read-summary-keys |
| 4375 | "\M-g" gnus-article-read-summary-keys) |
| 4376 | |
| 4377 | (substitute-key-definition |
| 4378 | 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map) |
| 4379 | |
| 4380 | (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map) |
| 4381 | "W" gnus-article-wide-reply-with-original) |
| 4382 | (if (featurep 'xemacs) |
| 4383 | (set-keymap-default-binding gnus-article-send-map |
| 4384 | 'gnus-article-read-summary-send-keys) |
| 4385 | (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys)) |
| 4386 | |
| 4387 | (defun gnus-article-make-menu-bar () |
| 4388 | (unless (boundp 'gnus-article-commands-menu) |
| 4389 | (gnus-summary-make-menu-bar)) |
| 4390 | (gnus-turn-off-edit-menu 'article) |
| 4391 | (unless (boundp 'gnus-article-article-menu) |
| 4392 | (easy-menu-define |
| 4393 | gnus-article-article-menu gnus-article-mode-map "" |
| 4394 | '("Article" |
| 4395 | ["Scroll forwards" gnus-article-goto-next-page t] |
| 4396 | ["Scroll backwards" gnus-article-goto-prev-page t] |
| 4397 | ["Show summary" gnus-article-show-summary t] |
| 4398 | ["Fetch Message-ID at point" gnus-article-refer-article t] |
| 4399 | ["Mail to address at point" gnus-article-mail t] |
| 4400 | ["Send a bug report" gnus-bug t])) |
| 4401 | |
| 4402 | (easy-menu-define |
| 4403 | gnus-article-treatment-menu gnus-article-mode-map "" |
| 4404 | ;; Fixme: this should use :active (and maybe :visible). |
| 4405 | '("Treatment" |
| 4406 | ["Hide headers" gnus-article-hide-headers t] |
| 4407 | ["Hide signature" gnus-article-hide-signature t] |
| 4408 | ["Hide citation" gnus-article-hide-citation t] |
| 4409 | ["Treat overstrike" gnus-article-treat-overstrike t] |
| 4410 | ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t] |
| 4411 | ["Remove carriage return" gnus-article-remove-cr t] |
| 4412 | ["Remove leading whitespace" gnus-article-remove-leading-whitespace t] |
| 4413 | ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] |
| 4414 | ["Remove base64" gnus-article-de-base64-unreadable t] |
| 4415 | ["Treat html" gnus-article-wash-html t] |
| 4416 | ["Remove newlines from within URLs" gnus-article-unsplit-urls t] |
| 4417 | ["Decode HZ" gnus-article-decode-HZ t])) |
| 4418 | |
| 4419 | ;; Note "Commands" menu is defined in gnus-sum.el for consistency |
| 4420 | |
| 4421 | ;; Note "Post" menu is defined in gnus-sum.el for consistency |
| 4422 | |
| 4423 | (gnus-run-hooks 'gnus-article-menu-hook))) |
| 4424 | |
| 4425 | (defvar bookmark-make-record-function) |
| 4426 | |
| 4427 | (defun gnus-article-mode () |
| 4428 | "Major mode for displaying an article. |
| 4429 | |
| 4430 | All normal editing commands are switched off. |
| 4431 | |
| 4432 | The following commands are available in addition to all summary mode |
| 4433 | commands: |
| 4434 | \\<gnus-article-mode-map> |
| 4435 | \\[gnus-article-next-page]\t Scroll the article one page forwards |
| 4436 | \\[gnus-article-prev-page]\t Scroll the article one page backwards |
| 4437 | \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point |
| 4438 | \\[gnus-article-show-summary]\t Display the summary buffer |
| 4439 | \\[gnus-article-mail]\t Send a reply to the address near point |
| 4440 | \\[gnus-article-describe-briefly]\t Describe the current mode briefly |
| 4441 | \\[gnus-info-find-node]\t Go to the Gnus info node" |
| 4442 | (interactive) |
| 4443 | (kill-all-local-variables) |
| 4444 | (gnus-simplify-mode-line) |
| 4445 | (setq mode-name "Article") |
| 4446 | (setq major-mode 'gnus-article-mode) |
| 4447 | (make-local-variable 'minor-mode-alist) |
| 4448 | (use-local-map gnus-article-mode-map) |
| 4449 | (when (gnus-visual-p 'article-menu 'menu) |
| 4450 | (gnus-article-make-menu-bar) |
| 4451 | (when gnus-summary-tool-bar-map |
| 4452 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))) |
| 4453 | (gnus-update-format-specifications nil 'article-mode) |
| 4454 | (set (make-local-variable 'page-delimiter) gnus-page-delimiter) |
| 4455 | (set (make-local-variable 'gnus-page-broken) nil) |
| 4456 | (make-local-variable 'gnus-button-marker-list) |
| 4457 | (make-local-variable 'gnus-article-current-summary) |
| 4458 | (make-local-variable 'gnus-article-mime-handles) |
| 4459 | (make-local-variable 'gnus-article-decoded-p) |
| 4460 | (make-local-variable 'gnus-article-mime-handle-alist) |
| 4461 | (make-local-variable 'gnus-article-wash-types) |
| 4462 | (make-local-variable 'gnus-article-image-alist) |
| 4463 | (make-local-variable 'gnus-article-charset) |
| 4464 | (make-local-variable 'gnus-article-ignored-charsets) |
| 4465 | (set (make-local-variable 'bookmark-make-record-function) |
| 4466 | 'gnus-summary-bookmark-make-record) |
| 4467 | ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space' |
| 4468 | ;; face. |
| 4469 | (set (make-local-variable 'nobreak-char-display) nil) |
| 4470 | (setq cursor-in-non-selected-windows nil) |
| 4471 | (setq truncate-lines gnus-article-truncate-lines) |
| 4472 | (gnus-set-default-directory) |
| 4473 | (buffer-disable-undo) |
| 4474 | (setq buffer-read-only t |
| 4475 | show-trailing-whitespace nil) |
| 4476 | (set-syntax-table gnus-article-mode-syntax-table) |
| 4477 | (mm-enable-multibyte) |
| 4478 | (gnus-run-mode-hooks 'gnus-article-mode-hook)) |
| 4479 | |
| 4480 | (defvar gnus-button-marker-list nil |
| 4481 | "Regexp matching any of the regexps from `gnus-button-alist'. |
| 4482 | Internal variable.") |
| 4483 | |
| 4484 | (defun gnus-article-setup-buffer () |
| 4485 | "Initialize the article buffer." |
| 4486 | (let* ((name (if gnus-single-article-buffer "*Article*" |
| 4487 | (concat "*Article " gnus-newsgroup-name "*"))) |
| 4488 | (original |
| 4489 | (progn (string-match "\\*Article" name) |
| 4490 | (concat " *Original Article" |
| 4491 | (substring name (match-end 0)))))) |
| 4492 | (setq gnus-article-buffer name) |
| 4493 | (setq gnus-original-article-buffer original) |
| 4494 | (setq gnus-article-mime-handle-alist nil) |
| 4495 | (with-current-buffer gnus-summary-buffer |
| 4496 | ;; This might be a variable local to the summary buffer. |
| 4497 | (unless gnus-single-article-buffer |
| 4498 | (setq gnus-article-buffer name) |
| 4499 | (setq gnus-original-article-buffer original) |
| 4500 | (gnus-set-global-variables))) |
| 4501 | (gnus-article-setup-highlight-words) |
| 4502 | ;; Init original article buffer. |
| 4503 | (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer) |
| 4504 | (mm-enable-multibyte) |
| 4505 | (setq major-mode 'gnus-original-article-mode) |
| 4506 | (make-local-variable 'gnus-original-article)) |
| 4507 | (if (and (get-buffer name) |
| 4508 | (with-current-buffer name |
| 4509 | (if gnus-article-edit-mode |
| 4510 | (if (y-or-n-p "Article mode edit in progress; discard? ") |
| 4511 | (progn |
| 4512 | (set-buffer-modified-p nil) |
| 4513 | (gnus-kill-buffer name) |
| 4514 | (message "") |
| 4515 | nil) |
| 4516 | (error "Action aborted")) |
| 4517 | t))) |
| 4518 | (with-current-buffer name |
| 4519 | (set (make-local-variable 'gnus-article-edit-mode) nil) |
| 4520 | (when gnus-article-mime-handles |
| 4521 | (mm-destroy-parts gnus-article-mime-handles) |
| 4522 | (setq gnus-article-mime-handles nil)) |
| 4523 | ;; Set it to nil in article-buffer! |
| 4524 | (setq gnus-article-mime-handle-alist nil) |
| 4525 | (buffer-disable-undo) |
| 4526 | (setq buffer-read-only t) |
| 4527 | ;; This list just keeps growing if we don't reset it. |
| 4528 | (setq gnus-button-marker-list nil) |
| 4529 | (unless (eq major-mode 'gnus-article-mode) |
| 4530 | (gnus-article-mode)) |
| 4531 | (current-buffer)) |
| 4532 | (with-current-buffer (gnus-get-buffer-create name) |
| 4533 | (gnus-article-mode) |
| 4534 | (make-local-variable 'gnus-summary-buffer) |
| 4535 | (setq gnus-summary-buffer |
| 4536 | (gnus-summary-buffer-name gnus-newsgroup-name)) |
| 4537 | (gnus-summary-set-local-parameters gnus-newsgroup-name) |
| 4538 | (current-buffer))))) |
| 4539 | |
| 4540 | ;; Set article window start at LINE, where LINE is the number of lines |
| 4541 | ;; from the head of the article. |
| 4542 | (defun gnus-article-set-window-start (&optional line) |
| 4543 | (let ((article-window (gnus-get-buffer-window gnus-article-buffer t))) |
| 4544 | (when article-window |
| 4545 | (set-window-start |
| 4546 | article-window |
| 4547 | (with-current-buffer gnus-article-buffer |
| 4548 | (goto-char (point-min)) |
| 4549 | (if (not line) |
| 4550 | (point-min) |
| 4551 | (gnus-message 6 "Moved to bookmark") |
| 4552 | (search-forward "\n\n" nil t) |
| 4553 | (forward-line line) |
| 4554 | (point))))))) |
| 4555 | |
| 4556 | (defun gnus-article-prepare (article &optional all-headers header) |
| 4557 | "Prepare ARTICLE in article mode buffer. |
| 4558 | ARTICLE should either be an article number or a Message-ID. |
| 4559 | If ARTICLE is an id, HEADER should be the article headers. |
| 4560 | If ALL-HEADERS is non-nil, no headers are hidden." |
| 4561 | (save-excursion |
| 4562 | ;; Make sure we start in a summary buffer. |
| 4563 | (unless (eq major-mode 'gnus-summary-mode) |
| 4564 | (set-buffer gnus-summary-buffer)) |
| 4565 | (setq gnus-summary-buffer (current-buffer)) |
| 4566 | (let* ((gnus-article (if header (mail-header-number header) article)) |
| 4567 | (summary-buffer (current-buffer)) |
| 4568 | (gnus-tmp-internal-hook gnus-article-internal-prepare-hook) |
| 4569 | (group gnus-newsgroup-name) |
| 4570 | result) |
| 4571 | (save-excursion |
| 4572 | (gnus-article-setup-buffer) |
| 4573 | (set-buffer gnus-article-buffer) |
| 4574 | ;; Deactivate active regions. |
| 4575 | (when (and (boundp 'transient-mark-mode) |
| 4576 | transient-mark-mode) |
| 4577 | (setq mark-active nil)) |
| 4578 | (if (not (setq result (let ((inhibit-read-only t)) |
| 4579 | (gnus-request-article-this-buffer |
| 4580 | article group)))) |
| 4581 | ;; There is no such article. |
| 4582 | (save-excursion |
| 4583 | (when (and (numberp article) |
| 4584 | (not (memq article gnus-newsgroup-sparse))) |
| 4585 | (setq gnus-article-current |
| 4586 | (cons gnus-newsgroup-name article)) |
| 4587 | (set-buffer gnus-summary-buffer) |
| 4588 | (setq gnus-current-article article) |
| 4589 | (if (and (memq article gnus-newsgroup-undownloaded) |
| 4590 | (not (gnus-online (gnus-find-method-for-group |
| 4591 | gnus-newsgroup-name)))) |
| 4592 | (progn |
| 4593 | (gnus-summary-set-agent-mark article) |
| 4594 | (message "Message marked for downloading")) |
| 4595 | (gnus-summary-mark-article article gnus-canceled-mark) |
| 4596 | (unless (memq article gnus-newsgroup-sparse) |
| 4597 | (gnus-error 1 "No such article (may have expired or been canceled)"))))) |
| 4598 | (if (or (eq result 'pseudo) |
| 4599 | (eq result 'nneething)) |
| 4600 | (progn |
| 4601 | (with-current-buffer summary-buffer |
| 4602 | (push article gnus-newsgroup-history) |
| 4603 | (setq gnus-last-article gnus-current-article |
| 4604 | gnus-current-article 0 |
| 4605 | gnus-current-headers nil |
| 4606 | gnus-article-current nil) |
| 4607 | (if (eq result 'nneething) |
| 4608 | (gnus-configure-windows 'summary) |
| 4609 | (gnus-configure-windows 'article)) |
| 4610 | (gnus-set-global-variables)) |
| 4611 | (let ((gnus-article-mime-handle-alist-1 |
| 4612 | gnus-article-mime-handle-alist)) |
| 4613 | (gnus-set-mode-line 'article))) |
| 4614 | ;; The result from the `request' was an actual article - |
| 4615 | ;; or at least some text that is now displayed in the |
| 4616 | ;; article buffer. |
| 4617 | (when (and (numberp article) |
| 4618 | (not (eq article gnus-current-article))) |
| 4619 | ;; Seems like a new article has been selected. |
| 4620 | ;; `gnus-current-article' must be an article number. |
| 4621 | (with-current-buffer summary-buffer |
| 4622 | (push article gnus-newsgroup-history) |
| 4623 | (setq gnus-last-article gnus-current-article |
| 4624 | gnus-current-article article |
| 4625 | gnus-current-headers |
| 4626 | (gnus-summary-article-header gnus-current-article) |
| 4627 | gnus-article-current |
| 4628 | (cons gnus-newsgroup-name gnus-current-article)) |
| 4629 | (unless (vectorp gnus-current-headers) |
| 4630 | (setq gnus-current-headers nil)) |
| 4631 | (gnus-summary-goto-subject gnus-current-article) |
| 4632 | (when (gnus-summary-show-thread) |
| 4633 | ;; If the summary buffer really was folded, the |
| 4634 | ;; previous goto may not actually have gone to |
| 4635 | ;; the right article, but the thread root instead. |
| 4636 | ;; So we go again. |
| 4637 | (gnus-summary-goto-subject gnus-current-article)) |
| 4638 | (gnus-run-hooks 'gnus-mark-article-hook) |
| 4639 | (gnus-set-mode-line 'summary) |
| 4640 | (when (gnus-visual-p 'article-highlight 'highlight) |
| 4641 | (gnus-run-hooks 'gnus-visual-mark-article-hook)) |
| 4642 | ;; Set the global newsgroup variables here. |
| 4643 | (gnus-set-global-variables) |
| 4644 | (setq gnus-have-all-headers |
| 4645 | (or all-headers gnus-show-all-headers)))) |
| 4646 | (save-excursion |
| 4647 | (gnus-configure-windows 'article)) |
| 4648 | (when (or (numberp article) |
| 4649 | (stringp article)) |
| 4650 | (gnus-article-prepare-display) |
| 4651 | ;; Do page break. |
| 4652 | (goto-char (point-min)) |
| 4653 | (when gnus-break-pages |
| 4654 | (gnus-narrow-to-page))) |
| 4655 | (let ((gnus-article-mime-handle-alist-1 |
| 4656 | gnus-article-mime-handle-alist)) |
| 4657 | (gnus-set-mode-line 'article)) |
| 4658 | (article-goto-body) |
| 4659 | (unless (bobp) |
| 4660 | (forward-line -1)) |
| 4661 | (set-window-point (get-buffer-window (current-buffer)) (point)) |
| 4662 | (gnus-configure-windows 'article) |
| 4663 | t)))))) |
| 4664 | |
| 4665 | ;;;###autoload |
| 4666 | (defun gnus-article-prepare-display () |
| 4667 | "Make the current buffer look like a nice article." |
| 4668 | ;; Hooks for getting information from the article. |
| 4669 | ;; This hook must be called before being narrowed. |
| 4670 | (let ((gnus-article-buffer (current-buffer)) |
| 4671 | buffer-read-only |
| 4672 | (inhibit-read-only t)) |
| 4673 | (unless (eq major-mode 'gnus-article-mode) |
| 4674 | (gnus-article-mode)) |
| 4675 | (setq buffer-read-only nil |
| 4676 | gnus-article-wash-types nil |
| 4677 | gnus-article-image-alist nil) |
| 4678 | (gnus-run-hooks 'gnus-tmp-internal-hook) |
| 4679 | (when gnus-display-mime-function |
| 4680 | (funcall gnus-display-mime-function)) |
| 4681 | (gnus-run-hooks 'gnus-article-prepare-hook))) |
| 4682 | |
| 4683 | ;;; |
| 4684 | ;;; Gnus Sticky Article Mode |
| 4685 | ;;; |
| 4686 | |
| 4687 | (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle" |
| 4688 | "Mode for sticky articles." |
| 4689 | ;; Release bindings that won't work. |
| 4690 | (substitute-key-definition 'gnus-article-read-summary-keys 'undefined |
| 4691 | gnus-sticky-article-mode-map) |
| 4692 | (substitute-key-definition 'gnus-article-refer-article 'undefined |
| 4693 | gnus-sticky-article-mode-map) |
| 4694 | (dolist (k '("e" "h" "s" "F" "R")) |
| 4695 | (define-key gnus-sticky-article-mode-map k nil)) |
| 4696 | (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer) |
| 4697 | (define-key gnus-sticky-article-mode-map "q" 'bury-buffer) |
| 4698 | (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly) |
| 4699 | (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key)) |
| 4700 | |
| 4701 | (defun gnus-sticky-article (arg) |
| 4702 | "Make the current article sticky. |
| 4703 | If a prefix ARG is given, ask for a name for this sticky article buffer." |
| 4704 | (interactive "P") |
| 4705 | (gnus-summary-show-thread) |
| 4706 | (gnus-summary-select-article nil nil 'pseudo) |
| 4707 | (let (new-art-buf-name) |
| 4708 | (gnus-eval-in-buffer-window gnus-article-buffer |
| 4709 | (setq new-art-buf-name |
| 4710 | (concat |
| 4711 | "*Sticky Article: " |
| 4712 | (if arg |
| 4713 | (read-from-minibuffer "Sticky article buffer name: ") |
| 4714 | (gnus-with-article-headers |
| 4715 | (gnus-article-goto-header "subject") |
| 4716 | (setq new-art-buf-name |
| 4717 | (buffer-substring-no-properties |
| 4718 | (line-beginning-position) (line-end-position))) |
| 4719 | (goto-char (point-min)) |
| 4720 | (gnus-article-goto-header "from") |
| 4721 | (setq new-art-buf-name |
| 4722 | (concat |
| 4723 | new-art-buf-name ", " |
| 4724 | (buffer-substring-no-properties |
| 4725 | (line-beginning-position) (line-end-position)))) |
| 4726 | (goto-char (point-min)) |
| 4727 | (gnus-article-goto-header "date") |
| 4728 | (setq new-art-buf-name |
| 4729 | (concat |
| 4730 | new-art-buf-name ", " |
| 4731 | (buffer-substring-no-properties |
| 4732 | (line-beginning-position) (line-end-position)))))) |
| 4733 | "*")) |
| 4734 | (if (and (gnus-buffer-live-p new-art-buf-name) |
| 4735 | (with-current-buffer new-art-buf-name |
| 4736 | (eq major-mode 'gnus-sticky-article-mode))) |
| 4737 | (switch-to-buffer new-art-buf-name) |
| 4738 | (setq new-art-buf-name (rename-buffer new-art-buf-name t))) |
| 4739 | (gnus-sticky-article-mode)) |
| 4740 | (setq gnus-article-buffer new-art-buf-name)) |
| 4741 | (gnus-summary-recenter) |
| 4742 | (gnus-summary-position-point)) |
| 4743 | |
| 4744 | (defun gnus-kill-sticky-article-buffer (&optional buffer) |
| 4745 | "Kill the given sticky article BUFFER. |
| 4746 | If none is given, assume the current buffer and kill it if it has |
| 4747 | `gnus-sticky-article-mode'." |
| 4748 | (interactive) |
| 4749 | (unless buffer |
| 4750 | (setq buffer (current-buffer))) |
| 4751 | (with-current-buffer buffer |
| 4752 | (when (eq major-mode 'gnus-sticky-article-mode) |
| 4753 | (gnus-kill-buffer buffer)))) |
| 4754 | |
| 4755 | (defun gnus-kill-sticky-article-buffers (arg) |
| 4756 | "Kill all sticky article buffers. |
| 4757 | If a prefix ARG is given, ask for confirmation." |
| 4758 | (interactive "P") |
| 4759 | (dolist (buf (gnus-buffers)) |
| 4760 | (with-current-buffer buf |
| 4761 | (when (eq major-mode 'gnus-sticky-article-mode) |
| 4762 | (if (not arg) |
| 4763 | (gnus-kill-buffer buf) |
| 4764 | (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? ")) |
| 4765 | (gnus-kill-buffer buf))))))) |
| 4766 | |
| 4767 | ;;; |
| 4768 | ;;; Gnus MIME viewing functions |
| 4769 | ;;; |
| 4770 | |
| 4771 | (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n" |
| 4772 | "Format of the MIME buttons. |
| 4773 | |
| 4774 | Valid specifiers include: |
| 4775 | %t The MIME type |
| 4776 | %T MIME type, along with additional info |
| 4777 | %n The `name' parameter |
| 4778 | %d The description, if any |
| 4779 | %l The length of the encoded part |
| 4780 | %p The part identifier number |
| 4781 | %e Dots if the part isn't displayed |
| 4782 | |
| 4783 | General format specifiers can also be used. See Info node |
| 4784 | `(gnus)Formatting Variables'.") |
| 4785 | |
| 4786 | (defvar gnus-mime-button-line-format-alist |
| 4787 | '((?t gnus-tmp-type ?s) |
| 4788 | (?T gnus-tmp-type-long ?s) |
| 4789 | (?n gnus-tmp-name ?s) |
| 4790 | (?d gnus-tmp-description ?s) |
| 4791 | (?p gnus-tmp-id ?s) |
| 4792 | (?l gnus-tmp-length ?d) |
| 4793 | (?e gnus-tmp-dots ?s))) |
| 4794 | |
| 4795 | (defvar gnus-mime-button-commands |
| 4796 | '((gnus-article-press-button "\r" "Toggle Display") |
| 4797 | (gnus-mime-view-part "v" "View Interactively...") |
| 4798 | (gnus-mime-view-part-as-type "t" "View As Type...") |
| 4799 | (gnus-mime-view-part-as-charset "C" "View As charset...") |
| 4800 | (gnus-mime-save-part "o" "Save...") |
| 4801 | (gnus-mime-save-part-and-strip "\C-o" "Save and Strip") |
| 4802 | (gnus-mime-replace-part "r" "Replace part") |
| 4803 | (gnus-mime-delete-part "d" "Delete part") |
| 4804 | (gnus-mime-copy-part "c" "View As Text, In Other Buffer") |
| 4805 | (gnus-mime-inline-part "i" "View As Text, In This Buffer") |
| 4806 | (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'? |
| 4807 | (gnus-mime-view-part-externally "e" "View Externally") |
| 4808 | (gnus-mime-print-part "p" "Print") |
| 4809 | (gnus-mime-pipe-part "|" "Pipe To Command...") |
| 4810 | (gnus-mime-action-on-part "." "Take action on the part..."))) |
| 4811 | |
| 4812 | (defun gnus-article-mime-part-status () |
| 4813 | (if gnus-article-mime-handle-alist-1 |
| 4814 | (if (eq 1 (length gnus-article-mime-handle-alist-1)) |
| 4815 | " (1 part)" |
| 4816 | (format " (%d parts)" (length gnus-article-mime-handle-alist-1))) |
| 4817 | "")) |
| 4818 | |
| 4819 | (defvar gnus-mime-button-map |
| 4820 | (let ((map (make-sparse-keymap))) |
| 4821 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
| 4822 | (define-key map gnus-down-mouse-3 'gnus-mime-button-menu) |
| 4823 | (dolist (c gnus-mime-button-commands) |
| 4824 | (define-key map (cadr c) (car c))) |
| 4825 | map)) |
| 4826 | |
| 4827 | (easy-menu-define |
| 4828 | gnus-mime-button-menu gnus-mime-button-map "MIME button menu." |
| 4829 | `("MIME Part" |
| 4830 | ,@(mapcar (lambda (c) |
| 4831 | (vector (caddr c) (car c) :active t)) |
| 4832 | gnus-mime-button-commands))) |
| 4833 | |
| 4834 | (defvar gnus-url-button-commands |
| 4835 | '((gnus-article-copy-string "u" "Copy URL to kill ring"))) |
| 4836 | |
| 4837 | (defvar gnus-url-button-map |
| 4838 | (let ((map (make-sparse-keymap))) |
| 4839 | (dolist (c gnus-url-button-commands) |
| 4840 | (define-key map (cadr c) (car c))) |
| 4841 | map)) |
| 4842 | |
| 4843 | (easy-menu-define |
| 4844 | gnus-url-button-menu gnus-url-button-map "URL button menu." |
| 4845 | `("Url Button" |
| 4846 | ,@(mapcar (lambda (c) |
| 4847 | (vector (caddr c) (car c) :active t)) |
| 4848 | gnus-url-button-commands))) |
| 4849 | |
| 4850 | (defmacro gnus-bind-safe-url-regexp (&rest body) |
| 4851 | "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'." |
| 4852 | `(let ((mm-w3m-safe-url-regexp |
| 4853 | (let ((group (if (and (eq major-mode 'gnus-article-mode) |
| 4854 | (gnus-buffer-live-p |
| 4855 | gnus-article-current-summary)) |
| 4856 | (with-current-buffer gnus-article-current-summary |
| 4857 | gnus-newsgroup-name) |
| 4858 | gnus-newsgroup-name))) |
| 4859 | (if (cond ((not group) |
| 4860 | ;; Maybe we're in a mml-preview buffer |
| 4861 | ;; and no group is selected. |
| 4862 | t) |
| 4863 | ((stringp gnus-safe-html-newsgroups) |
| 4864 | (string-match gnus-safe-html-newsgroups group)) |
| 4865 | ((consp gnus-safe-html-newsgroups) |
| 4866 | (member group gnus-safe-html-newsgroups))) |
| 4867 | nil |
| 4868 | mm-w3m-safe-url-regexp)))) |
| 4869 | ,@body)) |
| 4870 | |
| 4871 | (defun gnus-mime-button-menu (event prefix) |
| 4872 | "Construct a context-sensitive menu of MIME commands." |
| 4873 | (interactive "e\nP") |
| 4874 | (save-window-excursion |
| 4875 | (let ((pos (event-start event))) |
| 4876 | (select-window (posn-window pos)) |
| 4877 | (goto-char (posn-point pos)) |
| 4878 | (gnus-article-check-buffer) |
| 4879 | (popup-menu gnus-mime-button-menu nil prefix)))) |
| 4880 | |
| 4881 | (defun gnus-mime-view-all-parts (&optional handles) |
| 4882 | "View all the MIME parts." |
| 4883 | (interactive) |
| 4884 | (with-current-buffer gnus-article-buffer |
| 4885 | (let ((handles (or handles gnus-article-mime-handles)) |
| 4886 | (mail-parse-charset gnus-newsgroup-charset) |
| 4887 | (mail-parse-ignored-charsets |
| 4888 | (with-current-buffer gnus-summary-buffer |
| 4889 | gnus-newsgroup-ignored-charsets))) |
| 4890 | (when handles |
| 4891 | (mm-remove-parts handles) |
| 4892 | (goto-char (point-min)) |
| 4893 | (or (search-forward "\n\n") (goto-char (point-max))) |
| 4894 | (let ((inhibit-read-only t)) |
| 4895 | (delete-region (point) (point-max)) |
| 4896 | (gnus-bind-safe-url-regexp (mm-display-parts handles))))))) |
| 4897 | |
| 4898 | (defun gnus-article-jump-to-part (n) |
| 4899 | "Jump to MIME part N." |
| 4900 | (interactive "P") |
| 4901 | (pop-to-buffer gnus-article-buffer) |
| 4902 | ;; FIXME: why is it necessary? |
| 4903 | (sit-for 0) |
| 4904 | (let ((parts (length gnus-article-mime-handle-alist))) |
| 4905 | (or n (setq n (read-number (format "Jump to part (2..%s): " parts)))) |
| 4906 | (unless (and (integerp n) (<= n parts) (>= n 1)) |
| 4907 | (setq n |
| 4908 | (progn |
| 4909 | (gnus-message 7 "Invalid part `%s', using %s instead." |
| 4910 | n parts) |
| 4911 | parts))) |
| 4912 | (gnus-message 9 "Jumping to part %s." n) |
| 4913 | (cond ((>= gnus-auto-select-part 1) |
| 4914 | (while (and (<= n parts) |
| 4915 | (not (gnus-article-goto-part n))) |
| 4916 | (setq n (1+ n)))) |
| 4917 | ((< gnus-auto-select-part 0) |
| 4918 | (while (and (>= n 1) |
| 4919 | (not (gnus-article-goto-part n))) |
| 4920 | (setq n (1- n)))) |
| 4921 | (t |
| 4922 | (gnus-article-goto-part n))))) |
| 4923 | |
| 4924 | (defvar gnus-mime-buttonized-part-id nil |
| 4925 | "ID of a mime part that should be buttonized. |
| 4926 | `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.") |
| 4927 | |
| 4928 | (eval-when-compile |
| 4929 | (defsubst gnus-article-edit-part (handles &optional current-id) |
| 4930 | "Edit an article in order to delete a mime part. |
| 4931 | This function is exclusively used by `gnus-mime-save-part-and-strip' |
| 4932 | and `gnus-mime-delete-part', and not provided at run-time normally." |
| 4933 | (gnus-article-edit-article |
| 4934 | `(lambda () |
| 4935 | (buffer-disable-undo) |
| 4936 | (erase-buffer) |
| 4937 | (let ((mail-parse-charset (or gnus-article-charset |
| 4938 | ',gnus-newsgroup-charset)) |
| 4939 | (mail-parse-ignored-charsets |
| 4940 | (or gnus-article-ignored-charsets |
| 4941 | ',gnus-newsgroup-ignored-charsets)) |
| 4942 | (mbl mml-buffer-list)) |
| 4943 | (setq mml-buffer-list nil) |
| 4944 | (insert-buffer-substring gnus-original-article-buffer) |
| 4945 | (mime-to-mml ',handles) |
| 4946 | (setq gnus-article-mime-handles nil) |
| 4947 | (let ((mbl1 mml-buffer-list)) |
| 4948 | (setq mml-buffer-list mbl) |
| 4949 | (set (make-local-variable 'mml-buffer-list) mbl1)) |
| 4950 | (gnus-make-local-hook 'kill-buffer-hook) |
| 4951 | (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))) |
| 4952 | `(lambda (no-highlight) |
| 4953 | (let ((mail-parse-charset (or gnus-article-charset |
| 4954 | ',gnus-newsgroup-charset)) |
| 4955 | (message-options message-options) |
| 4956 | (message-options-set-recipient) |
| 4957 | (mail-parse-ignored-charsets |
| 4958 | (or gnus-article-ignored-charsets |
| 4959 | ',gnus-newsgroup-ignored-charsets))) |
| 4960 | (mml-to-mime) |
| 4961 | (mml-destroy-buffers) |
| 4962 | (remove-hook 'kill-buffer-hook |
| 4963 | 'mml-destroy-buffers t) |
| 4964 | (kill-local-variable 'mml-buffer-list)) |
| 4965 | (gnus-summary-edit-article-done |
| 4966 | ,(or (mail-header-references gnus-current-headers) "") |
| 4967 | ,(gnus-group-read-only-p) |
| 4968 | ,gnus-summary-buffer no-highlight)) |
| 4969 | t) |
| 4970 | ;; Force buttonizing this part. |
| 4971 | (let ((gnus-mime-buttonized-part-id current-id)) |
| 4972 | (gnus-article-edit-done)) |
| 4973 | (gnus-configure-windows 'article) |
| 4974 | (when (and current-id (integerp gnus-auto-select-part)) |
| 4975 | (gnus-article-jump-to-part |
| 4976 | (min (max (+ current-id gnus-auto-select-part) 1) |
| 4977 | (with-current-buffer gnus-article-buffer |
| 4978 | (length gnus-article-mime-handle-alist))))))) |
| 4979 | |
| 4980 | (defun gnus-mime-replace-part (file) |
| 4981 | "Replace MIME part under point with an external body." |
| 4982 | ;; Useful if file has already been saved to disk |
| 4983 | (interactive |
| 4984 | (list |
| 4985 | (read-file-name "Replace MIME part with file: " |
| 4986 | (or mm-default-directory default-directory) |
| 4987 | nil nil))) |
| 4988 | (gnus-mime-save-part-and-strip file)) |
| 4989 | |
| 4990 | (defun gnus-mime-save-part-and-strip (&optional file) |
| 4991 | "Save the MIME part under point then replace it with an external body. |
| 4992 | If FILE is given, use it for the external part." |
| 4993 | (interactive) |
| 4994 | (gnus-article-check-buffer) |
| 4995 | (when (gnus-group-read-only-p) |
| 4996 | (error "The current group does not support deleting of parts")) |
| 4997 | (when (mm-complicated-handles gnus-article-mime-handles) |
| 4998 | (error "\ |
| 4999 | The current article has a complicated MIME structure, giving up...")) |
| 5000 | (let* ((data (get-text-property (point) 'gnus-data)) |
| 5001 | (id (get-text-property (point) 'gnus-part)) |
| 5002 | param |
| 5003 | (handles gnus-article-mime-handles)) |
| 5004 | (unless file |
| 5005 | (setq file |
| 5006 | (and data (mm-save-part data "Delete MIME part and save to: ")))) |
| 5007 | (when file |
| 5008 | (with-current-buffer (mm-handle-buffer data) |
| 5009 | (erase-buffer) |
| 5010 | (insert "Content-Type: " (mm-handle-media-type data)) |
| 5011 | (mml-insert-parameter-string (cdr (mm-handle-type data)) |
| 5012 | '(charset)) |
| 5013 | ;; Add a filename for the sake of saving the part again. |
| 5014 | (mml-insert-parameter |
| 5015 | (mail-header-encode-parameter "name" (file-name-nondirectory file))) |
| 5016 | (insert "\n") |
| 5017 | (insert "Content-ID: " (message-make-message-id) "\n") |
| 5018 | (insert "Content-Transfer-Encoding: binary\n") |
| 5019 | (insert "\n")) |
| 5020 | (setcdr data |
| 5021 | (cdr (mm-make-handle nil |
| 5022 | `("message/external-body" |
| 5023 | (access-type . "LOCAL-FILE") |
| 5024 | (name . ,file))))) |
| 5025 | ;; (set-buffer gnus-summary-buffer) |
| 5026 | (gnus-article-edit-part handles id)))) |
| 5027 | |
| 5028 | ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all |
| 5029 | ;; parts...>') but with stripping would be nice. |
| 5030 | |
| 5031 | (defun gnus-mime-delete-part () |
| 5032 | "Delete the MIME part under point. |
| 5033 | Replace it with some information about the removed part." |
| 5034 | (interactive) |
| 5035 | (gnus-article-check-buffer) |
| 5036 | (when (gnus-group-read-only-p) |
| 5037 | (error "The current group does not support deleting of parts")) |
| 5038 | (when (mm-complicated-handles gnus-article-mime-handles) |
| 5039 | (error "\ |
| 5040 | The current article has a complicated MIME structure, giving up...")) |
| 5041 | (when (or gnus-expert-user |
| 5042 | (gnus-yes-or-no-p "\ |
| 5043 | Deleting parts may malfunction or destroy the article; continue? ")) |
| 5044 | (let* ((data (get-text-property (point) 'gnus-data)) |
| 5045 | (id (get-text-property (point) 'gnus-part)) |
| 5046 | (handles gnus-article-mime-handles) |
| 5047 | (none "(none)") |
| 5048 | (description |
| 5049 | (let ((desc (mm-handle-description data))) |
| 5050 | (when desc |
| 5051 | (mail-decode-encoded-word-string desc)))) |
| 5052 | (filename |
| 5053 | (or (mail-content-type-get (mm-handle-disposition data) 'filename) |
| 5054 | none)) |
| 5055 | (type (mm-handle-media-type data))) |
| 5056 | (unless data |
| 5057 | (error "No MIME part under point")) |
| 5058 | (with-current-buffer (mm-handle-buffer data) |
| 5059 | (let ((bsize (buffer-size))) |
| 5060 | (erase-buffer) |
| 5061 | (insert |
| 5062 | (concat |
| 5063 | ",----\n" |
| 5064 | "| The following attachment has been deleted:\n" |
| 5065 | "|\n" |
| 5066 | "| Type: " type "\n" |
| 5067 | "| Filename: " filename "\n" |
| 5068 | "| Size (encoded): " (format "%s byte%s\n" |
| 5069 | bsize (if (= bsize 1) |
| 5070 | "" |
| 5071 | "s")) |
| 5072 | (when description |
| 5073 | (concat "| Description: " description "\n")) |
| 5074 | "`----\n")) |
| 5075 | (setcdr data |
| 5076 | (cdr (mm-make-handle |
| 5077 | nil `("text/plain" (charset . gnus-decoded)) nil nil |
| 5078 | (list "attachment") |
| 5079 | (format "Deleted attachment (%s bytes)" bsize)))))) |
| 5080 | ;; (set-buffer gnus-summary-buffer) |
| 5081 | (gnus-article-edit-part handles id)))) |
| 5082 | |
| 5083 | (defun gnus-mime-save-part () |
| 5084 | "Save the MIME part under point." |
| 5085 | (interactive) |
| 5086 | (gnus-article-check-buffer) |
| 5087 | (let ((data (get-text-property (point) 'gnus-data))) |
| 5088 | (when data |
| 5089 | (mm-save-part data)))) |
| 5090 | |
| 5091 | (defun gnus-mime-pipe-part (&optional cmd) |
| 5092 | "Pipe the MIME part under point to a process. |
| 5093 | Use CMD as the process." |
| 5094 | (interactive) |
| 5095 | (gnus-article-check-buffer) |
| 5096 | (let ((data (get-text-property (point) 'gnus-data))) |
| 5097 | (when data |
| 5098 | (mm-pipe-part data cmd)))) |
| 5099 | |
| 5100 | (defun gnus-mime-view-part () |
| 5101 | "Interactively choose a viewing method for the MIME part under point." |
| 5102 | (interactive) |
| 5103 | (gnus-article-check-buffer) |
| 5104 | (let ((data (get-text-property (point) 'gnus-data))) |
| 5105 | (when data |
| 5106 | (setq gnus-article-mime-handles |
| 5107 | (mm-merge-handles |
| 5108 | gnus-article-mime-handles (setq data (copy-sequence data)))) |
| 5109 | (mm-interactively-view-part data)))) |
| 5110 | |
| 5111 | (defun gnus-mime-view-part-as-type-internal () |
| 5112 | (gnus-article-check-buffer) |
| 5113 | (let* ((handle (get-text-property (point) 'gnus-data)) |
| 5114 | (name (or |
| 5115 | ;; Content-Type: foo/bar; name=... |
| 5116 | (mail-content-type-get (mm-handle-type handle) 'name) |
| 5117 | ;; Content-Disposition: attachment; filename=... |
| 5118 | (cdr (assq 'filename (cdr (mm-handle-disposition handle)))))) |
| 5119 | (def-type (and name (mm-default-file-encoding name)))) |
| 5120 | (or (and def-type (cons def-type 0)) |
| 5121 | (and handle |
| 5122 | (equal (mm-handle-media-supertype handle) "text") |
| 5123 | '("text/plain" . 0)) |
| 5124 | '("application/octet-stream" . 0)))) |
| 5125 | |
| 5126 | (defun gnus-mime-view-part-as-type (&optional mime-type pred) |
| 5127 | "Choose a MIME media type, and view the part as such. |
| 5128 | If non-nil, PRED is a predicate to use during completion to limit the |
| 5129 | available media-types." |
| 5130 | (interactive) |
| 5131 | (unless mime-type |
| 5132 | (setq mime-type |
| 5133 | (let ((default (gnus-mime-view-part-as-type-internal))) |
| 5134 | (gnus-completing-read |
| 5135 | "View as MIME type" |
| 5136 | (remove-if-not pred (mailcap-mime-types)) |
| 5137 | nil nil nil |
| 5138 | (car default))))) |
| 5139 | (gnus-article-check-buffer) |
| 5140 | (let ((handle (get-text-property (point) 'gnus-data))) |
| 5141 | (when handle |
| 5142 | (when (equal (mm-handle-media-type handle) "message/external-body") |
| 5143 | (unless (mm-handle-cache handle) |
| 5144 | (mm-extern-cache-contents handle)) |
| 5145 | (setq handle (mm-handle-cache handle))) |
| 5146 | (setq handle |
| 5147 | (mm-make-handle (mm-handle-buffer handle) |
| 5148 | (cons mime-type (cdr (mm-handle-type handle))) |
| 5149 | (mm-handle-encoding handle) |
| 5150 | (mm-handle-undisplayer handle) |
| 5151 | (mm-handle-disposition handle) |
| 5152 | (mm-handle-description handle) |
| 5153 | nil |
| 5154 | (mm-handle-id handle))) |
| 5155 | (setq gnus-article-mime-handles |
| 5156 | (mm-merge-handles gnus-article-mime-handles handle)) |
| 5157 | (when (mm-handle-displayed-p handle) |
| 5158 | (mm-remove-part handle)) |
| 5159 | (gnus-mm-display-part handle)))) |
| 5160 | |
| 5161 | (defun gnus-mime-copy-part (&optional handle arg) |
| 5162 | "Put the MIME part under point into a new buffer. |
| 5163 | If `auto-compression-mode' is enabled, compressed files like .gz and .bz2 |
| 5164 | are decompressed." |
| 5165 | (interactive (list nil current-prefix-arg)) |
| 5166 | (gnus-article-check-buffer) |
| 5167 | (unless handle |
| 5168 | (setq handle (get-text-property (point) 'gnus-data))) |
| 5169 | (when handle |
| 5170 | (let ((filename (or (mail-content-type-get (mm-handle-type handle) |
| 5171 | 'name) |
| 5172 | (mail-content-type-get (mm-handle-disposition handle) |
| 5173 | 'filename))) |
| 5174 | contents dont-decode charset coding-system) |
| 5175 | (mm-with-unibyte-buffer |
| 5176 | (mm-insert-part handle) |
| 5177 | (setq contents (or (condition-case nil |
| 5178 | (mm-decompress-buffer filename nil 'sig) |
| 5179 | (error |
| 5180 | (setq dont-decode t) |
| 5181 | nil)) |
| 5182 | (buffer-string)))) |
| 5183 | (setq filename (cond (filename (file-name-nondirectory filename)) |
| 5184 | (dont-decode "*raw data*") |
| 5185 | (t "*decoded*"))) |
| 5186 | (cond |
| 5187 | (dont-decode) |
| 5188 | ((not arg) |
| 5189 | (unless (setq charset (mail-content-type-get |
| 5190 | (mm-handle-type handle) 'charset)) |
| 5191 | (unless (setq coding-system (mm-with-unibyte-buffer |
| 5192 | (insert contents) |
| 5193 | (mm-find-buffer-file-coding-system))) |
| 5194 | (setq charset gnus-newsgroup-charset)))) |
| 5195 | ((numberp arg) |
| 5196 | (setq charset (or (cdr (assq arg |
| 5197 | gnus-summary-show-article-charset-alist)) |
| 5198 | (mm-read-coding-system "Charset: "))))) |
| 5199 | (switch-to-buffer (generate-new-buffer filename)) |
| 5200 | (if (or coding-system |
| 5201 | (and charset |
| 5202 | (setq coding-system (mm-charset-to-coding-system charset)) |
| 5203 | (not (eq charset 'ascii)))) |
| 5204 | (progn |
| 5205 | (mm-enable-multibyte) |
| 5206 | (insert (mm-decode-coding-string contents coding-system)) |
| 5207 | (setq buffer-file-coding-system |
| 5208 | (if (boundp 'last-coding-system-used) |
| 5209 | (symbol-value 'last-coding-system-used) |
| 5210 | coding-system))) |
| 5211 | (mm-disable-multibyte) |
| 5212 | (insert contents) |
| 5213 | (setq buffer-file-coding-system mm-binary-coding-system)) |
| 5214 | ;; We do it this way to make `normal-mode' set the appropriate mode. |
| 5215 | (unwind-protect |
| 5216 | (progn |
| 5217 | (setq buffer-file-name (expand-file-name filename)) |
| 5218 | (normal-mode)) |
| 5219 | (setq buffer-file-name nil)) |
| 5220 | (goto-char (point-min))))) |
| 5221 | |
| 5222 | (defun gnus-mime-print-part (&optional handle filename) |
| 5223 | "Print the MIME part under point." |
| 5224 | (interactive (list nil (ps-print-preprint current-prefix-arg))) |
| 5225 | (gnus-article-check-buffer) |
| 5226 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) |
| 5227 | (contents (and handle (mm-get-part handle))) |
| 5228 | (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory))) |
| 5229 | (printer (mailcap-mime-info (mm-handle-media-type handle) "print"))) |
| 5230 | (when contents |
| 5231 | (if printer |
| 5232 | (unwind-protect |
| 5233 | (progn |
| 5234 | (mm-save-part-to-file handle file) |
| 5235 | (call-process shell-file-name nil |
| 5236 | (generate-new-buffer " *mm*") |
| 5237 | nil |
| 5238 | shell-command-switch |
| 5239 | (mm-mailcap-command |
| 5240 | printer file (mm-handle-type handle)))) |
| 5241 | (delete-file file)) |
| 5242 | (with-temp-buffer |
| 5243 | (insert contents) |
| 5244 | (gnus-print-buffer)) |
| 5245 | (ps-despool filename))))) |
| 5246 | |
| 5247 | (defun gnus-mime-inline-part (&optional handle arg) |
| 5248 | "Insert the MIME part under point into the current buffer. |
| 5249 | Compressed files like .gz and .bz2 are decompressed." |
| 5250 | (interactive (list nil current-prefix-arg)) |
| 5251 | (gnus-article-check-buffer) |
| 5252 | (unless handle |
| 5253 | (setq handle (get-text-property (point) 'gnus-data))) |
| 5254 | (when handle |
| 5255 | (let ((b (point)) |
| 5256 | (inhibit-read-only t) |
| 5257 | contents charset coding-system) |
| 5258 | (if (and (not arg) (mm-handle-undisplayer handle)) |
| 5259 | (mm-remove-part handle) |
| 5260 | (mm-with-unibyte-buffer |
| 5261 | (mm-insert-part handle) |
| 5262 | (setq contents |
| 5263 | (or (mm-decompress-buffer |
| 5264 | (or (mail-content-type-get (mm-handle-type handle) |
| 5265 | 'name) |
| 5266 | (mail-content-type-get (mm-handle-disposition handle) |
| 5267 | 'filename)) |
| 5268 | nil t) |
| 5269 | (buffer-string)))) |
| 5270 | (cond |
| 5271 | ((not arg) |
| 5272 | (unless (setq charset (mail-content-type-get |
| 5273 | (mm-handle-type handle) 'charset)) |
| 5274 | (unless (setq coding-system |
| 5275 | (mm-with-unibyte-buffer |
| 5276 | (insert contents) |
| 5277 | (mm-find-buffer-file-coding-system))) |
| 5278 | (setq charset gnus-newsgroup-charset)))) |
| 5279 | ((numberp arg) |
| 5280 | (if (mm-handle-undisplayer handle) |
| 5281 | (mm-remove-part handle)) |
| 5282 | (setq charset |
| 5283 | (or (cdr (assq arg |
| 5284 | gnus-summary-show-article-charset-alist)) |
| 5285 | (mm-read-coding-system "Charset: ")))) |
| 5286 | (t |
| 5287 | (if (mm-handle-undisplayer handle) |
| 5288 | (mm-remove-part handle)))) |
| 5289 | (forward-line 2) |
| 5290 | (mm-insert-inline |
| 5291 | handle |
| 5292 | (if (or coding-system |
| 5293 | (and charset |
| 5294 | (setq coding-system |
| 5295 | (mm-charset-to-coding-system charset)) |
| 5296 | (not (eq coding-system 'ascii)))) |
| 5297 | (mm-decode-coding-string contents coding-system) |
| 5298 | (mm-string-to-multibyte contents))) |
| 5299 | (goto-char b))))) |
| 5300 | |
| 5301 | (defun gnus-mime-set-charset-parameters (handle charset) |
| 5302 | "Set CHARSET to parameters in HANDLE. |
| 5303 | CHARSET may either be a string or a symbol." |
| 5304 | (unless (stringp charset) |
| 5305 | (setq charset (symbol-name charset))) |
| 5306 | (if (stringp (car handle)) |
| 5307 | (dolist (h (cdr handle)) |
| 5308 | (gnus-mime-set-charset-parameters h charset)) |
| 5309 | (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle) |
| 5310 | "message/external-body") |
| 5311 | (progn |
| 5312 | (unless (mm-handle-cache handle) |
| 5313 | (mm-extern-cache-contents handle)) |
| 5314 | (mm-handle-cache handle)) |
| 5315 | handle))) |
| 5316 | (param (assq 'charset (cdr type)))) |
| 5317 | (if param |
| 5318 | (setcdr param charset) |
| 5319 | (setcdr type (cons (cons 'charset charset) (cdr type))))))) |
| 5320 | |
| 5321 | (defun gnus-mime-view-part-as-charset (&optional handle arg) |
| 5322 | "Insert the MIME part under point into the current buffer using the |
| 5323 | specified charset." |
| 5324 | (interactive (list nil current-prefix-arg)) |
| 5325 | (gnus-article-check-buffer) |
| 5326 | (let ((handle (or handle (get-text-property (point) 'gnus-data))) |
| 5327 | (fun (get-text-property (point) 'gnus-callback)) |
| 5328 | (gnus-newsgroup-ignored-charsets 'gnus-all) |
| 5329 | charset form preferred parts) |
| 5330 | (when handle |
| 5331 | (when (prog1 |
| 5332 | (and fun |
| 5333 | (setq charset |
| 5334 | (or (cdr (assq |
| 5335 | arg |
| 5336 | gnus-summary-show-article-charset-alist)) |
| 5337 | (mm-read-coding-system "Charset: ")))) |
| 5338 | (if (mm-handle-undisplayer handle) |
| 5339 | (mm-remove-part handle))) |
| 5340 | (gnus-mime-set-charset-parameters handle charset) |
| 5341 | (when (and (consp (setq form (cdr-safe fun))) |
| 5342 | (setq form (ignore-errors |
| 5343 | (assq 'gnus-mime-display-alternative form))) |
| 5344 | (setq preferred (caddr form)) |
| 5345 | (progn |
| 5346 | (when (eq (car preferred) 'quote) |
| 5347 | (setq preferred (cadr preferred))) |
| 5348 | (not (equal preferred |
| 5349 | (get-text-property (point) 'gnus-data)))) |
| 5350 | (setq parts (get-text-property (point) 'gnus-part)) |
| 5351 | (setq parts (cdr (assq parts |
| 5352 | gnus-article-mime-handle-alist))) |
| 5353 | (equal (mm-handle-media-type parts) "multipart/alternative") |
| 5354 | (setq parts (reverse (cdr parts)))) |
| 5355 | (setcar (cddr form) |
| 5356 | (list 'quote (or (cadr (member preferred parts)) |
| 5357 | (car parts))))) |
| 5358 | (funcall fun handle))))) |
| 5359 | |
| 5360 | (defun gnus-mime-view-part-externally (&optional handle) |
| 5361 | "View the MIME part under point with an external viewer." |
| 5362 | (interactive) |
| 5363 | (gnus-article-check-buffer) |
| 5364 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) |
| 5365 | (mm-user-display-methods nil) |
| 5366 | (mm-inlined-types nil) |
| 5367 | (mail-parse-charset gnus-newsgroup-charset) |
| 5368 | (mail-parse-ignored-charsets |
| 5369 | (with-current-buffer gnus-summary-buffer |
| 5370 | gnus-newsgroup-ignored-charsets)) |
| 5371 | (type (mm-handle-media-type handle)) |
| 5372 | (method (mailcap-mime-info type)) |
| 5373 | (mm-enable-external t)) |
| 5374 | (if (not (stringp method)) |
| 5375 | (gnus-mime-view-part-as-type |
| 5376 | nil (lambda (types) (stringp (mailcap-mime-info (car types))))) |
| 5377 | (when handle |
| 5378 | (if (mm-handle-undisplayer handle) |
| 5379 | (mm-remove-part handle) |
| 5380 | (mm-display-part handle)))))) |
| 5381 | |
| 5382 | (defun gnus-mime-view-part-internally (&optional handle) |
| 5383 | "View the MIME part under point with an internal viewer. |
| 5384 | If no internal viewer is available, use an external viewer." |
| 5385 | (interactive) |
| 5386 | (gnus-article-check-buffer) |
| 5387 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) |
| 5388 | (mm-inlined-types '(".*")) |
| 5389 | (mm-inline-large-images t) |
| 5390 | (mail-parse-charset gnus-newsgroup-charset) |
| 5391 | (mail-parse-ignored-charsets |
| 5392 | (with-current-buffer gnus-summary-buffer |
| 5393 | gnus-newsgroup-ignored-charsets)) |
| 5394 | (inhibit-read-only t)) |
| 5395 | (if (not (mm-inlinable-p handle)) |
| 5396 | (gnus-mime-view-part-as-type |
| 5397 | nil (lambda (types) (mm-inlinable-p handle (car types)))) |
| 5398 | (when handle |
| 5399 | (if (mm-handle-undisplayer handle) |
| 5400 | (mm-remove-part handle) |
| 5401 | (gnus-bind-safe-url-regexp (mm-display-part handle))))))) |
| 5402 | |
| 5403 | (defun gnus-mime-action-on-part (&optional action) |
| 5404 | "Do something with the MIME attachment at \(point\)." |
| 5405 | (interactive |
| 5406 | (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t))) |
| 5407 | (gnus-article-check-buffer) |
| 5408 | (let ((action-pair (assoc action gnus-mime-action-alist))) |
| 5409 | (if action-pair |
| 5410 | (funcall (cdr action-pair))))) |
| 5411 | |
| 5412 | (defun gnus-article-part-wrapper (n function &optional no-handle interactive) |
| 5413 | "Call FUNCTION on MIME part N. |
| 5414 | Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument. |
| 5415 | If INTERACTIVE, call FUNCTION interactivly." |
| 5416 | (let (window frame) |
| 5417 | ;; Check whether the article is displayed. |
| 5418 | (unless (and (gnus-buffer-live-p gnus-article-buffer) |
| 5419 | (setq window (get-buffer-window gnus-article-buffer t)) |
| 5420 | (frame-visible-p (setq frame (window-frame window)))) |
| 5421 | (error "No article is displayed")) |
| 5422 | (with-current-buffer gnus-article-buffer |
| 5423 | ;; Check whether the article displays the right contents. |
| 5424 | (unless (with-current-buffer gnus-summary-buffer |
| 5425 | (eq gnus-current-article (gnus-summary-article-number))) |
| 5426 | (error "You should select the right article first")) |
| 5427 | (if n |
| 5428 | (setq n (prefix-numeric-value n)) |
| 5429 | (let ((pt (point))) |
| 5430 | (setq n (or (get-text-property pt 'gnus-part) |
| 5431 | (and (not (bobp)) |
| 5432 | (get-text-property (1- pt) 'gnus-part)) |
| 5433 | (get-text-property (prog2 |
| 5434 | (forward-line 1) |
| 5435 | (point) |
| 5436 | (goto-char pt)) |
| 5437 | 'gnus-part) |
| 5438 | (get-text-property |
| 5439 | (or (and (setq pt (previous-single-property-change |
| 5440 | pt 'gnus-part)) |
| 5441 | (1- pt)) |
| 5442 | (next-single-property-change (point) 'gnus-part) |
| 5443 | (point)) |
| 5444 | 'gnus-part) |
| 5445 | 1)))) |
| 5446 | ;; Check whether the specified part exists. |
| 5447 | (when (> n (length gnus-article-mime-handle-alist)) |
| 5448 | (error "No such part"))) |
| 5449 | (unless |
| 5450 | (progn |
| 5451 | ;; To select the window is needed so that the cursor |
| 5452 | ;; might be visible on the MIME button. |
| 5453 | (select-window (prog1 |
| 5454 | window |
| 5455 | (setq window (selected-window)) |
| 5456 | ;; Article may be displayed in the other frame. |
| 5457 | (gnus-select-frame-set-input-focus |
| 5458 | (prog1 |
| 5459 | frame |
| 5460 | (setq frame (selected-frame)))))) |
| 5461 | (when (gnus-article-goto-part n) |
| 5462 | ;; We point the cursor and the arrow at the MIME button |
| 5463 | ;; when the `function' prompt the user for something. |
| 5464 | (let ((cursor-in-non-selected-windows t) |
| 5465 | (overlay-arrow-string "=>") |
| 5466 | (overlay-arrow-position (point-marker))) |
| 5467 | (unwind-protect |
| 5468 | (cond |
| 5469 | ((and no-handle interactive) |
| 5470 | (call-interactively function)) |
| 5471 | (no-handle |
| 5472 | (funcall function)) |
| 5473 | (interactive |
| 5474 | (call-interactively |
| 5475 | function |
| 5476 | (cdr (assq n gnus-article-mime-handle-alist)))) |
| 5477 | (t |
| 5478 | (funcall function |
| 5479 | (cdr (assq n gnus-article-mime-handle-alist))))) |
| 5480 | (set-marker overlay-arrow-position nil) |
| 5481 | (unless gnus-auto-select-part |
| 5482 | (gnus-select-frame-set-input-focus frame) |
| 5483 | (select-window window)))) |
| 5484 | t)) |
| 5485 | (if gnus-inhibit-mime-unbuttonizing |
| 5486 | ;; This is the default though the program shouldn't reach here. |
| 5487 | (error "No such part") |
| 5488 | ;; The part which doesn't have the MIME button is selected. |
| 5489 | ;; So, we display all the buttons and redo it. |
| 5490 | (let ((gnus-inhibit-mime-unbuttonizing t)) |
| 5491 | (gnus-summary-show-article) |
| 5492 | (gnus-article-part-wrapper n function no-handle)))))) |
| 5493 | |
| 5494 | (defun gnus-article-pipe-part (n) |
| 5495 | "Pipe MIME part N, which is the numerical prefix." |
| 5496 | (interactive "P") |
| 5497 | (gnus-article-part-wrapper n 'mm-pipe-part)) |
| 5498 | |
| 5499 | (defun gnus-article-save-part (n) |
| 5500 | "Save MIME part N, which is the numerical prefix." |
| 5501 | (interactive "P") |
| 5502 | (gnus-article-part-wrapper n 'mm-save-part)) |
| 5503 | |
| 5504 | (defun gnus-article-interactively-view-part (n) |
| 5505 | "View MIME part N interactively, which is the numerical prefix." |
| 5506 | (interactive "P") |
| 5507 | (gnus-article-part-wrapper n 'mm-interactively-view-part)) |
| 5508 | |
| 5509 | (defun gnus-article-copy-part (n) |
| 5510 | "Copy MIME part N, which is the numerical prefix." |
| 5511 | (interactive "P") |
| 5512 | (gnus-article-part-wrapper n 'gnus-mime-copy-part)) |
| 5513 | |
| 5514 | (defun gnus-article-view-part-as-charset (n) |
| 5515 | "View MIME part N using a specified charset. |
| 5516 | N is the numerical prefix." |
| 5517 | (interactive "P") |
| 5518 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset)) |
| 5519 | |
| 5520 | (defun gnus-article-view-part-externally (n) |
| 5521 | "View MIME part N externally, which is the numerical prefix." |
| 5522 | (interactive "P") |
| 5523 | (gnus-article-part-wrapper n 'gnus-mime-view-part-externally)) |
| 5524 | |
| 5525 | (defun gnus-article-inline-part (n) |
| 5526 | "Inline MIME part N, which is the numerical prefix." |
| 5527 | (interactive "P") |
| 5528 | (gnus-article-part-wrapper n 'gnus-mime-inline-part)) |
| 5529 | |
| 5530 | (defun gnus-article-save-part-and-strip (n) |
| 5531 | "Save MIME part N and replace it with an external body. |
| 5532 | N is the numerical prefix." |
| 5533 | (interactive "P") |
| 5534 | (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t)) |
| 5535 | |
| 5536 | (defun gnus-article-replace-part (n) |
| 5537 | "Replace MIME part N with an external body. |
| 5538 | N is the numerical prefix." |
| 5539 | (interactive "P") |
| 5540 | (gnus-article-part-wrapper n 'gnus-mime-replace-part t t)) |
| 5541 | |
| 5542 | (defun gnus-article-delete-part (n) |
| 5543 | "Delete MIME part N and add some information about the removed part. |
| 5544 | N is the numerical prefix." |
| 5545 | (interactive "P") |
| 5546 | (gnus-article-part-wrapper n 'gnus-mime-delete-part t)) |
| 5547 | |
| 5548 | (defun gnus-article-view-part-as-type (n) |
| 5549 | "Choose a MIME media type, and view part N as such. |
| 5550 | N is the numerical prefix." |
| 5551 | (interactive "P") |
| 5552 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t)) |
| 5553 | |
| 5554 | (defun gnus-article-mime-match-handle-first (condition) |
| 5555 | (if condition |
| 5556 | (let (n) |
| 5557 | (dolist (ihandle gnus-article-mime-handle-alist) |
| 5558 | (if (and (cond |
| 5559 | ((functionp condition) |
| 5560 | (funcall condition (cdr ihandle))) |
| 5561 | ((eq condition 'undisplayed) |
| 5562 | (not (or (mm-handle-undisplayer (cdr ihandle)) |
| 5563 | (equal (mm-handle-media-type (cdr ihandle)) |
| 5564 | "multipart/alternative")))) |
| 5565 | ((eq condition 'undisplayed-alternative) |
| 5566 | (not (mm-handle-undisplayer (cdr ihandle)))) |
| 5567 | (t t)) |
| 5568 | (gnus-article-goto-part (car ihandle)) |
| 5569 | (or (not n) (< (car ihandle) n))) |
| 5570 | (setq n (car ihandle)))) |
| 5571 | (or n 1)) |
| 5572 | 1)) |
| 5573 | |
| 5574 | (defun gnus-article-view-part (&optional n) |
| 5575 | "View MIME part N, which is the numerical prefix. |
| 5576 | If the part is already shown, hide the part. If N is nil, view |
| 5577 | all parts." |
| 5578 | (interactive "P") |
| 5579 | (with-current-buffer gnus-article-buffer |
| 5580 | (or (numberp n) (setq n (gnus-article-mime-match-handle-first |
| 5581 | gnus-article-mime-match-handle-function))) |
| 5582 | (when (> n (length gnus-article-mime-handle-alist)) |
| 5583 | (error "No such part")) |
| 5584 | (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) |
| 5585 | (when (gnus-article-goto-part n) |
| 5586 | (if (equal (car handle) "multipart/alternative") |
| 5587 | (gnus-article-press-button) |
| 5588 | (when (eq (gnus-mm-display-part handle) 'internal) |
| 5589 | (gnus-set-window-start))))))) |
| 5590 | |
| 5591 | (defsubst gnus-article-mime-total-parts () |
| 5592 | (if (bufferp (car gnus-article-mime-handles)) |
| 5593 | 1 ;; single part |
| 5594 | (1- (length gnus-article-mime-handles)))) |
| 5595 | |
| 5596 | (defun gnus-mm-display-part (handle) |
| 5597 | "Display HANDLE and fix MIME button." |
| 5598 | (let ((id (get-text-property (point) 'gnus-part)) |
| 5599 | (point (point)) |
| 5600 | (inhibit-read-only t)) |
| 5601 | (forward-line 1) |
| 5602 | (prog1 |
| 5603 | (let ((window (selected-window)) |
| 5604 | (mail-parse-charset gnus-newsgroup-charset) |
| 5605 | (mail-parse-ignored-charsets |
| 5606 | (if (gnus-buffer-live-p gnus-summary-buffer) |
| 5607 | (with-current-buffer gnus-summary-buffer |
| 5608 | gnus-newsgroup-ignored-charsets) |
| 5609 | nil))) |
| 5610 | (save-excursion |
| 5611 | (unwind-protect |
| 5612 | (let ((win (gnus-get-buffer-window (current-buffer) t)) |
| 5613 | (beg (point))) |
| 5614 | (when win |
| 5615 | (select-window win)) |
| 5616 | (goto-char point) |
| 5617 | (forward-line) |
| 5618 | (if (mm-handle-displayed-p handle) |
| 5619 | ;; This will remove the part. |
| 5620 | (mm-display-part handle) |
| 5621 | (save-restriction |
| 5622 | (narrow-to-region (point) |
| 5623 | (if (eobp) (point) (1+ (point)))) |
| 5624 | (gnus-bind-safe-url-regexp (mm-display-part handle)) |
| 5625 | ;; We narrow to the part itself and |
| 5626 | ;; then call the treatment functions. |
| 5627 | (goto-char (point-min)) |
| 5628 | (forward-line 1) |
| 5629 | (narrow-to-region (point) (point-max)) |
| 5630 | (gnus-treat-article |
| 5631 | nil id |
| 5632 | (gnus-article-mime-total-parts) |
| 5633 | (mm-handle-media-type handle))))) |
| 5634 | (if (window-live-p window) |
| 5635 | (select-window window))))) |
| 5636 | (goto-char point) |
| 5637 | (gnus-delete-line) |
| 5638 | (gnus-insert-mime-button |
| 5639 | handle id (list (mm-handle-displayed-p handle))) |
| 5640 | (goto-char point)))) |
| 5641 | |
| 5642 | (defun gnus-article-goto-part (n) |
| 5643 | "Go to MIME part N." |
| 5644 | (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n))) |
| 5645 | |
| 5646 | (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) |
| 5647 | (let ((gnus-tmp-name |
| 5648 | (or (mail-content-type-get (mm-handle-type handle) 'name) |
| 5649 | (mail-content-type-get (mm-handle-disposition handle) 'filename) |
| 5650 | (mail-content-type-get (mm-handle-type handle) 'url) |
| 5651 | "")) |
| 5652 | (gnus-tmp-type (mm-handle-media-type handle)) |
| 5653 | (gnus-tmp-description (or (mm-handle-description handle) "")) |
| 5654 | (gnus-tmp-dots |
| 5655 | (if (if displayed (car displayed) |
| 5656 | (mm-handle-displayed-p handle)) |
| 5657 | "" "...")) |
| 5658 | (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle) |
| 5659 | (buffer-size))) |
| 5660 | gnus-tmp-type-long b e) |
| 5661 | (when (string-match ".*/" gnus-tmp-name) |
| 5662 | (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name))) |
| 5663 | (setq gnus-tmp-type-long (concat gnus-tmp-type |
| 5664 | (and (not (equal gnus-tmp-name "")) |
| 5665 | (concat "; " gnus-tmp-name)))) |
| 5666 | (unless (equal gnus-tmp-description "") |
| 5667 | (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long))) |
| 5668 | (unless (bolp) |
| 5669 | (insert "\n")) |
| 5670 | (setq b (point)) |
| 5671 | (gnus-eval-format |
| 5672 | gnus-mime-button-line-format gnus-mime-button-line-format-alist |
| 5673 | `(keymap ,gnus-mime-button-map |
| 5674 | gnus-callback gnus-mm-display-part |
| 5675 | gnus-part ,gnus-tmp-id |
| 5676 | article-type annotation |
| 5677 | gnus-data ,handle)) |
| 5678 | (setq e (if (bolp) |
| 5679 | ;; Exclude a newline. |
| 5680 | (1- (point)) |
| 5681 | (point))) |
| 5682 | (when gnus-article-button-face |
| 5683 | (gnus-overlay-put (gnus-make-overlay b e nil t) |
| 5684 | 'face gnus-article-button-face)) |
| 5685 | (widget-convert-button |
| 5686 | 'link b e |
| 5687 | :mime-handle handle |
| 5688 | :action 'gnus-widget-press-button |
| 5689 | :button-keymap gnus-mime-button-map |
| 5690 | :help-echo |
| 5691 | (lambda (widget) |
| 5692 | ;; Needed to properly clear the message due to a bug in |
| 5693 | ;; wid-edit (XEmacs only). |
| 5694 | (if (boundp 'help-echo-owns-message) |
| 5695 | (setq help-echo-owns-message t)) |
| 5696 | (format |
| 5697 | "%S: %s the MIME part; %S: more options" |
| 5698 | (aref gnus-mouse-2 0) |
| 5699 | (if (mm-handle-displayed-p (widget-get widget :mime-handle)) |
| 5700 | "hide" "show") |
| 5701 | (aref gnus-down-mouse-3 0)))))) |
| 5702 | |
| 5703 | (defun gnus-widget-press-button (elems el) |
| 5704 | (goto-char (widget-get elems :from)) |
| 5705 | (gnus-article-press-button)) |
| 5706 | |
| 5707 | (defvar gnus-displaying-mime nil) |
| 5708 | |
| 5709 | (defun gnus-display-mime (&optional ihandles) |
| 5710 | "Display the MIME parts." |
| 5711 | (save-excursion |
| 5712 | (save-selected-window |
| 5713 | (let ((window (get-buffer-window gnus-article-buffer)) |
| 5714 | (point (point))) |
| 5715 | (when window |
| 5716 | (select-window window) |
| 5717 | ;; We have to do this since selecting the window |
| 5718 | ;; may change the point. So we set the window point. |
| 5719 | (set-window-point window point))) |
| 5720 | (let ((handles ihandles) |
| 5721 | (inhibit-read-only t) |
| 5722 | handle) |
| 5723 | (cond (handles) |
| 5724 | ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime)) |
| 5725 | (when gnus-article-emulate-mime |
| 5726 | (mm-uu-dissect-text-parts handles))) |
| 5727 | (gnus-article-emulate-mime |
| 5728 | (setq handles (mm-uu-dissect)))) |
| 5729 | (when (and (not ihandles) |
| 5730 | (not gnus-displaying-mime)) |
| 5731 | ;; Top-level call; we clean up. |
| 5732 | (when gnus-article-mime-handles |
| 5733 | (mm-destroy-parts gnus-article-mime-handles) |
| 5734 | (setq gnus-article-mime-handle-alist nil));; A trick. |
| 5735 | (setq gnus-article-mime-handles handles) |
| 5736 | ;; We allow users to glean info from the handles. |
| 5737 | (when gnus-article-mime-part-function |
| 5738 | (gnus-mime-part-function handles))) |
| 5739 | (if (and handles |
| 5740 | (or (not (stringp (car handles))) |
| 5741 | (cdr handles))) |
| 5742 | (progn |
| 5743 | (when (and (not ihandles) |
| 5744 | (not gnus-displaying-mime)) |
| 5745 | ;; Clean up for mime parts. |
| 5746 | (article-goto-body) |
| 5747 | (delete-region (point) (point-max))) |
| 5748 | (let ((gnus-displaying-mime t)) |
| 5749 | (gnus-mime-display-part handles))) |
| 5750 | (save-restriction |
| 5751 | (article-goto-body) |
| 5752 | (narrow-to-region (point) (point-max)) |
| 5753 | (gnus-treat-article nil 1 1) |
| 5754 | (widen))) |
| 5755 | (unless ihandles |
| 5756 | ;; Highlight the headers. |
| 5757 | (save-excursion |
| 5758 | (save-restriction |
| 5759 | (article-goto-body) |
| 5760 | (narrow-to-region (point-min) (point)) |
| 5761 | (gnus-article-save-original-date |
| 5762 | (gnus-treat-article 'head))))))) |
| 5763 | ;; Cope with broken MIME messages. |
| 5764 | (goto-char (point-max)) |
| 5765 | (unless (bolp) |
| 5766 | (insert "\n")))) |
| 5767 | |
| 5768 | (defcustom gnus-mime-display-multipart-as-mixed nil |
| 5769 | "Display \"multipart\" parts as \"multipart/mixed\". |
| 5770 | |
| 5771 | If t, it overrides nil values of |
| 5772 | `gnus-mime-display-multipart-alternative-as-mixed' and |
| 5773 | `gnus-mime-display-multipart-related-as-mixed'." |
| 5774 | :group 'gnus-article-mime |
| 5775 | :type 'boolean) |
| 5776 | |
| 5777 | (defcustom gnus-mime-display-multipart-alternative-as-mixed nil |
| 5778 | "Display \"multipart/alternative\" parts as \"multipart/mixed\"." |
| 5779 | :version "22.1" |
| 5780 | :group 'gnus-article-mime |
| 5781 | :type 'boolean) |
| 5782 | |
| 5783 | (defcustom gnus-mime-display-multipart-related-as-mixed nil |
| 5784 | "Display \"multipart/related\" parts as \"multipart/mixed\". |
| 5785 | |
| 5786 | If displaying \"text/html\" is discouraged \(see |
| 5787 | `mm-discouraged-alternatives'\) images or other material inside a |
| 5788 | \"multipart/related\" part might be overlooked when this variable is nil." |
| 5789 | :version "22.1" |
| 5790 | :group 'gnus-article-mime |
| 5791 | :type 'boolean) |
| 5792 | |
| 5793 | (defun gnus-mime-display-part (handle) |
| 5794 | (cond |
| 5795 | ;; Maybe a broken MIME message. |
| 5796 | ((null handle)) |
| 5797 | ;; Single part. |
| 5798 | ((not (stringp (car handle))) |
| 5799 | (gnus-mime-display-single handle)) |
| 5800 | ;; User-defined multipart |
| 5801 | ((cdr (assoc (car handle) gnus-mime-multipart-functions)) |
| 5802 | (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions)) |
| 5803 | handle)) |
| 5804 | ;; multipart/alternative |
| 5805 | ((and (equal (car handle) "multipart/alternative") |
| 5806 | (not (or gnus-mime-display-multipart-as-mixed |
| 5807 | gnus-mime-display-multipart-alternative-as-mixed))) |
| 5808 | (let ((id (1+ (length gnus-article-mime-handle-alist)))) |
| 5809 | (push (cons id handle) gnus-article-mime-handle-alist) |
| 5810 | (gnus-mime-display-alternative (cdr handle) nil nil id))) |
| 5811 | ;; multipart/related |
| 5812 | ((and (equal (car handle) "multipart/related") |
| 5813 | (not (or gnus-mime-display-multipart-as-mixed |
| 5814 | gnus-mime-display-multipart-related-as-mixed))) |
| 5815 | ;;;!!!We should find the start part, but we just default |
| 5816 | ;;;!!!to the first part. |
| 5817 | ;;(gnus-mime-display-part (cadr handle)) |
| 5818 | ;;;!!! Most multipart/related is an HTML message plus images. |
| 5819 | ;;;!!! Unfortunately we are unable to let W3 display those |
| 5820 | ;;;!!! included images, so we just display it as a mixed multipart. |
| 5821 | ;;(gnus-mime-display-mixed (cdr handle)) |
| 5822 | ;;;!!! No, w3 can display everything just fine. |
| 5823 | (gnus-mime-display-part (cadr handle))) |
| 5824 | ((equal (car handle) "multipart/signed") |
| 5825 | (gnus-add-wash-type 'signed) |
| 5826 | (gnus-mime-display-security handle)) |
| 5827 | ((equal (car handle) "multipart/encrypted") |
| 5828 | (gnus-add-wash-type 'encrypted) |
| 5829 | (gnus-mime-display-security handle)) |
| 5830 | ;; Other multiparts are handled like multipart/mixed. |
| 5831 | (t |
| 5832 | (gnus-mime-display-mixed (cdr handle))))) |
| 5833 | |
| 5834 | (defun gnus-mime-part-function (handles) |
| 5835 | (if (stringp (car handles)) |
| 5836 | (mapcar 'gnus-mime-part-function (cdr handles)) |
| 5837 | (funcall gnus-article-mime-part-function handles))) |
| 5838 | |
| 5839 | (defun gnus-mime-display-mixed (handles) |
| 5840 | (mapcar 'gnus-mime-display-part handles)) |
| 5841 | |
| 5842 | (defun gnus-mime-display-single (handle) |
| 5843 | (let ((type (mm-handle-media-type handle)) |
| 5844 | (ignored gnus-ignored-mime-types) |
| 5845 | (not-attachment t) |
| 5846 | (move nil) |
| 5847 | display text) |
| 5848 | (catch 'ignored |
| 5849 | (progn |
| 5850 | (while ignored |
| 5851 | (when (string-match (pop ignored) type) |
| 5852 | (throw 'ignored nil))) |
| 5853 | (if (and (setq not-attachment |
| 5854 | (and (not (mm-inline-override-p handle)) |
| 5855 | (or (not (mm-handle-disposition handle)) |
| 5856 | (equal (car (mm-handle-disposition handle)) |
| 5857 | "inline") |
| 5858 | (mm-attachment-override-p handle)))) |
| 5859 | (mm-automatic-display-p handle) |
| 5860 | (or (and |
| 5861 | (mm-inlinable-p handle) |
| 5862 | (mm-inlined-p handle)) |
| 5863 | (mm-automatic-external-display-p type))) |
| 5864 | (setq display t) |
| 5865 | (when (equal (mm-handle-media-supertype handle) "text") |
| 5866 | (setq text t))) |
| 5867 | (let ((id (1+ (length gnus-article-mime-handle-alist))) |
| 5868 | beg) |
| 5869 | (push (cons id handle) gnus-article-mime-handle-alist) |
| 5870 | (when (and display |
| 5871 | (equal (mm-handle-media-supertype handle) "message")) |
| 5872 | (insert-char |
| 5873 | ?\n |
| 5874 | (cond ((not (bolp)) 2) |
| 5875 | ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0) |
| 5876 | (t 1)))) |
| 5877 | (when (or (not display) |
| 5878 | (not (gnus-unbuttonized-mime-type-p type)) |
| 5879 | (eq id gnus-mime-buttonized-part-id)) |
| 5880 | (gnus-insert-mime-button |
| 5881 | handle id (list (or display (and not-attachment text)))) |
| 5882 | (gnus-article-insert-newline) |
| 5883 | ;; Remember modify the number of forward lines. |
| 5884 | (setq move t)) |
| 5885 | (setq beg (point)) |
| 5886 | (cond |
| 5887 | (display |
| 5888 | (when move |
| 5889 | (forward-line -1) |
| 5890 | (setq beg (point))) |
| 5891 | (let ((mail-parse-charset gnus-newsgroup-charset) |
| 5892 | (mail-parse-ignored-charsets |
| 5893 | (save-excursion (condition-case () |
| 5894 | (set-buffer gnus-summary-buffer) |
| 5895 | (error)) |
| 5896 | gnus-newsgroup-ignored-charsets))) |
| 5897 | (gnus-bind-safe-url-regexp (mm-display-part handle t))) |
| 5898 | (goto-char (point-max))) |
| 5899 | ((and text not-attachment) |
| 5900 | (when move |
| 5901 | (forward-line -1) |
| 5902 | (setq beg (point))) |
| 5903 | (gnus-article-insert-newline) |
| 5904 | (mm-insert-inline |
| 5905 | handle |
| 5906 | (let ((charset (or (mail-content-type-get (mm-handle-type handle) |
| 5907 | 'charset) |
| 5908 | (and (equal type "text/calendar") 'utf-8)))) |
| 5909 | (cond ((not charset) |
| 5910 | (mm-string-as-multibyte (mm-get-part handle))) |
| 5911 | ((eq charset 'gnus-decoded) |
| 5912 | (with-current-buffer (mm-handle-buffer handle) |
| 5913 | (buffer-string))) |
| 5914 | (t |
| 5915 | (mm-decode-string (mm-get-part handle) charset))))) |
| 5916 | (goto-char (point-max)))) |
| 5917 | ;; Do highlighting. |
| 5918 | (save-excursion |
| 5919 | (save-restriction |
| 5920 | (narrow-to-region beg (point)) |
| 5921 | (if (eq handle gnus-article-mime-handles) |
| 5922 | ;; The format=flowed case. |
| 5923 | (gnus-treat-article nil 1 1 (mm-handle-media-type handle)) |
| 5924 | ;; Don't count signature parts that are never displayed. |
| 5925 | ;; The part number should be re-calculated supposing this |
| 5926 | ;; might be a message/rfc822 part. |
| 5927 | (let (handles) |
| 5928 | (dolist (part gnus-article-mime-handles) |
| 5929 | (unless (or (stringp part) |
| 5930 | (equal (car (mm-handle-type part)) |
| 5931 | "application/pgp-signature")) |
| 5932 | (push part handles))) |
| 5933 | (gnus-treat-article |
| 5934 | nil (length (memq handle handles)) (length handles) |
| 5935 | (mm-handle-media-type handle))))))))))) |
| 5936 | |
| 5937 | (defun gnus-unbuttonized-mime-type-p (type) |
| 5938 | "Say whether TYPE is to be unbuttonized." |
| 5939 | (unless gnus-inhibit-mime-unbuttonizing |
| 5940 | (when (catch 'found |
| 5941 | (let ((types gnus-unbuttonized-mime-types)) |
| 5942 | (while types |
| 5943 | (when (string-match (pop types) type) |
| 5944 | (throw 'found t))))) |
| 5945 | (not (catch 'found |
| 5946 | (let ((types gnus-buttonized-mime-types)) |
| 5947 | (while types |
| 5948 | (when (string-match (pop types) type) |
| 5949 | (throw 'found t))))))))) |
| 5950 | |
| 5951 | (defun gnus-article-insert-newline () |
| 5952 | "Insert a newline, but mark it as undeletable." |
| 5953 | (gnus-put-text-property |
| 5954 | (point) (progn (insert "\n") (point)) 'gnus-undeletable t)) |
| 5955 | |
| 5956 | (defun gnus-mime-display-alternative (handles &optional preferred ibegend id) |
| 5957 | (let* ((preferred (or preferred (mm-preferred-alternative handles))) |
| 5958 | (ihandles handles) |
| 5959 | (point (point)) |
| 5960 | handle (inhibit-read-only t) from props begend not-pref) |
| 5961 | (save-window-excursion |
| 5962 | (save-restriction |
| 5963 | (when ibegend |
| 5964 | (narrow-to-region (car ibegend) |
| 5965 | (or (cdr ibegend) |
| 5966 | (progn |
| 5967 | (goto-char (car ibegend)) |
| 5968 | (forward-line 2) |
| 5969 | (point)))) |
| 5970 | (delete-region (point-min) (point-max)) |
| 5971 | (mm-remove-parts handles)) |
| 5972 | (setq begend (list (point-marker))) |
| 5973 | ;; Do the toggle. |
| 5974 | (unless (setq not-pref (cadr (member preferred ihandles))) |
| 5975 | (setq not-pref (car ihandles))) |
| 5976 | (when (or ibegend |
| 5977 | (not preferred) |
| 5978 | (not (gnus-unbuttonized-mime-type-p |
| 5979 | "multipart/alternative"))) |
| 5980 | (gnus-add-text-properties |
| 5981 | (setq from (point)) |
| 5982 | (progn |
| 5983 | (insert (format "%d. " id)) |
| 5984 | (point)) |
| 5985 | `(gnus-callback |
| 5986 | (lambda (handles) |
| 5987 | (unless ,(not ibegend) |
| 5988 | (setq gnus-article-mime-handle-alist |
| 5989 | ',gnus-article-mime-handle-alist)) |
| 5990 | (gnus-mime-display-alternative |
| 5991 | ',ihandles ',not-pref ',begend ,id)) |
| 5992 | keymap ,gnus-mime-button-map |
| 5993 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
| 5994 | face ,gnus-article-button-face |
| 5995 | gnus-part ,id |
| 5996 | article-type multipart)) |
| 5997 | (widget-convert-button 'link from (point) |
| 5998 | :action 'gnus-widget-press-button |
| 5999 | :button-keymap gnus-widget-button-keymap) |
| 6000 | ;; Do the handles |
| 6001 | (while (setq handle (pop handles)) |
| 6002 | (gnus-add-text-properties |
| 6003 | (setq from (point)) |
| 6004 | (progn |
| 6005 | (insert (format "(%c) %-18s" |
| 6006 | (if (equal handle preferred) ?* ? ) |
| 6007 | (mm-handle-media-type handle))) |
| 6008 | (point)) |
| 6009 | `(gnus-callback |
| 6010 | (lambda (handles) |
| 6011 | (unless ,(not ibegend) |
| 6012 | (setq gnus-article-mime-handle-alist |
| 6013 | ',gnus-article-mime-handle-alist)) |
| 6014 | (gnus-mime-display-alternative |
| 6015 | ',ihandles ',handle ',begend ,id)) |
| 6016 | keymap ,gnus-mime-button-map |
| 6017 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
| 6018 | face ,gnus-article-button-face |
| 6019 | gnus-part ,id |
| 6020 | gnus-data ,handle)) |
| 6021 | (widget-convert-button 'link from (point) |
| 6022 | :action 'gnus-widget-press-button |
| 6023 | :button-keymap gnus-widget-button-keymap) |
| 6024 | (insert " ")) |
| 6025 | (insert "\n\n")) |
| 6026 | (when preferred |
| 6027 | (if (stringp (car preferred)) |
| 6028 | (gnus-display-mime preferred) |
| 6029 | (let ((mail-parse-charset gnus-newsgroup-charset) |
| 6030 | (mail-parse-ignored-charsets |
| 6031 | (with-current-buffer gnus-summary-buffer |
| 6032 | gnus-newsgroup-ignored-charsets))) |
| 6033 | (gnus-bind-safe-url-regexp (mm-display-part preferred)) |
| 6034 | ;; Do highlighting. |
| 6035 | (save-excursion |
| 6036 | (save-restriction |
| 6037 | (narrow-to-region (car begend) (point-max)) |
| 6038 | (gnus-treat-article |
| 6039 | nil (length gnus-article-mime-handle-alist) |
| 6040 | (gnus-article-mime-total-parts) |
| 6041 | (mm-handle-media-type handle)))))) |
| 6042 | (goto-char (point-max)) |
| 6043 | (setcdr begend (point-marker))))) |
| 6044 | (when ibegend |
| 6045 | (goto-char point)))) |
| 6046 | |
| 6047 | (defconst gnus-article-wash-status-strings |
| 6048 | (let ((alist '((cite "c" "Possible hidden citation text" |
| 6049 | " " "All citation text visible") |
| 6050 | (headers "h" "Hidden headers" |
| 6051 | " " "All headers visible.") |
| 6052 | (pgp "p" "Encrypted or signed message status hidden" |
| 6053 | " " "No hidden encryption nor digital signature status") |
| 6054 | (signature "s" "Signature has been hidden" |
| 6055 | " " "Signature is visible") |
| 6056 | (overstrike "o" "Overstrike (^H) characters applied" |
| 6057 | " " "No overstrike characters applied") |
| 6058 | (emphasis "e" "/*_Emphasis_*/ characters applied" |
| 6059 | " " "No /*_emphasis_*/ characters applied"))) |
| 6060 | result) |
| 6061 | (dolist (entry alist result) |
| 6062 | (let ((key (nth 0 entry)) |
| 6063 | (on (copy-sequence (nth 1 entry))) |
| 6064 | (on-help (nth 2 entry)) |
| 6065 | (off (copy-sequence (nth 3 entry))) |
| 6066 | (off-help (nth 4 entry))) |
| 6067 | (put-text-property 0 1 'help-echo on-help on) |
| 6068 | (put-text-property 0 1 'help-echo off-help off) |
| 6069 | (push (list key on off) result)))) |
| 6070 | "Alist of strings describing wash status in the mode line. |
| 6071 | Each entry has the form (KEY ON OF), where the KEY is a symbol |
| 6072 | representing the particular washing function, ON is the string to use |
| 6073 | in the article mode line when the washing function is active, and OFF |
| 6074 | is the string to use when it is inactive.") |
| 6075 | |
| 6076 | (defun gnus-article-wash-status-entry (key value) |
| 6077 | (let ((entry (assoc key gnus-article-wash-status-strings))) |
| 6078 | (if value (nth 1 entry) (nth 2 entry)))) |
| 6079 | |
| 6080 | (defun gnus-article-wash-status () |
| 6081 | "Return a string which display status of article washing." |
| 6082 | (with-current-buffer gnus-article-buffer |
| 6083 | (let ((cite (memq 'cite gnus-article-wash-types)) |
| 6084 | (headers (memq 'headers gnus-article-wash-types)) |
| 6085 | (boring (memq 'boring-headers gnus-article-wash-types)) |
| 6086 | (pgp (memq 'pgp gnus-article-wash-types)) |
| 6087 | (pem (memq 'pem gnus-article-wash-types)) |
| 6088 | (signed (memq 'signed gnus-article-wash-types)) |
| 6089 | (encrypted (memq 'encrypted gnus-article-wash-types)) |
| 6090 | (signature (memq 'signature gnus-article-wash-types)) |
| 6091 | (overstrike (memq 'overstrike gnus-article-wash-types)) |
| 6092 | (emphasis (memq 'emphasis gnus-article-wash-types))) |
| 6093 | (concat |
| 6094 | (gnus-article-wash-status-entry 'cite cite) |
| 6095 | (gnus-article-wash-status-entry 'headers (or headers boring)) |
| 6096 | (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted)) |
| 6097 | (gnus-article-wash-status-entry 'signature signature) |
| 6098 | (gnus-article-wash-status-entry 'overstrike overstrike) |
| 6099 | (gnus-article-wash-status-entry 'emphasis emphasis))))) |
| 6100 | |
| 6101 | (defun gnus-add-wash-type (type) |
| 6102 | "Add a washing of TYPE to the current status." |
| 6103 | (add-to-list 'gnus-article-wash-types type)) |
| 6104 | |
| 6105 | (defun gnus-delete-wash-type (type) |
| 6106 | "Add a washing of TYPE to the current status." |
| 6107 | (setq gnus-article-wash-types (delq type gnus-article-wash-types))) |
| 6108 | |
| 6109 | (defun gnus-add-image (category image) |
| 6110 | "Add IMAGE of CATEGORY to the list of displayed images." |
| 6111 | (let ((entry (assq category gnus-article-image-alist))) |
| 6112 | (unless entry |
| 6113 | (setq entry (list category)) |
| 6114 | (push entry gnus-article-image-alist)) |
| 6115 | (nconc entry (list image)))) |
| 6116 | |
| 6117 | (defun gnus-delete-images (category) |
| 6118 | "Delete all images in CATEGORY." |
| 6119 | (let ((entry (assq category gnus-article-image-alist))) |
| 6120 | (dolist (image (cdr entry)) |
| 6121 | (gnus-remove-image image category)) |
| 6122 | (setq gnus-article-image-alist (delq entry gnus-article-image-alist)) |
| 6123 | (gnus-delete-wash-type category))) |
| 6124 | |
| 6125 | (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers) |
| 6126 | |
| 6127 | (defun gnus-article-maybe-hide-headers () |
| 6128 | "Hide unwanted headers if `gnus-have-all-headers' is nil. |
| 6129 | Provided for backwards compatibility." |
| 6130 | (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer)) |
| 6131 | (not (with-current-buffer gnus-summary-buffer |
| 6132 | gnus-have-all-headers))) |
| 6133 | (not gnus-inhibit-hiding)) |
| 6134 | (gnus-article-hide-headers))) |
| 6135 | |
| 6136 | ;;; Article savers. |
| 6137 | |
| 6138 | (defun gnus-output-to-file (file-name) |
| 6139 | "Append the current article to a file named FILE-NAME. |
| 6140 | If `gnus-article-save-coding-system' is non-nil, it is used to encode |
| 6141 | text and used as the value of the coding cookie which is added to the |
| 6142 | top of a file. Otherwise, this function saves a raw article without |
| 6143 | the coding cookie." |
| 6144 | (let* ((artbuf (current-buffer)) |
| 6145 | (file-name-coding-system nnmail-pathname-coding-system) |
| 6146 | (coding gnus-article-save-coding-system) |
| 6147 | (coding-system-for-read (if coding |
| 6148 | nil ;; Rely on the coding cookie. |
| 6149 | mm-text-coding-system)) |
| 6150 | (coding-system-for-write (or coding |
| 6151 | mm-text-coding-system-for-write |
| 6152 | mm-text-coding-system)) |
| 6153 | (exists (file-exists-p file-name))) |
| 6154 | (with-temp-buffer |
| 6155 | (when exists |
| 6156 | (insert-file-contents file-name) |
| 6157 | (goto-char (point-min)) |
| 6158 | ;; Remove the existing coding cookie. |
| 6159 | (when (looking-at "X-Gnus-Coding-System: .+\n\n") |
| 6160 | (delete-region (match-beginning 0) (match-end 0)))) |
| 6161 | (goto-char (point-max)) |
| 6162 | (insert-buffer-substring artbuf) |
| 6163 | ;; Append newline at end of the buffer as separator, and then |
| 6164 | ;; save it to file. |
| 6165 | (goto-char (point-max)) |
| 6166 | (insert "\n") |
| 6167 | (when coding |
| 6168 | ;; If the coding system is not suitable to encode the text, |
| 6169 | ;; ask a user for a proper one. |
| 6170 | (when (fboundp 'select-safe-coding-system) |
| 6171 | (setq coding (coding-system-base |
| 6172 | (save-window-excursion |
| 6173 | (select-safe-coding-system (point-min) (point-max) |
| 6174 | coding)))) |
| 6175 | (setq coding-system-for-write |
| 6176 | (or (cdr (assq coding '((mule-utf-8 . utf-8)))) |
| 6177 | coding))) |
| 6178 | (goto-char (point-min)) |
| 6179 | ;; Add the coding cookie. |
| 6180 | (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n" |
| 6181 | coding-system-for-write))) |
| 6182 | (if exists |
| 6183 | (progn |
| 6184 | (write-region (point-min) (point-max) file-name nil 'no-message) |
| 6185 | (message "Appended to %s" file-name)) |
| 6186 | (write-region (point-min) (point-max) file-name)))) |
| 6187 | t) |
| 6188 | |
| 6189 | (defun gnus-narrow-to-page (&optional arg) |
| 6190 | "Narrow the article buffer to a page. |
| 6191 | If given a numerical ARG, move forward ARG pages." |
| 6192 | (interactive "P") |
| 6193 | (setq arg (if arg (prefix-numeric-value arg) 0)) |
| 6194 | (with-current-buffer gnus-article-buffer |
| 6195 | (widen) |
| 6196 | ;; Remove any old next/prev buttons. |
| 6197 | (when (gnus-visual-p 'page-marker) |
| 6198 | (let ((inhibit-read-only t)) |
| 6199 | (gnus-remove-text-with-property 'gnus-prev) |
| 6200 | (gnus-remove-text-with-property 'gnus-next))) |
| 6201 | (let (st nd pt) |
| 6202 | (when (save-excursion |
| 6203 | (cond ((< arg 0) |
| 6204 | (if (re-search-backward page-delimiter nil 'move (abs arg)) |
| 6205 | (prog1 |
| 6206 | (setq nd (match-beginning 0) |
| 6207 | pt nd) |
| 6208 | (when (re-search-backward page-delimiter nil t) |
| 6209 | (setq st (match-end 0)))) |
| 6210 | (when (re-search-forward page-delimiter nil t) |
| 6211 | (setq nd (match-beginning 0) |
| 6212 | pt (point-min))))) |
| 6213 | ((> arg 0) |
| 6214 | (if (re-search-forward page-delimiter nil 'move arg) |
| 6215 | (prog1 |
| 6216 | (setq st (match-end 0) |
| 6217 | pt st) |
| 6218 | (when (re-search-forward page-delimiter nil t) |
| 6219 | (setq nd (match-beginning 0)))) |
| 6220 | (when (re-search-backward page-delimiter nil t) |
| 6221 | (setq st (match-end 0) |
| 6222 | pt (point-max))))) |
| 6223 | (t |
| 6224 | (when (re-search-backward page-delimiter nil t) |
| 6225 | (goto-char (setq st (match-end 0)))) |
| 6226 | (when (re-search-forward page-delimiter nil t) |
| 6227 | (setq nd (match-beginning 0))) |
| 6228 | (or st nd)))) |
| 6229 | (setq gnus-page-broken t) |
| 6230 | (when pt (goto-char pt)) |
| 6231 | (narrow-to-region (or st (point-min)) (or nd (point-max))) |
| 6232 | (when (gnus-visual-p 'page-marker) |
| 6233 | (save-excursion |
| 6234 | (when nd |
| 6235 | (goto-char nd) |
| 6236 | (gnus-insert-next-page-button)) |
| 6237 | (when st |
| 6238 | (goto-char st) |
| 6239 | (gnus-insert-prev-page-button)))))))) |
| 6240 | |
| 6241 | ;; Article mode commands |
| 6242 | |
| 6243 | (defun gnus-article-goto-next-page () |
| 6244 | "Show the next page of the article." |
| 6245 | (interactive) |
| 6246 | (when (gnus-article-next-page) |
| 6247 | (goto-char (point-min)) |
| 6248 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) |
| 6249 | |
| 6250 | |
| 6251 | (defun gnus-article-goto-prev-page () |
| 6252 | "Show the previous page of the article." |
| 6253 | (interactive) |
| 6254 | (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer? |
| 6255 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?p)) |
| 6256 | (gnus-article-prev-page nil))) |
| 6257 | |
| 6258 | ;; This is cleaner but currently breaks `gnus-pick-mode': |
| 6259 | ;; |
| 6260 | ;; (defun gnus-article-goto-next-page () |
| 6261 | ;; "Show the next page of the article." |
| 6262 | ;; (interactive) |
| 6263 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer |
| 6264 | ;; (gnus-summary-next-page))) |
| 6265 | ;; |
| 6266 | ;; (defun gnus-article-goto-prev-page () |
| 6267 | ;; "Show the next page of the article." |
| 6268 | ;; (interactive) |
| 6269 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer |
| 6270 | ;; (gnus-summary-prev-page))) |
| 6271 | |
| 6272 | (defun gnus-article-next-page (&optional lines) |
| 6273 | "Show the next page of the current article. |
| 6274 | If end of article, return non-nil. Otherwise return nil. |
| 6275 | Argument LINES specifies lines to be scrolled up." |
| 6276 | (interactive "p") |
| 6277 | (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin))) |
| 6278 | (if (and (not (and gnus-article-over-scroll |
| 6279 | (> (count-lines (window-start) (point-max)) |
| 6280 | (if (featurep 'xemacs) |
| 6281 | (or lines (1- (window-height))) |
| 6282 | (+ (or lines (1- (window-height))) scroll-margin))))) |
| 6283 | (save-excursion |
| 6284 | (end-of-line) |
| 6285 | (and (pos-visible-in-window-p) ;Not continuation line. |
| 6286 | (>= (1+ (point)) (point-max))))) ;Allow for trailing newline. |
| 6287 | ;; Nothing in this page. |
| 6288 | (if (or (not gnus-page-broken) |
| 6289 | (save-excursion |
| 6290 | (save-restriction |
| 6291 | (widen) |
| 6292 | (forward-line) |
| 6293 | (eobp)))) ;Real end-of-buffer? |
| 6294 | (progn |
| 6295 | (when gnus-article-over-scroll |
| 6296 | (gnus-article-next-page-1 lines)) |
| 6297 | t) ;Nothing more. |
| 6298 | (gnus-narrow-to-page 1) ;Go to next page. |
| 6299 | nil) |
| 6300 | ;; More in this page. |
| 6301 | (gnus-article-next-page-1 lines) |
| 6302 | nil)) |
| 6303 | |
| 6304 | (defun gnus-article-beginning-of-window () |
| 6305 | "Move point to the beginning of the window. |
| 6306 | In Emacs, the point is placed at the line number which `scroll-margin' |
| 6307 | specifies." |
| 6308 | (if (featurep 'xemacs) |
| 6309 | (move-to-window-line 0) |
| 6310 | ;; There is an obscure bug in Emacs that makes it impossible to |
| 6311 | ;; scroll past big pictures in the article buffer. Try to fix |
| 6312 | ;; this by adding a sanity check by counting the lines visible. |
| 6313 | (when (> (count-lines (window-start) (window-end)) 30) |
| 6314 | (move-to-window-line |
| 6315 | (min (max 0 scroll-margin) |
| 6316 | (max 1 (- (window-height) |
| 6317 | (if mode-line-format 1 0) |
| 6318 | (if header-line-format 1 0) |
| 6319 | 2))))))) |
| 6320 | |
| 6321 | (defun gnus-article-next-page-1 (lines) |
| 6322 | (condition-case () |
| 6323 | (let ((scroll-in-place nil)) |
| 6324 | (scroll-up lines)) |
| 6325 | (end-of-buffer |
| 6326 | ;; Long lines may cause an end-of-buffer error. |
| 6327 | (goto-char (point-max)))) |
| 6328 | (gnus-article-beginning-of-window)) |
| 6329 | |
| 6330 | (defun gnus-article-prev-page (&optional lines) |
| 6331 | "Show previous page of current article. |
| 6332 | Argument LINES specifies lines to be scrolled down." |
| 6333 | (interactive "p") |
| 6334 | (move-to-window-line 0) |
| 6335 | (if (and gnus-page-broken |
| 6336 | (bobp) |
| 6337 | (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? |
| 6338 | (progn |
| 6339 | (gnus-narrow-to-page -1) ;Go to previous page. |
| 6340 | (goto-char (point-max)) |
| 6341 | (recenter (if gnus-article-over-scroll |
| 6342 | (if lines |
| 6343 | (max (if (featurep 'xemacs) |
| 6344 | lines |
| 6345 | (+ lines scroll-margin)) |
| 6346 | 3) |
| 6347 | (- (window-height) 2)) |
| 6348 | -1))) |
| 6349 | (prog1 |
| 6350 | (condition-case () |
| 6351 | (let ((scroll-in-place nil)) |
| 6352 | (scroll-down lines)) |
| 6353 | (beginning-of-buffer |
| 6354 | (goto-char (point-min)))) |
| 6355 | (gnus-article-beginning-of-window)))) |
| 6356 | |
| 6357 | (defun gnus-article-only-boring-p () |
| 6358 | "Decide whether there is only boring text remaining in the article. |
| 6359 | Something \"interesting\" is a word of at least two letters that does |
| 6360 | not have a face in `gnus-article-boring-faces'." |
| 6361 | (when (and gnus-article-skip-boring |
| 6362 | (boundp 'gnus-article-boring-faces) |
| 6363 | (symbol-value 'gnus-article-boring-faces)) |
| 6364 | (save-excursion |
| 6365 | (let ((inhibit-point-motion-hooks t)) |
| 6366 | (catch 'only-boring |
| 6367 | (while (re-search-forward "\\b\\w\\w" nil t) |
| 6368 | (forward-char -1) |
| 6369 | (when (not (gnus-intersection |
| 6370 | (gnus-faces-at (point)) |
| 6371 | (symbol-value 'gnus-article-boring-faces))) |
| 6372 | (throw 'only-boring nil))) |
| 6373 | (throw 'only-boring t)))))) |
| 6374 | |
| 6375 | (defun gnus-article-refer-article () |
| 6376 | "Read article specified by message-id around point." |
| 6377 | (interactive) |
| 6378 | (save-excursion |
| 6379 | (re-search-backward "[ \t]\\|^" (point-at-bol) t) |
| 6380 | (re-search-forward "<?news:<?\\|<" (point-at-eol) t) |
| 6381 | (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t) |
| 6382 | (let ((msg-id (concat "<" (match-string 0) ">"))) |
| 6383 | (set-buffer gnus-summary-buffer) |
| 6384 | (gnus-summary-refer-article msg-id)) |
| 6385 | (error "No references around point")))) |
| 6386 | |
| 6387 | (defun gnus-article-show-summary () |
| 6388 | "Reconfigure windows to show summary buffer." |
| 6389 | (interactive) |
| 6390 | (if (not (gnus-buffer-live-p gnus-summary-buffer)) |
| 6391 | (error "There is no summary buffer for this article buffer") |
| 6392 | (gnus-article-set-globals) |
| 6393 | (gnus-configure-windows 'article) |
| 6394 | (gnus-summary-goto-subject gnus-current-article) |
| 6395 | (gnus-summary-position-point))) |
| 6396 | |
| 6397 | (defun gnus-article-describe-briefly () |
| 6398 | "Describe article mode commands briefly." |
| 6399 | (interactive) |
| 6400 | (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"))) |
| 6401 | |
| 6402 | (defun gnus-article-check-buffer () |
| 6403 | "Beep if not in an article buffer." |
| 6404 | (unless (equal major-mode 'gnus-article-mode) |
| 6405 | (error "Command invoked outside of a Gnus article buffer"))) |
| 6406 | |
| 6407 | (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) |
| 6408 | "Read a summary buffer key sequence and execute it from the article buffer." |
| 6409 | (interactive "P") |
| 6410 | (gnus-article-check-buffer) |
| 6411 | (let ((nosaves |
| 6412 | '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f" |
| 6413 | "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" |
| 6414 | "=" "^" "\M-^" "|")) |
| 6415 | (nosave-but-article |
| 6416 | '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae" |
| 6417 | "An" "Ap" [?A (meta return)] [?A delete])) |
| 6418 | (nosave-in-article |
| 6419 | '("AS" "\C-d")) |
| 6420 | (up-to-top |
| 6421 | '("n" "Gn" "p" "Gp")) |
| 6422 | keys new-sum-point) |
| 6423 | (with-current-buffer gnus-article-current-summary |
| 6424 | (let (gnus-pick-mode) |
| 6425 | (setq unread-command-events (nconc unread-command-events |
| 6426 | (list (or key last-command-event))) |
| 6427 | keys (if (featurep 'xemacs) |
| 6428 | (events-to-keys (read-key-sequence nil t)) |
| 6429 | (read-key-sequence nil t))))) |
| 6430 | |
| 6431 | (message "") |
| 6432 | |
| 6433 | (cond |
| 6434 | ((eq (aref keys (1- (length keys))) ?\C-h) |
| 6435 | (gnus-article-describe-bindings (substring keys 0 -1))) |
| 6436 | ((or (member keys nosaves) |
| 6437 | (member keys nosave-but-article) |
| 6438 | (member keys nosave-in-article)) |
| 6439 | (let (func) |
| 6440 | (save-window-excursion |
| 6441 | (pop-to-buffer gnus-article-current-summary) |
| 6442 | ;; We disable the pick minor mode commands. |
| 6443 | (let (gnus-pick-mode) |
| 6444 | (setq func (key-binding keys t)))) |
| 6445 | (if (or (not func) |
| 6446 | (numberp func)) |
| 6447 | (ding) |
| 6448 | (unless (member keys nosave-in-article) |
| 6449 | (set-buffer gnus-article-current-summary)) |
| 6450 | (call-interactively func) |
| 6451 | (setq new-sum-point (point))) |
| 6452 | (when (member keys nosave-but-article) |
| 6453 | (pop-to-buffer gnus-article-buffer)))) |
| 6454 | (t |
| 6455 | ;; These commands should restore window configuration. |
| 6456 | (let ((obuf (current-buffer)) |
| 6457 | (owin (current-window-configuration)) |
| 6458 | win func in-buffer selected new-sum-start new-sum-hscroll err) |
| 6459 | (cond (not-restore-window |
| 6460 | (pop-to-buffer gnus-article-current-summary) |
| 6461 | (setq win (selected-window))) |
| 6462 | ((setq win (get-buffer-window gnus-article-current-summary)) |
| 6463 | (select-window win)) |
| 6464 | (t |
| 6465 | (let ((summary-buffer gnus-article-current-summary)) |
| 6466 | (gnus-configure-windows 'article) |
| 6467 | (unless (setq win (get-buffer-window summary-buffer 'visible)) |
| 6468 | (let ((gnus-buffer-configuration |
| 6469 | '((article ((vertical 1.0 |
| 6470 | (summary 0.25 point) |
| 6471 | (article 1.0))))))) |
| 6472 | (gnus-configure-windows 'article)) |
| 6473 | (setq win (get-buffer-window summary-buffer 'visible))) |
| 6474 | (gnus-select-frame-set-input-focus (window-frame win)) |
| 6475 | (select-window win)))) |
| 6476 | (setq in-buffer (current-buffer)) |
| 6477 | ;; We disable the pick minor mode commands. |
| 6478 | (if (and (setq func (let (gnus-pick-mode) |
| 6479 | (key-binding keys t))) |
| 6480 | (functionp func) |
| 6481 | (condition-case code |
| 6482 | (progn |
| 6483 | (call-interactively func) |
| 6484 | t) |
| 6485 | (error |
| 6486 | (setq err code) |
| 6487 | nil))) |
| 6488 | (progn |
| 6489 | (when (eq win (selected-window)) |
| 6490 | (setq new-sum-point (point) |
| 6491 | new-sum-start (window-start win) |
| 6492 | new-sum-hscroll (window-hscroll win))) |
| 6493 | (when (or (eq in-buffer (current-buffer)) |
| 6494 | (when (eq obuf (current-buffer)) |
| 6495 | (set-buffer in-buffer) |
| 6496 | t)) |
| 6497 | (setq selected (gnus-summary-select-article)) |
| 6498 | (set-buffer obuf) |
| 6499 | (unless not-restore-window |
| 6500 | (set-window-configuration owin)) |
| 6501 | (when (and (eq selected 'old) |
| 6502 | new-sum-point) |
| 6503 | (set-window-start (get-buffer-window (current-buffer)) |
| 6504 | 1) |
| 6505 | (set-window-point (get-buffer-window (current-buffer)) |
| 6506 | (if (article-goto-body) |
| 6507 | (1- (point)) |
| 6508 | (point)))) |
| 6509 | (when (and (not not-restore-window) |
| 6510 | new-sum-point |
| 6511 | (window-live-p win) |
| 6512 | (with-current-buffer (window-buffer win) |
| 6513 | (eq major-mode 'gnus-summary-mode))) |
| 6514 | (set-window-point win new-sum-point) |
| 6515 | (set-window-start win new-sum-start) |
| 6516 | (set-window-hscroll win new-sum-hscroll)))) |
| 6517 | (set-window-configuration owin) |
| 6518 | (if err |
| 6519 | (signal (car err) (cdr err)) |
| 6520 | (ding)))))))) |
| 6521 | |
| 6522 | (defun gnus-article-read-summary-send-keys () |
| 6523 | (interactive) |
| 6524 | (let ((unread-command-events (list (gnus-character-to-event ?S)))) |
| 6525 | (gnus-article-read-summary-keys))) |
| 6526 | |
| 6527 | (defun gnus-article-describe-key (key) |
| 6528 | "Display documentation of the function invoked by KEY. |
| 6529 | KEY is a string or a vector." |
| 6530 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. |
| 6531 | (read-key-sequence "Describe key: ")))) |
| 6532 | (gnus-article-check-buffer) |
| 6533 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
| 6534 | gnus-article-read-summary-send-keys)) |
| 6535 | (with-current-buffer gnus-article-current-summary |
| 6536 | (setq unread-command-events |
| 6537 | (if (featurep 'xemacs) |
| 6538 | (append key nil) |
| 6539 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) |
| 6540 | (list 'meta (- x 128)) |
| 6541 | x)) |
| 6542 | key))) |
| 6543 | (let ((cursor-in-echo-area t) |
| 6544 | gnus-pick-mode) |
| 6545 | (describe-key (read-key-sequence nil t)))) |
| 6546 | (describe-key key))) |
| 6547 | |
| 6548 | (defun gnus-article-describe-key-briefly (key &optional insert) |
| 6549 | "Display documentation of the function invoked by KEY. |
| 6550 | KEY is a string or a vector." |
| 6551 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. |
| 6552 | (read-key-sequence "Describe key: ")) |
| 6553 | current-prefix-arg)) |
| 6554 | (gnus-article-check-buffer) |
| 6555 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
| 6556 | gnus-article-read-summary-send-keys)) |
| 6557 | (with-current-buffer gnus-article-current-summary |
| 6558 | (setq unread-command-events |
| 6559 | (if (featurep 'xemacs) |
| 6560 | (append key nil) |
| 6561 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) |
| 6562 | (list 'meta (- x 128)) |
| 6563 | x)) |
| 6564 | key))) |
| 6565 | (let ((cursor-in-echo-area t) |
| 6566 | gnus-pick-mode) |
| 6567 | (describe-key-briefly (read-key-sequence nil t) insert))) |
| 6568 | (describe-key-briefly key insert))) |
| 6569 | |
| 6570 | ;;`gnus-agent-mode' in gnus-agent.el will define it. |
| 6571 | (defvar gnus-agent-summary-mode) |
| 6572 | (defvar gnus-draft-mode) |
| 6573 | ;; Calling help-buffer will autoload help-mode. |
| 6574 | (defvar help-xref-stack-item) |
| 6575 | ;; Emacs 22 doesn't load it in the batch mode. |
| 6576 | (eval-when-compile |
| 6577 | (autoload 'help-buffer "help-mode")) |
| 6578 | |
| 6579 | (defun gnus-article-describe-bindings (&optional prefix) |
| 6580 | "Show a list of all defined keys, and their definitions. |
| 6581 | The optional argument PREFIX, if non-nil, should be a key sequence; |
| 6582 | then we display only bindings that start with that prefix." |
| 6583 | (interactive) |
| 6584 | (gnus-article-check-buffer) |
| 6585 | (let ((keymap (copy-keymap gnus-article-mode-map)) |
| 6586 | (map (copy-keymap gnus-article-send-map)) |
| 6587 | (sumkeys (where-is-internal 'gnus-article-read-summary-keys)) |
| 6588 | parent agent draft) |
| 6589 | (define-key keymap "S" map) |
| 6590 | (define-key map [t] nil) |
| 6591 | (with-current-buffer gnus-article-current-summary |
| 6592 | (set-keymap-parent |
| 6593 | keymap |
| 6594 | (if (setq parent (keymap-parent gnus-article-mode-map)) |
| 6595 | (prog1 |
| 6596 | (setq parent (copy-keymap parent)) |
| 6597 | (set-keymap-parent parent (current-local-map))) |
| 6598 | (current-local-map))) |
| 6599 | (set-keymap-parent map (key-binding "S")) |
| 6600 | (let (key def gnus-pick-mode) |
| 6601 | (while sumkeys |
| 6602 | (setq key (pop sumkeys)) |
| 6603 | (cond ((and (vectorp key) (= (length key) 1) |
| 6604 | (consp (setq def (aref key 0))) |
| 6605 | (numberp (car def)) (numberp (cdr def))) |
| 6606 | (when (< (max (car def) (cdr def)) 128) |
| 6607 | (setq sumkeys |
| 6608 | (append (mapcar |
| 6609 | #'vector |
| 6610 | (nreverse (gnus-uncompress-range def))) |
| 6611 | sumkeys)))) |
| 6612 | ((setq def (key-binding key)) |
| 6613 | (unless (eq def 'undefined) |
| 6614 | (define-key keymap key def)))))) |
| 6615 | (when (boundp 'gnus-agent-summary-mode) |
| 6616 | (setq agent gnus-agent-summary-mode)) |
| 6617 | (when (boundp 'gnus-draft-mode) |
| 6618 | (setq draft gnus-draft-mode))) |
| 6619 | (with-temp-buffer |
| 6620 | (use-local-map keymap) |
| 6621 | (set (make-local-variable 'gnus-agent-summary-mode) agent) |
| 6622 | (set (make-local-variable 'gnus-draft-mode) draft) |
| 6623 | (describe-bindings prefix)) |
| 6624 | (let ((item `((lambda (prefix) |
| 6625 | (with-current-buffer ,(current-buffer) |
| 6626 | (gnus-article-describe-bindings prefix))) |
| 6627 | ,prefix))) |
| 6628 | (with-current-buffer (let (help-xref-following) (help-buffer)) |
| 6629 | (setq help-xref-stack-item item))))) |
| 6630 | |
| 6631 | (defun gnus-article-reply-with-original (&optional wide) |
| 6632 | "Start composing a reply mail to the current message. |
| 6633 | The text in the region will be yanked. If the region isn't active, |
| 6634 | the entire article will be yanked." |
| 6635 | (interactive) |
| 6636 | (let ((article (cdr gnus-article-current)) |
| 6637 | contents) |
| 6638 | (if (not (gnus-region-active-p)) |
| 6639 | (with-current-buffer gnus-summary-buffer |
| 6640 | (gnus-summary-reply (list (list article)) wide)) |
| 6641 | (setq contents (buffer-substring (point) (mark t))) |
| 6642 | ;; Deactivate active regions. |
| 6643 | (when (and (boundp 'transient-mark-mode) |
| 6644 | transient-mark-mode) |
| 6645 | (setq mark-active nil)) |
| 6646 | (with-current-buffer gnus-summary-buffer |
| 6647 | (gnus-summary-reply |
| 6648 | (list (list article contents)) wide))))) |
| 6649 | |
| 6650 | (defun gnus-article-wide-reply-with-original () |
| 6651 | "Start composing a wide reply mail to the current message. |
| 6652 | The text in the region will be yanked. If the region isn't active, |
| 6653 | the entire article will be yanked." |
| 6654 | (interactive) |
| 6655 | (gnus-article-reply-with-original t)) |
| 6656 | |
| 6657 | (defun gnus-article-followup-with-original () |
| 6658 | "Compose a followup to the current article. |
| 6659 | The text in the region will be yanked. If the region isn't active, |
| 6660 | the entire article will be yanked." |
| 6661 | (interactive) |
| 6662 | (let ((article (cdr gnus-article-current)) |
| 6663 | contents) |
| 6664 | (if (not (gnus-region-active-p)) |
| 6665 | (with-current-buffer gnus-summary-buffer |
| 6666 | (gnus-summary-followup (list (list article)))) |
| 6667 | (setq contents (buffer-substring (point) (mark t))) |
| 6668 | ;; Deactivate active regions. |
| 6669 | (when (and (boundp 'transient-mark-mode) |
| 6670 | transient-mark-mode) |
| 6671 | (setq mark-active nil)) |
| 6672 | (with-current-buffer gnus-summary-buffer |
| 6673 | (gnus-summary-followup |
| 6674 | (list (list article contents))))))) |
| 6675 | |
| 6676 | (defun gnus-article-hide (&optional arg force) |
| 6677 | "Hide all the gruft in the current article. |
| 6678 | This means that signatures, cited text and (some) headers will be |
| 6679 | hidden. |
| 6680 | If given a prefix, show the hidden text instead." |
| 6681 | (interactive (append (gnus-article-hidden-arg) (list 'force))) |
| 6682 | (gnus-article-hide-headers arg) |
| 6683 | (gnus-article-hide-list-identifiers arg) |
| 6684 | (gnus-article-hide-citation-maybe arg force) |
| 6685 | (gnus-article-hide-signature arg)) |
| 6686 | |
| 6687 | (defun gnus-article-maybe-highlight () |
| 6688 | "Do some article highlighting if article highlighting is requested." |
| 6689 | (when (gnus-visual-p 'article-highlight 'highlight) |
| 6690 | (gnus-article-highlight-some))) |
| 6691 | |
| 6692 | (defun gnus-check-group-server () |
| 6693 | ;; Make sure the connection to the server is alive. |
| 6694 | (unless (gnus-server-opened |
| 6695 | (gnus-find-method-for-group gnus-newsgroup-name)) |
| 6696 | (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) |
| 6697 | (gnus-request-group gnus-newsgroup-name t))) |
| 6698 | |
| 6699 | (eval-when-compile |
| 6700 | (autoload 'nneething-get-file-name "nneething")) |
| 6701 | |
| 6702 | (defun gnus-request-article-this-buffer (article group) |
| 6703 | "Get an article and insert it into this buffer." |
| 6704 | (let (do-update-line sparse-header) |
| 6705 | (prog1 |
| 6706 | (save-excursion |
| 6707 | (erase-buffer) |
| 6708 | (gnus-kill-all-overlays) |
| 6709 | (setq group (or group gnus-newsgroup-name)) |
| 6710 | |
| 6711 | ;; Using `gnus-request-article' directly will insert the article into |
| 6712 | ;; `nntp-server-buffer' - so we'll save some time by not having to |
| 6713 | ;; copy it from the server buffer into the article buffer. |
| 6714 | |
| 6715 | ;; We only request an article by message-id when we do not have the |
| 6716 | ;; headers for it, so we'll have to get those. |
| 6717 | (when (stringp article) |
| 6718 | (gnus-read-header article)) |
| 6719 | |
| 6720 | ;; If the article number is negative, that means that this article |
| 6721 | ;; doesn't belong in this newsgroup (possibly), so we find its |
| 6722 | ;; message-id and request it by id instead of number. |
| 6723 | (when (and (numberp article) |
| 6724 | gnus-summary-buffer |
| 6725 | (get-buffer gnus-summary-buffer) |
| 6726 | (gnus-buffer-exists-p gnus-summary-buffer)) |
| 6727 | (with-current-buffer gnus-summary-buffer |
| 6728 | (let ((header (gnus-summary-article-header article))) |
| 6729 | (when (< article 0) |
| 6730 | (cond |
| 6731 | ((memq article gnus-newsgroup-sparse) |
| 6732 | ;; This is a sparse gap article. |
| 6733 | (setq do-update-line article) |
| 6734 | (setq article (mail-header-id header)) |
| 6735 | (setq sparse-header (gnus-read-header article)) |
| 6736 | (setq gnus-newsgroup-sparse |
| 6737 | (delq article gnus-newsgroup-sparse))) |
| 6738 | ((vectorp header) |
| 6739 | ;; It's a real article. |
| 6740 | (setq article (mail-header-id header))) |
| 6741 | (t |
| 6742 | ;; It is an extracted pseudo-article. |
| 6743 | (setq article 'pseudo) |
| 6744 | (gnus-request-pseudo-article header)))) |
| 6745 | |
| 6746 | (let ((method (gnus-find-method-for-group |
| 6747 | gnus-newsgroup-name))) |
| 6748 | (when (and (eq (car method) 'nneething) |
| 6749 | (vectorp header)) |
| 6750 | (let ((dir (nneething-get-file-name |
| 6751 | (mail-header-id header)))) |
| 6752 | (when (and (stringp dir) |
| 6753 | (file-directory-p dir)) |
| 6754 | (setq article 'nneething) |
| 6755 | (gnus-group-enter-directory dir)))))))) |
| 6756 | |
| 6757 | (cond |
| 6758 | ;; Refuse to select canceled articles. |
| 6759 | ((and (numberp article) |
| 6760 | gnus-summary-buffer |
| 6761 | (get-buffer gnus-summary-buffer) |
| 6762 | (gnus-buffer-exists-p gnus-summary-buffer) |
| 6763 | (eq (cdr (with-current-buffer gnus-summary-buffer |
| 6764 | (assq article gnus-newsgroup-reads))) |
| 6765 | gnus-canceled-mark)) |
| 6766 | nil) |
| 6767 | ;; We first check `gnus-original-article-buffer'. |
| 6768 | ((and (get-buffer gnus-original-article-buffer) |
| 6769 | (numberp article) |
| 6770 | (with-current-buffer gnus-original-article-buffer |
| 6771 | (and (equal (car gnus-original-article) group) |
| 6772 | (eq (cdr gnus-original-article) article)))) |
| 6773 | ;; `insert-buffer-substring' would incorrectly use the |
| 6774 | ;; equivalent of string-make-multibyte which amount to decoding |
| 6775 | ;; with locale-coding-system, causing failure of |
| 6776 | ;; subsequent decoding. |
| 6777 | (insert (mm-string-to-multibyte |
| 6778 | (with-current-buffer gnus-original-article-buffer |
| 6779 | (buffer-substring (point-min) (point-max))))) |
| 6780 | 'article) |
| 6781 | ;; Check the backlog. |
| 6782 | ((and gnus-keep-backlog |
| 6783 | (gnus-backlog-request-article group article (current-buffer))) |
| 6784 | 'article) |
| 6785 | ;; Check asynchronous pre-fetch. |
| 6786 | ((gnus-async-request-fetched-article group article (current-buffer)) |
| 6787 | (gnus-async-prefetch-next group article gnus-summary-buffer) |
| 6788 | (when (and (numberp article) gnus-keep-backlog) |
| 6789 | (gnus-backlog-enter-article group article (current-buffer))) |
| 6790 | 'article) |
| 6791 | ;; Check the cache. |
| 6792 | ((and gnus-use-cache |
| 6793 | (numberp article) |
| 6794 | (gnus-cache-request-article article group)) |
| 6795 | 'article) |
| 6796 | ;; Check the agent cache. |
| 6797 | ((gnus-agent-request-article article group) |
| 6798 | 'article) |
| 6799 | ;; Get the article and put into the article buffer. |
| 6800 | ((or (stringp article) |
| 6801 | (numberp article)) |
| 6802 | (let ((gnus-override-method gnus-override-method) |
| 6803 | (methods (and (stringp article) |
| 6804 | gnus-refer-article-method)) |
| 6805 | (backend (car (gnus-find-method-for-group |
| 6806 | gnus-newsgroup-name))) |
| 6807 | result |
| 6808 | (inhibit-read-only t)) |
| 6809 | (if (or (not (listp methods)) |
| 6810 | (and (symbolp (car methods)) |
| 6811 | (assq (car methods) nnoo-definition-alist))) |
| 6812 | (setq methods (list methods))) |
| 6813 | (when (and (null gnus-override-method) |
| 6814 | methods) |
| 6815 | (setq gnus-override-method (pop methods))) |
| 6816 | (while (not result) |
| 6817 | (when (eq gnus-override-method 'current) |
| 6818 | (setq gnus-override-method |
| 6819 | (with-current-buffer gnus-summary-buffer |
| 6820 | gnus-current-select-method))) |
| 6821 | (erase-buffer) |
| 6822 | (gnus-kill-all-overlays) |
| 6823 | (let ((gnus-newsgroup-name group)) |
| 6824 | (gnus-check-group-server)) |
| 6825 | (cond |
| 6826 | ((gnus-request-article article group (current-buffer)) |
| 6827 | (when (numberp article) |
| 6828 | (gnus-async-prefetch-next group article |
| 6829 | gnus-summary-buffer) |
| 6830 | (when gnus-keep-backlog |
| 6831 | (gnus-backlog-enter-article |
| 6832 | group article (current-buffer)))) |
| 6833 | (setq result 'article)) |
| 6834 | (methods |
| 6835 | (setq gnus-override-method (pop methods))) |
| 6836 | ((not (string-match "^400 " |
| 6837 | (nnheader-get-report backend))) |
| 6838 | ;; If we get 400 server disconnect, reconnect and |
| 6839 | ;; retry; otherwise, assume the article has expired. |
| 6840 | (setq result 'done)))) |
| 6841 | (and (eq result 'article) 'article))) |
| 6842 | ;; It was a pseudo. |
| 6843 | (t article))) |
| 6844 | |
| 6845 | ;; Associate this article with the current summary buffer. |
| 6846 | (setq gnus-article-current-summary gnus-summary-buffer) |
| 6847 | |
| 6848 | ;; Take the article from the original article buffer |
| 6849 | ;; and place it in the buffer it's supposed to be in. |
| 6850 | (when (and (get-buffer gnus-article-buffer) |
| 6851 | (equal (buffer-name (current-buffer)) |
| 6852 | (buffer-name (get-buffer gnus-article-buffer)))) |
| 6853 | (save-excursion |
| 6854 | (if (get-buffer gnus-original-article-buffer) |
| 6855 | (set-buffer gnus-original-article-buffer) |
| 6856 | (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) |
| 6857 | (buffer-disable-undo) |
| 6858 | (setq major-mode 'gnus-original-article-mode) |
| 6859 | (setq buffer-read-only t)) |
| 6860 | (let ((inhibit-read-only t)) |
| 6861 | (erase-buffer) |
| 6862 | (insert-buffer-substring gnus-article-buffer)) |
| 6863 | (setq gnus-original-article (cons group article))) |
| 6864 | |
| 6865 | ;; Decode charsets. |
| 6866 | (run-hooks 'gnus-article-decode-hook) |
| 6867 | ;; Mark article as decoded or not. |
| 6868 | (setq gnus-article-decoded-p gnus-article-decode-hook)) |
| 6869 | |
| 6870 | ;; Update sparse articles. |
| 6871 | (when (and do-update-line |
| 6872 | (or (numberp article) |
| 6873 | (stringp article))) |
| 6874 | (let ((buf (current-buffer))) |
| 6875 | (set-buffer gnus-summary-buffer) |
| 6876 | (gnus-summary-update-article do-update-line sparse-header) |
| 6877 | (gnus-summary-goto-subject do-update-line nil t) |
| 6878 | (set-window-point (gnus-get-buffer-window (current-buffer) t) |
| 6879 | (point)) |
| 6880 | (set-buffer buf)))))) |
| 6881 | |
| 6882 | ;;; |
| 6883 | ;;; Article editing |
| 6884 | ;;; |
| 6885 | |
| 6886 | (defcustom gnus-article-edit-mode-hook nil |
| 6887 | "Hook run in article edit mode buffers." |
| 6888 | :group 'gnus-article-various |
| 6889 | :type 'hook) |
| 6890 | |
| 6891 | (defvar gnus-article-edit-done-function nil) |
| 6892 | |
| 6893 | (defvar gnus-article-edit-mode-map nil) |
| 6894 | |
| 6895 | ;; Should we be using derived.el for this? |
| 6896 | (unless gnus-article-edit-mode-map |
| 6897 | (setq gnus-article-edit-mode-map (make-keymap)) |
| 6898 | (set-keymap-parent gnus-article-edit-mode-map text-mode-map) |
| 6899 | |
| 6900 | (gnus-define-keys gnus-article-edit-mode-map |
| 6901 | "\C-c?" describe-mode |
| 6902 | "\C-c\C-c" gnus-article-edit-done |
| 6903 | "\C-c\C-k" gnus-article-edit-exit |
| 6904 | "\C-c\C-f\C-t" message-goto-to |
| 6905 | "\C-c\C-f\C-o" message-goto-from |
| 6906 | "\C-c\C-f\C-b" message-goto-bcc |
| 6907 | ;;"\C-c\C-f\C-w" message-goto-fcc |
| 6908 | "\C-c\C-f\C-c" message-goto-cc |
| 6909 | "\C-c\C-f\C-s" message-goto-subject |
| 6910 | "\C-c\C-f\C-r" message-goto-reply-to |
| 6911 | "\C-c\C-f\C-n" message-goto-newsgroups |
| 6912 | "\C-c\C-f\C-d" message-goto-distribution |
| 6913 | "\C-c\C-f\C-f" message-goto-followup-to |
| 6914 | "\C-c\C-f\C-m" message-goto-mail-followup-to |
| 6915 | "\C-c\C-f\C-k" message-goto-keywords |
| 6916 | "\C-c\C-f\C-u" message-goto-summary |
| 6917 | "\C-c\C-f\C-i" message-insert-or-toggle-importance |
| 6918 | "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to |
| 6919 | "\C-c\C-b" message-goto-body |
| 6920 | "\C-c\C-i" message-goto-signature |
| 6921 | |
| 6922 | "\C-c\C-t" message-insert-to |
| 6923 | "\C-c\C-n" message-insert-newsgroups |
| 6924 | "\C-c\C-o" message-sort-headers |
| 6925 | "\C-c\C-e" message-elide-region |
| 6926 | "\C-c\C-v" message-delete-not-region |
| 6927 | "\C-c\C-z" message-kill-to-signature |
| 6928 | "\M-\r" message-newline-and-reformat |
| 6929 | "\C-c\C-a" mml-attach-file |
| 6930 | "\C-a" message-beginning-of-line |
| 6931 | "\t" message-tab |
| 6932 | "\M-;" comment-region) |
| 6933 | |
| 6934 | (gnus-define-keys (gnus-article-edit-wash-map |
| 6935 | "\C-c\C-w" gnus-article-edit-mode-map) |
| 6936 | "f" gnus-article-edit-full-stops)) |
| 6937 | |
| 6938 | (easy-menu-define |
| 6939 | gnus-article-edit-mode-field-menu gnus-article-edit-mode-map "" |
| 6940 | '("Field" |
| 6941 | ["Fetch To" message-insert-to t] |
| 6942 | ["Fetch Newsgroups" message-insert-newsgroups t] |
| 6943 | "----" |
| 6944 | ["To" message-goto-to t] |
| 6945 | ["From" message-goto-from t] |
| 6946 | ["Subject" message-goto-subject t] |
| 6947 | ["Cc" message-goto-cc t] |
| 6948 | ["Reply-To" message-goto-reply-to t] |
| 6949 | ["Summary" message-goto-summary t] |
| 6950 | ["Keywords" message-goto-keywords t] |
| 6951 | ["Newsgroups" message-goto-newsgroups t] |
| 6952 | ["Followup-To" message-goto-followup-to t] |
| 6953 | ["Mail-Followup-To" message-goto-mail-followup-to t] |
| 6954 | ["Distribution" message-goto-distribution t] |
| 6955 | ["Body" message-goto-body t] |
| 6956 | ["Signature" message-goto-signature t])) |
| 6957 | |
| 6958 | (define-derived-mode gnus-article-edit-mode message-mode "Article Edit" |
| 6959 | "Major mode for editing articles. |
| 6960 | This is an extended text-mode. |
| 6961 | |
| 6962 | \\{gnus-article-edit-mode-map}" |
| 6963 | (make-local-variable 'gnus-article-edit-done-function) |
| 6964 | (make-local-variable 'gnus-prev-winconf) |
| 6965 | (set (make-local-variable 'font-lock-defaults) |
| 6966 | '(message-font-lock-keywords t)) |
| 6967 | (set (make-local-variable 'mail-header-separator) "") |
| 6968 | (set (make-local-variable 'gnus-article-edit-mode) t) |
| 6969 | (easy-menu-add message-mode-field-menu message-mode-map) |
| 6970 | (mml-mode) |
| 6971 | (setq buffer-read-only nil) |
| 6972 | (buffer-enable-undo) |
| 6973 | (widen)) |
| 6974 | |
| 6975 | (defun gnus-article-edit (&optional force) |
| 6976 | "Edit the current article. |
| 6977 | This will have permanent effect only in mail groups. |
| 6978 | If FORCE is non-nil, allow editing of articles even in read-only |
| 6979 | groups." |
| 6980 | (interactive "P") |
| 6981 | (when (and (not force) |
| 6982 | (gnus-group-read-only-p)) |
| 6983 | (error "The current newsgroup does not support article editing")) |
| 6984 | (gnus-article-date-original) |
| 6985 | (gnus-article-edit-article |
| 6986 | 'ignore |
| 6987 | `(lambda (no-highlight) |
| 6988 | 'ignore |
| 6989 | (gnus-summary-edit-article-done |
| 6990 | ,(or (mail-header-references gnus-current-headers) "") |
| 6991 | ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) |
| 6992 | |
| 6993 | (defun gnus-article-edit-article (start-func exit-func &optional quiet) |
| 6994 | "Start editing the contents of the current article buffer." |
| 6995 | (let ((winconf (current-window-configuration))) |
| 6996 | (set-buffer gnus-article-buffer) |
| 6997 | (let ((message-auto-save-directory |
| 6998 | ;; Don't associate the article buffer with a draft file. |
| 6999 | nil)) |
| 7000 | (gnus-article-edit-mode)) |
| 7001 | (funcall start-func) |
| 7002 | (set-buffer-modified-p nil) |
| 7003 | (gnus-configure-windows 'edit-article) |
| 7004 | (setq gnus-article-edit-done-function exit-func) |
| 7005 | (setq gnus-prev-winconf winconf) |
| 7006 | (unless quiet |
| 7007 | (gnus-message 6 "C-c C-c to end edits")))) |
| 7008 | |
| 7009 | (defun gnus-article-edit-done (&optional arg) |
| 7010 | "Update the article edits and exit." |
| 7011 | (interactive "P") |
| 7012 | (let ((func gnus-article-edit-done-function) |
| 7013 | (buf (current-buffer)) |
| 7014 | (start (window-start)) |
| 7015 | (p (point)) |
| 7016 | (winconf gnus-prev-winconf)) |
| 7017 | (widen) ;; Widen it in case that users narrowed the buffer. |
| 7018 | (funcall func arg) |
| 7019 | (set-buffer buf) |
| 7020 | ;; The cache and backlog have to be flushed somewhat. |
| 7021 | (when gnus-keep-backlog |
| 7022 | (gnus-backlog-remove-article |
| 7023 | (car gnus-article-current) (cdr gnus-article-current))) |
| 7024 | ;; Flush original article as well. |
| 7025 | (gnus-flush-original-article-buffer) |
| 7026 | (when gnus-use-cache |
| 7027 | (gnus-cache-update-article |
| 7028 | (car gnus-article-current) (cdr gnus-article-current))) |
| 7029 | ;; We remove all text props from the article buffer. |
| 7030 | (kill-all-local-variables) |
| 7031 | (set-text-properties (point-min) (point-max) nil) |
| 7032 | (gnus-article-mode) |
| 7033 | (set-window-configuration winconf) |
| 7034 | (set-buffer buf) |
| 7035 | (set-window-start (get-buffer-window buf) start) |
| 7036 | (set-window-point (get-buffer-window buf) (point))) |
| 7037 | (gnus-summary-show-article)) |
| 7038 | |
| 7039 | (defun gnus-flush-original-article-buffer () |
| 7040 | (when (get-buffer gnus-original-article-buffer) |
| 7041 | (with-current-buffer gnus-original-article-buffer |
| 7042 | (setq gnus-original-article nil)))) |
| 7043 | |
| 7044 | (defun gnus-article-edit-exit () |
| 7045 | "Exit the article editing without updating." |
| 7046 | (interactive) |
| 7047 | (when (or (not (buffer-modified-p)) |
| 7048 | (yes-or-no-p "Article modified; kill anyway? ")) |
| 7049 | (let ((curbuf (current-buffer)) |
| 7050 | (p (point)) |
| 7051 | (window-start (window-start))) |
| 7052 | (erase-buffer) |
| 7053 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
| 7054 | (insert-buffer-substring gnus-original-article-buffer)) |
| 7055 | (let ((winconf gnus-prev-winconf)) |
| 7056 | (kill-all-local-variables) |
| 7057 | (gnus-article-mode) |
| 7058 | (set-window-configuration winconf) |
| 7059 | ;; Tippy-toe some to make sure that point remains where it was. |
| 7060 | (save-current-buffer |
| 7061 | (set-buffer curbuf) |
| 7062 | (set-window-start (get-buffer-window (current-buffer)) window-start) |
| 7063 | (goto-char p)))) |
| 7064 | (gnus-summary-show-article))) |
| 7065 | |
| 7066 | (defun gnus-article-edit-full-stops () |
| 7067 | "Interactively repair spacing at end of sentences." |
| 7068 | (interactive) |
| 7069 | (save-excursion |
| 7070 | (goto-char (point-min)) |
| 7071 | (search-forward-regexp "^$" nil t) |
| 7072 | (let ((case-fold-search nil)) |
| 7073 | (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2")))) |
| 7074 | |
| 7075 | ;;; |
| 7076 | ;;; Article highlights |
| 7077 | ;;; |
| 7078 | |
| 7079 | ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. |
| 7080 | |
| 7081 | ;;; Internal Variables: |
| 7082 | |
| 7083 | (defcustom gnus-button-url-regexp |
| 7084 | (concat |
| 7085 | "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|" |
| 7086 | "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)" |
| 7087 | "\\(//[-a-z0-9_.]+:[0-9]*\\)?" |
| 7088 | (if (string-match "[[:digit:]]" "1") ;; Support POSIX? |
| 7089 | (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]") |
| 7090 | (punct "!?:;.,")) |
| 7091 | (concat |
| 7092 | "\\(?:" |
| 7093 | ;; Match paired parentheses, e.g. in Wikipedia URLs: |
| 7094 | ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com |
| 7095 | "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*" |
| 7096 | "\\|" |
| 7097 | "[" chars punct "]+" "[" chars "]" |
| 7098 | "\\)")) |
| 7099 | (concat ;; XEmacs 21.4 doesn't support POSIX. |
| 7100 | "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+" |
| 7101 | "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)")) |
| 7102 | "\\)") |
| 7103 | "Regular expression that matches URLs." |
| 7104 | :group 'gnus-article-buttons |
| 7105 | :type 'regexp) |
| 7106 | |
| 7107 | (defcustom gnus-button-valid-fqdn-regexp |
| 7108 | message-valid-fqdn-regexp |
| 7109 | "Regular expression that matches a valid FQDN." |
| 7110 | :version "22.1" |
| 7111 | :group 'gnus-article-buttons |
| 7112 | :type 'regexp) |
| 7113 | |
| 7114 | ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de> |
| 7115 | (defcustom gnus-button-valid-localpart-regexp |
| 7116 | "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*" |
| 7117 | "Regular expression that matches a localpart of mail addresses or MIDs." |
| 7118 | :version "22.1" |
| 7119 | :group 'gnus-article-buttons |
| 7120 | :type 'regexp) |
| 7121 | |
| 7122 | (defcustom gnus-button-man-handler 'manual-entry |
| 7123 | "Function to use for displaying man pages. |
| 7124 | The function must take at least one argument with a string naming the |
| 7125 | man page." |
| 7126 | :version "22.1" |
| 7127 | :type '(choice (function-item :tag "Man" manual-entry) |
| 7128 | (function-item :tag "Woman" woman) |
| 7129 | (function :tag "Other")) |
| 7130 | :group 'gnus-article-buttons) |
| 7131 | |
| 7132 | (defcustom gnus-button-mid-or-mail-regexp |
| 7133 | (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@" |
| 7134 | gnus-button-valid-fqdn-regexp |
| 7135 | ">?\\)\\b") |
| 7136 | "Regular expression that matches a message ID or a mail address." |
| 7137 | :version "22.1" |
| 7138 | :group 'gnus-article-buttons |
| 7139 | :type 'regexp) |
| 7140 | |
| 7141 | (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic |
| 7142 | "What to do when the button on a string as \"foo123@bar.invalid\" is pushed. |
| 7143 | Strings like this can be either a message ID or a mail address. If it is one |
| 7144 | of the symbols `mid' or `mail', Gnus will always assume that the string is a |
| 7145 | message ID or a mail address, respectively. If this variable is set to the |
| 7146 | symbol `ask', always query the user what do do. If it is a function, this |
| 7147 | function will be called with the string as its only argument. The function |
| 7148 | must return `mid', `mail', `invalid' or `ask'." |
| 7149 | :version "22.1" |
| 7150 | :group 'gnus-article-buttons |
| 7151 | :type '(choice (function-item :tag "Heuristic function" |
| 7152 | gnus-button-mid-or-mail-heuristic) |
| 7153 | (const ask) |
| 7154 | (const mid) |
| 7155 | (const mail))) |
| 7156 | |
| 7157 | (defcustom gnus-button-mid-or-mail-heuristic-alist |
| 7158 | '((-10.0 . ".+\\$.+@") |
| 7159 | (-10.0 . "#") |
| 7160 | (-10.0 . "\\*") |
| 7161 | (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs |
| 7162 | (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i |
| 7163 | (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i; |
| 7164 | (-1.0 . "^[^a-z]+@") |
| 7165 | ;; |
| 7166 | (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@" |
| 7167 | (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@" |
| 7168 | (-3.0 . "[A-Z][A-Z][a-z][a-z].*@") |
| 7169 | (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@") |
| 7170 | ;; |
| 7171 | (-2.0 . "^[0-9]") |
| 7172 | (-1.0 . "^[0-9][0-9]") |
| 7173 | ;; |
| 7174 | ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/; |
| 7175 | (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") |
| 7176 | ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/; |
| 7177 | (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") |
| 7178 | ;; |
| 7179 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@" |
| 7180 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@") |
| 7181 | ;; "[0-9]{8,}.*\@" |
| 7182 | (-3.0 |
| 7183 | . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@") |
| 7184 | ;; "[0-9]{12,}.*\@" |
| 7185 | ;; compensation for TDMA dated mail addresses: |
| 7186 | (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@") |
| 7187 | ;; |
| 7188 | (-20.0 . "\\.fsf@") ;; Gnus |
| 7189 | (-20.0 . "^slrn") |
| 7190 | (-20.0 . "^Pine") |
| 7191 | (-20.0 . "^alpine\\.") |
| 7192 | (-20.0 . "_-_") ;; Subject change in thread |
| 7193 | ;; |
| 7194 | (-20.0 . "\\.ln@") ;; leafnode |
| 7195 | (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de") |
| 7196 | (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent |
| 7197 | ;; |
| 7198 | ;; (5.0 . "") ;; $local_part_len <= 7 |
| 7199 | (10.0 . "^[^0-9]+@") |
| 7200 | (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@") |
| 7201 | ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part |
| 7202 | (3.0 . "\@stud") |
| 7203 | ;; |
| 7204 | (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@") |
| 7205 | ;; |
| 7206 | (0.5 . "^[A-Z][a-z]") |
| 7207 | (0.5 . "^[A-Z][a-z][a-z]") |
| 7208 | (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3} |
| 7209 | (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4} |
| 7210 | "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'. |
| 7211 | |
| 7212 | A negative RATE indicates a message IDs, whereas a positive indicates a mail |
| 7213 | address. The REGEXP is processed with `case-fold-search' set to nil." |
| 7214 | :version "22.1" |
| 7215 | :group 'gnus-article-buttons |
| 7216 | :type '(repeat (cons (number :tag "Rate") |
| 7217 | (regexp :tag "Regexp")))) |
| 7218 | |
| 7219 | (defun gnus-button-mid-or-mail-heuristic (mid-or-mail) |
| 7220 | "Guess whether MID-OR-MAIL is a message ID or a mail address. |
| 7221 | Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail |
| 7222 | address, `ask' if unsure and `invalid' if the string is invalid." |
| 7223 | (let ((case-fold-search nil) |
| 7224 | (list gnus-button-mid-or-mail-heuristic-alist) |
| 7225 | (result 0) rate regexp lpartlen elem) |
| 7226 | (setq lpartlen |
| 7227 | (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1"))) |
| 7228 | (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen) |
| 7229 | ;; Certain special cases... |
| 7230 | (when (string-match |
| 7231 | (concat |
| 7232 | "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|" |
| 7233 | "^[0-9]+\\.[0-9]+@compuserve\\|" |
| 7234 | "@public\\.gmane\\.org") |
| 7235 | mid-or-mail) |
| 7236 | (gnus-message 8 "`%s' is a known mail address." mid-or-mail) |
| 7237 | (setq result 'mail)) |
| 7238 | (when (string-match "@.*@\\| " mid-or-mail) |
| 7239 | (gnus-message 8 "`%s' is invalid." mid-or-mail) |
| 7240 | (setq result 'invalid)) |
| 7241 | ;; Nothing more to do, if result is not a number here... |
| 7242 | (when (numberp result) |
| 7243 | (while list |
| 7244 | (setq elem (car list) |
| 7245 | rate (car elem) |
| 7246 | regexp (cdr elem) |
| 7247 | list (cdr list)) |
| 7248 | (when (string-match regexp mid-or-mail) |
| 7249 | (setq result (+ result rate)) |
| 7250 | (gnus-message |
| 7251 | 9 "`%s' matched `%s', rate `%s', result `%s'." |
| 7252 | mid-or-mail regexp rate result))) |
| 7253 | (when (<= lpartlen 7) |
| 7254 | (setq result (+ result 5.0)) |
| 7255 | (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'." |
| 7256 | mid-or-mail result)) |
| 7257 | (when (>= lpartlen 12) |
| 7258 | (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail) |
| 7259 | (cond |
| 7260 | ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail) |
| 7261 | ;; Long local part should contain realname if e-mail address, |
| 7262 | ;; too many digits: message-id. |
| 7263 | ;; $score -= 5.0 + 0.1 * $local_part_len; |
| 7264 | (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen)))) |
| 7265 | (setq result (+ result rate)) |
| 7266 | (gnus-message |
| 7267 | 9 "Many digits in `%s', rate `%s', result `%s'." |
| 7268 | mid-or-mail rate result)) |
| 7269 | ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@" |
| 7270 | mid-or-mail) |
| 7271 | ;; Too few vowels [^aeiouy]{4,}.*\@ |
| 7272 | (setq result (+ result -5.0)) |
| 7273 | (gnus-message |
| 7274 | 9 "Few vowels in `%s', rate `%s', result `%s'." |
| 7275 | mid-or-mail -5.0 result)) |
| 7276 | (t |
| 7277 | (setq result (+ result 5.0)) |
| 7278 | (gnus-message |
| 7279 | 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result))))) |
| 7280 | (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result) |
| 7281 | ;; Maybe we should make this a customizable alist: (condition . 'result) |
| 7282 | (cond |
| 7283 | ((symbolp result) result) |
| 7284 | ;; Now convert number into proper results: |
| 7285 | ((< result -10.0) 'mid) |
| 7286 | ((> result 10.0) 'mail) |
| 7287 | (t 'ask)))) |
| 7288 | |
| 7289 | (defun gnus-button-handle-mid-or-mail (mid-or-mail) |
| 7290 | (let* ((pref gnus-button-prefer-mid-or-mail) guessed |
| 7291 | (url-mid (concat "news" ":" mid-or-mail)) |
| 7292 | (url-mailto (concat "mailto" ":" mid-or-mail))) |
| 7293 | (gnus-message 9 "mid-or-mail=%s" mid-or-mail) |
| 7294 | (when (fboundp pref) |
| 7295 | (setq guessed |
| 7296 | ;; get rid of surrounding angles... |
| 7297 | (funcall pref |
| 7298 | (gnus-replace-in-string mid-or-mail "^<\\|>$" ""))) |
| 7299 | (if (or (eq 'mid guessed) (eq 'mail guessed)) |
| 7300 | (setq pref guessed) |
| 7301 | (setq pref 'ask))) |
| 7302 | (if (eq pref 'ask) |
| 7303 | (save-window-excursion |
| 7304 | (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? ")) |
| 7305 | (setq pref 'mail) |
| 7306 | (setq pref 'mid)))) |
| 7307 | (cond ((eq pref 'mid) |
| 7308 | (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid) |
| 7309 | (gnus-button-handle-news url-mid)) |
| 7310 | ((eq pref 'mail) |
| 7311 | (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto) |
| 7312 | (gnus-url-mailto url-mailto)) |
| 7313 | (t (gnus-message 3 "Invalid string."))))) |
| 7314 | |
| 7315 | (defun gnus-button-handle-custom (fun arg) |
| 7316 | "Call function FUN on argument ARG. |
| 7317 | Both FUN and ARG are supposed to be strings. ARG will be passed |
| 7318 | as a symbol to FUN." |
| 7319 | (funcall (intern fun) |
| 7320 | (if (string-match "^customize-apropos" fun) |
| 7321 | arg |
| 7322 | (intern arg)))) |
| 7323 | |
| 7324 | (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)") |
| 7325 | |
| 7326 | ;; FIXME: Maybe we should merge some of the functions that do quite similar |
| 7327 | ;; stuff? |
| 7328 | |
| 7329 | (defun gnus-button-handle-describe-function (url) |
| 7330 | "Call `describe-function' when pushing the corresponding URL button." |
| 7331 | (describe-function |
| 7332 | (intern |
| 7333 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) |
| 7334 | |
| 7335 | (defun gnus-button-handle-describe-variable (url) |
| 7336 | "Call `describe-variable' when pushing the corresponding URL button." |
| 7337 | (describe-variable |
| 7338 | (intern |
| 7339 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) |
| 7340 | |
| 7341 | (defun gnus-button-handle-symbol (url) |
| 7342 | "Display help on variable or function. |
| 7343 | Calls `describe-variable' or `describe-function'." |
| 7344 | (let ((sym (intern url))) |
| 7345 | (cond |
| 7346 | ((fboundp sym) (describe-function sym)) |
| 7347 | ((boundp sym) (describe-variable sym)) |
| 7348 | (t (gnus-message 3 "`%s' is not a known function of variable." url))))) |
| 7349 | |
| 7350 | (defun gnus-button-handle-describe-key (url) |
| 7351 | "Call `describe-key' when pushing the corresponding URL button." |
| 7352 | (let* ((key-string |
| 7353 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")) |
| 7354 | (keys (ignore-errors (eval `(kbd ,key-string))))) |
| 7355 | (if keys |
| 7356 | (describe-key keys) |
| 7357 | (gnus-message 3 "Invalid key sequence in button: %s" key-string)))) |
| 7358 | |
| 7359 | (defun gnus-button-handle-apropos (url) |
| 7360 | "Call `apropos' when pushing the corresponding URL button." |
| 7361 | (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) |
| 7362 | |
| 7363 | (defun gnus-button-handle-apropos-command (url) |
| 7364 | "Call `apropos' when pushing the corresponding URL button." |
| 7365 | (apropos-command |
| 7366 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) |
| 7367 | |
| 7368 | (defun gnus-button-handle-apropos-variable (url) |
| 7369 | "Call `apropos' when pushing the corresponding URL button." |
| 7370 | (funcall |
| 7371 | (if (fboundp 'apropos-variable) 'apropos-variable 'apropos) |
| 7372 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) |
| 7373 | |
| 7374 | (defun gnus-button-handle-apropos-documentation (url) |
| 7375 | "Call `apropos' when pushing the corresponding URL button." |
| 7376 | (funcall |
| 7377 | (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos) |
| 7378 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) |
| 7379 | |
| 7380 | (defun gnus-button-handle-library (url) |
| 7381 | "Call `locate-library' when pushing the corresponding URL button." |
| 7382 | (gnus-message 9 "url=`%s'" url) |
| 7383 | (let* ((lib (locate-library url)) |
| 7384 | (file (gnus-replace-in-string (or lib "") "\.elc" ".el"))) |
| 7385 | (if (not lib) |
| 7386 | (gnus-message 1 "Cannot locale library `%s'." url) |
| 7387 | (find-file-read-only file)))) |
| 7388 | |
| 7389 | (defcustom gnus-button-man-level 5 |
| 7390 | "*Integer that says how many man-related buttons Gnus will show. |
| 7391 | The higher the number, the more buttons will appear and the more false |
| 7392 | positives are possible. Note that you can set this variable local to |
| 7393 | specific groups. Setting it higher in Unix groups is probably a good idea. |
| 7394 | See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on |
| 7395 | how to set variables in specific groups." |
| 7396 | :version "22.1" |
| 7397 | :group 'gnus-article-buttons |
| 7398 | :link '(custom-manual "(gnus)Group Parameters") |
| 7399 | :type 'integer) |
| 7400 | |
| 7401 | (defcustom gnus-button-emacs-level 5 |
| 7402 | "*Integer that says how many emacs-related buttons Gnus will show. |
| 7403 | The higher the number, the more buttons will appear and the more false |
| 7404 | positives are possible. Note that you can set this variable local to |
| 7405 | specific groups. Setting it higher in Emacs or Gnus related groups is |
| 7406 | probably a good idea. See Info node `(gnus)Group Parameters' and the variable |
| 7407 | `gnus-parameters' on how to set variables in specific groups." |
| 7408 | :version "22.1" |
| 7409 | :group 'gnus-article-buttons |
| 7410 | :link '(custom-manual "(gnus)Group Parameters") |
| 7411 | :type 'integer) |
| 7412 | |
| 7413 | (defcustom gnus-button-message-level 5 |
| 7414 | "*Integer that says how many buttons for news or mail messages will appear. |
| 7415 | The higher the number, the more buttons will appear and the more false |
| 7416 | positives are possible." |
| 7417 | ;; mail addresses, MIDs, URLs for news, ... |
| 7418 | :version "22.1" |
| 7419 | :group 'gnus-article-buttons |
| 7420 | :type 'integer) |
| 7421 | |
| 7422 | (defcustom gnus-button-browse-level 5 |
| 7423 | "*Integer that says how many buttons for browsing will appear. |
| 7424 | The higher the number, the more buttons will appear and the more false |
| 7425 | positives are possible." |
| 7426 | ;; stuff handled by `browse-url' or `gnus-button-embedded-url' |
| 7427 | :version "22.1" |
| 7428 | :group 'gnus-article-buttons |
| 7429 | :type 'integer) |
| 7430 | |
| 7431 | (defcustom gnus-button-alist |
| 7432 | '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" |
| 7433 | 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3) |
| 7434 | ((concat "\\b\\(nntp\\|news\\):\\(" |
| 7435 | gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)") |
| 7436 | 0 t gnus-button-handle-news 2) |
| 7437 | ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)" |
| 7438 | 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5) |
| 7439 | ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)" |
| 7440 | 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3) |
| 7441 | ;; RFC 2392 (Don't allow `/' in domain part --> CID) |
| 7442 | ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)" |
| 7443 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 2) |
| 7444 | ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" |
| 7445 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) |
| 7446 | ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" |
| 7447 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) |
| 7448 | ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" |
| 7449 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 2) |
| 7450 | ;; RFC 2368 (The mailto URL scheme) |
| 7451 | ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
| 7452 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
| 7453 | ("\\bmailto:\\([^ \n\t]+\\)" |
| 7454 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
| 7455 | ;; Info Konqueror style <info:/foo/bar baz>. |
| 7456 | ;; Must come before " Gnus home-grown style". |
| 7457 | ("\\binfo://?\\([^'\">\n\t]+\\)" |
| 7458 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) |
| 7459 | ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz> |
| 7460 | ("\\binfo://\\([^'\">\n\t ]+\\)" |
| 7461 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) |
| 7462 | ;; Info GNOME style <info:foo#bar_baz> |
| 7463 | ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)" |
| 7464 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1) |
| 7465 | ;; Info KDE style <info:(foo)bar baz> |
| 7466 | ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>" |
| 7467 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2) |
| 7468 | ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0 |
| 7469 | (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2) |
| 7470 | ("\\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,]*\\)\\)?" |
| 7471 | ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET' |
| 7472 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0) |
| 7473 | ;; This is custom |
| 7474 | ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0 |
| 7475 | (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2) |
| 7476 | ;; Emacs help commands |
| 7477 | ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7478 | ;; regexp doesn't match arguments containing ` '. |
| 7479 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1) |
| 7480 | ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7481 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1) |
| 7482 | ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7483 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1) |
| 7484 | ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7485 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1) |
| 7486 | ;; The following entries may lead to many false positives so don't enable |
| 7487 | ;; them by default (use a high button level). |
| 7488 | ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]" |
| 7489 | ;; Exclude [.?] for URLs in gmane.emacs.cvs |
| 7490 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) |
| 7491 | ("`\\([a-z][-a-z0-9]+\\.el\\)'" |
| 7492 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) |
| 7493 | ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'" |
| 7494 | 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1) |
| 7495 | ("`\\([a-z][a-z0-9]+-[a-z]+\\)'" |
| 7496 | 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1) |
| 7497 | ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)" |
| 7498 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1) |
| 7499 | ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7500 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1) |
| 7501 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7502 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2) |
| 7503 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" |
| 7504 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2) |
| 7505 | ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" |
| 7506 | ;; Unlike the other regexps we really have to require quoting |
| 7507 | ;; here to determine where it ends. |
| 7508 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3) |
| 7509 | ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)... |
| 7510 | ("<URL: *\\([^\n<>]*\\)>" |
| 7511 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
| 7512 | ;; RFC 2396 (2.4.3., delims) ... |
| 7513 | ("\"URL: *\\([^\n\"]*\\)\"" |
| 7514 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
| 7515 | ;; Raw URLs. |
| 7516 | (gnus-button-url-regexp |
| 7517 | 0 (>= gnus-button-browse-level 0) browse-url 0) |
| 7518 | ;; man pages |
| 7519 | ("\\b\\([a-z][a-z]+([1-9])\\)\\W" |
| 7520 | 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3)) |
| 7521 | gnus-button-handle-man 1) |
| 7522 | ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x) |
| 7523 | ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W" |
| 7524 | 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5)) |
| 7525 | gnus-button-handle-man 1) |
| 7526 | ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), |
| 7527 | ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7) |
| 7528 | ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W" |
| 7529 | 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1) |
| 7530 | ;; Recognizing patches to .el files. This is somewhat obscure, |
| 7531 | ;; but considering the percentage of Gnus users who hack Emacs |
| 7532 | ;; Lisp files... |
| 7533 | ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1 |
| 7534 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) |
| 7535 | ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1 |
| 7536 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) |
| 7537 | ;; MID or mail: To avoid too many false positives we don't try to catch |
| 7538 | ;; all kind of allowed MIDs or mail addresses. Domain part must contain |
| 7539 | ;; at least one dot. TLD must contain two or three chars or be a know TLD |
| 7540 | ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist' |
| 7541 | ;; so that non-ambiguous entries (see above) match first. |
| 7542 | (gnus-button-mid-or-mail-regexp |
| 7543 | 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1)) |
| 7544 | "*Alist of regexps matching buttons in article bodies. |
| 7545 | |
| 7546 | Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where |
| 7547 | REGEXP: is the string (case insensitive) matching text around the button (can |
| 7548 | also be Lisp expression evaluating to a string), |
| 7549 | BUTTON: is the number of the regexp grouping actually matching the button, |
| 7550 | FORM: is a Lisp expression which must eval to true for the button to |
| 7551 | be added, |
| 7552 | CALLBACK: is the function to call when the user push this button, and each |
| 7553 | PAR: is a number of a regexp grouping whose text will be passed to CALLBACK. |
| 7554 | |
| 7555 | CALLBACK can also be a variable, in that case the value of that |
| 7556 | variable it the real callback function." |
| 7557 | :group 'gnus-article-buttons |
| 7558 | :type '(repeat (list (choice regexp variable sexp) |
| 7559 | (integer :tag "Button") |
| 7560 | (sexp :tag "Form") |
| 7561 | (function :tag "Callback") |
| 7562 | (repeat :tag "Par" |
| 7563 | :inline t |
| 7564 | (integer :tag "Regexp group"))))) |
| 7565 | (put 'gnus-button-alist 'risky-local-variable t) |
| 7566 | |
| 7567 | (defcustom gnus-header-button-alist |
| 7568 | '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>" |
| 7569 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 0) |
| 7570 | ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" |
| 7571 | 1 (>= gnus-button-message-level 0) gnus-button-reply 1) |
| 7572 | ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" |
| 7573 | 0 (>= gnus-button-message-level 0) gnus-msg-mail 0) |
| 7574 | ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp |
| 7575 | 0 (>= gnus-button-browse-level 0) browse-url 0) |
| 7576 | ("^Subject:" gnus-button-url-regexp |
| 7577 | 0 (>= gnus-button-browse-level 0) browse-url 0) |
| 7578 | ("^[^:]+:" gnus-button-url-regexp |
| 7579 | 0 (>= gnus-button-browse-level 0) browse-url 0) |
| 7580 | ("^OpenPGP:.*url=" gnus-button-url-regexp |
| 7581 | 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0) |
| 7582 | ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
| 7583 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
| 7584 | ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)" |
| 7585 | 1 (>= gnus-button-message-level 0) gnus-button-message-id 4)) |
| 7586 | "*Alist of headers and regexps to match buttons in article heads. |
| 7587 | |
| 7588 | This alist is very similar to `gnus-button-alist', except that each |
| 7589 | alist has an additional HEADER element first in each entry: |
| 7590 | |
| 7591 | \(HEADER REGEXP BUTTON FORM CALLBACK PAR) |
| 7592 | |
| 7593 | HEADER is a regexp to match a header. For a fuller explanation, see |
| 7594 | `gnus-button-alist'." |
| 7595 | :group 'gnus-article-buttons |
| 7596 | :group 'gnus-article-headers |
| 7597 | :type '(repeat (list (regexp :tag "Header") |
| 7598 | (choice regexp variable) |
| 7599 | (integer :tag "Button") |
| 7600 | (sexp :tag "Form") |
| 7601 | (function :tag "Callback") |
| 7602 | (repeat :tag "Par" |
| 7603 | :inline t |
| 7604 | (integer :tag "Regexp group"))))) |
| 7605 | (put 'gnus-header-button-alist 'risky-local-variable t) |
| 7606 | |
| 7607 | ;;; Commands: |
| 7608 | |
| 7609 | (defun gnus-article-push-button (event) |
| 7610 | "Check text under the mouse pointer for a callback function. |
| 7611 | If the text under the mouse pointer has a `gnus-callback' property, |
| 7612 | call it with the value of the `gnus-data' text property." |
| 7613 | (interactive "e") |
| 7614 | (set-buffer (window-buffer (posn-window (event-start event)))) |
| 7615 | (let* ((pos (posn-point (event-start event))) |
| 7616 | (data (get-text-property pos 'gnus-data)) |
| 7617 | (fun (get-text-property pos 'gnus-callback))) |
| 7618 | (goto-char pos) |
| 7619 | (when fun |
| 7620 | (funcall fun data)))) |
| 7621 | |
| 7622 | (defun gnus-article-press-button () |
| 7623 | "Check text at point for a callback function. |
| 7624 | If the text at point has a `gnus-callback' property, |
| 7625 | call it with the value of the `gnus-data' text property." |
| 7626 | (interactive) |
| 7627 | (let ((data (get-text-property (point) 'gnus-data)) |
| 7628 | (fun (get-text-property (point) 'gnus-callback))) |
| 7629 | (when fun |
| 7630 | (funcall fun data)))) |
| 7631 | |
| 7632 | (defun gnus-article-highlight (&optional force) |
| 7633 | "Highlight current article. |
| 7634 | This function calls `gnus-article-highlight-headers', |
| 7635 | `gnus-article-highlight-citation', |
| 7636 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to |
| 7637 | do the highlighting. See the documentation for those functions." |
| 7638 | (interactive (list 'force)) |
| 7639 | (gnus-article-highlight-headers) |
| 7640 | (gnus-article-highlight-citation force) |
| 7641 | (gnus-article-highlight-signature) |
| 7642 | (gnus-article-add-buttons force) |
| 7643 | (gnus-article-add-buttons-to-head)) |
| 7644 | |
| 7645 | (defun gnus-article-highlight-some (&optional force) |
| 7646 | "Highlight current article. |
| 7647 | This function calls `gnus-article-highlight-headers', |
| 7648 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to |
| 7649 | do the highlighting. See the documentation for those functions." |
| 7650 | (interactive (list 'force)) |
| 7651 | (gnus-article-highlight-headers) |
| 7652 | (gnus-article-highlight-signature) |
| 7653 | (gnus-article-add-buttons)) |
| 7654 | |
| 7655 | (defun gnus-article-highlight-headers () |
| 7656 | "Highlight article headers as specified by `gnus-header-face-alist'." |
| 7657 | (interactive) |
| 7658 | (gnus-with-article-headers |
| 7659 | (let (regexp header-face field-face from hpoints fpoints) |
| 7660 | (dolist (entry gnus-header-face-alist) |
| 7661 | (goto-char (point-min)) |
| 7662 | (setq regexp (concat "^\\(" |
| 7663 | (if (string-equal "" (nth 0 entry)) |
| 7664 | "[^\t ]" |
| 7665 | (nth 0 entry)) |
| 7666 | "\\)") |
| 7667 | header-face (nth 1 entry) |
| 7668 | field-face (nth 2 entry)) |
| 7669 | (while (and (re-search-forward regexp nil t) |
| 7670 | (not (eobp))) |
| 7671 | (beginning-of-line) |
| 7672 | (setq from (point)) |
| 7673 | (unless (search-forward ":" nil t) |
| 7674 | (forward-char 1)) |
| 7675 | (when (and header-face |
| 7676 | (not (memq (point) hpoints))) |
| 7677 | (push (point) hpoints) |
| 7678 | (gnus-put-text-property from (point) 'face header-face)) |
| 7679 | (when (and field-face |
| 7680 | (not (memq (setq from (point)) fpoints))) |
| 7681 | (push from fpoints) |
| 7682 | (if (re-search-forward "^[^ \t]" nil t) |
| 7683 | (forward-char -2) |
| 7684 | (goto-char (point-max))) |
| 7685 | (gnus-put-text-property from (point) 'face field-face))))))) |
| 7686 | |
| 7687 | (defun gnus-article-highlight-signature () |
| 7688 | "Highlight the signature in an article. |
| 7689 | It does this by highlighting everything after |
| 7690 | `gnus-signature-separator' using the face `gnus-signature'." |
| 7691 | (interactive) |
| 7692 | (gnus-with-article-buffer |
| 7693 | (let ((inhibit-point-motion-hooks t)) |
| 7694 | (save-restriction |
| 7695 | (when (and gnus-signature-face |
| 7696 | (gnus-article-narrow-to-signature)) |
| 7697 | (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t) |
| 7698 | 'face gnus-signature-face) |
| 7699 | (widen) |
| 7700 | (gnus-article-search-signature) |
| 7701 | (let ((start (match-beginning 0)) |
| 7702 | (end (set-marker (make-marker) (1+ (match-end 0))))) |
| 7703 | (gnus-article-add-button start (1- end) 'gnus-signature-toggle |
| 7704 | end))))))) |
| 7705 | |
| 7706 | (defun gnus-button-in-region-p (b e prop) |
| 7707 | "Say whether PROP exists in the region." |
| 7708 | (text-property-not-all b e prop nil)) |
| 7709 | |
| 7710 | (defun gnus-article-add-buttons (&optional force) |
| 7711 | "Find external references in the article and make buttons of them. |
| 7712 | \"External references\" are things like Message-IDs and URLs, as |
| 7713 | specified by `gnus-button-alist'." |
| 7714 | (interactive (list 'force)) |
| 7715 | (gnus-with-article-buffer |
| 7716 | (let ((inhibit-point-motion-hooks t) |
| 7717 | (case-fold-search t) |
| 7718 | (alist gnus-button-alist) |
| 7719 | beg entry regexp) |
| 7720 | ;; Remove all old markers. |
| 7721 | (let (marker entry new-list) |
| 7722 | (while (setq marker (pop gnus-button-marker-list)) |
| 7723 | (if (or (< marker (point-min)) (>= marker (point-max))) |
| 7724 | (push marker new-list) |
| 7725 | (goto-char marker) |
| 7726 | (when (setq entry (gnus-button-entry)) |
| 7727 | (put-text-property (match-beginning (nth 1 entry)) |
| 7728 | (match-end (nth 1 entry)) |
| 7729 | 'gnus-callback nil)) |
| 7730 | (set-marker marker nil))) |
| 7731 | (setq gnus-button-marker-list new-list)) |
| 7732 | ;; We skip the headers. |
| 7733 | (article-goto-body) |
| 7734 | (setq beg (point)) |
| 7735 | (while (setq entry (pop alist)) |
| 7736 | (setq regexp (eval (car entry))) |
| 7737 | (goto-char beg) |
| 7738 | (while (re-search-forward regexp nil t) |
| 7739 | (let ((start (match-beginning (nth 1 entry))) |
| 7740 | (end (match-end (nth 1 entry))) |
| 7741 | (from (match-beginning 0))) |
| 7742 | (when (and (or (eq t (nth 2 entry)) |
| 7743 | (eval (nth 2 entry))) |
| 7744 | (not (gnus-button-in-region-p |
| 7745 | start end 'gnus-callback))) |
| 7746 | ;; That optional form returned non-nil, so we add the |
| 7747 | ;; button. |
| 7748 | (setq from (set-marker (make-marker) from)) |
| 7749 | (push from gnus-button-marker-list) |
| 7750 | (unless (and (eq (car entry) 'gnus-button-url-regexp) |
| 7751 | (gnus-article-extend-url-button from start end)) |
| 7752 | (gnus-article-add-button start end |
| 7753 | 'gnus-button-push from) |
| 7754 | (gnus-put-text-property |
| 7755 | start end |
| 7756 | 'gnus-string (buffer-substring-no-properties |
| 7757 | start end)))))))))) |
| 7758 | |
| 7759 | (defun gnus-article-extend-url-button (beg start end) |
| 7760 | "Extend url button if url is folded into two or more lines. |
| 7761 | Return non-nil if button is extended. BEG is a marker that points to |
| 7762 | the beginning position of a text containing url. START and END are |
| 7763 | the endpoints of a url button before it is extended. The concatenated |
| 7764 | url is put as the `gnus-button-url' overlay property on the button." |
| 7765 | (let ((opoint (point)) |
| 7766 | (points (list start end)) |
| 7767 | url delim regexp) |
| 7768 | (prog1 |
| 7769 | (when (and (progn |
| 7770 | (goto-char end) |
| 7771 | (not (looking-at "[\t ]*[\">]"))) |
| 7772 | (progn |
| 7773 | (goto-char start) |
| 7774 | (string-match |
| 7775 | "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'" |
| 7776 | (buffer-substring (point-at-bol) start))) |
| 7777 | (progn |
| 7778 | (setq url (list (buffer-substring start end)) |
| 7779 | delim (if (match-beginning 1) ">" "\"")) |
| 7780 | (beginning-of-line) |
| 7781 | (setq regexp (concat |
| 7782 | (when (and (looking-at |
| 7783 | message-cite-prefix-regexp) |
| 7784 | (< (match-end 0) start)) |
| 7785 | (regexp-quote (match-string 0))) |
| 7786 | "\ |
| 7787 | \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*" |
| 7788 | delim "\\)")) |
| 7789 | (while (progn |
| 7790 | (forward-line 1) |
| 7791 | (and (looking-at regexp) |
| 7792 | (prog1 |
| 7793 | (match-beginning 1) |
| 7794 | (push (or (match-string 2) |
| 7795 | (match-string 1)) |
| 7796 | url) |
| 7797 | (push (setq end (or (match-end 2) |
| 7798 | (match-end 1))) |
| 7799 | points) |
| 7800 | (push (or (match-beginning 2) |
| 7801 | (match-beginning 1)) |
| 7802 | points))))) |
| 7803 | (match-beginning 2))) |
| 7804 | (let (gnus-article-mouse-face widget-mouse-face) |
| 7805 | (while points |
| 7806 | (gnus-article-add-button (pop points) (pop points) |
| 7807 | 'gnus-button-push beg))) |
| 7808 | (let ((overlay (gnus-make-overlay start end))) |
| 7809 | (gnus-overlay-put overlay 'evaporate t) |
| 7810 | (gnus-overlay-put overlay 'gnus-button-url |
| 7811 | (list (mapconcat 'identity (nreverse url) ""))) |
| 7812 | (when gnus-article-mouse-face |
| 7813 | (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face))) |
| 7814 | t) |
| 7815 | (goto-char opoint)))) |
| 7816 | |
| 7817 | ;; Add buttons to the head of an article. |
| 7818 | (defun gnus-article-add-buttons-to-head () |
| 7819 | "Add buttons to the head of the article." |
| 7820 | (interactive) |
| 7821 | (gnus-with-article-headers |
| 7822 | (let (beg end) |
| 7823 | (dolist (entry gnus-header-button-alist) |
| 7824 | ;; Each alist entry. |
| 7825 | (goto-char (point-min)) |
| 7826 | (while (re-search-forward (car entry) nil t) |
| 7827 | ;; Each header matching the entry. |
| 7828 | (setq beg (match-beginning 0)) |
| 7829 | (setq end (or (and (re-search-forward "^[^ \t]" nil t) |
| 7830 | (match-beginning 0)) |
| 7831 | (point-max))) |
| 7832 | (goto-char beg) |
| 7833 | (while (re-search-forward (eval (nth 1 entry)) end t) |
| 7834 | ;; Each match within a header. |
| 7835 | (let* ((entry (cdr entry)) |
| 7836 | (start (match-beginning (nth 1 entry))) |
| 7837 | (end (match-end (nth 1 entry))) |
| 7838 | (form (nth 2 entry))) |
| 7839 | (goto-char (match-end 0)) |
| 7840 | (when (eval form) |
| 7841 | (gnus-article-add-button |
| 7842 | start end (nth 3 entry) |
| 7843 | (buffer-substring (match-beginning (nth 4 entry)) |
| 7844 | (match-end (nth 4 entry))))))) |
| 7845 | (goto-char end)))))) |
| 7846 | |
| 7847 | ;;; External functions: |
| 7848 | |
| 7849 | (defun gnus-article-add-button (from to fun &optional data text) |
| 7850 | "Create a button between FROM and TO with callback FUN and data DATA." |
| 7851 | (when gnus-article-button-face |
| 7852 | (gnus-overlay-put (gnus-make-overlay from to nil t) |
| 7853 | 'face gnus-article-button-face)) |
| 7854 | (gnus-add-text-properties |
| 7855 | from to |
| 7856 | (nconc (and gnus-article-mouse-face |
| 7857 | (list gnus-mouse-face-prop gnus-article-mouse-face)) |
| 7858 | (list 'gnus-callback fun) |
| 7859 | (and data (list 'gnus-data data)))) |
| 7860 | (widget-convert-button 'link from to :action 'gnus-widget-press-button |
| 7861 | :help-echo (or text "Follow the link") |
| 7862 | :keymap gnus-url-button-map |
| 7863 | :button-keymap gnus-widget-button-keymap)) |
| 7864 | |
| 7865 | (defun gnus-article-copy-string () |
| 7866 | "Copy the string in the button to the kill ring." |
| 7867 | (interactive) |
| 7868 | (gnus-article-check-buffer) |
| 7869 | (let ((data (get-text-property (point) 'gnus-string))) |
| 7870 | (when data |
| 7871 | (with-temp-buffer |
| 7872 | (insert data) |
| 7873 | (copy-region-as-kill (point-min) (point-max)) |
| 7874 | (message "Copied %s" data))))) |
| 7875 | |
| 7876 | ;;; Internal functions: |
| 7877 | |
| 7878 | (defun gnus-article-set-globals () |
| 7879 | (with-current-buffer gnus-summary-buffer |
| 7880 | (gnus-set-global-variables))) |
| 7881 | |
| 7882 | (defun gnus-signature-toggle (end) |
| 7883 | (gnus-with-article-buffer |
| 7884 | (let ((inhibit-point-motion-hooks t)) |
| 7885 | (if (text-property-any end (point-max) 'article-type 'signature) |
| 7886 | (progn |
| 7887 | (gnus-delete-wash-type 'signature) |
| 7888 | (gnus-remove-text-properties-when |
| 7889 | 'article-type 'signature end (point-max) |
| 7890 | (cons 'article-type (cons 'signature |
| 7891 | gnus-hidden-properties)))) |
| 7892 | (gnus-add-wash-type 'signature) |
| 7893 | (gnus-add-text-properties-when |
| 7894 | 'article-type nil end (point-max) |
| 7895 | (cons 'article-type (cons 'signature |
| 7896 | gnus-hidden-properties))))) |
| 7897 | (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist)) |
| 7898 | (gnus-set-mode-line 'article)))) |
| 7899 | |
| 7900 | (defun gnus-button-entry () |
| 7901 | ;; Return the first entry in `gnus-button-alist' matching this place. |
| 7902 | (let ((alist gnus-button-alist) |
| 7903 | (entry nil)) |
| 7904 | (while alist |
| 7905 | (setq entry (pop alist)) |
| 7906 | (if (looking-at (eval (car entry))) |
| 7907 | (setq alist nil) |
| 7908 | (setq entry nil))) |
| 7909 | entry)) |
| 7910 | |
| 7911 | (defun gnus-button-push (marker) |
| 7912 | ;; Push button starting at MARKER. |
| 7913 | (save-excursion |
| 7914 | (goto-char marker) |
| 7915 | (let* ((entry (gnus-button-entry)) |
| 7916 | (inhibit-point-motion-hooks t) |
| 7917 | (fun (nth 3 entry)) |
| 7918 | (args (or (and (eq (car entry) 'gnus-button-url-regexp) |
| 7919 | (get-char-property marker 'gnus-button-url)) |
| 7920 | (mapcar (lambda (group) |
| 7921 | (let ((string (match-string group))) |
| 7922 | (set-text-properties |
| 7923 | 0 (length string) nil string) |
| 7924 | string)) |
| 7925 | (nthcdr 4 entry))))) |
| 7926 | (cond |
| 7927 | ((fboundp fun) |
| 7928 | (apply fun args)) |
| 7929 | ((and (boundp fun) |
| 7930 | (fboundp (symbol-value fun))) |
| 7931 | (apply (symbol-value fun) args)) |
| 7932 | (t |
| 7933 | (gnus-message 1 "You must define `%S' to use this button" |
| 7934 | (cons fun args))))))) |
| 7935 | |
| 7936 | (defun gnus-parse-news-url (url) |
| 7937 | (let (scheme server port group message-id articles) |
| 7938 | (with-temp-buffer |
| 7939 | (insert url) |
| 7940 | (goto-char (point-min)) |
| 7941 | (when (looking-at "\\([A-Za-z]+\\):") |
| 7942 | (setq scheme (match-string 1)) |
| 7943 | (goto-char (match-end 0))) |
| 7944 | (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/") |
| 7945 | (setq server (match-string 1)) |
| 7946 | (setq port (if (stringp (match-string 3)) |
| 7947 | (string-to-number (match-string 3)) |
| 7948 | (match-string 3))) |
| 7949 | (goto-char (match-end 0))) |
| 7950 | |
| 7951 | (cond |
| 7952 | ((looking-at "\\(.*@.*\\)") |
| 7953 | (setq message-id (match-string 1))) |
| 7954 | ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)") |
| 7955 | (setq group (match-string 1) |
| 7956 | articles (split-string (match-string 2) "-"))) |
| 7957 | ((looking-at "\\([^/]+\\)/?") |
| 7958 | (setq group (match-string 1))) |
| 7959 | (t |
| 7960 | (error "Unknown news URL syntax")))) |
| 7961 | (list scheme server port group message-id articles))) |
| 7962 | |
| 7963 | (defun gnus-button-handle-news (url) |
| 7964 | "Fetch a news URL." |
| 7965 | (destructuring-bind (scheme server port group message-id articles) |
| 7966 | (gnus-parse-news-url url) |
| 7967 | (cond |
| 7968 | (message-id |
| 7969 | (with-current-buffer gnus-summary-buffer |
| 7970 | (if server |
| 7971 | (let ((gnus-refer-article-method |
| 7972 | (nconc (list (list 'nntp server)) |
| 7973 | gnus-refer-article-method)) |
| 7974 | (nntp-port-number (or port "nntp"))) |
| 7975 | (gnus-message 7 "Fetching %s with %s" |
| 7976 | message-id gnus-refer-article-method) |
| 7977 | (gnus-summary-refer-article message-id)) |
| 7978 | (gnus-summary-refer-article message-id)))) |
| 7979 | (group |
| 7980 | (gnus-button-fetch-group url))))) |
| 7981 | |
| 7982 | (defun gnus-button-patch (library line) |
| 7983 | "Visit an Emacs Lisp library LIBRARY on line LINE." |
| 7984 | (interactive) |
| 7985 | (let ((file (locate-library (file-name-nondirectory library)))) |
| 7986 | (unless file |
| 7987 | (error "Couldn't find library %s" library)) |
| 7988 | (find-file file) |
| 7989 | (goto-char (point-min)) |
| 7990 | (forward-line (1- (string-to-number line))))) |
| 7991 | |
| 7992 | (defun gnus-button-handle-man (url) |
| 7993 | "Fetch a man page." |
| 7994 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) |
| 7995 | (when (eq gnus-button-man-handler 'woman) |
| 7996 | (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" ""))) |
| 7997 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) |
| 7998 | (funcall gnus-button-man-handler url)) |
| 7999 | |
| 8000 | (defun gnus-button-handle-info-url (url) |
| 8001 | "Fetch an info URL." |
| 8002 | (setq url (mm-subst-char-in-string ?+ ?\ url)) |
| 8003 | (cond |
| 8004 | ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url) |
| 8005 | (gnus-info-find-node |
| 8006 | (concat "(" (or (gnus-url-unhex-string (match-string 1 url)) |
| 8007 | "Gnus") |
| 8008 | ")" (gnus-url-unhex-string (match-string 2 url))))) |
| 8009 | ((string-match "([^)\"]+)[^\"]+" url) |
| 8010 | (setq url |
| 8011 | (gnus-replace-in-string |
| 8012 | (gnus-replace-in-string url "[\n\t ]+" " ") "\"" "")) |
| 8013 | (gnus-info-find-node url)) |
| 8014 | (t (error "Can't parse %s" url)))) |
| 8015 | |
| 8016 | (defun gnus-button-handle-info-url-gnome (url) |
| 8017 | "Fetch GNOME style info URL." |
| 8018 | (setq url (mm-subst-char-in-string ?_ ?\ url)) |
| 8019 | (if (string-match "\\([^#]+\\)#?\\(.*\\)" url) |
| 8020 | (gnus-info-find-node |
| 8021 | (concat "(" |
| 8022 | (gnus-url-unhex-string |
| 8023 | (match-string 1 url)) |
| 8024 | ")" |
| 8025 | (or (gnus-url-unhex-string |
| 8026 | (match-string 2 url)) |
| 8027 | "Top"))) |
| 8028 | (error "Can't parse %s" url))) |
| 8029 | |
| 8030 | (defun gnus-button-handle-info-url-kde (url) |
| 8031 | "Fetch KDE style info URL." |
| 8032 | (gnus-info-find-node (gnus-url-unhex-string url))) |
| 8033 | |
| 8034 | ;; (info) will autoload info.el |
| 8035 | (declare-function Info-menu "info" (menu-item &optional fork)) |
| 8036 | (declare-function Info-index-next "info" (num)) |
| 8037 | |
| 8038 | (defun gnus-button-handle-info-keystrokes (url) |
| 8039 | "Call `info' when pushing the corresponding URL button." |
| 8040 | ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'. |
| 8041 | (let (node indx comma) |
| 8042 | (if (string-match |
| 8043 | (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+" |
| 8044 | "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" |
| 8045 | "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET" |
| 8046 | "\\(?:[ \t\n,]*\\)\\)?") |
| 8047 | url) |
| 8048 | (setq node (match-string 2 url) |
| 8049 | indx (match-string 3 url)) |
| 8050 | (error "Can't parse %s" url)) |
| 8051 | (info) |
| 8052 | (Info-directory) |
| 8053 | (Info-menu node) |
| 8054 | (when (> (length indx) 0) |
| 8055 | (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" |
| 8056 | "\\([ \t\n,]*\\)") |
| 8057 | indx) |
| 8058 | (setq comma (match-string 2 indx)) |
| 8059 | (setq indx (match-string 1 indx)) |
| 8060 | (Info-index indx) |
| 8061 | (when comma |
| 8062 | (dotimes (i (with-temp-buffer |
| 8063 | (insert comma) |
| 8064 | ;; Note: the XEmacs version of `how-many' takes |
| 8065 | ;; no optional argument. |
| 8066 | (goto-char (point-min)) |
| 8067 | (how-many ","))) |
| 8068 | (Info-index-next 1))) |
| 8069 | nil))) |
| 8070 | |
| 8071 | ;; Called after pgg-snarf-keys-region, which autoloads pgg.el. |
| 8072 | (declare-function pgg-display-output-buffer "pgg" (start end status)) |
| 8073 | |
| 8074 | (defun gnus-button-openpgp (url) |
| 8075 | "Retrieve and add an OpenPGP key given URL from an OpenPGP header." |
| 8076 | (with-temp-buffer |
| 8077 | (mm-url-insert-file-contents-external url) |
| 8078 | (pgg-snarf-keys-region (point-min) (point-max)) |
| 8079 | (pgg-display-output-buffer nil nil nil))) |
| 8080 | |
| 8081 | (defun gnus-button-message-id (message-id) |
| 8082 | "Fetch MESSAGE-ID." |
| 8083 | (with-current-buffer gnus-summary-buffer |
| 8084 | (gnus-summary-refer-article message-id))) |
| 8085 | |
| 8086 | (defun gnus-button-fetch-group (address &rest ignore) |
| 8087 | "Fetch GROUP specified by ADDRESS." |
| 8088 | (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'" |
| 8089 | address) |
| 8090 | ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function' |
| 8091 | ;; for nntp:// and news:// |
| 8092 | (setq address (match-string 3 address))) |
| 8093 | (if (not (string-match "[:/]" address)) |
| 8094 | ;; This is just a simple group url. |
| 8095 | (gnus-group-read-ephemeral-group address gnus-select-method) |
| 8096 | (if (not |
| 8097 | (string-match |
| 8098 | "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?" |
| 8099 | address)) |
| 8100 | (error "Can't parse %s" address) |
| 8101 | (gnus-group-read-ephemeral-group |
| 8102 | (match-string 4 address) |
| 8103 | `(nntp ,(match-string 1 address) |
| 8104 | (nntp-address ,(match-string 1 address)) |
| 8105 | (nntp-port-number ,(if (match-end 3) |
| 8106 | (match-string 3 address) |
| 8107 | "nntp"))) |
| 8108 | nil nil nil |
| 8109 | (and (match-end 6) (list (string-to-number (match-string 6 address)))))))) |
| 8110 | |
| 8111 | (defun gnus-url-parse-query-string (query &optional downcase) |
| 8112 | (let (retval pairs cur key val) |
| 8113 | (setq pairs (split-string query "&")) |
| 8114 | (while pairs |
| 8115 | (setq cur (car pairs) |
| 8116 | pairs (cdr pairs)) |
| 8117 | (if (not (string-match "=" cur)) |
| 8118 | nil ; Grace |
| 8119 | (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0))) |
| 8120 | val (gnus-url-unhex-string (substring cur (match-end 0) nil) t)) |
| 8121 | (if downcase |
| 8122 | (setq key (downcase key))) |
| 8123 | (setq cur (assoc key retval)) |
| 8124 | (if cur |
| 8125 | (setcdr cur (cons val (cdr cur))) |
| 8126 | (setq retval (cons (list key val) retval))))) |
| 8127 | retval)) |
| 8128 | |
| 8129 | (defun gnus-url-mailto (url) |
| 8130 | ;; Send mail to someone |
| 8131 | (when (string-match "mailto:/*\\(.*\\)" url) |
| 8132 | (setq url (substring url (match-beginning 1) nil))) |
| 8133 | (let (to args subject func) |
| 8134 | (setq args (gnus-url-parse-query-string |
| 8135 | (if (string-match "^\\?" url) |
| 8136 | (substring url 1) |
| 8137 | (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url) |
| 8138 | (concat "to=" (match-string 1 url) "&" |
| 8139 | (match-string 2 url)) |
| 8140 | (concat "to=" url))) |
| 8141 | t) |
| 8142 | subject (cdr-safe (assoc "subject" args))) |
| 8143 | (gnus-msg-mail) |
| 8144 | (while args |
| 8145 | (setq func (intern-soft (concat "message-goto-" (downcase (caar args))))) |
| 8146 | (if (fboundp func) |
| 8147 | (funcall func) |
| 8148 | (message-position-on-field (caar args))) |
| 8149 | (insert (gnus-replace-in-string |
| 8150 | (mapconcat 'identity (reverse (cdar args)) ", ") |
| 8151 | "\r\n" "\n" t)) |
| 8152 | (setq args (cdr args))) |
| 8153 | (if subject |
| 8154 | (message-goto-body) |
| 8155 | (message-goto-subject)))) |
| 8156 | |
| 8157 | (defun gnus-button-embedded-url (address) |
| 8158 | "Activate ADDRESS with `browse-url'." |
| 8159 | (browse-url (gnus-strip-whitespace address))) |
| 8160 | |
| 8161 | ;;; Next/prev buttons in the article buffer. |
| 8162 | |
| 8163 | (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") |
| 8164 | (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") |
| 8165 | |
| 8166 | (defvar gnus-prev-page-map |
| 8167 | (let ((map (make-sparse-keymap))) |
| 8168 | (define-key map gnus-mouse-2 'gnus-button-prev-page) |
| 8169 | (define-key map "\r" 'gnus-button-prev-page) |
| 8170 | map)) |
| 8171 | |
| 8172 | (defvar gnus-next-page-map |
| 8173 | (let ((map (make-sparse-keymap))) |
| 8174 | (unless (>= emacs-major-version 21) |
| 8175 | ;; XEmacs doesn't care. |
| 8176 | (set-keymap-parent map gnus-article-mode-map)) |
| 8177 | (define-key map gnus-mouse-2 'gnus-button-next-page) |
| 8178 | (define-key map "\r" 'gnus-button-next-page) |
| 8179 | map)) |
| 8180 | |
| 8181 | (defun gnus-insert-prev-page-button () |
| 8182 | (let ((b (point)) e |
| 8183 | (inhibit-read-only t)) |
| 8184 | (gnus-eval-format |
| 8185 | gnus-prev-page-line-format nil |
| 8186 | `(keymap ,gnus-prev-page-map |
| 8187 | gnus-prev t |
| 8188 | gnus-callback gnus-article-button-prev-page |
| 8189 | article-type annotation)) |
| 8190 | (setq e (if (bolp) |
| 8191 | ;; Exclude a newline. |
| 8192 | (1- (point)) |
| 8193 | (point))) |
| 8194 | (when gnus-article-button-face |
| 8195 | (gnus-overlay-put (gnus-make-overlay b e nil t) |
| 8196 | 'face gnus-article-button-face)) |
| 8197 | (widget-convert-button |
| 8198 | 'link b e |
| 8199 | :action 'gnus-button-prev-page |
| 8200 | :button-keymap gnus-prev-page-map))) |
| 8201 | |
| 8202 | (defun gnus-button-next-page (&optional args more-args) |
| 8203 | "Go to the next page." |
| 8204 | (interactive) |
| 8205 | (let ((win (selected-window))) |
| 8206 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
| 8207 | (gnus-article-next-page) |
| 8208 | (select-window win))) |
| 8209 | |
| 8210 | (defun gnus-button-prev-page (&optional args more-args) |
| 8211 | "Go to the prev page." |
| 8212 | (interactive) |
| 8213 | (let ((win (selected-window))) |
| 8214 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
| 8215 | (gnus-article-prev-page) |
| 8216 | (select-window win))) |
| 8217 | |
| 8218 | (defun gnus-insert-next-page-button () |
| 8219 | (let ((b (point)) e |
| 8220 | (inhibit-read-only t)) |
| 8221 | (gnus-eval-format gnus-next-page-line-format nil |
| 8222 | `(keymap ,gnus-next-page-map |
| 8223 | gnus-next t |
| 8224 | gnus-callback gnus-article-button-next-page |
| 8225 | article-type annotation)) |
| 8226 | (setq e (if (bolp) |
| 8227 | ;; Exclude a newline. |
| 8228 | (1- (point)) |
| 8229 | (point))) |
| 8230 | (when gnus-article-button-face |
| 8231 | (gnus-overlay-put (gnus-make-overlay b e nil t) |
| 8232 | 'face gnus-article-button-face)) |
| 8233 | (widget-convert-button |
| 8234 | 'link b e |
| 8235 | :action 'gnus-button-next-page |
| 8236 | :button-keymap gnus-next-page-map))) |
| 8237 | |
| 8238 | (defun gnus-article-button-next-page (arg) |
| 8239 | "Go to the next page." |
| 8240 | (interactive "P") |
| 8241 | (let ((win (selected-window))) |
| 8242 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
| 8243 | (gnus-article-next-page) |
| 8244 | (select-window win))) |
| 8245 | |
| 8246 | (defun gnus-article-button-prev-page (arg) |
| 8247 | "Go to the prev page." |
| 8248 | (interactive "P") |
| 8249 | (let ((win (selected-window))) |
| 8250 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
| 8251 | (gnus-article-prev-page) |
| 8252 | (select-window win))) |
| 8253 | |
| 8254 | (defvar gnus-decode-header-methods |
| 8255 | '(mail-decode-encoded-word-region) |
| 8256 | "List of methods used to decode headers. |
| 8257 | |
| 8258 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item |
| 8259 | is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a |
| 8260 | \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups |
| 8261 | whose names match REGEXP. |
| 8262 | |
| 8263 | For example: |
| 8264 | \((\"chinese\" . gnus-decode-encoded-word-region-by-guess) |
| 8265 | mail-decode-encoded-word-region |
| 8266 | (\"chinese\" . rfc1843-decode-region)) |
| 8267 | ") |
| 8268 | |
| 8269 | (defvar gnus-decode-header-methods-cache nil) |
| 8270 | |
| 8271 | (defun gnus-multi-decode-header (start end) |
| 8272 | "Apply the functions from `gnus-encoded-word-methods' that match." |
| 8273 | (unless (and gnus-decode-header-methods-cache |
| 8274 | (eq gnus-newsgroup-name |
| 8275 | (car gnus-decode-header-methods-cache))) |
| 8276 | (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name)) |
| 8277 | (dolist (x gnus-decode-header-methods) |
| 8278 | (if (symbolp x) |
| 8279 | (nconc gnus-decode-header-methods-cache (list x)) |
| 8280 | (if (and gnus-newsgroup-name |
| 8281 | (string-match (car x) gnus-newsgroup-name)) |
| 8282 | (nconc gnus-decode-header-methods-cache |
| 8283 | (list (cdr x))))))) |
| 8284 | (let ((xlist gnus-decode-header-methods-cache)) |
| 8285 | (pop xlist) |
| 8286 | (save-restriction |
| 8287 | (narrow-to-region start end) |
| 8288 | (while xlist |
| 8289 | (funcall (pop xlist) (point-min) (point-max)))))) |
| 8290 | |
| 8291 | ;;; |
| 8292 | ;;; Treatment top-level handling. |
| 8293 | ;;; |
| 8294 | |
| 8295 | (defun gnus-treat-article (condition &optional part-number total-parts type) |
| 8296 | (let ((length (- (point-max) (point-min))) |
| 8297 | (alist gnus-treatment-function-alist) |
| 8298 | (article-goto-body-goes-to-point-min-p t) |
| 8299 | (treated-type |
| 8300 | (or (not type) |
| 8301 | (catch 'found |
| 8302 | (let ((list gnus-article-treat-types)) |
| 8303 | (while list |
| 8304 | (when (string-match (pop list) type) |
| 8305 | (throw 'found t))))))) |
| 8306 | (highlightp (gnus-visual-p 'article-highlight 'highlight)) |
| 8307 | val elem) |
| 8308 | (gnus-run-hooks 'gnus-part-display-hook) |
| 8309 | (dolist (elem alist) |
| 8310 | (setq val |
| 8311 | (save-excursion |
| 8312 | (when (gnus-buffer-live-p gnus-summary-buffer) |
| 8313 | (set-buffer gnus-summary-buffer)) |
| 8314 | (symbol-value (car elem)))) |
| 8315 | (when (and (or (consp val) |
| 8316 | treated-type) |
| 8317 | (gnus-treat-predicate val) |
| 8318 | (or (not (get (car elem) 'highlight)) |
| 8319 | highlightp)) |
| 8320 | (save-restriction |
| 8321 | (funcall (cadr elem))))))) |
| 8322 | |
| 8323 | ;; Dynamic variables. |
| 8324 | (defvar part-number) |
| 8325 | (defvar total-parts) |
| 8326 | (defvar type) |
| 8327 | (defvar condition) |
| 8328 | (defvar length) |
| 8329 | |
| 8330 | (defun gnus-treat-predicate (val) |
| 8331 | (cond |
| 8332 | ((null val) |
| 8333 | nil) |
| 8334 | (condition |
| 8335 | (eq condition val)) |
| 8336 | ((and (listp val) |
| 8337 | (stringp (car val))) |
| 8338 | (apply 'gnus-or (mapcar `(lambda (s) |
| 8339 | (string-match s ,(or gnus-newsgroup-name ""))) |
| 8340 | val))) |
| 8341 | ((listp val) |
| 8342 | (let ((pred (pop val))) |
| 8343 | (cond |
| 8344 | ((eq pred 'or) |
| 8345 | (apply 'gnus-or (mapcar 'gnus-treat-predicate val))) |
| 8346 | ((eq pred 'and) |
| 8347 | (apply 'gnus-and (mapcar 'gnus-treat-predicate val))) |
| 8348 | ((eq pred 'not) |
| 8349 | (not (gnus-treat-predicate (car val)))) |
| 8350 | ((eq pred 'typep) |
| 8351 | (equal (car val) type)) |
| 8352 | (t |
| 8353 | (error "%S is not a valid predicate" pred))))) |
| 8354 | ((eq val t) |
| 8355 | t) |
| 8356 | ((eq val 'head) |
| 8357 | nil) |
| 8358 | ((eq val 'first) |
| 8359 | (eq part-number 1)) |
| 8360 | ((eq val 'last) |
| 8361 | (eq part-number total-parts)) |
| 8362 | ((numberp val) |
| 8363 | (< length val)) |
| 8364 | (t |
| 8365 | (error "%S is not a valid value" val)))) |
| 8366 | |
| 8367 | (defun gnus-article-encrypt-body (protocol &optional n) |
| 8368 | "Encrypt the article body." |
| 8369 | (interactive |
| 8370 | (list |
| 8371 | (or gnus-article-encrypt-protocol |
| 8372 | (gnus-completing-read "Encrypt protocol" |
| 8373 | (mapcar 'car gnus-article-encrypt-protocol-alist) |
| 8374 | t)) |
| 8375 | current-prefix-arg)) |
| 8376 | ;; User might hit `K E' instead of `K e', so prompt once. |
| 8377 | (when (and gnus-article-encrypt-protocol |
| 8378 | gnus-novice-user) |
| 8379 | (unless (gnus-y-or-n-p "Really encrypt article(s)? ") |
| 8380 | (error "Encrypt aborted"))) |
| 8381 | (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist)))) |
| 8382 | (unless func |
| 8383 | (error "Can't find the encrypt protocol %s" protocol)) |
| 8384 | (if (member gnus-newsgroup-name '("nndraft:delayed" |
| 8385 | "nndraft:drafts" |
| 8386 | "nndraft:queue")) |
| 8387 | (error "Can't encrypt the article in group %s" |
| 8388 | gnus-newsgroup-name)) |
| 8389 | (gnus-summary-iterate n |
| 8390 | (with-current-buffer gnus-summary-buffer |
| 8391 | (let ((mail-parse-charset gnus-newsgroup-charset) |
| 8392 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) |
| 8393 | (summary-buffer gnus-summary-buffer) |
| 8394 | references point) |
| 8395 | (gnus-set-global-variables) |
| 8396 | (when (gnus-group-read-only-p) |
| 8397 | (error "The current newsgroup does not support article encrypt")) |
| 8398 | (gnus-summary-show-article t) |
| 8399 | (setq references |
| 8400 | (or (mail-header-references gnus-current-headers) "")) |
| 8401 | (set-buffer gnus-article-buffer) |
| 8402 | (let* ((inhibit-read-only t) |
| 8403 | (headers |
| 8404 | (mapcar (lambda (field) |
| 8405 | (and (save-restriction |
| 8406 | (message-narrow-to-head) |
| 8407 | (goto-char (point-min)) |
| 8408 | (search-forward field nil t)) |
| 8409 | (prog2 |
| 8410 | (message-narrow-to-field) |
| 8411 | (buffer-string) |
| 8412 | (delete-region (point-min) (point-max)) |
| 8413 | (widen)))) |
| 8414 | '("Content-Type:" "Content-Transfer-Encoding:" |
| 8415 | "Content-Disposition:")))) |
| 8416 | (message-narrow-to-head) |
| 8417 | (message-remove-header "MIME-Version") |
| 8418 | (goto-char (point-max)) |
| 8419 | (setq point (point)) |
| 8420 | (insert (apply 'concat headers)) |
| 8421 | (widen) |
| 8422 | (narrow-to-region point (point-max)) |
| 8423 | (let ((message-options message-options)) |
| 8424 | (message-options-set 'message-sender user-mail-address) |
| 8425 | (message-options-set 'message-recipients user-mail-address) |
| 8426 | (message-options-set 'message-sign-encrypt 'not) |
| 8427 | (funcall func)) |
| 8428 | (goto-char (point-min)) |
| 8429 | (insert "MIME-Version: 1.0\n") |
| 8430 | (widen) |
| 8431 | (gnus-summary-edit-article-done |
| 8432 | references nil summary-buffer t)) |
| 8433 | (when gnus-keep-backlog |
| 8434 | (gnus-backlog-remove-article |
| 8435 | (car gnus-article-current) (cdr gnus-article-current))) |
| 8436 | (gnus-flush-original-article-buffer) |
| 8437 | (when gnus-use-cache |
| 8438 | (gnus-cache-update-article |
| 8439 | (car gnus-article-current) (cdr gnus-article-current)))))))) |
| 8440 | |
| 8441 | (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n" |
| 8442 | "The following specs can be used: |
| 8443 | %t The security MIME type |
| 8444 | %i Additional info |
| 8445 | %d Details |
| 8446 | %D Details if button is pressed") |
| 8447 | |
| 8448 | (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n" |
| 8449 | "The following specs can be used: |
| 8450 | %t The security MIME type |
| 8451 | %i Additional info |
| 8452 | %d Details |
| 8453 | %D Details if button is pressed") |
| 8454 | |
| 8455 | (defvar gnus-mime-security-button-line-format-alist |
| 8456 | '((?t gnus-tmp-type ?s) |
| 8457 | (?i gnus-tmp-info ?s) |
| 8458 | (?d gnus-tmp-details ?s) |
| 8459 | (?D gnus-tmp-pressed-details ?s))) |
| 8460 | |
| 8461 | (defvar gnus-mime-security-button-commands |
| 8462 | '((gnus-article-press-button "\r" "Show Detail") |
| 8463 | (undefined "v") |
| 8464 | (undefined "t") |
| 8465 | (undefined "C") |
| 8466 | (gnus-mime-security-save-part "o" "Save...") |
| 8467 | (undefined "\C-o") |
| 8468 | (undefined "r") |
| 8469 | (undefined "d") |
| 8470 | (undefined "c") |
| 8471 | (undefined "i") |
| 8472 | (undefined "E") |
| 8473 | (undefined "e") |
| 8474 | (undefined "p") |
| 8475 | (gnus-mime-security-pipe-part "|" "Pipe To Command...") |
| 8476 | (undefined "."))) |
| 8477 | |
| 8478 | (defvar gnus-mime-security-button-map |
| 8479 | (let ((map (make-sparse-keymap))) |
| 8480 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
| 8481 | (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu) |
| 8482 | (dolist (c gnus-mime-security-button-commands) |
| 8483 | (define-key map (cadr c) (car c))) |
| 8484 | map)) |
| 8485 | |
| 8486 | (easy-menu-define |
| 8487 | gnus-mime-security-button-menu gnus-mime-security-button-map |
| 8488 | "Security button menu." |
| 8489 | `("Security Part" |
| 8490 | ,@(delq nil |
| 8491 | (mapcar (lambda (c) |
| 8492 | (unless (eq (car c) 'undefined) |
| 8493 | (vector (caddr c) (car c) :active t))) |
| 8494 | gnus-mime-security-button-commands)))) |
| 8495 | |
| 8496 | (defun gnus-mime-security-button-menu (event prefix) |
| 8497 | "Construct a context-sensitive menu of security commands." |
| 8498 | (interactive "e\nP") |
| 8499 | (save-window-excursion |
| 8500 | (let ((pos (event-start event))) |
| 8501 | (select-window (posn-window pos)) |
| 8502 | (goto-char (posn-point pos)) |
| 8503 | (gnus-article-check-buffer) |
| 8504 | (popup-menu gnus-mime-security-button-menu nil prefix)))) |
| 8505 | |
| 8506 | (defvar gnus-mime-security-details-buffer nil) |
| 8507 | |
| 8508 | (defvar gnus-mime-security-button-pressed nil) |
| 8509 | |
| 8510 | (defvar gnus-mime-security-show-details-inline t |
| 8511 | "If non-nil, show details in the article buffer.") |
| 8512 | |
| 8513 | (defun gnus-mime-security-verify-or-decrypt (handle) |
| 8514 | (mm-remove-parts (cdr handle)) |
| 8515 | (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region)) |
| 8516 | point (inhibit-read-only t)) |
| 8517 | (if region |
| 8518 | (goto-char (car region))) |
| 8519 | (setq point (point)) |
| 8520 | (with-current-buffer (mm-handle-multipart-original-buffer handle) |
| 8521 | (let* ((mm-verify-option 'known) |
| 8522 | (mm-decrypt-option 'known) |
| 8523 | (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle))) |
| 8524 | (unless (eq nparts (cdr handle)) |
| 8525 | (mm-destroy-parts (cdr handle)) |
| 8526 | (setcdr handle nparts)))) |
| 8527 | (gnus-mime-display-security handle) |
| 8528 | (when region |
| 8529 | (delete-region (point) (cdr region)) |
| 8530 | (set-marker (car region) nil) |
| 8531 | (set-marker (cdr region) nil)) |
| 8532 | (goto-char point))) |
| 8533 | |
| 8534 | (defun gnus-mime-security-show-details (handle) |
| 8535 | (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details))) |
| 8536 | (if (not details) |
| 8537 | (gnus-message 5 "No details.") |
| 8538 | (if gnus-mime-security-show-details-inline |
| 8539 | (let ((gnus-mime-security-button-pressed |
| 8540 | (not (get-text-property (point) 'gnus-mime-details))) |
| 8541 | (gnus-mime-security-button-line-format |
| 8542 | (get-text-property (point) 'gnus-line-format)) |
| 8543 | (inhibit-read-only t)) |
| 8544 | (forward-char -1) |
| 8545 | (while (eq (get-text-property (point) 'gnus-line-format) |
| 8546 | gnus-mime-security-button-line-format) |
| 8547 | (forward-char -1)) |
| 8548 | (forward-char) |
| 8549 | (save-restriction |
| 8550 | (narrow-to-region (point) (point)) |
| 8551 | (gnus-insert-mime-security-button handle)) |
| 8552 | (delete-region (point) |
| 8553 | (or (text-property-not-all |
| 8554 | (point) (point-max) |
| 8555 | 'gnus-line-format |
| 8556 | gnus-mime-security-button-line-format) |
| 8557 | (point-max)))) |
| 8558 | ;; Not inlined. |
| 8559 | (if (gnus-buffer-live-p gnus-mime-security-details-buffer) |
| 8560 | (with-current-buffer gnus-mime-security-details-buffer |
| 8561 | (erase-buffer) |
| 8562 | t) |
| 8563 | (setq gnus-mime-security-details-buffer |
| 8564 | (gnus-get-buffer-create "*MIME Security Details*"))) |
| 8565 | (with-current-buffer gnus-mime-security-details-buffer |
| 8566 | (insert details) |
| 8567 | (goto-char (point-min))) |
| 8568 | (pop-to-buffer gnus-mime-security-details-buffer))))) |
| 8569 | |
| 8570 | (defun gnus-mime-security-press-button (handle) |
| 8571 | (save-excursion |
| 8572 | (if (mm-handle-multipart-ctl-parameter handle 'gnus-info) |
| 8573 | (gnus-mime-security-show-details handle) |
| 8574 | (gnus-mime-security-verify-or-decrypt handle)))) |
| 8575 | |
| 8576 | (defun gnus-insert-mime-security-button (handle &optional displayed) |
| 8577 | (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol)) |
| 8578 | (gnus-tmp-type |
| 8579 | (concat |
| 8580 | (or (nth 2 (assoc protocol mm-verify-function-alist)) |
| 8581 | (nth 2 (assoc protocol mm-decrypt-function-alist)) |
| 8582 | "Unknown") |
| 8583 | (if (equal (car handle) "multipart/signed") |
| 8584 | " Signed" " Encrypted") |
| 8585 | " Part")) |
| 8586 | (gnus-tmp-info |
| 8587 | (or (mm-handle-multipart-ctl-parameter handle 'gnus-info) |
| 8588 | "Undecided")) |
| 8589 | (gnus-tmp-details |
| 8590 | (mm-handle-multipart-ctl-parameter handle 'gnus-details)) |
| 8591 | gnus-tmp-pressed-details |
| 8592 | b e) |
| 8593 | (setq gnus-tmp-details |
| 8594 | (if gnus-tmp-details |
| 8595 | (concat "\n" gnus-tmp-details) |
| 8596 | "")) |
| 8597 | (setq gnus-tmp-pressed-details |
| 8598 | (if gnus-mime-security-button-pressed gnus-tmp-details "")) |
| 8599 | (unless (bolp) |
| 8600 | (insert "\n")) |
| 8601 | (setq b (point)) |
| 8602 | (gnus-eval-format |
| 8603 | gnus-mime-security-button-line-format |
| 8604 | gnus-mime-security-button-line-format-alist |
| 8605 | `(keymap ,gnus-mime-security-button-map |
| 8606 | gnus-callback gnus-mime-security-press-button |
| 8607 | gnus-line-format ,gnus-mime-security-button-line-format |
| 8608 | gnus-mime-details ,gnus-mime-security-button-pressed |
| 8609 | article-type annotation |
| 8610 | gnus-data ,handle)) |
| 8611 | (setq e (if (bolp) |
| 8612 | ;; Exclude a newline. |
| 8613 | (1- (point)) |
| 8614 | (point))) |
| 8615 | (when gnus-article-button-face |
| 8616 | (gnus-overlay-put (gnus-make-overlay b e nil t) |
| 8617 | 'face gnus-article-button-face)) |
| 8618 | (widget-convert-button |
| 8619 | 'link b e |
| 8620 | :mime-handle handle |
| 8621 | :action 'gnus-widget-press-button |
| 8622 | :button-keymap gnus-mime-security-button-map |
| 8623 | :help-echo |
| 8624 | (lambda (widget) |
| 8625 | ;; Needed to properly clear the message due to a bug in |
| 8626 | ;; wid-edit (XEmacs only). |
| 8627 | (when (boundp 'help-echo-owns-message) |
| 8628 | (setq help-echo-owns-message t)) |
| 8629 | (format |
| 8630 | "%S: show detail; %S: more options" |
| 8631 | (aref gnus-mouse-2 0) |
| 8632 | (aref gnus-down-mouse-3 0)))))) |
| 8633 | |
| 8634 | (defun gnus-mime-display-security (handle) |
| 8635 | (save-restriction |
| 8636 | (narrow-to-region (point) (point)) |
| 8637 | (unless (gnus-unbuttonized-mime-type-p (car handle)) |
| 8638 | (gnus-insert-mime-security-button handle)) |
| 8639 | (gnus-mime-display-part (cadr handle)) |
| 8640 | (unless (bolp) |
| 8641 | (insert "\n")) |
| 8642 | (unless (gnus-unbuttonized-mime-type-p (car handle)) |
| 8643 | (let ((gnus-mime-security-button-line-format |
| 8644 | gnus-mime-security-button-end-line-format)) |
| 8645 | (gnus-insert-mime-security-button handle))) |
| 8646 | (mm-set-handle-multipart-parameter |
| 8647 | handle 'gnus-region |
| 8648 | (cons (set-marker (make-marker) (point-min)) |
| 8649 | (set-marker (make-marker) (point-max)))) |
| 8650 | (goto-char (point-max)))) |
| 8651 | |
| 8652 | (defun gnus-mime-security-run-function (function) |
| 8653 | "Run FUNCTION with the security part under point." |
| 8654 | (gnus-article-check-buffer) |
| 8655 | (let ((data (get-text-property (point) 'gnus-data)) |
| 8656 | buffer handle) |
| 8657 | (when (and (stringp (car-safe data)) |
| 8658 | (setq buffer (mm-handle-multipart-original-buffer data)) |
| 8659 | (setq handle (cadr data))) |
| 8660 | (if (bufferp (mm-handle-buffer handle)) |
| 8661 | (progn |
| 8662 | (setq handle (cons buffer (copy-sequence (cdr handle)))) |
| 8663 | (mm-handle-set-undisplayer handle nil)) |
| 8664 | (setq handle (mm-make-handle |
| 8665 | buffer |
| 8666 | (mm-handle-multipart-ctl-parameter handle 'protocol) |
| 8667 | nil nil nil nil nil nil))) |
| 8668 | (funcall function handle)))) |
| 8669 | |
| 8670 | (defun gnus-mime-security-save-part () |
| 8671 | "Save the security part under point." |
| 8672 | (interactive) |
| 8673 | (gnus-mime-security-run-function 'mm-save-part)) |
| 8674 | |
| 8675 | (defun gnus-mime-security-pipe-part () |
| 8676 | "Pipe the security part under point to a process." |
| 8677 | (interactive) |
| 8678 | (gnus-mime-security-run-function 'mm-pipe-part)) |
| 8679 | |
| 8680 | (gnus-ems-redefine) |
| 8681 | |
| 8682 | (provide 'gnus-art) |
| 8683 | |
| 8684 | (run-hooks 'gnus-art-load-hook) |
| 8685 | |
| 8686 | ;;; gnus-art.el ends here |