all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philip K <philip@warpmail.net>
Cc: emacs-devel@gnu.org
Subject: Re: master 2ab66c9: Replace project-kill-buffers-ignores with project-kill-buffer-conditions
Date: Tue, 28 Jul 2020 19:10:34 -0400	[thread overview]
Message-ID: <jwvy2n39qys.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20200728222420.F3D25209DF@vcs0.savannah.gnu.org> (Dmitry Gutov's message of "Tue, 28 Jul 2020 18:24:20 -0400 (EDT)")

> +(defun project--kill-buffer-check (buf conditions)
> +  "Check if buffer BUF matches any element of the list CONDITIONS.
> +See `project-kill-buffer-conditions' for more details on the form
> +of CONDITIONS."
> +  (catch 'kill
> +    (dolist (c conditions)
> +      (when (cond
> +             ((stringp c)
> +              (string-match-p c (buffer-name buf)))
> +             ((symbolp c)
> +              (funcall c buf))
> +             ((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) 'or)
> +              (project--kill-buffer-check buf (cdr c)))
> +             ((eq (car-safe c) 'and)
> +              (seq-every-p
> +               (apply-partially #'project--kill-buffer-check
> +                                buf)
> +               (mapcar #'list (cdr c)))))
> +        (throw 'kill t)))))

Why do we need to invent a small language for that?


        Stefan




       reply	other threads:[~2020-07-28 23:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200728222419.2111.71622@vcs0.savannah.gnu.org>
     [not found] ` <20200728222420.F3D25209DF@vcs0.savannah.gnu.org>
2020-07-28 23:10   ` Stefan Monnier [this message]
2020-07-31 23:28     ` master 2ab66c9: Replace project-kill-buffers-ignores with project-kill-buffer-conditions Dmitry Gutov
2020-09-05 18:19       ` Stefan Monnier
2020-09-05 19:06         ` Philip K.
2020-09-05 19:39           ` Stefan Monnier
2020-09-06 21:42             ` Philip K.
2020-09-07  3:24               ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=jwvy2n39qys.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.