From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode Date: Fri, 23 Sep 2022 18:37:57 +0000 Message-ID: References: <875yqbdhvy.fsf@posteo.net> <87czbmv9hp.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22845"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 53446@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 23 20:41:50 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 1obncT-0005nM-Gr for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Sep 2022 20:41:49 +0200 Original-Received: from localhost ([::1]:36236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obncS-0000gQ-Hd for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Sep 2022 14:41:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obnZm-0004Nm-CP for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2022 14:39:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obnZl-0005vi-W5 for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2022 14:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obnZl-00029j-Rb for bug-gnu-emacs@gnu.org; Fri, 23 Sep 2022 14:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Sep 2022 18:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53446 X-GNU-PR-Package: emacs Original-Received: via spool by 53446-submit@debbugs.gnu.org id=B53446.16639582888226 (code B ref 53446); Fri, 23 Sep 2022 18:39:01 +0000 Original-Received: (at 53446) by debbugs.gnu.org; 23 Sep 2022 18:38:08 +0000 Original-Received: from localhost ([127.0.0.1]:41769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obnYt-00028c-Uv for submit@debbugs.gnu.org; Fri, 23 Sep 2022 14:38:08 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]:58029) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obnYr-000286-1c for 53446@debbugs.gnu.org; Fri, 23 Sep 2022 14:38:06 -0400 Original-Received: (qmail 44748 invoked by uid 3782); 23 Sep 2022 20:37:58 +0200 Original-Received: from acm.muc.de (p4fe15e96.dip0.t-ipconnect.de [79.225.94.150]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 23 Sep 2022 20:37:58 +0200 Original-Received: (qmail 20966 invoked by uid 1000); 23 Sep 2022 18:37:57 -0000 Content-Disposition: inline In-Reply-To: <87czbmv9hp.fsf@posteo.net> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:243494 Archived-At: Hello, Philip. Sorry I missed this bug in January. On Fri, Sep 23, 2022 at 07:24:34 +0000, Philip Kaludercic wrote: > Philip Kaludercic writes: > > Open an AWK file, and ensure that electric-pair-mode is enabled. It > > seems that some character pairs like braces or parentheses are > > automatically paired, while others like apostrophes or double quotes are > > not. The reason apostrophes don't work with electric-pair-mode is that they are not quote characters in AWK. :-) > I have managed to narrow this bug to the function > `c-electric-pair-inhibit-predicate' that is used as > `electric-pair-inhibit-predicate' by cc-mode. Specifically this check > (not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15))) > fails, because the macro > (c-get-char-property last-quote 'c-fl-syn-tab) > that expands to > (get-text-property last-quote 'c-fl-syn-tab) > where `last-quote' is the position of the last quotation mark in a > "logical line", evaluates to nil, not (15). I do not understand why > this happens, or what the text property `c-fl-syn-tab' is supposed to > indicate. It happens because AWK Mode doesn't use the unterminated string detection code the other CC Mode modes use. (It doesn't need to, being simpler.) So, rather than temporarily storing its "working" syntax-table text properties, AWK just lets them be. So, we can just test the syntax-table text property for being '(15) (string fence) in AWK Mode. > I have CC'ed Alan to see if he can help. Would you please try out the following patch, and let me know how it goes. Thanks! diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 9309a546db..679690b33c 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -2714,7 +2714,10 @@ c-electric-pair-inhibit-predicate (save-excursion (goto-char (c-point 'eoll)) (search-backward "\""))))) - (not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15)))) + (not (equal + (or (c-get-char-property last-quote 'c-fl-syn-tab) + (c-get-char-property last-quote 'syntax-table)) ; for AWK + '(15)))) (funcall (default-value 'electric-pair-inhibit-predicate) char))) -- Alan Mackenzie (Nuremberg, Germany).