aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2018-02-27 20:47:23 -0500
committerStefan Monnier2018-02-27 20:47:23 -0500
commit7a8f3311a79d63c221dda6e680747669bb3d555d (patch)
tree90185b25bd5a0601700ff1be772a0f59ca001036
parentc005b089d1997218cba5540d37be0a5dfc2c4e1c (diff)
downloademacs-7a8f3311a79d63c221dda6e680747669bb3d555d.tar.gz
emacs-7a8f3311a79d63c221dda6e680747669bb3d555d.zip
* lisp/gnus/mm-decode.el: Use lexical-binding and use cl-lib
(mm-display-parts): Remove unused arg 'no-default'. Use 'cond'. (mm-display-external): Use closures rather than `(lambda ...). Don't bother with 'lexical-let'. (mm-insert-part): No need for string-to-multibyte now that 'insert' will do that for us now (it used to behave more like string-make-multibyte). (mm-pipe-part): Remove unused var 'name'. (shr-width, shr-content-function, shr-inhibit-images): Declare. (mm-shr): Use a closure rather than `(lambda ...).
-rw-r--r--lisp/gnus/mm-decode.el125
1 files changed, 61 insertions, 64 deletions
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index e1a0435b55a..372b6da44b5 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1,4 +1,4 @@
1;;; mm-decode.el --- Functions for decoding MIME things 1;;; mm-decode.el --- Functions for decoding MIME things -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1998-2018 Free Software Foundation, Inc. 3;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
4 4
@@ -773,15 +773,16 @@ MIME-Version header before proceeding."
773 (insert-buffer-substring obuf beg) 773 (insert-buffer-substring obuf beg)
774 (current-buffer)))) 774 (current-buffer))))
775 775
776(defun mm-display-parts (handle &optional no-default) 776(defun mm-display-parts (handle)
777 (if (stringp (car handle)) 777 (cond
778 (mapcar 'mm-display-parts (cdr handle)) 778 ((stringp (car handle)) (mapcar #'mm-display-parts (cdr handle)))
779 (if (bufferp (car handle)) 779 ((bufferp (car handle))
780 (save-restriction 780 (save-restriction
781 (narrow-to-region (point) (point)) 781 (narrow-to-region (point) (point))
782 (mm-display-part handle) 782 (mm-display-part handle)
783 (goto-char (point-max))) 783 (goto-char (point-max))))
784 (mapcar 'mm-display-parts handle)))) 784 (t
785 (mapcar #'mm-display-parts handle))))
785 786
786(autoload 'mailcap-parse-mailcaps "mailcap") 787(autoload 'mailcap-parse-mailcaps "mailcap")
787(autoload 'mailcap-mime-info "mailcap") 788(autoload 'mailcap-mime-info "mailcap")
@@ -961,15 +962,15 @@ external if displayed external."
961 mm-external-terminal-program 962 mm-external-terminal-program
962 "-e" shell-file-name 963 "-e" shell-file-name
963 shell-command-switch command) 964 shell-command-switch command)
964 `(lambda (process state) 965 (lambda (process _state)
965 (if (eq 'exit (process-status process)) 966 (if (eq 'exit (process-status process))
966 (run-at-time 967 (run-at-time
967 60.0 nil 968 60.0 nil
968 (lambda () 969 (lambda ()
969 (ignore-errors (delete-file ,file)) 970 (ignore-errors (delete-file file))
970 (ignore-errors (delete-directory 971 (ignore-errors (delete-directory
971 ,(file-name-directory 972 (file-name-directory
972 file)))))))) 973 file))))))))
973 (require 'term) 974 (require 'term)
974 (require 'gnus-win) 975 (require 'gnus-win)
975 (set-buffer 976 (set-buffer
@@ -982,13 +983,13 @@ external if displayed external."
982 (term-char-mode) 983 (term-char-mode)
983 (set-process-sentinel 984 (set-process-sentinel
984 (get-buffer-process buffer) 985 (get-buffer-process buffer)
985 `(lambda (process state) 986 (let ((wc gnus-current-window-configuration))
986 (when (eq 'exit (process-status process)) 987 (lambda (process _state)
987 (ignore-errors (delete-file ,file)) 988 (when (eq 'exit (process-status process))
988 (ignore-errors 989 (ignore-errors (delete-file file))
989 (delete-directory ,(file-name-directory file))) 990 (ignore-errors
990 (gnus-configure-windows 991 (delete-directory (file-name-directory file)))
991 ',gnus-current-window-configuration)))) 992 (gnus-configure-windows wc)))))
992 (gnus-configure-windows 'display-term)) 993 (gnus-configure-windows 'display-term))
993 (mm-handle-set-external-undisplayer handle (cons file buffer)) 994 (mm-handle-set-external-undisplayer handle (cons file buffer))
994 (add-to-list 'mm-temp-files-to-be-deleted file t)) 995 (add-to-list 'mm-temp-files-to-be-deleted file t))
@@ -1032,34 +1033,29 @@ external if displayed external."
1032 shell-command-switch command) 1033 shell-command-switch command)
1033 (set-process-sentinel 1034 (set-process-sentinel
1034 (get-buffer-process buffer) 1035 (get-buffer-process buffer)
1035 (lexical-let ((outbuf outbuf) 1036 (lambda (process _state)
1036 (file file) 1037 (when (eq (process-status process) 'exit)
1037 (buffer buffer) 1038 (run-at-time
1038 (command command) 1039 60.0 nil
1039 (handle handle)) 1040 (lambda ()
1040 (lambda (process state) 1041 (ignore-errors (delete-file file))
1041 (when (eq (process-status process) 'exit) 1042 (ignore-errors (delete-directory
1042 (run-at-time 1043 (file-name-directory file)))))
1043 60.0 nil 1044 (when (buffer-live-p outbuf)
1044 (lambda () 1045 (with-current-buffer outbuf
1045 (ignore-errors (delete-file file)) 1046 (let ((buffer-read-only nil)
1046 (ignore-errors (delete-directory 1047 (point (point)))
1047 (file-name-directory file))))) 1048 (forward-line 2)
1048 (when (buffer-live-p outbuf) 1049 (let ((start (point)))
1049 (with-current-buffer outbuf 1050 (mm-insert-inline
1050 (let ((buffer-read-only nil) 1051 handle (with-current-buffer buffer
1051 (point (point))) 1052 (buffer-string)))
1052 (forward-line 2) 1053 (put-text-property start (point)
1053 (let ((start (point))) 1054 'face 'mm-command-output))
1054 (mm-insert-inline 1055 (goto-char point))))
1055 handle (with-current-buffer buffer 1056 (when (buffer-live-p buffer)
1056 (buffer-string))) 1057 (kill-buffer buffer)))
1057 (put-text-property start (point) 1058 (message "Displaying %s...done" command))))
1058 'face 'mm-command-output))
1059 (goto-char point))))
1060 (when (buffer-live-p buffer)
1061 (kill-buffer buffer)))
1062 (message "Displaying %s...done" command)))))
1063 (mm-handle-set-external-undisplayer 1059 (mm-handle-set-external-undisplayer
1064 handle (cons file buffer)) 1060 handle (cons file buffer))
1065 (add-to-list 'mm-temp-files-to-be-deleted file t)) 1061 (add-to-list 'mm-temp-files-to-be-deleted file t))
@@ -1170,9 +1166,9 @@ external if displayed external."
1170 (goto-char (point-min)))) 1166 (goto-char (point-min))))
1171 1167
1172(defun mm-assoc-string-match (alist type) 1168(defun mm-assoc-string-match (alist type)
1173 (dolist (elem alist) 1169 (cl-dolist (elem alist)
1174 (when (string-match (car elem) type) 1170 (when (string-match (car elem) type)
1175 (return elem)))) 1171 (cl-return elem))))
1176 1172
1177(defun mm-automatic-display-p (handle) 1173(defun mm-automatic-display-p (handle)
1178 "Say whether the user wants HANDLE to be displayed automatically." 1174 "Say whether the user wants HANDLE to be displayed automatically."
@@ -1302,8 +1298,6 @@ are ignored."
1302 'gnus-decoded) 1298 'gnus-decoded)
1303 (with-current-buffer (mm-handle-buffer handle) 1299 (with-current-buffer (mm-handle-buffer handle)
1304 (buffer-string))) 1300 (buffer-string)))
1305 ((mm-multibyte-p)
1306 (string-to-multibyte (mm-get-part handle no-cache)))
1307 (t 1301 (t
1308 (mm-get-part handle no-cache))))) 1302 (mm-get-part handle no-cache)))))
1309 (save-restriction 1303 (save-restriction
@@ -1448,8 +1442,7 @@ text/html\\(?:;\\s-*charset=\\([^\t\n\r \"'>]+\\)\\)?[^>]*>" nil t)
1448(defun mm-pipe-part (handle &optional cmd) 1442(defun mm-pipe-part (handle &optional cmd)
1449 "Pipe HANDLE to a process. 1443 "Pipe HANDLE to a process.
1450Use CMD as the process." 1444Use CMD as the process."
1451 (let ((name (mail-content-type-get (mm-handle-type handle) 'name)) 1445 (let ((command (or cmd
1452 (command (or cmd
1453 (read-shell-command 1446 (read-shell-command
1454 "Shell command on MIME part: " mm-last-shell-command)))) 1447 "Shell command on MIME part: " mm-last-shell-command))))
1455 (mm-with-unibyte-buffer 1448 (mm-with-unibyte-buffer
@@ -1784,6 +1777,9 @@ If RECURSIVE, search recursively."
1784(declare-function shr-insert-document "shr" (dom)) 1777(declare-function shr-insert-document "shr" (dom))
1785(defvar shr-blocked-images) 1778(defvar shr-blocked-images)
1786(defvar shr-use-fonts) 1779(defvar shr-use-fonts)
1780(defvar shr-width)
1781(defvar shr-content-function)
1782(defvar shr-inhibit-images)
1787 1783
1788(defun mm-shr (handle) 1784(defun mm-shr (handle)
1789 ;; Require since we bind its variables. 1785 ;; Require since we bind its variables.
@@ -1840,10 +1836,11 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t)
1840 (mm-convert-shr-links) 1836 (mm-convert-shr-links)
1841 (mm-handle-set-undisplayer 1837 (mm-handle-set-undisplayer
1842 handle 1838 handle
1843 `(lambda () 1839 (let ((min (point-min-marker))
1844 (let ((inhibit-read-only t)) 1840 (max (point-max-marker)))
1845 (delete-region ,(point-min-marker) 1841 (lambda ()
1846 ,(point-max-marker)))))))) 1842 (let ((inhibit-read-only t))
1843 (delete-region min max))))))))
1847 1844
1848(defvar shr-image-map) 1845(defvar shr-image-map)
1849 1846