unofficial mirror of bug-gnu-emacs@gnu.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 07:35:53 +0000	[thread overview]
Message-ID: <87bnlgk9eu.fsf@violet.siamics.net> (raw)
In-Reply-To: <ZKbSgk3EKWpoFCRTA5qk9DTvLRixbLK1HxxvMgMTvSZ@local> (Kelly Dean's message of "Fri, 30 Jan 2015 07:11:52 +0000")

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

>>>>> 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

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

--- 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	other threads:[~2015-01-30  7:35 UTC|newest]

Thread overview: 12+ 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
     [not found]   ` <4HEgHd24tKVHJkFYvKryLuxc8K21mIEO6gzZl9psynt@local>
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 [this message]
2015-01-30 13:45       ` Ivan Shmakov
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87bnlgk9eu.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).