From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#46374: 28.0.50; Ask me to save buffers only if they are under callers dir Date: Tue, 16 Mar 2021 18:54:12 -0400 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5515"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46374@debbugs.gnu.org, =?UTF-8?Q?Qu=C3=A1ch_?= =?UTF-8?Q?M=E1=BB=B9_?= =?UTF-8?Q?Uy=C3=AAn?= Nhi , Tino Calancha To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 16 23:55:10 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 1lMIak-0001Jg-2b for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Mar 2021 23:55:10 +0100 Original-Received: from localhost ([::1]:48838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMIaj-0003aR-3l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Mar 2021 18:55:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMIac-0003ZA-2J for bug-gnu-emacs@gnu.org; Tue, 16 Mar 2021 18:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMIab-0007lX-QI for bug-gnu-emacs@gnu.org; Tue, 16 Mar 2021 18:55:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lMIab-0006Fa-Ot for bug-gnu-emacs@gnu.org; Tue, 16 Mar 2021 18:55:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Mar 2021 22:55: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.161593526523980 (code B ref 46374); Tue, 16 Mar 2021 22:55:01 +0000 Original-Received: (at 46374) by debbugs.gnu.org; 16 Mar 2021 22:54:25 +0000 Original-Received: from localhost ([127.0.0.1]:41410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMIa1-0006Ei-4c for submit@debbugs.gnu.org; Tue, 16 Mar 2021 18:54:25 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMIZw-0006ES-NC for 46374@debbugs.gnu.org; Tue, 16 Mar 2021 18:54:24 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 027284410A4; Tue, 16 Mar 2021 18:54:15 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AFC6344108B; Tue, 16 Mar 2021 18:54:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1615935253; bh=isH07Jq6aXvqIEcPOTSCv5KFGIgDKPQjcXj/vkL8wvc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Y6R2DFNbI+97EuQQ23mJoVrQI+lM1mRuN/Y7nwEB5DlMuUk4Ck4FYS/uv6VvPbcHN SaApAeP5Q/97OZfw9dzzQ3U9ZybJLOpWUmQnLHrYJ9EyoFn+ii5WTDeDaWLnkfTgmz PiRFJqPVyWvhWpZQKeyCRMXYrFhxd0ZwXqkKNH/d6KKt6vbhK5PBi1+heVEh3JTwWX prPL5iEL5ReHD/6O1jhw+Ssi4ZBQO0gdfbzyv2E+Xej0fEcOhi1wQTZUyAkUyNjbBs wbfF0fz6/IwSRgS/Ilgm9Le7vCZ4MUe/g1AAHznbnqGgElfcsE20e/WKHnUPB3mX0X VXoBvpsYQRxrw== Original-Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 868E9120242; Tue, 16 Mar 2021 18:54:13 -0400 (EDT) In-Reply-To: <87zgz3gfqo.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 16 Mar 2021 19:49:27 +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:202499 Archived-At: > (let ((one-arg (equal (func-arity pred) '(1 . 1)))) Please don't. This will break down as soon as you set the function with `add-function`. [ I wish people could forget that `func-arity` exists. Its use is a bug-in-the-waiting in most cases. ] > (dolist (buffer (buffer-list)) > (if one-arg > (funcall pred buffer) > (with-current-buffer buffer (funcall pred)))) > > Then 'default-directory' of the original buffer will be preserved > inside the pred function, so it will be possible to call the pred function > with one arg 'buffer' and check whether the buffer is under the original > 'default-directory' with > > (file-in-directory-p (buffer-local-value 'default-directory buffer) > default-directory) How 'bout using something like `isearch-search-fun-function`: i.e. *compute* the predicate by calling save-some-buffers-predicate-function, so this function can return a predicate that remembers the default-dir of the original buffer (or any other aspect relevant to the state from which we started the save-some-buffers). Stefan