From: Dmitry Gutov <dgutov@yandex.ru>
To: "Philip K." <philip@warpmail.net>
Cc: 42386@debbugs.gnu.org
Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores)
Date: Mon, 20 Jul 2020 02:10:53 +0300 [thread overview]
Message-ID: <89ff9cf6-e85b-4c36-4fb7-763c41e41b02@yandex.ru> (raw)
In-Reply-To: <87mu3xdm50.fsf@warpmail.net>
On 18.07.2020 15:48, Philip K. wrote:
> I like this idea a lot, the patch below should implement this +
> backwards compatibility code. Thought this might be getting too
> complicated, I also went ahead and added "and" and "or".
All right. That's a bit further than I expected, but the result is still
fast in the default scenario, so why not. ;-)
I take it this approach behaved well enough in your testing?
Should we replace
(derived-mode . special-mode)
with
(and (derived-mode . special-mode)
(not (major-mode . help-mode)))
?
Some other minor comments below.
> 0001-Replace-project-kill-buffers-ignores-with-.-kill-buf.patch
>
> From 6a9c268a340025bca428b5ec7c35229a29b4a95f Mon Sep 17 00:00:00 2001
> From: Philip K<philip@warpmail.net>
> Date: Thu, 16 Jul 2020 10:03:35 +0200
> Subject: [PATCH] Replace project-kill-buffers-ignores with
> ...-kill-buffer-conditions
Full commit message, if you can.
> +- a symbol, denoting a buffer local variable, where the buffer
> + is killed if it's value is non-nil. If the symbol also has a
> + function slot, it will be interpreted as a function first.
This also introduces an ambiguity which I'd like to avoid. Let's just
make it if a symbol is there, it must be a function (and we should
silence its errors).
> +Buffers that match any of the conditions will not be killed."
Will be. I think.
> +(defcustom project-kill-buffers-ignores nil
> + "Conditions for buffers `project-kill-buffers' should not kill."
> + :type '(repeat choice regexp function)
> + :set (lambda (var val)
> + (add-to-list 'project-kill-buffer-conditions
> + (cons 'not val))
> + (custom-set-default var val))
> + :version "28.1"
> + :group 'project
> + :package-version '(project . "0.6.0")))
Nice thought, but I think we're allowed to simply do away with this
variable.
At least I have been informed that as long as the package version
haven't been in a "proper" Emacs release, its contents don't have the
same backward compatibility promise.
> +(defun project--kill-buffer-check (buf &optional conds)
> + "Throw"
Just so you don't forget to update or delete this docstring.
> + (unless conds
> + (setq conds project-kill-buffer-conditions))
I think we can make the CONDS argument required and pass in this value
from project-kill-buffers.
> + (catch (if (eq project-kill-buffer-conditions conds)
> + 'kill 'other)
Do we really need this condition?
> + (dolist (c conds)
> + (when (cond
> + ((stringp c)
> + (string-match-p c (buffer-name buf)))
> + ((and (functionp c)
Let's just make this (symbolp c).
> + (ignore-errors (funcall c buf))))
and remove the 'ignore-errors' form. It's better to inform the user
right away that their predicate is broken.
> + ((and (symbolp c) (boundp c))
> + (buffer-local-value c buf))
And remove this case.
> + ((eq (car-safe c) 'major-mode)
> + (eq (buffer-local-value 'major-mode buf)
> + (cdr c)))
> + ((eq (car-safe c) 'derived-mode)
> + (provided-mode-derived-p
> + (buffer-local-value 'major-mode buf)
> + (cdr c)))
> + ((eq (car-safe c) 'not)
> + (not (project--kill-buffer-check buf (cdr c))))
> + ((eq (car-safe c) 'and)
> + (seq-every-p
> + (apply-partially #'project--kill-buffer-check
> + buf)
> + (cdr c)))
> + ((eq (car-safe c) 'or)
> + (seq-some
> + (apply-partially #'project--kill-buffer-check
> + buf)
I think we can simply recurse in this case.
Thanks!
next prev parent reply other threads:[~2020-07-19 23:10 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 [this message]
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
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=89ff9cf6-e85b-4c36-4fb7-763c41e41b02@yandex.ru \
--to=dgutov@yandex.ru \
--cc=42386@debbugs.gnu.org \
--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).