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: Wed, 28 Apr 2021 22:51:51 +0300 Organization: LINKOV.NET Message-ID: <87zgxigpbc.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> <871rcgr4qp.fsf@mail.linkov.net> <87zgz3gfqo.fsf@mail.linkov.net> <87blbhhghk.fsf@mail.linkov.net> <87pmzsgzh3.fsf@gmail.com> <87o8fc5jq0.fsf@mail.linkov.net> <87wnsz7jmy.fsf@gmail.com> <87tunvnxfo.fsf@linkov.net> <87h7jq1a0i.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="30429"; 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 Wed Apr 28 22:04:16 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 1lbqPv-0007nt-B6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Apr 2021 22:04:15 +0200 Original-Received: from localhost ([::1]:36598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbqPu-0002jw-D0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Apr 2021 16:04:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbqMo-0008PL-1s for bug-gnu-emacs@gnu.org; Wed, 28 Apr 2021 16:01:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbqMn-0001zO-P9 for bug-gnu-emacs@gnu.org; Wed, 28 Apr 2021 16:01:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lbqMn-0007VS-M4 for bug-gnu-emacs@gnu.org; Wed, 28 Apr 2021 16:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Apr 2021 20:01:01 +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.161964004828829 (code B ref 46374); Wed, 28 Apr 2021 20:01:01 +0000 Original-Received: (at 46374) by debbugs.gnu.org; 28 Apr 2021 20:00:48 +0000 Original-Received: from localhost ([127.0.0.1]:54142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqMa-0007Uv-H8 for submit@debbugs.gnu.org; Wed, 28 Apr 2021 16:00:48 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:56301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbqMY-0007Uh-NB for 46374@debbugs.gnu.org; Wed, 28 Apr 2021 16:00:47 -0400 X-Originating-IP: 91.129.102.166 Original-Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4E8B4E0006; Wed, 28 Apr 2021 20:00:38 +0000 (UTC) In-Reply-To: <87h7jq1a0i.fsf@gmail.com> (Tino Calancha's message of "Wed, 28 Apr 2021 21:31:25 +0200") 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:205138 Archived-At: > I have found a way to merge the two approaches. Not sure if > idiomatic, but it works. > > [The patch omits NEWS entry and documentation; I will add those once we > found the implementation] Thanks, now your patch is taking a good shape. I'm testing it now. Here is a condensed version of your patch to think about it. #+begin_src emacs-lisp (defvar save-some-buffers-default-fun (lambda () nil)) (defvar save-some-buffers-in-current-project-fun (lambda () (let ((project-dir (or (and (project-current) (project-root (project-current))) default-directory))) (lambda () (file-in-directory-p default-directory project-dir))))) (defcustom save-some-buffers-default-predicate save-some-buffers-default-fun :type `(choice (function :tag "All buffers" :value ,save-some-buffers-default-fun) (function :tag "Buffers inside current project" :value ,save-some-buffers-in-current-project-fun))) (defun save-some-buffers-fun () (funcall save-some-buffers-default-predicate)) (defun save-some-buffers (&optional arg pred) (unless pred (setq pred (save-some-buffers-fun))) #+end_src I see a problem in save-some-buffers-fun: what if save-some-buffers-default-predicate is still customized to nil? This value is currently allowed. It seems it should check if it's a function, then call it. Also needs to check if the function doesn't return another lambda, then return its original value.