From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores) Date: Tue, 21 Jul 2020 17:27:59 +0300 Message-ID: <838sfdgcy8.fsf@gnu.org> References: <878sfjkh8o.fsf@warpmail.net> <87eep59qqr.fsf@warpmail.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20345"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42386@debbugs.gnu.org, dgutov@yandex.ru To: "Philip K." Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 21 16:29:54 2020 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 1jxtHG-0005Bb-GL for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Jul 2020 16:29:54 +0200 Original-Received: from localhost ([::1]:50664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jxtHF-0008A4-HY for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Jul 2020 10:29:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jxtGQ-00073z-Dd for bug-gnu-emacs@gnu.org; Tue, 21 Jul 2020 10:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jxtGQ-0004bY-27 for bug-gnu-emacs@gnu.org; Tue, 21 Jul 2020 10:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jxtGP-0005sZ-VR for bug-gnu-emacs@gnu.org; Tue, 21 Jul 2020 10:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Jul 2020 14:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42386-submit@debbugs.gnu.org id=B42386.159534169122542 (code B ref 42386); Tue, 21 Jul 2020 14:29:01 +0000 Original-Received: (at 42386) by debbugs.gnu.org; 21 Jul 2020 14:28:11 +0000 Original-Received: from localhost ([127.0.0.1]:40027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jxtFb-0005rW-FZ for submit@debbugs.gnu.org; Tue, 21 Jul 2020 10:28:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39740) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jxtFZ-0005rJ-UL for 42386@debbugs.gnu.org; Tue, 21 Jul 2020 10:28:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57400) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jxtFU-0004Ox-Hc; Tue, 21 Jul 2020 10:28:04 -0400 Original-Received: from [176.228.60.248] (port=2343 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jxtFT-0007OS-DI; Tue, 21 Jul 2020 10:28:04 -0400 In-Reply-To: <87eep59qqr.fsf@warpmail.net> (philip@warpmail.net) 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:183352 Archived-At: > From: "Philip K." > Date: Tue, 21 Jul 2020 11:11:56 +0200 > Cc: 42386@debbugs.gnu.org > > +(defcustom project-kill-buffer-conditions > + '(buffer-file-name ; All file-visiting buffers are included. > + ;; Most of the temp buffers in the background: > + (major-mode . fundamental-mode) > + ;; non-text buffer such as xref, occur, vc, log, ... > + (and (derived-mode . special-mode) > + (not (major-mode . help-mode))) > + (derived-mode . compilation-mode) > + (derived-mode . dired-mode) > + (derived-mode . diff-mode)) > + "Conditions for buffers `project-kill-buffers' should kill. This should tell, somewhere, that these conditions are in addition to the buffer being related to the project, otherwise someone could interpret the above as meaning that _all_ the file-visiting buffers will be killed... > +Buffers that match any of the conditions will not be killed." This and the previous sentence ("Conditions for...") contradict each other. Are these conditions for killing a buffer, or for NOT killing it? And if the former, then I guess the doc string of project-kill-buffers should be amended accordingly? > + :type '(repeat (choice regexp function symbol > + (cons :tag "Major mode" > + (const major-mode) symbol) > + (cons :tag "Derived mode" > + (const derived-mode) symbol) > + (cons :tag "Negation" > + (const not) sexp) > + (cons :tag "Conjunction" > + (const and) sexp) > + (cons :tag "Disjunction" > + (const or) sexp))) > :version "28.1" > - :package-version '(project . "0.5.0")) > + :group 'project > + :package-version '(project . "0.6.0")) > > (defun project--buffer-list (pr) > "Return the list of all buffers in project PR." > @@ -864,6 +900,38 @@ project--buffer-list > (push buf bufs))) > (nreverse bufs))) > > +(defun project--kill-buffer-check (buf conds) > + "Return non-nil, if buffer BUF matches any CONDS. > +CONDS is a list of conditions. See It is better to explain what CONDS are in the same 1st line. Alternatively, rename the argument to 'conditions", then the name will explain itself naturally (although it might still be a good idea to say it should be a list). Also, please be sure to leave 2 spaces between sentences in comments and doc strings. > (defun project-kill-buffers () > "Kill all live buffers belonging to the current project. > @@ -873,17 +941,13 @@ project-kill-buffers > (interactive) > (let ((pr (project-current t)) bufs) > (dolist (buf (project--buffer-list pr)) > - (unless (seq-some > - (lambda (c) > - (cond ((stringp c) > - (string-match-p c (buffer-name buf))) > - ((functionp c) > - (funcall c buf)))) > - project-kill-buffers-ignores) > + (when (project--kill-buffer-check buf project-kill-buffer-conditions) > (push buf bufs))) > - (when (yes-or-no-p (format "Kill %d buffers in %s? " > - (length bufs) (project-root pr))) > - (mapc #'kill-buffer bufs)))) > + (if (null bufs) > + (message "No buffers to kill") > + (when (yes-or-no-p (format "Kill %d buffers in %s? " > + (length bufs) (project-root pr))) > + (mapc #'kill-buffer bufs))))) Is this function intended to never be invoked from Lisp? If it can be invoked from Lisp, then asking the yes-or-no-p question might not be appropriate in the non-interactive case (and the "No buffers to kill" message might be spared as well). Thanks.