diff options
| author | Stefan Monnier | 2018-09-14 11:05:33 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-09-14 11:05:33 -0400 |
| commit | 441e23b5eb13929db9341f93ee71b761135943e3 (patch) | |
| tree | 31a4f8a8d4500af7f3128901e3015212f652d777 | |
| parent | ff349d021df40fd73ac1ead2ed1e376b214d07fd (diff) | |
| download | emacs-441e23b5eb13929db9341f93ee71b761135943e3.tar.gz emacs-441e23b5eb13929db9341f93ee71b761135943e3.zip | |
* lisp/mail/feedmail.el: Use lexical-binding
(feedmail-queue-buffer-file-name): Improve advising example.
(feedmail-vm-mail-mode): Improve auto-mode-alist example.
(feedmail-queue-runner-prompt): Remove unused function.
| -rw-r--r-- | lisp/mail/feedmail.el | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el index 6093aecd5c3..ec4a1162b28 100644 --- a/lisp/mail/feedmail.el +++ b/lisp/mail/feedmail.el | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | ;;; feedmail.el --- assist other email packages to massage outgoing messages | 1 | ;;; feedmail.el --- assist other email packages to massage outgoing messages -*- lexical-binding:t -*- |
| 2 | ;;; This file is in the public domain. | 2 | |
| 3 | ;; This file is in the public domain. | ||
| 3 | 4 | ||
| 4 | ;; This file is part of GNU Emacs. | 5 | ;; This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -1312,25 +1313,21 @@ There's no trivial way to avoid it. It's unwise to just set the value | |||
| 1312 | of `buffer-file-name' to nil because that will defeat feedmail's file | 1313 | of `buffer-file-name' to nil because that will defeat feedmail's file |
| 1313 | management features. Instead, arrange for this variable to be set to | 1314 | management features. Instead, arrange for this variable to be set to |
| 1314 | the value of `buffer-file-name' before setting that to nil. An easy way | 1315 | the value of `buffer-file-name' before setting that to nil. An easy way |
| 1315 | to do that would be with defadvice on `mail-send' \(undoing the | 1316 | to do that would be with an advice on `mail-send'. |
| 1316 | assignments in a later advice). | ||
| 1317 | 1317 | ||
| 1318 | feedmail will pretend that `buffer-file-name', if nil, has the value | 1318 | feedmail will pretend that `buffer-file-name', if nil, has the value |
| 1319 | assigned of `feedmail-queue-buffer-file-name' and carry out its normal | 1319 | assigned of `feedmail-queue-buffer-file-name' and carry out its normal |
| 1320 | activities. feedmail does not restore the non-nil value of | 1320 | activities. feedmail does not restore the non-nil value of |
| 1321 | `buffer-file-name'. For safe bookkeeping, the user should insure that | 1321 | `buffer-file-name'. For safe bookkeeping, the user should ensure that |
| 1322 | feedmail-queue-buffer-file-name is restored to nil. | 1322 | feedmail-queue-buffer-file-name is restored to nil. |
| 1323 | 1323 | ||
| 1324 | Example `defadvice' for mail-send: | 1324 | Example advice for mail-send: |
| 1325 | |||
| 1326 | (defadvice mail-send (before feedmail-mail-send-before-advice activate) | ||
| 1327 | (setq feedmail-queue-buffer-file-name buffer-file-name) | ||
| 1328 | (setq buffer-file-name nil)) | ||
| 1329 | 1325 | ||
| 1330 | (defadvice mail-send (after feedmail-mail-send-after-advice activate) | 1326 | (advice-add 'mail-send :around #'my-feedmail-mail-send-advice) |
| 1331 | (if feedmail-queue-buffer-file-name (setq buffer-file-name feedmail-queue-buffer-file-name)) | 1327 | (defun my-feedmail-mail-send-advice (orig-fun &rest args) |
| 1332 | (setq feedmail-queue-buffer-file-name nil)) | 1328 | (let ((feedmail-queue-buffer-file-name buffer-file-name) |
| 1333 | ") | 1329 | (buffer-file-name nil)) |
| 1330 | (apply orig-fun args)))") | ||
| 1334 | 1331 | ||
| 1335 | ;; defvars to make byte-compiler happy(er) | 1332 | ;; defvars to make byte-compiler happy(er) |
| 1336 | (defvar feedmail-error-buffer nil) | 1333 | (defvar feedmail-error-buffer nil) |
| @@ -1438,7 +1435,7 @@ internal buffers will be reused and things will get confused." | |||
| 1438 | ) | 1435 | ) |
| 1439 | 1436 | ||
| 1440 | (defcustom feedmail-queue-runner-mode-setter | 1437 | (defcustom feedmail-queue-runner-mode-setter |
| 1441 | (lambda (&optional arg) (mail-mode)) | 1438 | (lambda (&optional _) (mail-mode)) |
| 1442 | "A function to set the proper mode of a message file. | 1439 | "A function to set the proper mode of a message file. |
| 1443 | Called when the message is read back out of the queue directory with a single | 1440 | Called when the message is read back out of the queue directory with a single |
| 1444 | argument, the optional argument used in the call to | 1441 | argument, the optional argument used in the call to |
| @@ -1474,7 +1471,10 @@ set `mail-header-separator' to the value of | |||
| 1474 | 1471 | ||
| 1475 | 1472 | ||
| 1476 | (defcustom feedmail-queue-runner-message-sender | 1473 | (defcustom feedmail-queue-runner-message-sender |
| 1477 | (lambda (&optional arg) (mail-send)) | 1474 | (lambda (&optional _) |
| 1475 | ;; `mail-send' is not autoloaded, which is why we need the `require'. | ||
| 1476 | (require 'sendmail) (declare-function mail-send "sendmail") | ||
| 1477 | (mail-send)) | ||
| 1478 | "Function to initiate sending a message file. | 1478 | "Function to initiate sending a message file. |
| 1479 | Called for each message read back out of the queue directory with a | 1479 | Called for each message read back out of the queue directory with a |
| 1480 | single argument, the optional argument used in the call to | 1480 | single argument, the optional argument used in the call to |
| @@ -1737,7 +1737,7 @@ insertion.") | |||
| 1737 | 1737 | ||
| 1738 | (declare-function vm-mail "ext:vm" (&optional to subject)) | 1738 | (declare-function vm-mail "ext:vm" (&optional to subject)) |
| 1739 | 1739 | ||
| 1740 | (defun feedmail-vm-mail-mode (&optional arg) | 1740 | (defun feedmail-vm-mail-mode (&optional _) |
| 1741 | "Make something like a buffer that has been created via `vm-mail'. | 1741 | "Make something like a buffer that has been created via `vm-mail'. |
| 1742 | The optional argument is ignored and is just for argument compatibility with | 1742 | The optional argument is ignored and is just for argument compatibility with |
| 1743 | `feedmail-queue-runner-mode-setter'. This function is suitable for being | 1743 | `feedmail-queue-runner-mode-setter'. This function is suitable for being |
| @@ -1745,9 +1745,7 @@ applied to a file after you've just read it from disk: for example, a | |||
| 1745 | feedmail FQM message file from a queue. You could use something like | 1745 | feedmail FQM message file from a queue. You could use something like |
| 1746 | this: | 1746 | this: |
| 1747 | 1747 | ||
| 1748 | \(setq auto-mode-alist | 1748 | (add-to-list 'auto-mode-alist \\='(\"\\\\.fqm\\\\\\='\" . feedmail-vm-mail-mode))" |
| 1749 | (cons \\='(\"\\\\.fqm$\" . feedmail-vm-mail-mode) auto-mode-alist)) | ||
| 1750 | " | ||
| 1751 | (feedmail-say-debug ">in-> feedmail-vm-mail-mode") | 1749 | (feedmail-say-debug ">in-> feedmail-vm-mail-mode") |
| 1752 | (let ((the-buf (current-buffer))) | 1750 | (let ((the-buf (current-buffer))) |
| 1753 | (vm-mail) | 1751 | (vm-mail) |
| @@ -2150,19 +2148,8 @@ you can set `feedmail-queue-reminder-alist' to nil." | |||
| 2150 | feedmail-prompt-before-queue-user-alist | 2148 | feedmail-prompt-before-queue-user-alist |
| 2151 | )) | 2149 | )) |
| 2152 | 2150 | ||
| 2153 | (defun feedmail-queue-runner-prompt () | ||
| 2154 | "Ask whether to queue, send immediately, or return to editing a message, etc." | ||
| 2155 | (feedmail-say-debug ">in-> feedmail-queue-runner-prompt") | ||
| 2156 | (feedmail-queue-send-edit-prompt-inner | ||
| 2157 | feedmail-ask-before-queue-default | ||
| 2158 | feedmail-ask-before-queue-prompt | ||
| 2159 | feedmail-ask-before-queue-reprompt | ||
| 2160 | 'feedmail-message-action-help | ||
| 2161 | feedmail-prompt-before-queue-standard-alist | ||
| 2162 | feedmail-prompt-before-queue-user-alist | ||
| 2163 | )) | ||
| 2164 | (defun feedmail-queue-send-edit-prompt-inner (default prompt reprompt helper | 2151 | (defun feedmail-queue-send-edit-prompt-inner (default prompt reprompt helper |
| 2165 | standard-alist user-alist) | 2152 | standard-alist user-alist) |
| 2166 | (feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt-inner") | 2153 | (feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt-inner") |
| 2167 | ;; Some implementation ideas here came from the userlock.el code | 2154 | ;; Some implementation ideas here came from the userlock.el code |
| 2168 | (or defining-kbd-macro (discard-input)) | 2155 | (or defining-kbd-macro (discard-input)) |
| @@ -2181,6 +2168,8 @@ you can set `feedmail-queue-reminder-alist' to nil." | |||
| 2181 | (let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 0)) | 2168 | (let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 0)) |
| 2182 | (read-char-exclusive)))) | 2169 | (read-char-exclusive)))) |
| 2183 | (if (= user-sez help-char) | 2170 | (if (= user-sez help-char) |
| 2171 | ;; FIXME: This seems to want to refer to the `helper' argument, | ||
| 2172 | ;; but it's quoted so the `helper' arg ends up unused! | ||
| 2184 | (setq answer '(^ . helper)) | 2173 | (setq answer '(^ . helper)) |
| 2185 | (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y)) | 2174 | (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y)) |
| 2186 | (setq user-sez d-char)) | 2175 | (setq user-sez d-char)) |
| @@ -2209,7 +2198,7 @@ you can set `feedmail-queue-reminder-alist' to nil." | |||
| 2209 | ;; emacs convention is that scroll-up moves text up, window down | 2198 | ;; emacs convention is that scroll-up moves text up, window down |
| 2210 | (feedmail-say-debug ">in-> feedmail-scroll-buffer %s" direction) | 2199 | (feedmail-say-debug ">in-> feedmail-scroll-buffer %s" direction) |
| 2211 | (save-selected-window | 2200 | (save-selected-window |
| 2212 | (let ((signal-error-on-buffer-boundary nil) | 2201 | (let ((signal-error-on-buffer-boundary nil) ;FIXME: Unknown var!? |
| 2213 | (fqm-window (display-buffer (if buffy buffy (current-buffer))))) | 2202 | (fqm-window (display-buffer (if buffy buffy (current-buffer))))) |
| 2214 | (select-window fqm-window) | 2203 | (select-window fqm-window) |
| 2215 | (if (eq direction 'up) | 2204 | (if (eq direction 'up) |
| @@ -2697,8 +2686,10 @@ fiddle-plex, as described in the documentation for the variable | |||
| 2697 | (save-excursion | 2686 | (save-excursion |
| 2698 | (if feedmail-enable-spray | 2687 | (if feedmail-enable-spray |
| 2699 | (mapcar | 2688 | (mapcar |
| 2700 | (lambda (feedmail-spray-this-address) | 2689 | (lambda (address) |
| 2701 | (let ((spray-buffer (get-buffer-create " *FQM Outgoing Email Spray*"))) | 2690 | (let ((feedmail-spray-this-address address) |
| 2691 | (spray-buffer | ||
| 2692 | (get-buffer-create " *FQM Outgoing Email Spray*"))) | ||
| 2702 | (with-current-buffer spray-buffer | 2693 | (with-current-buffer spray-buffer |
| 2703 | (erase-buffer) | 2694 | (erase-buffer) |
| 2704 | ;; not life's most efficient methodology, but spraying isn't | 2695 | ;; not life's most efficient methodology, but spraying isn't |
| @@ -2712,7 +2703,8 @@ fiddle-plex, as described in the documentation for the variable | |||
| 2712 | ;; Message-Id:s, but I doubt that anyone cares, | 2703 | ;; Message-Id:s, but I doubt that anyone cares, |
| 2713 | ;; practically. If someone complains about it, I'll | 2704 | ;; practically. If someone complains about it, I'll |
| 2714 | ;; add it. | 2705 | ;; add it. |
| 2715 | (feedmail-fiddle-list-of-spray-fiddle-plexes feedmail-spray-address-fiddle-plex-list) | 2706 | (feedmail-fiddle-list-of-spray-fiddle-plexes |
| 2707 | feedmail-spray-address-fiddle-plex-list) | ||
| 2716 | ;; this (let ) is just in case some buffer eater | 2708 | ;; this (let ) is just in case some buffer eater |
| 2717 | ;; is cheating and using the global variable name instead | 2709 | ;; is cheating and using the global variable name instead |
| 2718 | ;; of its argument to find the buffer | 2710 | ;; of its argument to find the buffer |
| @@ -3147,13 +3139,17 @@ been weeded out." | |||
| 3147 | (identity address-list))) | 3139 | (identity address-list))) |
| 3148 | 3140 | ||
| 3149 | 3141 | ||
| 3150 | (defun feedmail-one-last-look (feedmail-prepped-text-buffer) | 3142 | (defun feedmail-one-last-look (buffer) |
| 3151 | "Offer the user one last chance to give it up." | 3143 | "Offer the user one last chance to give it up." |
| 3152 | (feedmail-say-debug ">in-> feedmail-one-last-look") | 3144 | (feedmail-say-debug ">in-> feedmail-one-last-look") |
| 3153 | (save-excursion | 3145 | (save-excursion |
| 3146 | ;; FIXME: switch-to-buffer may fail or pop up a new frame | ||
| 3147 | ;; (in minibuffer-only frames, for example) and save-window-excursion | ||
| 3148 | ;; won't delete the newly created frame upon exit! | ||
| 3154 | (save-window-excursion | 3149 | (save-window-excursion |
| 3155 | (switch-to-buffer feedmail-prepped-text-buffer) | 3150 | (switch-to-buffer buffer) |
| 3156 | (if (and (fboundp 'y-or-n-p-with-timeout) (numberp feedmail-confirm-outgoing-timeout)) | 3151 | (if (and (fboundp 'y-or-n-p-with-timeout) |
| 3152 | (numberp feedmail-confirm-outgoing-timeout)) | ||
| 3157 | (y-or-n-p-with-timeout | 3153 | (y-or-n-p-with-timeout |
| 3158 | "FQM: Send this email? " | 3154 | "FQM: Send this email? " |
| 3159 | (abs feedmail-confirm-outgoing-timeout) | 3155 | (abs feedmail-confirm-outgoing-timeout) |