emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 441e23b: * lisp/mail/feedmail.el: Use lexical-bindi


From: Stefan Monnier
Subject: [Emacs-diffs] master 441e23b: * lisp/mail/feedmail.el: Use lexical-binding
Date: Fri, 14 Sep 2018 11:05:39 -0400 (EDT)

branch: master
commit 441e23b5eb13929db9341f93ee71b761135943e3
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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.
---
 lisp/mail/feedmail.el | 74 ++++++++++++++++++++++++---------------------------
 1 file changed, 35 insertions(+), 39 deletions(-)

diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index 6093aec..ec4a116 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -1,5 +1,6 @@
-;;; feedmail.el --- assist other email packages to massage outgoing messages
-;;; This file is in the public domain.
+;;; feedmail.el --- assist other email packages to massage outgoing messages  
-*- lexical-binding:t -*-
+
+;; This file is in the public domain.
 
 ;; This file is part of GNU Emacs.
 
@@ -1312,25 +1313,21 @@ There's no trivial way to avoid it.  It's unwise to 
just set the value
 of `buffer-file-name' to nil because that will defeat feedmail's file
 management features.  Instead, arrange for this variable to be set to
 the value of `buffer-file-name' before setting that to nil.  An easy way
-to do that would be with defadvice on `mail-send' \(undoing the
-assignments in a later advice).
+to do that would be with an advice on `mail-send'.
 
 feedmail will pretend that `buffer-file-name', if nil, has the value
 assigned of `feedmail-queue-buffer-file-name' and carry out its normal
 activities.  feedmail does not restore the non-nil value of
-`buffer-file-name'.  For safe bookkeeping, the user should insure that
+`buffer-file-name'.  For safe bookkeeping, the user should ensure that
 feedmail-queue-buffer-file-name is restored to nil.
 
