From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Date: Mon, 08 Mar 2021 19:28:00 +0200 Organization: LINKOV.NET Message-ID: <87r1kpemnr.fsf@mail.linkov.net> References: <878s7z4ihk.fsf@gmail.com> <87a6sdzeh6.fsf@mail.linkov.net> <87ft16g0u2.fsf@gmail.com> <87tupmisel.fsf@mail.linkov.net> <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3348"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 46374@debbugs.gnu.org, stefan monnier , =?UTF-8?Q?Qu=C3=A1ch_?= =?UTF-8?Q?M=E1=BB=B9_?= =?UTF-8?Q?Uy=C3=AAn?= Nhi To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 08 19:43:46 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lJKr3-0000kE-NM for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 19:43:45 +0100 Original-Received: from localhost ([::1]:54524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJKr2-0000fd-MW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 13:43:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJJoX-0003ct-OF for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 12:37:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJJoU-0000L4-GK for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 12:37:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lJJoU-00025p-DF for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 12:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Mar 2021 17:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46374 X-GNU-PR-Package: emacs Original-Received: via spool by 46374-submit@debbugs.gnu.org id=B46374.16152249637950 (code B ref 46374); Mon, 08 Mar 2021 17:37:02 +0000 Original-Received: (at 46374) by debbugs.gnu.org; 8 Mar 2021 17:36:03 +0000 Original-Received: from localhost ([127.0.0.1]:44687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJJnW-000249-Co for submit@debbugs.gnu.org; Mon, 08 Mar 2021 12:36:02 -0500 Original-Received: from relay13.mail.gandi.net ([217.70.178.233]:50287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJJnT-00023c-II for 46374@debbugs.gnu.org; Mon, 08 Mar 2021 12:36:00 -0500 Original-Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay13.mail.gandi.net (Postfix) with ESMTPSA id 59B4A8000D; Mon, 8 Mar 2021 17:35:51 +0000 (UTC) In-Reply-To: <1952f2d9-51b6-a4ba-6c9e-98594222f017@gmail.com> (Tino Calancha's message of "Sun, 7 Mar 2021 22:31:47 +0100 (CET)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:201864 Archived-At: >>>> Why not simply add a new option to the existing variable >>>> save-some-buffers-default-predicate? For example: >>>> >>>> (defcustom save-some-buffers-default-predicate nil >>>> "Default predicate for `save-some-buffers'." >>>> :group 'auto-save >>>> ;; FIXME nil should not be a valid option, let alone the default, >>>> ;; eg so that add-function can be used. >>>> :type '(choice (const :tag "Default" nil) >>>> (const :tag "Subdirs of default directory" default-directory) >>>> (const :tag "Project root" project-root) >>>> function) >>> >>> Indeed, this was my initial implemention. >>> Then I moved to the one I shared here; I found my second version >>> superior for the following reason: >>> >>> 1. Users can restrict the buffer default directory AND still pass a >>> predicate to filter by any other thing they wish; >>> i.e. you don't need to chose either one of the other. >>> >>> 2. I find it cleaner having it in a separated option. >> >> I'm not sure if there is a need for adding >> another dimension with another option. > > This is explained in my point 1. above. > I might want to restrict to the caller subdir and still filter with > a function. You cannot get both things just with one option. > > For my normal worflow, this is a very important addition and I am looking > forward to see it added in master soon. Please consider the consequences of backward-incompatibility of adding such a separate option. For example, in the org package: org-mobile-push: (save-some-buffers nil (lambda () (memq (current-buffer) agenda-buffers))) When a user customizes a new option to restrict saving of buffers to the subdirectories only, this means it will skip saving agenda-buffers since most of them usually are located outside of the current directory. This change would have a drastic effect for external packages where a new option can't be forced to be bound to nil. More examples: org-save-all-org-buffers: (save-some-buffers t (lambda () (derived-mode-p 'org-mode))) etc. This means reusing the existing save-some-buffers-default-predicate would be still preferable that guarantees backward-compatibility. When it's customized to a predicate to filter out non-current subdirs, then such call '(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))' still overrides the customized value. This is the right thing to do. >> But if yes, then still shouldn't a new option >> provide a wider choice of restricting predicates >> like above? > > Yeah, we could made wider the new option as you've suggested: >>>> (const :tag "Subdirs of default directory" default-directory) >>>> (const :tag "Project root" project-root) > > Since Stefan mentioned `project-root` is not ready and I am not familiar > with it, I suggest we add the option as it is, possibly with a modified > name that fit well our future intention and a TODO comment. > Then, me or someone else, can update the option when `project-root` > become mature. > > Agreed? Then the option could be named 'project-root-or-subdirs', so when a command is called outside a project, it will fall back to subdirs.