unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58951: [PATCH] ; Fix handling of 'not' by 'buffer-match-p'
@ 2022-11-01 19:36 Philip Kaludercic
       [not found] ` <handler.58951.B.166733138129551.ack@debbugs.gnu.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Philip Kaludercic @ 2022-11-01 19:36 UTC (permalink / raw)
  To: 58951

[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]

Tags: patch


In preparing bug#58950 I noticed that the 'not' clause is confusing, and
is misused on the place I could find it being used in the core
(show-paren-predicate).  The current implementation would require a
negation to be written as

    (not . CONDITION)

while it is more natural to write

    (not CONDITION)

which is more in line with (and ...) and (or ...).

The issue appears to go back to `project--buffer-check', that takes a
list of conditions instead of a single one.  This means that the above
are equivalent. since (not CONDITION) will check each element in the
unary list in (not . (CONDITION)).

I believe this is preferable to fixing `show-paren-predicate', as this
is the kind of issue a lot of people could trip over.

This patch is based on the patch from bug#58950, but can be back-ported
to the previous implementations if there are any issues with that report.

In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.30, cairo version 1.16.0) of 2022-10-31 built on heron
Repository revision: 462a66e79edcc34ecbeef7cc1604765adfdc038e
Repository branch: feature/package+vc
System Description: Guix System

Configured using:
 'configure --with-pgtk --with-imagemagick
 PKG_CONFIG_PATH=/gnu/store/ssg343s6ldqdwh30136pnawhbgd0cb6i-profile/lib/pkgconfig:/gnu/store/ssg343s6ldqdwh30136pnawhbgd0cb6i-profile/share/pkgconfig'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-handling-of-not-by-buffer-match-p.patch --]
[-- Type: text/patch, Size: 1351 bytes --]

From cb88a512eacb3ad73c22682c9c794cdc80445f43 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Tue, 1 Nov 2022 20:27:17 +0100
Subject: [PATCH] ; Fix handling of 'not' by 'buffer-match-p'

* lisp/subr.el (buffer-match-p): Look up the cadr instead of the cdr
for the negation in 'not'.
---
 lisp/subr.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index b667339db9..0252e66686 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -7023,7 +7023,7 @@ string-lines
                `(provided-mode-derived-p
                  (buffer-local-value 'major-mode ,buffer-sym)
                  ',mode))
-              (`(not . ,cond)
+              (`(not ,cond)
                `(not ,(funcall translate cond)))
               (`(or . ,conds)
                `(or ,@(mapcar translate conds)))
@@ -7045,7 +7045,7 @@ string-lines
   * `major-mode': the buffer matches if the buffer's major mode
     is eq to the cons-cell's cdr.  Prefer using `derived-mode'
     instead when both can work.
-  * `not': the cdr is interpreted as a negation of a condition.
+  * `not': the cadr 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 condition, of which at
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-31 16:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01 19:36 bug#58951: [PATCH] ; Fix handling of 'not' by 'buffer-match-p' Philip Kaludercic
     [not found] ` <handler.58951.B.166733138129551.ack@debbugs.gnu.org>
2022-11-01 20:19   ` bug#58951: Acknowledgement ([PATCH] ; Fix handling of 'not' by 'buffer-match-p') Philip Kaludercic
     [not found]   ` <87pme6cts5.fsf@posteo.net>
2022-11-02 12:04     ` Eli Zaretskii
2022-12-31 14:05       ` bug#58951: [PATCH] ; Fix handling of 'not' by 'buffer-match-p' Philip Kaludercic
2022-11-01 22:09 ` Dmitry Gutov
2022-11-01 22:18   ` Philip Kaludercic
2022-11-01 22:29     ` Dmitry Gutov
2022-12-31 16:26 ` Mattias Engdegård
2022-12-31 16:34   ` Eli Zaretskii

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).