X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-art.el;h=f8bdca65d4691314a9a2d3b8ac5c7fe5118ab9d6;hb=765e0918a9207bc3fb08aa56226ec52cff44fc8a;hp=a476851dffb0c4f42b57cf0a8a18b9e5da712265;hpb=8f7476d4cfadb358d635238ae62c48a89efc6db2;p=gnus diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index a476851df..f8bdca65d 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -1,6 +1,6 @@ ;;; gnus-art.el --- article mode commands for Gnus -;; Copyright (C) 1996-2013 Free Software Foundation, Inc. +;; Copyright (C) 1996-2014 Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen ;; Keywords: news @@ -1033,15 +1033,15 @@ Some of these headers are updated automatically. See `gnus-article-update-date-headers' for details." :version "24.1" :group 'gnus-article-headers - :type '(repeat - (item :tag "Universal time (UT)" :value 'ut) - (item :tag "Local time zone" :value 'local) - (item :tag "Readable English" :value 'english) - (item :tag "Elapsed time" :value 'lapsed) - (item :tag "Original and elapsed time" :value 'combined-lapsed) - (item :tag "Original date header" :value 'original) - (item :tag "ISO8601 format" :value 'iso8601) - (item :tag "User-defined" :value 'user-defined))) + :type '(set + (const :tag "Universal time (UT)" ut) + (const :tag "Local time zone" local) + (const :tag "Readable English" english) + (const :tag "Elapsed time" lapsed) + (const :tag "Original and elapsed time" combined-lapsed) + (const :tag "Original date header" original) + (const :tag "ISO8601 format" iso8601) + (const :tag "User-defined" user-defined))) (defcustom gnus-article-update-date-headers nil "A number that says how often to update the date header (in seconds). @@ -1652,7 +1652,7 @@ called with the group name as the parameter, and should return a regexp." :version "24.1" :group 'gnus-art - :type 'regexp) + :type '(choice regexp function)) ;;; Internal variables @@ -2666,7 +2666,7 @@ If READ-CHARSET, ask for a coding system." (string-match "quoted-printable" type)))) (article-goto-body) (quoted-printable-decode-region - (point) (point-max) (mm-charset-to-coding-system charset)))))) + (point) (point-max) (mm-charset-to-coding-system charset nil t)))))) (defun article-de-base64-unreadable (&optional force read-charset) "Translate a base64 article. @@ -2697,7 +2697,8 @@ If READ-CHARSET, ask for a coding system." (narrow-to-region (point) (point-max)) (base64-decode-region (point-min) (point-max)) (mm-decode-coding-region - (point-min) (point-max) (mm-charset-to-coding-system charset))))))) + (point-min) (point-max) + (mm-charset-to-coding-system charset nil t))))))) (eval-when-compile (require 'rfc1843)) @@ -2795,6 +2796,9 @@ Return file name." (dolist (handle handles) (cond ((not (listp handle))) + ;; Exclude broken handles that `gnus-summary-enter-digest-group' + ;; may create. + ((not (or (bufferp (car handle)) (stringp (car handle))))) ((equal (mm-handle-media-supertype handle) "multipart") (when (setq file (gnus-article-browse-html-save-cid-content cid handle directory)) @@ -2802,11 +2806,12 @@ Return file name." ((equal (concat "<" cid ">") (mm-handle-id handle)) (setq file (expand-file-name - (or (mm-handle-filename handle) - (concat - (make-temp-name "cid") - (car (rassoc (car (mm-handle-type handle)) mailcap-mime-extensions)))) - directory)) + (or (mm-handle-filename handle) + (concat + (make-temp-name "cid") + (car (rassoc (car (mm-handle-type handle)) + mailcap-mime-extensions)))) + directory)) (mm-save-part-to-file handle file) (throw 'found file)))))))) @@ -2892,6 +2897,13 @@ message header will be added to the bodies of the \"text/html\" parts." ((match-beginning 3) "&") (t "
\n")))) (goto-char (point-min)) + (while (re-search-forward "^[\t ]+" nil t) + (dotimes (i (prog1 + (current-column) + (delete-region (match-beginning 0) + (match-end 0)))) + (insert " "))) + (goto-char (point-min)) (insert "
\n") (goto-char (point-max)) (insert "
\n
\n") @@ -2909,7 +2921,7 @@ message header will be added to the bodies of the \"text/html\" parts." (cond ((= (length hcharset) 1) (setq hcharset (car hcharset) coding (mm-charset-to-coding-system - hcharset))) + hcharset nil t))) ((> (length hcharset) 1) (setq hcharset 'utf-8 coding hcharset))) @@ -2917,7 +2929,8 @@ message header will be added to the bodies of the \"text/html\" parts." (if charset (progn (setq body - (mm-charset-to-coding-system charset)) + (mm-charset-to-coding-system charset + nil t)) (if (eq coding body) (setq eheader (mm-encode-coding-string (buffer-string) coding) @@ -3431,15 +3444,13 @@ possible values." (visible-date (mail-fetch-field "Date")) pos date bface eface) (save-excursion - (goto-char (point-min)) - (when (re-search-forward "^Date:" nil t) - (setq bface (get-text-property (point-at-bol) 'face) - eface (get-text-property (1- (point-at-eol)) 'face))) - ;; Delete any old Date headers. (if date-position (progn (goto-char date-position) (setq date (get-text-property (point) 'original-date)) + (when (looking-at "[^:]+:[\t ]*") + (setq bface (get-text-property (match-beginning 0) 'face) + eface (get-text-property (match-end 0) 'face))) (delete-region (point) (progn (gnus-article-forward-header) @@ -3455,12 +3466,26 @@ possible values." (narrow-to-region pos (if (search-forward "\n\n" nil t) (1+ (match-beginning 0)) (point-max))) - (goto-char (point-min)) - (while (re-search-forward "^Date:" nil t) - (setq date (get-text-property (match-beginning 0) 'original-date)) - (delete-region (point-at-bol) (progn - (gnus-article-forward-header) - (point)))) + (while (setq pos (text-property-not-all pos (point-max) + 'gnus-date-type nil)) + (setq date (get-text-property pos 'original-date)) + (goto-char pos) + (when (looking-at "[^:]+:[\t ]*") + (setq bface (get-text-property (match-beginning 0) 'face) + eface (get-text-property (match-end 0) 'face))) + (delete-region pos (or (text-property-any pos (point-max) + 'gnus-date-type nil) + (point-max)))) + (unless date ;; the 1st time + (goto-char (point-min)) + (while (re-search-forward "^Date:[\t ]*" nil t) + (setq date (get-text-property (match-beginning 0) + 'original-date) + bface (get-text-property (match-beginning 0) 'face) + eface (get-text-property (match-end 0) 'face)) + (delete-region (point-at-bol) (progn + (gnus-article-forward-header) + (point))))) (when (and (not date) visible-date) (setq date visible-date)) @@ -3477,20 +3502,25 @@ possible values." (list type)) (t type))) - (insert (article-make-date-line date (or this-type 'ut)) "\n") - (forward-line -1) - (beginning-of-line) - (put-text-property (point) (1+ (point)) - 'original-date date) - (put-text-property (point) (1+ (point)) - 'gnus-date-type this-type) + (goto-char + (prog1 + (point) + (add-text-properties + (point) + (progn + (insert (article-make-date-line date (or this-type 'ut)) "\n") + (point)) + (list 'original-date date 'gnus-date-type this-type)))) ;; Do highlighting. - (when (looking-at "\\([^:]+\\): *\\(.*\\)$") - (put-text-property (match-beginning 1) (1+ (match-end 1)) - 'face bface) - (put-text-property (match-beginning 2) (match-end 2) - 'face eface)) - (forward-line 1))) + (when (looking-at + "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?") + (put-text-property (match-beginning 1) (match-end 1) 'face bface) + (when (match-beginning 2) + (put-text-property (match-beginning 2) (match-end 2) 'face eface)) + (while (and (zerop (forward-line 1)) + (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")) + (when (match-beginning 1) + (put-text-property (match-beginning 1) (match-end 1) 'face eface)))))) (defun article-make-date-line (date type) "Return a DATE line of TYPE." @@ -3667,28 +3697,29 @@ function and want to see what the date was before converting." (walk-windows (lambda (w) (set-buffer (window-buffer w)) - (when (eq major-mode 'gnus-article-mode) + (when (derived-mode-p 'gnus-article-mode) (let ((old-line (count-lines (point-min) (point))) (old-column (- (point) (line-beginning-position))) - (window-start - (window-start (get-buffer-window (current-buffer))))) - (goto-char (point-min)) - (while (re-search-forward "^Date:" nil t) - (let ((type (get-text-property (match-beginning 0) - 'gnus-date-type))) - (when (memq type '(lapsed combined-lapsed user-format)) - (when (and window-start - (not (= window-start - (save-excursion - (forward-line 1) - (point))))) - (setq window-start nil)) - (save-excursion - (article-date-ut type t (match-beginning 0))) - (forward-line 1) - (when window-start - (set-window-start (get-buffer-window (current-buffer)) - (point)))))) + (window-start (window-start w)) + (pos (point-min)) + type next end) + (while (setq pos (text-property-not-all pos (point-max) + 'gnus-date-type nil)) + (setq next (or (next-single-property-change pos + 'gnus-date-type) + (point-max))) + (setq type (get-text-property pos 'gnus-date-type)) + (when (memq type '(lapsed combined-lapsed user-defined)) + (article-date-ut type t pos) + (setq end (or (next-single-property-change pos + 'gnus-date-type) + (point-max))) + (when window-start + (if (/= window-start next) + (setq window-start nil) + (set-window-start w end))) + (setq next end)) + (setq pos next)) (goto-char (point-min)) (when (> old-column 0) (setq old-line (1- old-line))) @@ -4362,9 +4393,9 @@ If variable `gnus-use-long-file-name' is non-nil, it is (gnus-define-keys gnus-article-mode-map " " gnus-article-goto-next-page + [?\S-\ ] gnus-article-goto-prev-page "\177" gnus-article-goto-prev-page [delete] gnus-article-goto-prev-page - [backspace] gnus-article-goto-prev-page "\C-c^" gnus-article-refer-article "h" gnus-article-show-summary "s" gnus-article-show-summary @@ -4437,7 +4468,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is (defvar bookmark-make-record-function) (defvar shr-put-image-function) -(defun gnus-article-mode () +(define-derived-mode gnus-article-mode fundamental-mode "Article" "Major mode for displaying an article. All normal editing commands are switched off. @@ -4452,13 +4483,8 @@ commands: \\[gnus-article-mail]\t Send a reply to the address near point \\[gnus-article-describe-briefly]\t Describe the current mode briefly \\[gnus-info-find-node]\t Go to the Gnus info node" - (interactive) - (kill-all-local-variables) (gnus-simplify-mode-line) - (setq mode-name "Article") - (setq major-mode 'gnus-article-mode) (make-local-variable 'minor-mode-alist) - (use-local-map gnus-article-mode-map) (when (gnus-visual-p 'article-menu 'menu) (gnus-article-make-menu-bar) (when gnus-summary-tool-bar-map @@ -4486,9 +4512,7 @@ commands: (buffer-disable-undo) (setq buffer-read-only t show-trailing-whitespace nil) - (set-syntax-table gnus-article-mode-syntax-table) - (mm-enable-multibyte) - (gnus-run-mode-hooks 'gnus-article-mode-hook)) + (mm-enable-multibyte)) (defun gnus-article-setup-buffer () "Initialize the article buffer." @@ -4526,20 +4550,22 @@ commands: nil) (error "Action aborted")) t))) - (with-current-buffer name - (set (make-local-variable 'gnus-article-edit-mode) nil) - (gnus-article-stop-animations) - (when gnus-article-mime-handles - (mm-destroy-parts gnus-article-mime-handles) - (setq gnus-article-mime-handles nil)) - ;; Set it to nil in article-buffer! - (setq gnus-article-mime-handle-alist nil) - (buffer-disable-undo) - (setq buffer-read-only t) - (unless (eq major-mode 'gnus-article-mode) - (gnus-article-mode)) - (setq truncate-lines gnus-article-truncate-lines) - (current-buffer)) + (let ((summary gnus-summary-buffer)) + (with-current-buffer name + (set (make-local-variable 'gnus-article-edit-mode) nil) + (gnus-article-stop-animations) + (when gnus-article-mime-handles + (mm-destroy-parts gnus-article-mime-handles) + (setq gnus-article-mime-handles nil)) + ;; Set it to nil in article-buffer! + (setq gnus-article-mime-handle-alist nil) + (buffer-disable-undo) + (setq buffer-read-only t) + (unless (derived-mode-p 'gnus-article-mode) + (gnus-article-mode)) + (set (make-local-variable 'gnus-summary-buffer) summary) + (setq truncate-lines gnus-article-truncate-lines) + (current-buffer))) (let ((summary gnus-summary-buffer)) (with-current-buffer (gnus-get-buffer-create name) (gnus-article-mode) @@ -4585,7 +4611,7 @@ If ARTICLE is an id, HEADER should be the article headers. If ALL-HEADERS is non-nil, no headers are hidden." (save-excursion ;; Make sure we start in a summary buffer. - (unless (eq major-mode 'gnus-summary-mode) + (unless (derived-mode-p 'gnus-summary-mode) (set-buffer gnus-summary-buffer)) (setq gnus-summary-buffer (current-buffer)) (let* ((gnus-article (if header (mail-header-number header) article)) @@ -4696,7 +4722,7 @@ If ALL-HEADERS is non-nil, no headers are hidden." (let ((gnus-article-buffer (current-buffer)) buffer-read-only (inhibit-read-only t)) - (unless (eq major-mode 'gnus-article-mode) + (unless (derived-mode-p 'gnus-article-mode) (gnus-article-mode)) (setq buffer-read-only nil gnus-article-wash-types nil @@ -4758,7 +4784,7 @@ If a prefix ARG is given, ask for a name for this sticky article buffer." "*")) (if (and (gnus-buffer-live-p new-art-buf-name) (with-current-buffer new-art-buf-name - (eq major-mode 'gnus-sticky-article-mode))) + (derived-mode-p 'gnus-sticky-article-mode))) (switch-to-buffer new-art-buf-name) (setq new-art-buf-name (rename-buffer new-art-buf-name t))) (gnus-sticky-article-mode)) @@ -4774,7 +4800,7 @@ If none is given, assume the current buffer and kill it if it has (unless buffer (setq buffer (current-buffer))) (with-current-buffer buffer - (when (eq major-mode 'gnus-sticky-article-mode) + (when (derived-mode-p 'gnus-sticky-article-mode) (gnus-kill-buffer buffer)))) (defun gnus-kill-sticky-article-buffers (arg) @@ -4783,11 +4809,11 @@ If a prefix ARG is given, ask for confirmation." (interactive "P") (dolist (buf (gnus-buffers)) (with-current-buffer buf - (when (eq major-mode 'gnus-sticky-article-mode) - (if (not arg) - (gnus-kill-buffer buf) - (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? ")) - (gnus-kill-buffer buf))))))) + (when (derived-mode-p 'gnus-sticky-article-mode) + (if (not arg) + (gnus-kill-buffer buf) + (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? ")) + (gnus-kill-buffer buf))))))) ;;; ;;; Gnus MIME viewing functions @@ -4875,7 +4901,7 @@ General format specifiers can also be used. See Info node (defmacro gnus-bind-safe-url-regexp (&rest body) "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'." `(let ((mm-w3m-safe-url-regexp - (let ((group (if (and (eq major-mode 'gnus-article-mode) + (let ((group (if (and (derived-mode-p 'gnus-article-mode) (gnus-buffer-live-p gnus-article-current-summary)) (with-current-buffer gnus-article-current-summary @@ -5224,7 +5250,8 @@ are decompressed." (switch-to-buffer (generate-new-buffer filename)) (if (or coding-system (and charset - (setq coding-system (mm-charset-to-coding-system charset)) + (setq coding-system (mm-charset-to-coding-system + charset nil t)) (not (eq coding-system 'ascii)))) (progn (mm-enable-multibyte) @@ -5858,14 +5885,6 @@ If displaying \"text/html\" is discouraged \(see ((and (equal (car handle) "multipart/related") (not (or gnus-mime-display-multipart-as-mixed gnus-mime-display-multipart-related-as-mixed))) - ;;;!!!We should find the start part, but we just default - ;;;!!!to the first part. - ;;(gnus-mime-display-part (cadr handle)) - ;;;!!! Most multipart/related is an HTML message plus images. - ;;;!!! Unfortunately we are unable to let W3 display those - ;;;!!! included images, so we just display it as a mixed multipart. - ;;(gnus-mime-display-mixed (cdr handle)) - ;;;!!! No, w3 can display everything just fine. (gnus-mime-display-part (cadr handle))) ((equal (car handle) "multipart/signed") (gnus-add-wash-type 'signed) @@ -6179,9 +6198,14 @@ Provided for backwards compatibility." (defun gnus-shr-put-image (data alt &optional flags) "Put image DATA with a string ALT. Enable image to be deleted." - (let ((image (shr-put-image data (propertize (or alt "*") - 'gnus-image-category 'shr) - flags))) + (let ((image (if flags + (shr-put-image data (propertize (or alt "*") + 'gnus-image-category 'shr) + flags) + ;; Old `shr-put-image' doesn't take the optional `flags' + ;; argument. + (shr-put-image data (propertize (or alt "*") + 'gnus-image-category 'shr))))) (when image (gnus-add-image 'shr image)))) @@ -6454,7 +6478,7 @@ not have a face in `gnus-article-boring-faces'." (defun gnus-article-check-buffer () "Beep if not in an article buffer." - (unless (equal major-mode 'gnus-article-mode) + (unless (derived-mode-p 'gnus-article-mode) (error "Command invoked outside of a Gnus article buffer"))) (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) @@ -6569,7 +6593,7 @@ not have a face in `gnus-article-boring-faces'." new-sum-point (window-live-p win) (with-current-buffer (window-buffer win) - (eq major-mode 'gnus-summary-mode))) + (derived-mode-p 'gnus-summary-mode))) (set-window-point win new-sum-point) (set-window-start win new-sum-start) (set-window-hscroll win new-sum-hscroll)))) @@ -6629,11 +6653,7 @@ KEY is a string or a vector." ;;`gnus-agent-mode' in gnus-agent.el will define it. (defvar gnus-agent-summary-mode) (defvar gnus-draft-mode) -;; Calling help-buffer will autoload help-mode. (defvar help-xref-stack-item) -;; Emacs 22 doesn't load it in the batch mode. -(eval-when-compile - (autoload 'help-buffer "help-mode")) (defun gnus-article-describe-bindings (&optional prefix) "Show a list of all defined keys, and their definitions. @@ -6684,6 +6704,9 @@ then we display only bindings that start with that prefix." (with-current-buffer ,(current-buffer) (gnus-article-describe-bindings prefix))) ,prefix))) + ;; Loading `help-mode' here is necessary if `describe-bindings' + ;; is replaced with something, e.g. `helm-descbinds'. + (require 'help-mode) (with-current-buffer (let (help-xref-following) (help-buffer)) (setq help-xref-stack-item item))))) @@ -6930,7 +6953,8 @@ If given a prefix, show the hidden text instead." (set-buffer buf)))))) (defun gnus-block-private-groups (group) - (if (gnus-news-group-p group) + (if (or (gnus-news-group-p group) + (gnus-member-of-valid 'global group)) ;; Block nothing in news groups. nil ;; Block everything anywhere else. @@ -7154,15 +7178,17 @@ groups." "\\(?:" ;; Match paired parentheses, e.g. in Wikipedia URLs: ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com - "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*" + "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" + "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?" "\\|" - "[" chars punct "]+" "[" chars "]" + "[" chars punct "]+" "[" chars "]" "\\)")) (concat ;; XEmacs 21.4 doesn't support POSIX. "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+" "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)")) "\\)") "Regular expression that matches URLs." + :version "24.4" :group 'gnus-article-buttons :type 'regexp) @@ -7849,7 +7875,9 @@ url is put as the `gnus-button-url' overlay property on the button." (let (gnus-article-mouse-face widget-mouse-face) (while points (gnus-article-add-button (pop points) (pop points) - 'gnus-button-push beg))) + 'gnus-button-push + (list beg (assq 'gnus-button-url-regexp + gnus-button-alist))))) (let ((overlay (gnus-make-overlay start end))) (gnus-overlay-put overlay 'evaporate t) (gnus-overlay-put overlay 'gnus-button-url @@ -8394,6 +8422,8 @@ For example: (not (gnus-treat-predicate (car val)))) ((eq pred 'typep) (equal (car val) gnus-treat-type)) + ((functionp pred) + (funcall pred)) (t (error "%S is not a valid predicate" pred))))) ((eq val t) @@ -8689,9 +8719,7 @@ For example: gnus-mime-security-button-end-line-format)) (gnus-insert-mime-security-button handle))) (mm-set-handle-multipart-parameter - handle 'gnus-region - (cons (set-marker (make-marker) (point-min)) - (set-marker (make-marker) (point-max)))) + handle 'gnus-region (cons (point-min-marker) (point-max-marker))) (goto-char (point-max)))) (defun gnus-mime-security-run-function (function)