unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Philip K." <philip@warpmail.net>
Cc: 42386@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores)
Date: Tue, 21 Jul 2020 17:27:59 +0300	[thread overview]
Message-ID: <838sfdgcy8.fsf@gnu.org> (raw)
In-Reply-To: <87eep59qqr.fsf@warpmail.net> (philip@warpmail.net)

> From: "Philip K." <philip@warpmail.net>
> 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.





  reply	other threads:[~2020-07-21 14:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  8:15 bug#42386: [PATCH] Handle symbols in project-kill-buffers-ignores Philip K.
     [not found] ` <handler.42386.B.159488736413990.ack@debbugs.gnu.org>
2020-07-16  8:47   ` bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores) Philip K.
2020-07-16 15:14     ` Eli Zaretskii
2020-07-16 18:08       ` Philip K.
2020-07-16 18:16       ` Philip K.
2020-07-16 19:35         ` Eli Zaretskii
2020-07-16 22:22           ` Philip K.
2020-07-17  6:38             ` Eli Zaretskii
2020-07-17  8:16               ` Philip K.
2020-07-17 10:49                 ` Eli Zaretskii
2020-07-17 11:17                   ` Philip K.
2020-07-17 11:26                     ` Eli Zaretskii
2020-07-17 15:30                       ` Philip K.
2020-07-17 15:43                         ` Dmitry Gutov
2020-07-17 17:16                           ` Philip K.
2020-07-17 22:21                             ` Dmitry Gutov
2020-07-18 12:48                               ` Philip K.
2020-07-19 23:10                                 ` Dmitry Gutov
2020-07-20 12:07                                   ` Philip K.
2020-07-20 13:39                                     ` Dmitry Gutov
2020-07-21  9:11                                       ` Philip K.
2020-07-21 14:27                                         ` Eli Zaretskii [this message]
2020-07-21 18:35                                           ` Philip K.
2020-07-21 18:57                                             ` Eli Zaretskii
2020-07-21 20:47                                               ` Dmitry Gutov
2020-07-21 18:45                                         ` Dmitry Gutov
2020-07-21 18:51                                           ` Philip K.
2020-07-27 16:26                                             ` Dmitry Gutov
2020-07-27 18:33                                               ` Philip K.
2020-07-28 22:33                                                 ` Dmitry Gutov
2020-07-16 18:41       ` Dmitry Gutov
2020-07-16 22:46         ` Juri Linkov
2020-07-17  0:23           ` Dmitry Gutov
2020-07-16 13:43 ` bug#42386: [PATCH] Handle symbols in project-kill-buffers-ignores Dmitry Gutov
2020-07-16 18:00   ` Philip K.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=838sfdgcy8.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=42386@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=philip@warpmail.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).