From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#34911: 26.1; doc about lock file names Date: Sun, 12 May 2019 12:34:37 -0400 Message-ID: <874l5ziqci.fsf@gmail.com> References: > <83bm27uzbr.fsf@gnu.org>> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="33480"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 34911@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 12 18:35:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPrRU-0008aq-DU for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 May 2019 18:35:16 +0200 Original-Received: from localhost ([127.0.0.1]:45120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPrRT-0005BQ-Fr for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 May 2019 12:35:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPrRL-0005B9-Ov for bug-gnu-emacs@gnu.org; Sun, 12 May 2019 12:35:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPrRJ-0001fw-Bc for bug-gnu-emacs@gnu.org; Sun, 12 May 2019 12:35:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57870) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPrRG-0001NS-99 for bug-gnu-emacs@gnu.org; Sun, 12 May 2019 12:35:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hPrRF-0005qT-Vc for bug-gnu-emacs@gnu.org; Sun, 12 May 2019 12:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 May 2019 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34911 X-GNU-PR-Package: emacs Original-Received: via spool by 34911-submit@debbugs.gnu.org id=B34911.155767888722444 (code B ref 34911); Sun, 12 May 2019 16:35:01 +0000 Original-Received: (at 34911) by debbugs.gnu.org; 12 May 2019 16:34:47 +0000 Original-Received: from localhost ([127.0.0.1]:43181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPrR0-0005pw-HK for submit@debbugs.gnu.org; Sun, 12 May 2019 12:34:46 -0400 Original-Received: from mail-io1-f49.google.com ([209.85.166.49]:40413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPrQz-0005ph-6S for 34911@debbugs.gnu.org; Sun, 12 May 2019 12:34:45 -0400 Original-Received: by mail-io1-f49.google.com with SMTP id s20so8184133ioj.7 for <34911@debbugs.gnu.org>; Sun, 12 May 2019 09:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=rwNncCIu7OknDRdNmy3iBglcDUFEaBoYjLCh0CzWMAs=; b=ujxvpbKH0YEgN4kaNoyTDf1FnG1cEtooRcaH0TDohKYKSHQYPoFmloI3XdolMx8ecQ NfR03/2MStnT+MOrS8qV8y/qdArdkJpdnpVgoCDaAK0Vvpjms1fUjIIRDHjvJLbhUw2x kpORSl4iAkOqGN9Jm02BBCUfSjMZgecoyFfPDVLkE2f3uVMOI/e+TPRzMxZa8HZyXf5O 9hwpf2qKU+0ftMIF8g1S7Y8tNJhUXyarE3EzRRVGJCAD2H2W59KxueRevahxYUX6b+YW u7WnbC7tDb4bgavzqxckIiHKAQiMpCsD1FqNiH8gXDw5xKc9o4u58/Gz2y+Oon6B367o 0l6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=rwNncCIu7OknDRdNmy3iBglcDUFEaBoYjLCh0CzWMAs=; b=etABj95Bcr/MWBHmW9WxuH8DK5x+/vAqrNvWKUmsSNZtAtlfaFIyoizpApt7dQxb3s U7DwS18cIraMcP1QJELz292WgQL2JF3NBCOrjXHPBBqsqjK+4Ws+m3ZtKLsMoqtTIltY fihioQ4cmk3maPaLroxxaT1dHK8lQ/9vqfGtkfwCHPdfxrLPajvvsrq4WOXKlOslImQ2 VR22Mrac7p6+HbL60sxuJMH8PgTC7lXyjWnt67dD1NpSnlaZU4gyT7/y6qZDbWrLfCcU 2gY+Rp5priujAECHGeyOsOu1/qF6EkSnEkvgBVxCSAVfsUwB9yFbIpT+2JlZIzLOL6sj DWhA== X-Gm-Message-State: APjAAAVIGaqD+8bRfylO6CX/L0pjESz3vgIOjXlnBUMJ/2EO/ptM6NBh puP6y8Q/9OYl4tvWG9bJjDleTzEn X-Google-Smtp-Source: APXvYqxPyjEojqUeZMQoFNJ5+VCIlwctmhL6eDzK+IkZErRLiiODdCPqDXRkNzlsuyAMbgd5MQJYGA== X-Received: by 2002:a5e:8c14:: with SMTP id n20mr4597808ioj.184.1557678879314; Sun, 12 May 2019 09:34:39 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id 1sm5513431ity.9.2019.05.12.09.34.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 May 2019 09:34:38 -0700 (PDT) In-Reply-To: (Drew Adams's message of "Tue, 19 Mar 2019 07:54:48 -0700 (PDT)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:159143 Archived-At: --=-=-= Content-Type: text/plain Drew Adams writes: > >> > Please also update the doc of `dired-omit-files' to make clear that its >> > default value only approximately matches auto-save files (and lock >> > files?), and that even this is true only for the default naming regime >> > for auto-save files. >> >> I don't understand this part. Concretely, what is missing in the doc >> string, and why do you think it is necessary to add whatever is >> missing? > > The default value is "^\\.?#\\|^\\.$\\|^\\.\\.$". > > \\.?# matches only the first char of an auto-save file > name, and the first two chars of a lock file name. It > does not match the full name, requiring it to end with > `#'. That means that (1) it cannot be used as is for, > say, font-locking such a (complete) name, and (2) as > it is now, it can falsely identify files that are not > auto-save or lock files. It's a regexp, so of course you can name files which aren't auto-save or lock files in such a way that they match it. > And it does not necessarily match auto-save file names > at all, as they can be nearly anything, it seems: > > (elisp) `Auto-Saving' makes a point of saying that each > of `auto-save-file-name-p' and `make-auto-save-file-name' > exists "so that you can customize it if you wish to change > the naming convention for auto-save files". And for each > it reminds us "If you redefine it, be sure to redefine the > [other] function ... correspondingly." > > IOW, apparently the `#...#' is conventional but users are > practically invited to adopt alternative naming schemes. How about we stop inviting that? It sounds like something from before user options were invented, and messing around with auto-save functions kind of seems like asking for trouble. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Don-t-recommend-redefining-auto-save-filename-functi.patch Content-Description: patch >From a0a64e54e72d8b88810104e7fcc275dd1bb32bec Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 12 May 2019 12:27:41 -0400 Subject: [PATCH] Don't recommend redefining auto-save filename functions (Bug#34911) * doc/lispref/backups.texi (Auto-Saving): Document auto-save-file-name-transforms. * lisp/files.el (make-auto-save-file-name) (auto-save-file-name-p): Remove suggestion to redefine for customization. --- doc/lispref/backups.texi | 67 +++++++++++++++++++----------------------------- lisp/files.el | 5 ++-- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi index 6a5b6d1661..5f414e3066 100644 --- a/doc/lispref/backups.texi +++ b/doc/lispref/backups.texi @@ -460,6 +460,33 @@ Auto Save mode is enabled if @code{buffer-auto-save-file-name} is non-@code{nil} and @code{buffer-saved-size} (see below) is non-zero. @end deffn +@defvar auto-save-file-name-transforms +This variable lists transforms to apply to buffer file name before +making auto-save file name. + +Each transform is a list of the form @code{(@var{regexp} +@var{replacement} [@var{uniquify}])}: @var{regexp} is a regular +expression to match against the file name. If it matches, +@code{replace-match} is used to replace the matching part with +@var{replacement}. If the optional element @var{uniquify} is non-nil, +the auto-save file name is constructed by taking the directory part of +the replaced file-name, concatenated with the buffer file name with +all directory separators changed to @samp{!} to prevent clashes. This +will not work correctly if your filesystem truncates the resulting +name. + +All the transforms in the list are tried, in the order they are listed. +When one transform applies, its result is final; +no further transforms are tried. + +The default value is set up to put the auto-save file into the +temporary directory (@pxref{Unique File Names}) for editing a +remote file. + +On MS-DOS filesystems without long names this variable is always +ignored. +@end defvar + @defun auto-save-file-name-p filename This function returns a non-@code{nil} value if @var{filename} is a string that could be the name of an auto-save file. It assumes @@ -481,21 +508,6 @@ name. The argument @var{filename} should not contain a directory part. @result{} nil @end group @end example - -The standard definition of this function is as follows: - -@example -@group -(defun auto-save-file-name-p (filename) - "Return non-nil if FILENAME can be yielded by..." - (string-match "^#.*#$" filename)) -@end group -@end example - -This function exists so that you can customize it if you wish to -change the naming convention for auto-save files. If you redefine it, -be sure to redefine the function @code{make-auto-save-file-name} -correspondingly. @end defun @defun make-auto-save-file-name @@ -511,31 +523,6 @@ function should check that variable first. @result{} "/xcssun/users/rms/lewis/#backups.texi#" @end group @end example - -Here is a simplified version of the standard definition of this -function: - -@example -@group -(defun make-auto-save-file-name () - "Return file name to use for auto-saves \ -of current buffer.." - (if buffer-file-name -@end group -@group - (concat - (file-name-directory buffer-file-name) - "#" - (file-name-nondirectory buffer-file-name) - "#") - (expand-file-name - (concat "#%" (buffer-name) "#")))) -@end group -@end example - -This exists as a separate function so that you can redefine it to -customize the naming convention for auto-save files. Be sure to -change @code{auto-save-file-name-p} in a corresponding way. @end defun @defopt auto-save-visited-file-name diff --git a/lisp/files.el b/lisp/files.el index f3b502095d..501073c71c 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6176,7 +6176,7 @@ (defun rename-auto-save-file () (defun make-auto-save-file-name () "Return file name to use for auto-saves of current buffer. Does not consider `auto-save-visited-file-name' as that variable is checked -before calling this function. You can redefine this for customization. +before calling this function. See also `auto-save-file-name-p'." (if buffer-file-name (let ((handler (find-file-name-handler buffer-file-name @@ -6283,7 +6283,8 @@ (defun make-auto-save-file-name () (defun auto-save-file-name-p (filename) "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. -FILENAME should lack slashes. You can redefine this for customization." +FILENAME should lack slashes. +See also `make-auto-save-file-name'." (string-match "\\`#.*#\\'" filename)) (defun wildcard-to-regexp (wildcard) -- 2.11.0 --=-=-=--