-Example `defadvice' for mail-send:
-
-   (defadvice mail-send (before feedmail-mail-send-before-advice activate)
-     (setq feedmail-queue-buffer-file-name buffer-file-name)
-     (setq buffer-file-name nil))
+Example advice for mail-send:
 
-   (defadvice mail-send (after feedmail-mail-send-after-advice activate)
-     (if feedmail-queue-buffer-file-name (setq buffer-file-name 
feedmail-queue-buffer-file-name))
-     (setq feedmail-queue-buffer-file-name nil))
-")
+    (advice-add 'mail-send :around #'my-feedmail-mail-send-advice)
+    (defun my-feedmail-mail-send-advice (orig-fun &rest args)
+      (let ((feedmail-queue-buffer-file-name buffer-file-name)
+             (buffer-file-name nil))
+        (apply orig-fun args)))")
 
 ;; defvars to make byte-compiler happy(er)
 (defvar feedmail-error-buffer        nil)
@@ -1438,7 +1435,7 @@ internal buffers will be reused and things will get 
confused."
   )
 
 (defcustom feedmail-queue-runner-mode-setter
-  (lambda (&optional arg) (mail-mode))
+  (lambda (&optional _) (mail-mode))
   "A function to set the proper mode of a message file.
 Called when the message is read back out of the queue directory with a single
 argument, the optional argument used in the call to
@@ -1474,7 +1471,10 @@ set `mail-header-separator' to the value of
 
 
 (defcustom feedmail-queue-runner-message-sender
-  (lambda (&optional arg) (mail-send))
+  (lambda (&optional _)
+    ;; `mail-send' is not autoloaded, which is why we need the `require'.
+    (require 'sendmail) (declare-function mail-send "sendmail")
+    (mail-send))
   "Function to initiate sending a message file.
 Called for each message read back out of the queue directory with a
 single argument, the optional argument used in the call to
@@ -1737,7 +1737,7 @@ insertion.")
 
 (declare-function vm-mail "ext:vm" (&optional to subject))
 
-(defun feedmail-vm-mail-mode (&optional arg)
+(defun feedmail-vm-mail-mode (&optional _)
   "Make something like a buffer that has been created via `vm-mail'.
 The optional argument is ignored and is just for argument compatibility with
 `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
 feedmail FQM message file from a queue.  You could use something like
 this:
 
-\(setq auto-mode-alist
-      (cons \\='(\"\\\\.fqm$\" . feedmail-vm-mail-mode) auto-mode-alist))
-"
+    (add-to-list 'auto-mode-alist \\='(\"\\\\.fqm\\\\\\='\" . 
feedmail-vm-mail-mode))"
   (feedmail-say-debug ">in-> feedmail-vm-mail-mode")
   (let ((the-buf (current-buffer)))
     (vm-mail)
@@ -2150,19 +2148,8 @@ you can set `feedmail-queue-reminder-alist' to nil."
    feedmail-prompt-before-queue-user-alist
    ))
 
-(defun feedmail-queue-runner-prompt ()
-  "Ask whether to queue, send immediately, or return to editing a message, 
etc."
-  (feedmail-say-debug ">in-> feedmail-queue-runner-prompt")
-  (feedmail-queue-send-edit-prompt-inner
-   feedmail-ask-before-queue-default
-   feedmail-ask-before-queue-prompt
-   feedmail-ask-before-queue-reprompt
-   'feedmail-message-action-help
-   feedmail-prompt-before-queue-standard-alist
-   feedmail-prompt-before-queue-user-alist
-   ))
 (defun feedmail-queue-send-edit-prompt-inner (default prompt reprompt helper
-                                              standard-alist user-alist)
+                                             standard-alist user-alist)
   (feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt-inner")
   ;; Some implementation ideas here came from the userlock.el code
   (or defining-kbd-macro (discard-input))
@@ -2181,6 +2168,8 @@ you can set `feedmail-queue-reminder-alist' to nil."
               (let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 
0))
                 (read-char-exclusive))))
          (if (= user-sez help-char)
+              ;; FIXME: This seems to want to refer to the `helper' argument,
+              ;; but it's quoted so the `helper' arg ends up unused!
              (setq answer '(^ . helper))
            (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y))
                (setq user-sez d-char))
@@ -2209,7 +2198,7 @@ you can set `feedmail-queue-reminder-alist' to nil."
   ;; emacs convention is that scroll-up moves text up, window down
   (feedmail-say-debug ">in-> feedmail-scroll-buffer %s" direction)
   (save-selected-window
-    (let ((signal-error-on-buffer-boundary nil)
+    (let ((signal-error-on-buffer-boundary nil) ;FIXME: Unknown var!?
          (fqm-window (display-buffer (if buffy buffy (current-buffer)))))
       (select-window fqm-window)
       (if (eq direction 'up)
@@ -2697,8 +2686,10 @@ fiddle-plex, as described in the documentation for the 
variable
   (save-excursion
     (if feedmail-enable-spray
        (mapcar
-        (lambda (feedmail-spray-this-address)
-           (let ((spray-buffer (get-buffer-create " *FQM Outgoing Email 
Spray*")))
+        (lambda (address)
+          (let ((feedmail-spray-this-address address)
+                 (spray-buffer
+                  (get-buffer-create " *FQM Outgoing Email Spray*")))
              (with-current-buffer spray-buffer
                (erase-buffer)
                ;; not life's most efficient methodology, but spraying isn't
@@ -2712,7 +2703,8 @@ fiddle-plex, as described in the documentation for the 
variable
                ;; Message-Id:s, but I doubt that anyone cares,
                ;; practically.  If someone complains about it, I'll
                ;; add it.
-               (feedmail-fiddle-list-of-spray-fiddle-plexes 
feedmail-spray-address-fiddle-plex-list)
+               (feedmail-fiddle-list-of-spray-fiddle-plexes
+                 feedmail-spray-address-fiddle-plex-list)
                ;; this (let ) is just in case some buffer eater
                ;; is cheating and using the global variable name instead
                ;; of its argument to find the buffer
@@ -3147,13 +3139,17 @@ been weeded out."
     (identity address-list)))
 
 
-(defun feedmail-one-last-look (feedmail-prepped-text-buffer)
+(defun feedmail-one-last-look (buffer)
   "Offer the user one last chance to give it up."
   (feedmail-say-debug ">in-> feedmail-one-last-look")
   (save-excursion
+    ;; FIXME: switch-to-buffer may fail or pop up a new frame
+    ;; (in minibuffer-only frames, for example) and save-window-excursion
+    ;; won't delete the newly created frame upon exit!
     (save-window-excursion
-      (switch-to-buffer feedmail-prepped-text-buffer)
-      (if (and (fboundp 'y-or-n-p-with-timeout) (numberp 
feedmail-confirm-outgoing-timeout))
+      (switch-to-buffer buffer)
+      (if (and (fboundp 'y-or-n-p-with-timeout)
+               (numberp feedmail-confirm-outgoing-timeout))
          (y-or-n-p-with-timeout
           "FQM: Send this email? "
           (abs feedmail-confirm-outgoing-timeout)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]