From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#58951: [PATCH] ; Fix handling of 'not' by 'buffer-match-p' Date: Tue, 01 Nov 2022 19:36:12 +0000 Message-ID: <871qqmeac3.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23690"; mail-complaints-to="usenet@ciao.gmane.io" To: 58951@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 01 20:37:17 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opx4X-0005yN-Ca for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Nov 2022 20:37:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opx4L-0006WV-Gl; Tue, 01 Nov 2022 15:37:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opx4K-0006WA-6O for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 15:37:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opx4J-0002nS-Vb for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 15:37:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1opx4I-0007hY-Bu for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 15:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Nov 2022 19:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58951 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166733138129551 (code B ref -1); Tue, 01 Nov 2022 19:37:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Nov 2022 19:36:21 +0000 Original-Received: from localhost ([127.0.0.1]:44267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opx3c-0007gZ-Rs for submit@debbugs.gnu.org; Tue, 01 Nov 2022 15:36:21 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:37354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opx3b-0007gR-3Q for submit@debbugs.gnu.org; Tue, 01 Nov 2022 15:36:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opx3a-0006QH-22 for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 15:36:18 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opx3Y-0002Sd-1q for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 15:36:17 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 94F10240105 for ; Tue, 1 Nov 2022 20:36:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667331373; bh=f4qTeUVFO/gkHQNodkZGOhCm4Iiwyw9twgMGuk52yhI=; h=From:To:Subject:Autocrypt:Date:From; b=J52qOylNjUKWZ4HpWTqcrXLkTvlDFYURrUmVS1N7Q8va2TifWAbGO+TVhoTPVCcza SQZ8Q7Mhm3BuC2ynMUt0f3/xEuwoAPYU74MVtQ4UoxMsRZ4eLrnrZnw4TMWy1MmpF9 VqTYUlTB0QvXC1efOQn66HaGXzsb7zKTIkKnPGiACzz0KHec2HDBideA57ub5K19xv X8iUx9q97H57ZY61fBoRLyUSv7rWuiTlZAMLLAYpLhyGgoPCDpjrtIu9LQ59o3s2dT Y+A6jhJt6pvEZwtGJRo9MK4DutE/zOvNe1xwk3PmkixDAT8cSi+JfWSFNRGCXNThkY ELc+EMGZ8Hzeg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N20cs1Wxhz6tmP for ; Tue, 1 Nov 2022 20:36:13 +0100 (CET) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246805 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Fix-handling-of-not-by-buffer-match-p.patch >From cb88a512eacb3ad73c22682c9c794cdc80445f43 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic 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 --=-=-=--