From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Allow inhibiting 'auto-save-visited-mode' on a per-buffer basis. Date: Sun, 05 Apr 2020 10:18:58 -0400 Message-ID: References: <20200401175736.203124-1-phst@google.com> <83wo6yxb0s.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="4240"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Philipp Stephani , Eli Zaretskii , Emacs developers To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Apr 05 16:19:48 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jL67k-0000w7-O3 for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Apr 2020 16:19:44 +0200 Original-Received: from localhost ([::1]:48306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL67j-0000FS-S0 for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Apr 2020 10:19:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60322) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL67B-0008Hr-6c for emacs-devel@gnu.org; Sun, 05 Apr 2020 10:19:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jL679-00060Z-V9 for emacs-devel@gnu.org; Sun, 05 Apr 2020 10:19:08 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:37031) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jL678-0005yc-L7; Sun, 05 Apr 2020 10:19:06 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B0D8B44FC89; Sun, 5 Apr 2020 10:19:05 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id F1C5F44FC82; Sun, 5 Apr 2020 10:18:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1586096339; bh=lRfMV/6x55vszlkKOSNsiEvLysuaB7Ci++m2VBfiT6U=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=e1jniTEDUxafxnSUJ2Mnzb6CVQ9dNZydu1R+6R+RQCQzOYBZhzglwqPTZ5fShIavZ 7ghC/ob9lvsPhM/5UTNLw+5MunzfZ/jVKwpQxs0XDicL2KgWzwVl8D161n8eP71Dpd 0JQ3MjvSyHfIUB9zt1VM52jaevU+xwFfSSVbOJUVwLoMN4o4w/d/nC9eno27dncb/+ P3x4kcThJePFqWBM0QsRmBbBSgFA162jNd0CcMv4Dxfcmy2HXXqzPNqdomqKIXo3Yr ayhOSR0NTM7qWln4ppFhzeTEQ3qVB9Ujt3K1v2FJ/mCcsr+kIYPMqaPr9GaP/+zRCR EGSeyb8iwEwEg== Original-Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 85B9712039E; Sun, 5 Apr 2020 10:18:59 -0400 (EDT) In-Reply-To: (Philipp Stephani's message of "Sun, 5 Apr 2020 11:50:18 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246459 Archived-At: >> diff --git a/lisp/files.el b/lisp/files.el >> index 55a0958f54..5132aa456a 100644 >> --- a/lisp/files.el >> +++ b/lisp/files.el >> @@ -441,6 +441,7 @@ auto-save-visited-mode >> #'save-some-buffers :no-prompt >> (lambda () >> (and buffer-file-name >> + auto-save-visited-mode >> (not (and buffer-auto-save-file-name >> auto-save-visited-file-name)))))))) > > Is this really OK? Depends what you mean by "this". The above patch is definitely OK, yes. It's actually "standard operation procedure" for a minor mode to double check its minor mode variable in timers and hooks ;-) > All minor mode variables, including auto-save-visited-mode, by default > get the "Setting this variable directly does not take effect" > documentation string, because we want to use minor mode variables only > for checking a mode's state and always want users to call the > mode function. Indeed the above implies suggestions to do: (add-hook 'foo-mode-hook (lambda () (setq-local auto-save-visited-mode nil))) which doesn't go through such functions and is hence arguably "bad style". Especially it will likely encourage the use of plain `setq` on the variable. This part of what I meant by "...but lacks the rest of the code". The rest would be something like (define-minor-mode auto-save-visited-local-mode ...) which would do the `setq-local` internally and might take inspiration from `electric-indent-local-mode`. Stefan