[Top][All Lists]

[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 13:45:38 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>>>>> Ivan Shmakov <address@hidden> writes:


 > I [hereby] 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.

        This of course will not work, as this variable already uses nil
        to mean “do not auto save,” so we need some other value (say,
        'auto) for the purpose.

        Please consider the revised patch MIMEd.

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

FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index de7e9ba..da5c871 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -29,7 +29,8 @@
 ;;; Code:
-  (require 'cl))
+  (require 'cl)
+  (require 'subr-x))                   ; For when-let.
 (require 'mailheader)
 (require 'gmm-utils)
@@ -1331,15 +1332,16 @@
   :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 'auto
   "*Directory where Message auto-saves buffers if Gnus isn't running.
-If nil, Message won't auto-save."
+If nil, Message won't auto-save.
+If 'auto, derive from `message-directory'."
+  :version "25.1"
   :group 'message-buffers
   :link '(custom-manual "(message)Various Message Variables")
-  :type '(choice directory (const :tag "Don't auto-save" nil)))
+  :type '(choice directory
+                (const :tag "Don't auto-save" nil)
+                (const :tag "Derive from `message-directory'" auto)))
 (defcustom message-default-charset
   (and (not (mm-multibyte-p)) 'iso-8859-1)
@@ -6666,12 +6668,28 @@
   ;; rmail-start-mail expects message-mail to return t (Bug#9392)
+(defun message-auto-save-directory nil
+  "Return message auto save directory.
+Return the value of the `message-auto-save-directory' variable if it is
+a string or 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 ((or (stringp message-auto-save-directory)
+            (not message-auto-save-directory))
+        message-auto-save-directory)
+       ((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 +6707,7 @@ defun message-set-auto-save-file-name ()
                               (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)))
     (setq buffer-file-coding-system message-draft-coding-system)))

reply via email to

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