From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Shmakov Newsgroups: gmane.emacs.bugs Subject: bug#19068: Mail file vars aren't derived from customized message-directory Date: Fri, 30 Jan 2015 07:35:53 +0000 Message-ID: <87bnlgk9eu.fsf@violet.siamics.net> References: <83r3udmuvp.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1422603438 13061 80.91.229.3 (30 Jan 2015 07:37:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Jan 2015 07:37:18 +0000 (UTC) To: 19068@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 30 08:37:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YH68d-00043R-Es for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Jan 2015 08:37:11 +0100 Original-Received: from localhost ([::1]:35117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH68c-0005tQ-Pk for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Jan 2015 02:37:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH68Y-0005t3-GW for bug-gnu-emacs@gnu.org; Fri, 30 Jan 2015 02:37:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH68V-0006Vo-8s for bug-gnu-emacs@gnu.org; Fri, 30 Jan 2015 02:37:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH68U-0006Vh-GM for bug-gnu-emacs@gnu.org; Fri, 30 Jan 2015 02:37:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YH68U-0000jw-5t; Fri, 30 Jan 2015 02:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Shmakov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Fri, 30 Jan 2015 07:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19068 X-GNU-PR-Package: emacs,gnus X-GNU-PR-Keywords: Original-Received: via spool by 19068-submit@debbugs.gnu.org id=B19068.14226033702775 (code B ref 19068); Fri, 30 Jan 2015 07:37:02 +0000 Original-Received: (at 19068) by debbugs.gnu.org; 30 Jan 2015 07:36:10 +0000 Original-Received: from localhost ([127.0.0.1]:57738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YH67c-0000id-V4 for submit@debbugs.gnu.org; Fri, 30 Jan 2015 02:36:09 -0500 Original-Received: from fely.am-1.org ([78.47.74.50]:41254) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YH67Z-0000iO-Ls for 19068@debbugs.gnu.org; Fri, 30 Jan 2015 02:36:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net; s=a2013295; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:Sender:References:Subject:To:From; bh=j7oyOo8ci5VmEOInqxtaowca9Xm3BMjUGACWF8zpboo=; b=gNbrcj/zRDSGN739z++DTGBJTX3bSX8X/VREV5NC5SGDwz3gqvZtQZ/+vwpp4sCcoCeB3AtyzUG3Do6qxgao0B5BzE2ptsxn0MIsMAjG2jbcWF2/EbTkYrjfR5+6uD3iSQm8ENjhF/+t2Peu8Zjh8pzM5AnEbD1m7xR10lKZt7g=; Original-Received: from [2a02:2560:6d4:26ca::1:1d] (helo=violet.siamics.net) by fely.am-1.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YH67V-00056m-Ug for 19068@debbugs.gnu.org; Fri, 30 Jan 2015 07:36:02 +0000 Original-Received: from localhost ([::1] helo=violet.siamics.net) by violet.siamics.net with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YH67O-0001BA-33 for 19068@debbugs.gnu.org; Fri, 30 Jan 2015 14:35:54 +0700 Mail-Followup-To: 19068@debbugs.gnu.org In-Reply-To: (Kelly Dean's message of "Fri, 30 Jan 2015 07:11:52 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98894 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> Kelly Dean 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 =E2=8C=9CMail=E2=8C=9D directory to =E2=8C=9Cmail= =E2=8C=9D, then he'll want all > the things that previously used =E2=8C=9CMail=E2=8C=9D to use =E2=8C=9Cm= ail=E2=8C=9D. 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=E2=80=99s :set does not fit for this case, and instead suggest using nil as the default for the variables whose defaults derive from message-directory, =E2=80=93 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. --=20 FSF associate member #7257 np. Face Another Day =E2=80=94 Jogeir Liljedahl= 230E 334A --=-=-= Content-Type: text/diff Content-Disposition: inline --- 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))) --=-=-=--