* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
@ 2022-02-22 8:27 Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-22 8:27 UTC (permalink / raw)
To: 54100
Hi,
currently I am redifining `project-buffers' to ensure 'C-x p b'
(`project-switch-to-buffer') ignores some buffers I never want to switch to with
that command:
(defvar mu-ignored-buffers
'("\\` " "^\\*Async" "^\\*Completions" "^\\*Flymake" "^\\*Help"
"^\\*Messages" "^\\*eldoc" "^\\*envrc" "\\*tramp" "^\\*vc" "^\\*xref")
"A list of predicates for buffers to ignore.")
(cl-defmethod project-buffers ((project (head vc)))
(let* ((root (expand-file-name (file-name-as-directory (project-root project))))
(modules (unless (or (project--vc-merge-submodules-p root)
(project--submodule-p root))
(mapcar
(lambda (m) (format "%s%s/" root m))
(project--git-submodules))))
dd
bufs)
(dolist (buf (buffer-list))
(setq dd (expand-file-name (buffer-local-value 'default-directory buf)))
(when (and (string-prefix-p root dd)
(not (cl-find-if (lambda (module) (string-prefix-p module dd))
modules))
(not (seq-contains-p
mu-ignored-buffers (buffer-name buf) #'string-match-p)))
(push buf bufs)))
(nreverse bufs)))
I am not sure this is the best approach, though.
Would it be possible to add a defcustom to specify a predicate for the project
buffers to be shown in `project-switch-to-buffer'?
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.18, cairo
version 1.16.0)
of 2022-02-22 built on hathaway
Repository revision: 8d02624c0ec029ee99e0b1e410429c440bcc4499
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04 LTS
Configured using:
'configure --with-harfbuzz --with-native-compilation'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB
Important settings:
value of $LC_MONETARY: it_IT.UTF-8
value of $LC_NUMERIC: it_IT.UTF-8
value of $LC_TIME: it_IT.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: ELisp/l
Minor modes in effect:
electric-pair-mode: t
flymake-mode: t
windmove-mode: t
savehist-mode: t
global-so-long-mode: t
global-subword-mode: t
subword-mode: t
winner-mode: t
envrc-global-mode: t
envrc-mode: t
mct-region-mode: t
mct-minibuffer-mode: t
pixel-scroll-precision-mode: t
minibuffer-electric-default-mode: t
minibuffer-depth-indicate-mode: t
delete-selection-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
window-divider-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message yank-media rmc puny dired-x
dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils help-fns radix-tree misearch multi-isearch
time-date noutline outline checkdoc lisp-mnt elec-pair flymake-proc
flymake thingatpt compile text-property-search comint vc-dir ewoc vc-git
diff-mode easy-mmode vc vc-dispatcher cursor-sensor project server
modus-operandi-theme modus-themes pcase windmove delight comp comp-cstr
warnings cl-extra help-mode savehist so-long cap-words superword subword
winner envrc inheritenv ansi-color mct pixel-scroll ring minibuf-eldef
mb-depth ibuf-macs rx delsel info tex-site package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars
seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget keymap hashtable-print-readable backquote threads
dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process native-compile emacs)
Memory information:
((conses 16 241664 84480)
(symbols 48 15348 1)
(strings 32 46778 3597)
(string-bytes 1 1497114)
(vectors 16 28407)
(vector-slots 8 833744 120150)
(floats 8 139 444)
(intervals 56 1087 217)
(buffers 992 18))
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-22 8:27 bug#54100: 29.0.50; Allow project-buffers to ignore some buffers Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 14:23 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 15:00 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-24 7:18 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-22 9:41 UTC (permalink / raw)
To: 54100
FTR, I am using `seq-contains-p' instead of `cl-find-if' because I am more
familiar with the former.
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-22 14:23 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 2:49 ` Dmitry Gutov
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-22 14:23 UTC (permalink / raw)
To: 54100
I will reply to myself and say that extending `project-buffers' as I did is not
the proper way to do what I am after.
`project-buffers' is also used by `project--buffers-to-kill' and so I was ending
up with some buffers of the current project not being killed on 'C-x p k'.
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-22 14:23 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-23 2:49 ` Dmitry Gutov
2022-02-23 6:56 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2022-02-23 2:49 UTC (permalink / raw)
To: Manuel Uberti, 54100
On 22.02.2022 16:23, Manuel Uberti via Bug reports for GNU Emacs, the
Swiss army knife of text editors wrote:
> `project-buffers' is also used by `project--buffers-to-kill' and so I
> was ending up with some buffers of the current project not being killed
> on 'C-x p k'.
I suppose we can add a var similar to project-kill-buffer-conditions,
call it project-switch-[to-]buffer-conditions, and have
project-switch-to-buffer use it.
Care to write a patch?
You're already the best person to evaluate its performance, so... ;-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-23 2:49 ` Dmitry Gutov
@ 2022-02-23 6:56 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 9:48 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-23 6:56 UTC (permalink / raw)
To: Dmitry Gutov, 54100
On 23/02/22 03:49, Dmitry Gutov wrote:
> I suppose we can add a var similar to project-kill-buffer-conditions, call it
> project-switch-[to-]buffer-conditions, and have project-switch-to-buffer use it.
>
> Care to write a patch?
>
> You're already the best person to evaluate its performance, so... ;-)
Sure, I'll see what I can do.
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-23 6:56 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-23 9:48 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 9:55 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-23 9:48 UTC (permalink / raw)
To: Dmitry Gutov, 54100
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
On 23/02/22 07:56, Manuel Uberti wrote:
> On 23/02/22 03:49, Dmitry Gutov wrote:
>> I suppose we can add a var similar to project-kill-buffer-conditions, call it
>> project-switch-[to-]buffer-conditions, and have project-switch-to-buffer use it.
>>
>> Care to write a patch?
>>
>> You're already the best person to evaluate its performance, so... ;-)
I attached a patch. Let me know if I missed something or am approach the matter
in a wrong way.
To try my code I used the following predicate (mu-ignored-buffers is in the
first message of this ticket):
(defun mu-buffer-predicate (buffer)
"Check if BUFFER is NOT a member of `mu-ignored-buffers'."
(not (seq-contains-p mu-ignored-buffers
(buffer-name (cdr buffer))
#'string-match-p)))
And this setting:
(setq-default project-switch-to-buffer-conditions '(mu-buffer-predicate))
Note that I didn't bump the package-version on
`project-switch-to-buffer-conditions' because I don't know if it is required.
--
Manuel Uberti
www.manueluberti.eu
[-- Attachment #2: 0001-Add-project-switch-to-buffer-conditions.patch --]
[-- Type: text/x-patch, Size: 5266 bytes --]
From 682ea21f669c46d90046a17d0ff6598e0624907d Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Wed, 23 Feb 2022 09:25:32 +0100
Subject: [PATCH] Add project-switch-to-buffer-conditions
* lisp/progmodes/project.el (project-switch-to-buffer-conditions):
New defcustom.
* lisp/progmodes/project (project--switch-to-buffer-check):
New function.
(project-switch-to-buffer):
Use it (bug#54100).
---
lisp/progmodes/project.el | 81 ++++++++++++++++++++++++++++++++++++---
1 file changed, 76 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 880c5b5517..5357e1aa58 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1112,16 +1112,17 @@ project-compile
compilation-buffer-name-function)))
(call-interactively #'compile)))
-(defun project--read-project-buffer ()
+(defun project--read-project-buffer (&optional predicate)
(let* ((pr (project-current t))
(current-buffer (current-buffer))
(other-buffer (other-buffer current-buffer))
(other-name (buffer-name other-buffer))
(buffers (project-buffers pr))
(predicate
- (lambda (buffer)
- ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (or predicate
+ (lambda (buffer)
+ ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
+ (memq (cdr buffer) buffers)))))
(read-buffer
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
@@ -1129,6 +1130,72 @@ project--read-project-buffer
nil
predicate)))
+(defcustom project-switch-to-buffer-conditions nil
+ "List of conditions to filter the buffers to be switched to.
+This list is used by `project-switch-to-buffer'.
+Each condition is either:
+- a regular expression, to match a buffer name,
+- a predicate function that takes a buffer object as argument
+ and returns non-nil if the buffer should be switched to,
+- a cons-cell, where the car describes how to interpret the cdr.
+ The car can be one of the following:
+ * `major-mode': the buffer is switched to if the buffer's major
+ mode is eq to the cons-cell's cdr
+ * `derived-mode': the buffer is switched to if the buffer's major
+ mode is derived from the major mode denoted by the cons-cell's
+ cdr
+ * `not': the cdr is interpreted as a negation of a condition.
+ * `and': the cdr is a list of recursive conditions, that all have
+ to be met.
+ * `or': the cdr is a list of recursive conditions, of which at
+ least one has to be met.
+
+If any of these conditions are satisfied for a buffer in the
+current project, `project-switch-to-buffer' switches to it."
+ :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 "29.1"
+ :group 'project
+ :package-version '(project . "0.8.2"))
+
+(defun project--switch-to-buffer-check (buf conditions)
+ "Check if buffer BUF matches any element of the list CONDITIONS.
+See `project-switch-to-buffer-conditions' for more details on the
+form of CONDITIONS."
+ (catch 'switch
+ (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--switch-to-buffer-check buf (cdr c))))
+ ((eq (car-safe c) 'or)
+ (project--switch-to-buffer-check buf (cdr c)))
+ ((eq (car-safe c) 'and)
+ (seq-every-p
+ (apply-partially #'project--switch-to-buffer-check
+ buf)
+ (mapcar #'list (cdr c)))))
+ (throw 'switch t)))))
+
;;;###autoload
(defun project-switch-to-buffer (buffer-or-name)
"Display buffer BUFFER-OR-NAME in the selected window.
@@ -1136,7 +1203,11 @@ project-switch-to-buffer
current project. Two buffers belong to the same project if their
project instances, as reported by `project-current' in each
buffer, are identical."
- (interactive (list (project--read-project-buffer)))
+ (interactive
+ (list (project--read-project-buffer
+ (lambda (buffer)
+ (project--switch-to-buffer-check
+ buffer project-switch-to-buffer-conditions)))))
(switch-to-buffer buffer-or-name))
;;;###autoload
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-23 9:48 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-23 9:55 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-23 9:55 UTC (permalink / raw)
To: Dmitry Gutov, 54100
On 23/02/22 10:48, Manuel Uberti wrote:
> I attached a patch. Let me know if I missed something or am approach the matter
> in a wrong way.
>
> To try my code I used the following predicate (mu-ignored-buffers is in the
> first message of this ticket):
>
> (defun mu-buffer-predicate (buffer)
> "Check if BUFFER is NOT a member of `mu-ignored-buffers'."
> (not (seq-contains-p mu-ignored-buffers
> (buffer-name (cdr buffer))
> #'string-match-p)))
>
> And this setting:
>
> (setq-default project-switch-to-buffer-conditions '(mu-buffer-predicate))
>
> Note that I didn't bump the package-version on
> `project-switch-to-buffer-conditions' because I don't know if it is required.
It also works with `mu-buffer-predicate' using this instead:
(not (seq-contains-p mu-ignored-buffers (car buffer) #'string-match-p))
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-22 8:27 bug#54100: 29.0.50; Allow project-buffers to ignore some buffers Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-23 15:00 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-24 7:18 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2 siblings, 0 replies; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-23 15:00 UTC (permalink / raw)
To: 54100, Dmitry Gutov
[-- Attachment #1: Type: text/plain, Size: 763 bytes --]
Attached a better patch.
I need a little help, though. The following setting does not filter as intended,
meaning I see the dired buffer for the current project and I also see the
buffers `mu-project-buffer-p' should ignore:
(defun mu-project-buffer-p (buffer)
"Check if BUFFER is NOT a member of `mu-ignored-buffers'."
(not (seq-contains-p mu-ignored-buffers (buffer-name buffer) #'string-match-p)))
(setq-default project-switch-to-buffer-conditions '(mu-project-buffer-p
(not (derived-mode .
comint-mode))))
However, this correctly hides the buffers specified in mu-ignored-buffers:
(setq-default project-switch-to-buffer-conditions '(mu-project-buffer-p)
--
Manuel Uberti
www.manueluberti.eu
[-- Attachment #2: 0001-Add-project-switch-to-buffer-conditions.patch --]
[-- Type: text/x-patch, Size: 5272 bytes --]
From bc706f9aa73034b2fe36600ceba9f9c50af3da69 Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Wed, 23 Feb 2022 09:25:32 +0100
Subject: [PATCH] Add project-switch-to-buffer-conditions
* lisp/progmodes/project.el (project-switch-to-buffer-conditions):
New defcustom.
* lisp/progmodes/project (project--switch-to-buffer-check):
New function.
(project-switch-to-buffer):
Use it (bug#54100).
---
lisp/progmodes/project.el | 81 ++++++++++++++++++++++++++++++++++++---
1 file changed, 76 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 880c5b5517..3c998c00f5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1112,16 +1112,17 @@ project-compile
compilation-buffer-name-function)))
(call-interactively #'compile)))
-(defun project--read-project-buffer ()
+(defun project--read-project-buffer (&optional predicate)
(let* ((pr (project-current t))
(current-buffer (current-buffer))
(other-buffer (other-buffer current-buffer))
(other-name (buffer-name other-buffer))
(buffers (project-buffers pr))
(predicate
- (lambda (buffer)
- ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (or predicate
+ (lambda (buffer)
+ ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
+ (memq (cdr buffer) buffers)))))
(read-buffer
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
@@ -1129,6 +1130,72 @@ project--read-project-buffer
nil
predicate)))
+(defcustom project-switch-to-buffer-conditions nil
+ "List of conditions to filter the buffers to be switched to.
+This list is used by `project-switch-to-buffer'.
+Each condition is either:
+- a regular expression, to match a buffer name,
+- a predicate function that takes a buffer object as argument
+ and returns non-nil if the buffer should be switched to,
+- a cons-cell, where the car describes how to interpret the cdr.
+ The car can be one of the following:
+ * `major-mode': the buffer is switched to if the buffer's major
+ mode is eq to the cons-cell's cdr
+ * `derived-mode': the buffer is switched to if the buffer's major
+ mode is derived from the major mode denoted by the cons-cell's
+ cdr
+ * `not': the cdr is interpreted as a negation of a condition.
+ * `and': the cdr is a list of recursive conditions, that all have
+ to be met.
+ * `or': the cdr is a list of recursive conditions, of which at
+ least one has to be met.
+
+If any of these conditions are satisfied for a buffer in the
+current project, `project-switch-to-buffer' switches to it."
+ :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 "29.1"
+ :group 'project
+ :package-version '(project . "0.8.2"))
+
+(defun project--switch-to-buffer-check (buf conditions)
+ "Check if buffer BUF matches any element of the list CONDITIONS.
+See `project-switch-to-buffer-conditions' for more details on the
+form of CONDITIONS."
+ (catch 'switch
+ (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--switch-to-buffer-check buf (cdr c))))
+ ((eq (car-safe c) 'or)
+ (project--switch-to-buffer-check buf (cdr c)))
+ ((eq (car-safe c) 'and)
+ (seq-every-p
+ (apply-partially #'project--switch-to-buffer-check
+ buf)
+ (mapcar #'list (cdr c)))))
+ (throw 'switch t)))))
+
;;;###autoload
(defun project-switch-to-buffer (buffer-or-name)
"Display buffer BUFFER-OR-NAME in the selected window.
@@ -1136,7 +1203,11 @@ project-switch-to-buffer
current project. Two buffers belong to the same project if their
project instances, as reported by `project-current' in each
buffer, are identical."
- (interactive (list (project--read-project-buffer)))
+ (interactive
+ (list (project--read-project-buffer
+ (lambda (buffer)
+ (project--switch-to-buffer-check
+ (cdr buffer) project-switch-to-buffer-conditions)))))
(switch-to-buffer buffer-or-name))
;;;###autoload
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-22 8:27 bug#54100: 29.0.50; Allow project-buffers to ignore some buffers Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 15:00 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-24 7:18 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 2:33 ` Dmitry Gutov
2 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-24 7:18 UTC (permalink / raw)
To: 54100, Dmitry Gutov
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
Find attached yet a better approach to avoid repetition.
Note that the above mention problem about multiple conditions remains, though.
Help appreciated. :)
--
Manuel Uberti
www.manueluberti.eu
[-- Attachment #2: 0001-Add-project-switch-to-buffer-conditions.patch --]
[-- Type: text/x-patch, Size: 5785 bytes --]
From a8143035ea71376f0e53ce784991d9cd490719ee Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Wed, 23 Feb 2022 09:25:32 +0100
Subject: [PATCH] Add project-switch-to-buffer-conditions
* lisp/progmodes/project.el (project-switch-to-buffer-conditions):
New defcustom.
(project-switch-to-buffer):
Use it (bug#54100).
---
lisp/progmodes/project.el | 71 +++++++++++++++++++++++++++++++--------
1 file changed, 57 insertions(+), 14 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 880c5b5517..e4184c69bc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1112,16 +1112,17 @@ project-compile
compilation-buffer-name-function)))
(call-interactively #'compile)))
-(defun project--read-project-buffer ()
+(defun project--read-project-buffer (&optional predicate)
(let* ((pr (project-current t))
(current-buffer (current-buffer))
(other-buffer (other-buffer current-buffer))
(other-name (buffer-name other-buffer))
(buffers (project-buffers pr))
(predicate
- (lambda (buffer)
- ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (or predicate
+ (lambda (buffer)
+ ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
+ (memq (cdr buffer) buffers)))))
(read-buffer
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
@@ -1129,6 +1130,43 @@ project--read-project-buffer
nil
predicate)))
+(defcustom project-switch-to-buffer-conditions nil
+ "List of conditions to filter the buffers to be switched to.
+This list is used by `project-switch-to-buffer'.
+Each condition is either:
+- a regular expression, to match a buffer name,
+- a predicate function that takes a buffer object as argument
+ and returns non-nil if the buffer should be switched to,
+- a cons-cell, where the car describes how to interpret the cdr.
+ The car can be one of the following:
+ * `major-mode': the buffer is switched to if the buffer's major
+ mode is eq to the cons-cell's cdr
+ * `derived-mode': the buffer is switched to if the buffer's major
+ mode is derived from the major mode denoted by the cons-cell's
+ cdr
+ * `not': the cdr is interpreted as a negation of a condition.
+ * `and': the cdr is a list of recursive conditions, that all have
+ to be met.
+ * `or': the cdr is a list of recursive conditions, of which at
+ least one has to be met.
+
+If any of these conditions are satisfied for a buffer in the
+current project, `project-switch-to-buffer' switches to it."
+ :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 "29.1"
+ :group 'project
+ :package-version '(project . "0.8.2"))
+
;;;###autoload
(defun project-switch-to-buffer (buffer-or-name)
"Display buffer BUFFER-OR-NAME in the selected window.
@@ -1136,7 +1174,11 @@ project-switch-to-buffer
current project. Two buffers belong to the same project if their
project instances, as reported by `project-current' in each
buffer, are identical."
- (interactive (list (project--read-project-buffer)))
+ (interactive
+ (list (project--read-project-buffer
+ (lambda (buffer)
+ (project--buffer-check
+ (cdr buffer) project-switch-to-buffer-conditions)))))
(switch-to-buffer buffer-or-name))
;;;###autoload
@@ -1239,11 +1281,12 @@ project--buffer-list
(push buf bufs)))
(nreverse bufs)))
-(defun project--kill-buffer-check (buf conditions)
+(defun project--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
+See `project-kill-buffer-conditions' or
+`project-switch-to-buffer-conditions' for more details on the
+form of CONDITIONS."
+ (catch 'match
(dolist (c conditions)
(when (cond
((stringp c)
@@ -1258,15 +1301,15 @@ project--kill-buffer-check
(buffer-local-value 'major-mode buf)
(cdr c)))
((eq (car-safe c) 'not)
- (not (project--kill-buffer-check buf (cdr c))))
+ (not (project--buffer-check buf (cdr c))))
((eq (car-safe c) 'or)
- (project--kill-buffer-check buf (cdr c)))
+ (project--buffer-check buf (cdr c)))
((eq (car-safe c) 'and)
(seq-every-p
- (apply-partially #'project--kill-buffer-check
+ (apply-partially #'project--buffer-check
buf)
(mapcar #'list (cdr c)))))
- (throw 'kill t)))))
+ (throw 'match t)))))
(defun project--buffers-to-kill (pr)
"Return list of buffers in project PR to kill.
@@ -1274,7 +1317,7 @@ project--buffers-to-kill
in `project-kill-buffer-conditions'."
(let (bufs)
(dolist (buf (project-buffers pr))
- (when (project--kill-buffer-check buf project-kill-buffer-conditions)
+ (when (project--buffer-check buf project-kill-buffer-conditions)
(push buf bufs)))
bufs))
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-24 7:18 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-25 2:33 ` Dmitry Gutov
2022-02-25 6:44 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2022-02-25 2:33 UTC (permalink / raw)
To: Manuel Uberti, 54100
On 24.02.2022 09:18, Manuel Uberti via Bug reports for GNU Emacs, the
Swiss army knife of text editors wrote:
> Find attached yet a better approach to avoid repetition.
The patch looks good except for this part:
(predicate
- (lambda (buffer)
- ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (or predicate
+ (lambda (buffer)
+ ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of
Vbuffer_alist.
+ (memq (cdr buffer) buffers)))))
Doesn't this mean that it won't do the (memq ... buffers) check and thus
ignore the result of the (project-buffers pr) call?
Instead, it could be a lambda like
(lambda (buffer)
;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
(and (memq (cdr buffer) buffers)
(funcall predicate buffer)))
Does that make sense?
(I would also try to shorten the new defcustom's docstring by referring
to the existing one, but I can make that change myself.)
> Note that the above mention problem about multiple conditions remains,
> though. Help appreciated. :)
As described in the docstring:
If any of these conditions are satisfied ...
So when you use this value
'(mu-project-buffer-p
(not (derived-mode . comint-mode)))
it means "either satisfies my-project-buffer-p or not derived from
comint-mode". Whereas you probably wanted to combine them with "and":
(setq-default project-switch-to-buffer-conditions
'(and mu-project-buffer-p
(not (derived-mode . comint-mode))))
And IDK, maybe the "and" top-level combination would work better for
project-switch-to-buffer-conditions. It might trip up a user who's
customizing both vars, though.
Or if you wanted to stay on "or" but make it easier for certain usage
pattern, you could call the var 'project-ignore-buffer-conditions' (or
"hide" or etc), and change its use appropriately. Then the value could
contain
'((not mu-project-buffer-p)
(derived-mode . comint-mode))
...and (not mu-project-buffer-p) could obviously be rewritten in a
negated way in the function's definition.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-25 2:33 ` Dmitry Gutov
@ 2022-02-25 6:44 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 1:50 ` Dmitry Gutov
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-25 6:44 UTC (permalink / raw)
To: Dmitry Gutov, 54100
[-- Attachment #1: Type: text/plain, Size: 1638 bytes --]
On 25/02/22 03:33, Dmitry Gutov wrote:
> Doesn't this mean that it won't do the (memq ... buffers) check and thus ignore
> the result of the (project-buffers pr) call?
>
> Instead, it could be a lambda like
>
> (lambda (buffer)
> ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
> (and (memq (cdr buffer) buffers)
> (funcall predicate buffer)))
>
> Does that make sense?
Totally, thank you!
> (I would also try to shorten the new defcustom's docstring by referring to the
> existing one, but I can make that change myself.)
Done.
> Or if you wanted to stay on "or" but make it easier for certain usage pattern,
> you could call the var 'project-ignore-buffer-conditions' (or "hide" or etc),
> and change its use appropriately. Then the value could contain
>
> '((not mu-project-buffer-p)
> (derived-mode . comint-mode))
>
> ...and (not mu-project-buffer-p) could obviously be rewritten in a negated way
> in the function's definition.
I followed your suggestion and used `project-ignore-buffer-conditions' in the
attached patch.
Now everything works as expected when I use this:
(defun mu-project-ignore-buffer-p (buffer)
"Check if BUFFER is a member of `mu-ignored-buffers'."
(seq-contains-p mu-ignored-buffers (buffer-name buffer) #'string-match-p))
(setq-default project-ignore-buffer-conditions '(mu-project-ignore-buffer-p
(derived-mode . dired-mode)))
Again, thank you for the help on this.
--
Manuel Uberti
www.manueluberti.eu
[-- Attachment #2: 0001-Add-project-ignore-buffer-conditions.patch --]
[-- Type: text/x-patch, Size: 4894 bytes --]
From 2fbb408219a2f17928705be048510c630ef3175f Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Wed, 23 Feb 2022 09:25:32 +0100
Subject: [PATCH] Add project-ignore-buffer-conditions
* lisp/progmodes/project.el (project-ignore-buffer-conditions):
New defcustom.
(project-switch-to-buffer):
Use it (bug#54100).
---
lisp/progmodes/project.el | 52 ++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 12 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 880c5b5517..78ccedf9fa 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1112,7 +1112,7 @@ project-compile
compilation-buffer-name-function)))
(call-interactively #'compile)))
-(defun project--read-project-buffer ()
+(defun project--read-project-buffer (&optional predicate)
(let* ((pr (project-current t))
(current-buffer (current-buffer))
(other-buffer (other-buffer current-buffer))
@@ -1121,7 +1121,8 @@ project--read-project-buffer
(predicate
(lambda (buffer)
;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (and (memq (cdr buffer) buffers)
+ (funcall predicate buffer)))))
(read-buffer
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
@@ -1129,6 +1130,27 @@ project--read-project-buffer
nil
predicate)))
+(defcustom project-ignore-buffer-conditions nil
+ "List of conditions to filter the buffers to be switched to.
+If any of these conditions are satisfied for a buffer in the
+current project, `project-switch-to-buffer' ignores it.
+See the doc string of `project-kill-buffer-conditions' for the
+general form of conditions."
+ :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 "29.1"
+ :group 'project
+ :package-version '(project . "0.8.2"))
+
;;;###autoload
(defun project-switch-to-buffer (buffer-or-name)
"Display buffer BUFFER-OR-NAME in the selected window.
@@ -1136,7 +1158,12 @@ project-switch-to-buffer
current project. Two buffers belong to the same project if their
project instances, as reported by `project-current' in each
buffer, are identical."
- (interactive (list (project--read-project-buffer)))
+ (interactive
+ (list (project--read-project-buffer
+ (lambda (buffer)
+ (not
+ (project--buffer-check
+ (cdr buffer) project-ignore-buffer-conditions))))))
(switch-to-buffer buffer-or-name))
;;;###autoload
@@ -1239,11 +1266,12 @@ project--buffer-list
(push buf bufs)))
(nreverse bufs)))
-(defun project--kill-buffer-check (buf conditions)
+(defun project--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
+See `project-kill-buffer-conditions' or
+`project-ignore-buffer-conditions' for more details on the
+form of CONDITIONS."
+ (catch 'match
(dolist (c conditions)
(when (cond
((stringp c)
@@ -1258,15 +1286,15 @@ project--kill-buffer-check
(buffer-local-value 'major-mode buf)
(cdr c)))
((eq (car-safe c) 'not)
- (not (project--kill-buffer-check buf (cdr c))))
+ (not (project--buffer-check buf (cdr c))))
((eq (car-safe c) 'or)
- (project--kill-buffer-check buf (cdr c)))
+ (project--buffer-check buf (cdr c)))
((eq (car-safe c) 'and)
(seq-every-p
- (apply-partially #'project--kill-buffer-check
+ (apply-partially #'project--buffer-check
buf)
(mapcar #'list (cdr c)))))
- (throw 'kill t)))))
+ (throw 'match t)))))
(defun project--buffers-to-kill (pr)
"Return list of buffers in project PR to kill.
@@ -1274,7 +1302,7 @@ project--buffers-to-kill
in `project-kill-buffer-conditions'."
(let (bufs)
(dolist (buf (project-buffers pr))
- (when (project--kill-buffer-check buf project-kill-buffer-conditions)
+ (when (project--buffer-check buf project-kill-buffer-conditions)
(push buf bufs)))
bufs))
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-25 6:44 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-26 1:50 ` Dmitry Gutov
2022-02-26 6:32 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2022-02-26 1:50 UTC (permalink / raw)
To: Manuel Uberti, 54100
On 25.02.2022 08:44, Manuel Uberti via Bug reports for GNU Emacs, the
Swiss army knife of text editors wrote:
> On 25/02/22 03:33, Dmitry Gutov wrote:
>> Doesn't this mean that it won't do the (memq ... buffers) check and
>> thus ignore the result of the (project-buffers pr) call?
>>
>> Instead, it could be a lambda like
>>
>> (lambda (buffer)
>> ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
>> (and (memq (cdr buffer) buffers)
>> (funcall predicate buffer)))
>>
>> Does that make sense?
>
> Totally, thank you!
>
>> (I would also try to shorten the new defcustom's docstring by
>> referring to the existing one, but I can make that change myself.)
>
> Done.
Very good.
Looking at it more thoroughly, though, shouldn't we simply inline the
check added to project-switch-to-buffer to the function
project--read-project-buffer?
It's used by two other related commands (project-display-buffer and
project-display-buffer-other-frame), and users would probably expect
them to have the same filtering.
project-ignore-buffer-conditions's docstring can be updated accordingly.
>> Or if you wanted to stay on "or" but make it easier for certain usage
>> pattern, you could call the var 'project-ignore-buffer-conditions' (or
>> "hide" or etc), and change its use appropriately. Then the value could
>> contain
>>
>> '((not mu-project-buffer-p)
>> (derived-mode . comint-mode))
>>
>> ...and (not mu-project-buffer-p) could obviously be rewritten in a
>> negated way in the function's definition.
>
> I followed your suggestion and used `project-ignore-buffer-conditions'
> in the attached patch.
>
> Now everything works as expected when I use this:
>
> (defun mu-project-ignore-buffer-p (buffer)
> "Check if BUFFER is a member of `mu-ignored-buffers'."
> (seq-contains-p mu-ignored-buffers (buffer-name buffer)
> #'string-match-p))
>
> (setq-default project-ignore-buffer-conditions '(mu-project-ignore-buffer-p
> (derived-mode .
> dired-mode)))
>
>
> Again, thank you for the help on this.
No problem!
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-26 1:50 ` Dmitry Gutov
@ 2022-02-26 6:32 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-27 3:27 ` Dmitry Gutov
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-26 6:32 UTC (permalink / raw)
To: Dmitry Gutov, 54100
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
On 26/02/22 02:50, Dmitry Gutov wrote:
> Looking at it more thoroughly, though, shouldn't we simply inline the check
> added to project-switch-to-buffer to the function project--read-project-buffer?
>
> It's used by two other related commands (project-display-buffer and
> project-display-buffer-other-frame), and users would probably expect them to
> have the same filtering.
>
> project-ignore-buffer-conditions's docstring can be updated accordingly.
I like the idea. I attached a new version of the patch.
--
Manuel Uberti
www.manueluberti.eu
[-- Attachment #2: 0001-Add-project-ignore-buffer-conditions.patch --]
[-- Type: text/x-patch, Size: 4217 bytes --]
From ea92923b8e907c5f4b884481630a3ab12940ca99 Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Wed, 23 Feb 2022 09:25:32 +0100
Subject: [PATCH] Add project-ignore-buffer-conditions
* lisp/progmodes/project.el (project-ignore-buffer-conditions):
New defcustom.
(project--read-project-buffer):
Use it (bug#54100).
---
lisp/progmodes/project.el | 47 ++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 880c5b5517..4d6b93ceb5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1112,6 +1112,29 @@ project-compile
compilation-buffer-name-function)))
(call-interactively #'compile)))
+(defcustom project-ignore-buffer-conditions nil
+ "List of conditions to filter the buffers to be switched to.
+If any of these conditions are satisfied for a buffer in the
+current project, `project-switch-to-buffer',
+`project-display-buffer' and `project-display-buffer-other-frame'
+ignore it.
+See the doc string of `project-kill-buffer-conditions' for the
+general form of conditions."
+ :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 "29.1"
+ :group 'project
+ :package-version '(project . "0.8.2"))
+
(defun project--read-project-buffer ()
(let* ((pr (project-current t))
(current-buffer (current-buffer))
@@ -1121,7 +1144,10 @@ project--read-project-buffer
(predicate
(lambda (buffer)
;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
- (memq (cdr buffer) buffers))))
+ (and (memq (cdr buffer) buffers)
+ (not
+ (project--buffer-check
+ (cdr buffer) project-ignore-buffer-conditions))))))
(read-buffer
"Switch to buffer: "
(when (funcall predicate (cons other-name other-buffer))
@@ -1239,11 +1265,12 @@ project--buffer-list
(push buf bufs)))
(nreverse bufs)))
-(defun project--kill-buffer-check (buf conditions)
+(defun project--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
+See `project-kill-buffer-conditions' or
+`project-ignore-buffer-conditions' for more details on the
+form of CONDITIONS."
+ (catch 'match
(dolist (c conditions)
(when (cond
((stringp c)
@@ -1258,15 +1285,15 @@ project--kill-buffer-check
(buffer-local-value 'major-mode buf)
(cdr c)))
((eq (car-safe c) 'not)
- (not (project--kill-buffer-check buf (cdr c))))
+ (not (project--buffer-check buf (cdr c))))
((eq (car-safe c) 'or)
- (project--kill-buffer-check buf (cdr c)))
+ (project--buffer-check buf (cdr c)))
((eq (car-safe c) 'and)
(seq-every-p
- (apply-partially #'project--kill-buffer-check
+ (apply-partially #'project--buffer-check
buf)
(mapcar #'list (cdr c)))))
- (throw 'kill t)))))
+ (throw 'match t)))))
(defun project--buffers-to-kill (pr)
"Return list of buffers in project PR to kill.
@@ -1274,7 +1301,7 @@ project--buffers-to-kill
in `project-kill-buffer-conditions'."
(let (bufs)
(dolist (buf (project-buffers pr))
- (when (project--kill-buffer-check buf project-kill-buffer-conditions)
+ (when (project--buffer-check buf project-kill-buffer-conditions)
(push buf bufs)))
bufs))
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-26 6:32 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-27 3:27 ` Dmitry Gutov
2022-02-27 7:09 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2022-02-27 3:27 UTC (permalink / raw)
To: Manuel Uberti, 54100-done
On 26.02.2022 08:32, Manuel Uberti wrote:
> I like the idea. I attached a new version of the patch.
Thanks! Pushed.
BTW, do you have copyright assignment for Emacs?
I see an assignment on file for a person with the same name, but with a
different email. Anyway, it's only important for any future patches.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-27 3:27 ` Dmitry Gutov
@ 2022-02-27 7:09 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-27 7:41 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-27 7:09 UTC (permalink / raw)
To: Dmitry Gutov, 54100-done
On 27/02/22 04:27, Dmitry Gutov wrote:
> Thanks! Pushed.
Great, thank you.
> BTW, do you have copyright assignment for Emacs?
>
> I see an assignment on file for a person with the same name, but with a
> different email. Anyway, it's only important for any future patches.
Yes, it's me with an old email. I don't know whether it is possible to change it
to the one I am using now.
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-27 7:09 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-27 7:41 ` Eli Zaretskii
2022-02-27 7:43 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-27 7:41 UTC (permalink / raw)
To: Manuel Uberti; +Cc: 54100-done, dgutov
> Date: Sun, 27 Feb 2022 08:09:42 +0100
> From: Manuel Uberti via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> > I see an assignment on file for a person with the same name, but with a
> > different email. Anyway, it's only important for any future patches.
>
> Yes, it's me with an old email. I don't know whether it is possible to change it
> to the one I am using now.
You can write to the copyright clerk with the information about your
new email address, and they will do what needs to be done for that.
As long as your legal employment status didn't change, AFAIK the
original assignment is still valid and doesn't depend on the email
address you use.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#54100: 29.0.50; Allow project-buffers to ignore some buffers
2022-02-27 7:41 ` Eli Zaretskii
@ 2022-02-27 7:43 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 17+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-27 7:43 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 54100-done, dgutov
On 27/02/22 08:41, Eli Zaretskii wrote:
> You can write to the copyright clerk with the information about your
> new email address, and they will do what needs to be done for that.
> As long as your legal employment status didn't change, AFAIK the
> original assignment is still valid and doesn't depend on the email
> address you use.
Awesome, I'll do it then. Thanks.
--
Manuel Uberti
www.manueluberti.eu
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2022-02-27 7:43 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-22 8:27 bug#54100: 29.0.50; Allow project-buffers to ignore some buffers Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 9:41 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 14:23 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 2:49 ` Dmitry Gutov
2022-02-23 6:56 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 9:48 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 9:55 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-23 15:00 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-24 7:18 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 2:33 ` Dmitry Gutov
2022-02-25 6:44 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 1:50 ` Dmitry Gutov
2022-02-26 6:32 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-27 3:27 ` Dmitry Gutov
2022-02-27 7:09 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-27 7:41 ` Eli Zaretskii
2022-02-27 7:43 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
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).