]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure that user-mail-address always has a value
authorGlenn Morris <rgm@gnu.org>
Sat, 18 Feb 2017 00:06:15 +0000 (19:06 -0500)
committerGlenn Morris <rgm@gnu.org>
Sat, 18 Feb 2017 00:06:15 +0000 (19:06 -0500)
* 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
lisp/mail/feedmail.el
lisp/mail/rmail.el
lisp/mail/rmailsum.el
lisp/startup.el

index c0a9c81fda26101f4153eefe3d026f1d25801dc9..9b6752c5e1abf7584a1c09d672acb31b2a81a0da 100644 (file)
@@ -941,8 +941,6 @@ If this variable is non-@code{nil}, 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}.
-@c FIXME sounds like should probably give this a :set-after and some
-@c custom-initialize-delay voodoo.
 @end defopt
 
 @deffn Command getenv var &optional frame
index 53791565bb14e0635f5818e85f6e3b70297ee962..e0bd4590b138b6462b2baa4ed7ea30b6b3b57085 100644 (file)
@@ -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 kpc@ptolemy.arc.nasa.gov (=Kimball Collins)
    ;; improvement using user-mail-address suggested by
    ;;   gray@austin.apc.slb.com (Douglas Gray Stephens)
-   ;; improvement using mail-host-address suggested by "Jason Eisner" <jason@cs.jhu.edu>
-   ;; ((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
index 695638fa0627c4c71fe9860402bb7516e9ef41ad..4b72b3562d1bbcae2b284ebbf7f61195282ea09b 100644 (file)
@@ -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
index 729538173a0319813d2ff8208eb8523a9693a486..37ac46c6af60a421c9c06b25c5261e0fc2065e64 100644 (file)
@@ -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.
index 4272708ce9a8605f4bf93145fec670a2387a9de8..2d48bd5df15b31dd24381cf7dfeeedebbf79a2c9 100644 (file)
@@ -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
+user@host, 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