Subject: bug#54296: Add buffer-matching functionality

From: Dmitry Gutov <[email-masked]>
Date: Fri, 17 Jun 2022 16:39:27 +0300

On 17.06.2022 08:48, Eli Zaretskii wrote:
>> Date: Fri, 17 Jun 2022 04:21:04 +0300
>> Cc: [email-masked], [email-masked], [email-masked]
>> From: Dmitry Gutov <[email-masked]>
>>
>>> In any case, if we will keep both major-mode and derived-mode
>>> conditions in subr.el, let's at least document that derived-mode
>>> should be preferred where it can do the job, and major-mode used only
>>> where derived-mode will not DTRT.
>>
>> Sure. Here you go.
> 
> Fine with me, with one nit:
> 
>> +Satisfied if the buffer's major mode is eq to @var{expr}.  Prefer
> 
> Using "eq" as a word in the manual is not a good idea.  We use "is
> equal" elsewhere in the manual.

Thanks, done. Backward compatibility and capability are restored.

Now, if we wanted to downplay the option of doing equality comparison 
for major-mode, we could perhaps introduce a more general condition like 
'value-equal'.

That would change the definition of project-kill-buffer-conditions very 
slightly, still keeping it readable. And a gradual deprecation of the 
'major-mode' matcher could be done.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 30f51704dc..dea11d4231 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1223,10 +1223,10 @@ project-display-buffer-other-frame
  (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)
+    (value-equal major-mode . fundamental-mode)
      ;; non-text buffer such as xref, occur, vc, log, ...
      (and (derived-mode . special-mode)
-         (not (major-mode . help-mode)))
+         (not (value-equal major-mode . help-mode)))
      (derived-mode . compilation-mode)
      (derived-mode . dired-mode)
      (derived-mode . diff-mode)