bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#19068: Mail file vars aren't derived from customized message-directo


From: Ivan Shmakov
Subject: bug#19068: Mail file vars aren't derived from customized message-directory
Date: Fri, 30 Jan 2015 07:35:53 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>>>>> Kelly Dean <kelly@prtime.org> writes:
>>>>> Eli Zaretskii wrote:

 >>> Also, grep -r "~/Mail/" emacs-24.4/lisp/ | grep 'el:' gives 19
 >>> hits, all of which are inappropriate if ~/Mail isn't supposed to be
 >>> hardcoded.  If ~/Mail is supposed to be hardcoded, then the
 >>> message-directory variable should be removed, to avoid misleading
 >>> users.

 >> This is a red herring: all of these hits are either in comments or
 >> in default values of other defcustoms.

 > If a user renames his ⌜Mail⌝ directory to ⌜mail⌝, then he'll want all
 > the things that previously used ⌜Mail⌝ to use ⌜mail⌝.  Manually
 > changing them all is tedious and error-prone, so it'd be nice to have
 > one place to make the change.  In Emacs, message-directory advertises
 > itself as that place.

        Only as long as message-mode (or anything deriving from it) is
        considered.

        I tend to think that defcustom’s :set does not fit for this
        case, and instead suggest using nil as the default for the
        variables whose defaults derive from message-directory, –
        something along the lines of the (untested) patch MIMEd.

        * lisp/gnus/message.el (subr-x): Require feature.
        (message-auto-save-directory): Default to nil.
        (message-auto-save-directory): New function.
        (message-set-auto-save-file-name): Use it.

 > I lowercased my mail directory name both because it's easier to type
 > that way (don't have to press shift),

        Seconded.

 > and because some other things already use the lowercase version by
 > default, and there was no reason to use both upper- and lower-case
 > versions.

-- 
FSF associate member #7257  np. Face Another Day — Jogeir Liljedahl 230E 334A
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -29,7 +29,8 @@
 ;;; Code:
 
 (eval-when-compile
-  (require 'cl))
+  (require 'cl)
+  (require 'subr-x))                   ; For when-let.
 
 (require 'mailheader)
 (require 'gmm-utils)
@@ -1331,12 +1332,10 @@
   :group 'message-various
   :type '(repeat function))
 
-(defcustom message-auto-save-directory
-  (if (file-writable-p message-directory)
-      (file-name-as-directory (expand-file-name "drafts" message-directory))
-    "~/")
+(defcustom message-auto-save-directory nil
   "*Directory where Message auto-saves buffers if Gnus isn't running.
 If nil, Message won't auto-save."
+  :version 25.1
   :group 'message-buffers
   :link '(custom-manual "(message)Various Message Variables")
   :type '(choice directory (const :tag "Don't auto-save" nil)))
@@ -6666,12 +6665,24 @@ defun message-setup-1 (headers &optional yank-action 
actions return-action)
   ;; rmail-start-mail expects message-mail to return t (Bug#9392)
   t)
 
+(defun message-auto-save-directory nil
+  "Return message auto save directory.
+Return the value of the `message-auto-save-directory' variable if non-nil.
+Otherwise, if `message-directory' is non-nil, return a suitable
+directory name under it if it is writeable, or "~/" if not.
+Return nil if all the above fails."
+  (cond ((not message-directory) nil)
+       ((file-writable-p message-directory)
+        (file-name-as-directory
+         (expand-file-name "drafts" message-directory)))
+       (t "~/")))
+
 (defun message-set-auto-save-file-name ()
   "Associate the message buffer with a file in the drafts directory."
-  (when message-auto-save-directory
+  (when-let ((dir (message-auto-save-directory)))
     (unless (file-directory-p
-            (directory-file-name message-auto-save-directory))
-      (make-directory message-auto-save-directory t))
+            (directory-file-name dir))
+      (make-directory dir t))
     (if (gnus-alive-p)
        (setq message-draft-article
              (nndraft-request-associate-buffer "drafts"))
@@ -6689,7 +6700,7 @@ defun message-set-auto-save-file-name ()
                                  "message"
                                "*message*")
                               (format-time-string "-%Y%m%d-%H%M%S"))
-                             message-auto-save-directory))
+                             dir))
       (setq buffer-auto-save-file-name (make-auto-save-file-name)))
     (clear-visited-file-modtime)
     (setq buffer-file-coding-system message-draft-coding-system)))

reply via email to

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