all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ivan Shmakov <ivan@siamics.net>
To: 19068@debbugs.gnu.org
Subject: bug#19068: Mail file vars aren't derived from customized message-directory
Date: Fri, 30 Jan 2015 13:45:38 +0000	[thread overview]
Message-ID: <877fw4jsal.fsf@violet.siamics.net> (raw)
In-Reply-To: <87bnlgk9eu.fsf@violet.siamics.net> (Ivan Shmakov's message of "Fri, 30 Jan 2015 07:35:53 +0000")

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

>>>>> Ivan Shmakov <ivan@siamics.net> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/diff, Size: 2799 bytes --]

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:
 
 (eval-when-compile
-  (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)
   t)
 
+(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 ()
 				  "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	other threads:[~2015-01-30 13:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-16 11:27 bug#19068: Mail file vars aren't derived from customized message-directory Kelly Dean
2015-01-23  3:31 ` Kelly Dean
2015-01-28 10:17 ` bug#19068: [PATCH] " Kelly Dean
2015-01-29  8:27 ` bug#19068: " Lars Ingebrigtsen
2015-01-29 10:59   ` Kelly Dean
2015-01-29 11:36     ` Ivan Shmakov
2015-01-29 11:36     ` Ivan Shmakov
2015-01-29 16:09 ` Eli Zaretskii
2015-01-30  7:11   ` Kelly Dean
2015-01-30  7:35     ` Ivan Shmakov
2015-01-30 13:45       ` Ivan Shmakov [this message]
2015-01-30  9:06     ` Eli Zaretskii
2015-02-14  5:37 ` Lars Ingebrigtsen
2015-02-14  6:54   ` Ivan Shmakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fw4jsal.fsf@violet.siamics.net \
    --to=ivan@siamics.net \
    --cc=19068@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.