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, 15 Mar 2021 19:10:02 +0200 Organization: LINKOV.NET Message-ID: <871rcgr4qp.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> <87r1kpemnr.fsf@mail.linkov.net> <87mtv6yloe.fsf@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="2284"; 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 15 18:29:19 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 1lLr1q-0000Ua-Vc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Mar 2021 18:29:18 +0100 Original-Received: from localhost ([::1]:46354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLr1p-0003Yb-Sr for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Mar 2021 13:29:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLqkC-0005yH-Cv for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:11:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLqkC-0003mo-4W for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:11:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lLqkB-0000sT-UG for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:11:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Mar 2021 17:11:03 +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.16158282603331 (code B ref 46374); Mon, 15 Mar 2021 17:11:03 +0000 Original-Received: (at 46374) by debbugs.gnu.org; 15 Mar 2021 17:11:00 +0000 Original-Received: from localhost ([127.0.0.1]:36671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqk8-0000rf-0a for submit@debbugs.gnu.org; Mon, 15 Mar 2021 13:11:00 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:35897) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqk3-0000qp-Bc for 46374@debbugs.gnu.org; Mon, 15 Mar 2021 13:10:55 -0400 X-Originating-IP: 91.129.108.46 Original-Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id ACA8DFF809; Mon, 15 Mar 2021 17:10:47 +0000 (UTC) In-Reply-To: <87mtv6yloe.fsf@gmail.com> (Tino Calancha's message of "Sun, 14 Mar 2021 13:17:05 +0100") 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:202417 Archived-At: >> 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. > > OK, back to my original implementation (i.e., adding a new option > to `save-some-buffers-default-predicate`). > > I have been playing with the followig patch this morning. > - it only adds a new option 'project-root > - in case there is not a root there, then `default-directory` is taken > (this is a requirement from the OP, that ie me :-) > - this patch doesn't interfere with the 2nd argument of `save-some-buffers'. > > Please, try it: Thanks, I tried it. The only problem is that the value 'project-root' is hard-coded. Would it be possible to create a real function from it? This will require giving a proper prefix to it, indeed, such as e.g. 'save-some-buffers-project-root'. But this will allow greater customization. For example, everyone could copy its default implementation to the init file and modify its logic to check separately project-root from subdirs, etc. Also it will remove unnecessary details of getting the project root from the implementation of 'save-some-buffers', and to avoid the need to preload project.el. Is it a problem that such separate function can't get information about the original default-directory when called as: (with-current-buffer buffer (funcall pred))? Actually, this is the shortcoming of the old design of save-some-buffers-default-predicate. Is it possible to add a new arg (with an original dir) to the predicate function? Then for backward-compatibility before calling it, the function arity could be checked, then called with one arg when it's accepted by the function, otherwise call without args.