emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 8675f9c: Ensure that user-mail-address always has a


From: Glenn Morris
Subject: [Emacs-diffs] master 8675f9c: Ensure that user-mail-address always has a value
Date: Fri, 17 Feb 2017 19:06:26 -0500 (EST)

branch: master
commit 8675f9c8b8a002530d0c4e0263bb3d4cf3a649fa
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    Ensure that user-mail-address always has a value
    
    * lisp/startup.el (user-mail-address): Initialize in the normal way.
    (command-line): Reset user-mail-address if needed using
    standard custom machinery.
    * lisp/mail/feedmail.el (feedmail-fiddle-from):
    * lisp/mail/rmail.el (rmail-unknown-mail-followup-to):
    * lisp/mail/rmailsum.el (rmail-header-summary):
    Simplify now that user-mail-address is always set.
    ; * doc/lispref/os.texi (System Environment): Remove fixme comment.
---
 doc/lispref/os.texi   |  2 --
 lisp/mail/feedmail.el | 19 ++++++-------------
 lisp/mail/rmail.el    |  7 +------
 lisp/mail/rmailsum.el | 10 +---------
 lisp/startup.el       | 35 +++++++++++++++++++----------------
 5 files changed, 27 insertions(+), 46 deletions(-)

diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index c0a9c81..9b6752c 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -941,8 +941,6 @@ If this variable is address@hidden, it is used instead of
 @code{system-name} for purposes of generating email addresses.  For
 example, it is used when constructing the default value of
 @code{user-mail-address}.  @xref{User Identification}.
address@hidden FIXME sounds like should probably give this a :set-after and some
address@hidden custom-initialize-delay voodoo.
 @end defopt
 
 @deffn Command getenv var &optional frame
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index 5379156..e0bd459 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -2759,24 +2759,17 @@ return that value."
   (cond
    ;; nil means do nothing
    ((eq nil feedmail-from-line) nil)
-   ;; t is the same a using the default computation, so compute it and recurse
+   ;; t is the same as using the default computation, so compute it and recurse
    ;; user-full-name suggested by address@hidden (=Kimball Collins)
    ;; improvement using user-mail-address suggested by
    ;;   address@hidden (Douglas Gray Stephens)
-   ;; improvement using mail-host-address suggested by "Jason Eisner" 
<address@hidden>
-   ;; ((this situation really is hopeless, though)
    ((eq t feedmail-from-line)
     (let ((feedmail-from-line
-          (let ((at-stuff
-                 (if (> (length user-mail-address) 0)
-                     user-mail-address
-                   (concat (user-login-name) "@"
-                           (or mail-host-address (system-name))))))
-            (cond
-             ((eq mail-from-style nil) at-stuff)
-             ((eq mail-from-style 'parens) (concat at-stuff " (" 
(user-full-name) ")"))
-             ((eq mail-from-style 'angles) (concat "\"" (user-full-name) "\" 
<" at-stuff ">"))
-             ))))
+          (cond
+           ((eq mail-from-style nil) user-mail-address)
+           ((eq mail-from-style 'parens) (concat user-mail-address " (" 
(user-full-name) ")"))
+           ((eq mail-from-style 'angles) (concat "\"" (user-full-name) "\" <" 
user-mail-address ">"))
+           )))
       (feedmail-fiddle-from)))
 
    ;; if it's a string, simply make a fiddle-plex out of it and recurse
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 695638f..4b72b35 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2665,12 +2665,7 @@ Ask the user whether to add that list name to 
`mail-mailing-lists'."
                              (concat "^\\("
                                      (regexp-quote (user-login-name))
                                      "\\($\\|@\\)\\|"
-                                     (regexp-quote
-                                      (if (> (length user-mail-address) 0)
-                                          user-mail-address
-                                        (concat (user-login-name) "@"
-                                                (or mail-host-address
-                                                    (system-name)))))
+                                     (regexp-quote user-mail-address)
                                      "\\>\\)"))
                          addr))
                        (y-or-n-p
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 7295381..37ac46c 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -753,15 +753,7 @@ the message being processed."
                            (concat "^\\("
                                    (regexp-quote (user-login-name))
                                    "\\($\\|@\\)\\|"
-                                   (regexp-quote
-                                    ;; Don't lose if run from init file
-                                    ;; where user-mail-address is not
-                                    ;; set yet.
-                                    (if (> (length user-mail-address) 0)
-                                        user-mail-address
-                                      (concat (user-login-name) "@"
-                                              (or mail-host-address
-                                                  (system-name)))))
+                                   (regexp-quote user-mail-address)
                                    "\\>\\)"))
                        from))
                   ;; No From field, or it's this user.
diff --git a/lisp/startup.el b/lisp/startup.el
index 4272708..2d48bd5 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -381,17 +381,14 @@ If this is nil, Emacs uses `system-name'."
   :type '(choice (const nil) string)
   :group 'mail)
 
-(defcustom user-mail-address (if command-line-processed
-                                (or (getenv "EMAIL")
-                                    (concat (user-login-name) "@"
-                                            (or mail-host-address
-                                                (system-name))))
-                              ;; Empty string means "not set yet".
-                              "")
-  "Full mailing address of this user.
-This is initialized with environment variable `EMAIL' or, as a
-fallback, using `mail-host-address'.  This is done after your
-init file is read, in case it sets `mail-host-address'."
+(defcustom user-mail-address
+  (or (getenv "EMAIL")
+      (concat (user-login-name) "@" (or mail-host-address (system-name))))
+  "The email address of the current user.
+This defaults to either: the value of EMAIL environment variable; or
address@hidden, using `user-login-name' and `mail-host-address' (or 
`system-name')."
+  :initialize 'custom-initialize-delay
+  :set-after '(mail-host-address)
   :type 'string
   :group 'mail)
 
@@ -1296,11 +1293,17 @@ the `--debug-init' option to view a complete error 
backtrace."
        (set-language-environment current-language-environment)))
 
     ;; Do this here in case the init file sets mail-host-address.
-    (if (equal user-mail-address "")
-       (setq user-mail-address (or (getenv "EMAIL")
-                                   (concat (user-login-name) "@"
-                                           (or mail-host-address
-                                               (system-name))))))
+    (and mail-host-address
+        ;; Check that user-mail-address has not been set by hand.
+        ;; Yes, this is ugly, but slightly less so than leaving
+        ;; user-mail-address uninitialized during init file processing.
+        ;; Perhaps we should make :set-after do something like this?
+        ;; Ie, extend it to also mean (re)initialize-after.
+        (equal user-mail-address
+               (let (mail-host-address)
+                 (ignore-errors
+                   (eval (car (get 'user-mail-address 'standard-value))))))
+        (custom-reevaluate-setting 'user-mail-address))
 
     ;; If parameter have been changed in the init file which influence
     ;; face realization, clear the face cache so that new faces will



reply via email to

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