From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#34805: 25.2; smie-indent-fixindent wrong if comment-start-skip has alternatives Date: Thu, 11 Apr 2019 23:52:16 -0400 Message-ID: <87d0lranin.fsf@gmail.com> References: <1552224185.548106836@f547.i.mail.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="77023"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux) Cc: 34805@debbugs.gnu.org To: Andrey Bondarenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 12 05:53:19 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hEnFf-000JuP-7E for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Apr 2019 05:53:19 +0200 Original-Received: from localhost ([127.0.0.1]:58457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEnFd-0001RY-Vn for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Apr 2019 23:53:18 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEnFP-0001RI-CQ for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2019 23:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEnFO-0006Fz-74 for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2019 23:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEnFN-0006Ff-Pq for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2019 23:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hEnFN-0000Cw-Lg for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2019 23:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Apr 2019 03:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34805 X-GNU-PR-Package: emacs Original-Received: via spool by 34805-submit@debbugs.gnu.org id=B34805.1555041146754 (code B ref 34805); Fri, 12 Apr 2019 03:53:01 +0000 Original-Received: (at 34805) by debbugs.gnu.org; 12 Apr 2019 03:52:26 +0000 Original-Received: from localhost ([127.0.0.1]:55362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hEnEo-0000C0-51 for submit@debbugs.gnu.org; Thu, 11 Apr 2019 23:52:26 -0400 Original-Received: from mail-qt1-f173.google.com ([209.85.160.173]:44603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hEnEm-0000Bi-0Y; Thu, 11 Apr 2019 23:52:24 -0400 Original-Received: by mail-qt1-f173.google.com with SMTP id w5so9684347qtb.11; Thu, 11 Apr 2019 20:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=8ZY+7HeJvnyOU+3TYJ9DCXM1U0utE3nBGAP5I2AxyiA=; b=cvb1yw6C48wnGgNUU9CAU37RPSfI3teMrPZmL3n/GTDVu8MUI0Tmm6DYSa/9DHyllJ VkL42P35zKjUvEUxbXaB9fs6HYwNTQxlwHaTvVjRs9u1FEICEEk/c3K5YM+NugXsU1uS 51P/kC5XyFck8VJI/xGXkXxpgQveANiRF8m0Ry86qm8aFpyulee6euDPbpZ9d7Z1rnWi GEXIVNdVdAQoqW46DBvIjAiHa6+6dIcZIPlPabtI3kuY7MC+3vKi0Rxn20NM24RcCF+S iXSDFPkN27diLK6undoZ+KZ0vrNCGtgcT9a5WtGHwZ7rMpnhXTpPySv5fLkX08L/d771 s4hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=8ZY+7HeJvnyOU+3TYJ9DCXM1U0utE3nBGAP5I2AxyiA=; b=X0tY0sqWkrIMbwNlu1upBPutdnTc9H4mr4Ibq66KkEAidlWKf7GsaM8Ohit+mdFW0U rLAY+t2QZuiUREX/ZMkTJGRxi+3cRvQ8300+HLOM7UngCGrNTxo5iTwD+v/R4leVaJoU zhEmt2K/PiExZ+8nJIUruXSXE1vXG2YN5i2YX8IYweOsCTuhrpnQYaq2ripTR4gw21jq R2JXlgV9tbcIRYioQRB2bDuDXBCNWuic5mjmR5vYV629owWn3u4KcnGc/Dzd1Ge3ecTT sFENgYv6qETxy2zn96y76aC9JM6s77TAxKXdH2jj515t27yyIC4n6HoJhlbLuuMqGO7k B1bQ== X-Gm-Message-State: APjAAAUlgzK2bfhfiSeJKTE7folWm0NTUtGnT3ZkDzn1PoV/QhCuI7Oc 01c0aym0ld+/rzaYJ6F/R8F7tNa2 X-Google-Smtp-Source: APXvYqyj3FgIyqjfEY8ZVPTT674wJNxl5geUIiR73kIuynewZ551//8+Lr44Lgxq23yFHFTTfkrEww== X-Received: by 2002:a0c:d217:: with SMTP id m23mr44796960qvh.154.1555041138221; Thu, 11 Apr 2019 20:52:18 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id y5sm23463177qkl.73.2019.04.11.20.52.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2019 20:52:17 -0700 (PDT) In-Reply-To: <1552224185.548106836@f547.i.mail.ru> (Andrey Bondarenko's message of "Sun, 10 Mar 2019 16:23:05 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157536 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 34805 + patch quit Andrey Bondarenko writes: > If comment-start-skip contains alternatives smie-indent-fixindent will > construct wrong regexp that appends "fixindent" only to last alternative > and match all other aletrnatives as is. > > For example:=20 > > (let ((comment-start-skip "#+\\s *\\|//+\\s *") > (comment-end-skip "")) > (concat comment-start-skip > "fixindent"=20 > comment-end-skip)) =E2=86=92 "#+\\s *\\|//+\\s *fixindent" > > This regexp would match "// fixindent" comments and any comment > that starts with "#", which is wrong.=20 > > I think it should enclose comment-start-skip and comment-end-skip in \\( > \\) to work correctly. I used a shy group \\(?:\\), but yes that makes sense. I found a couple of other spots by grepping, fixed in the patch below. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Properly-bracket-concat-of-comment-start-skip-Bug.patch Content-Description: patch >From ea144b28028f6ef72d67d84f550e1798c61347e2 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 5 Apr 2019 08:00:09 -0400 Subject: [PATCH v1] Properly bracket concat of comment-start-skip (Bug#34805) * lisp/emacs-lisp/smie.el (smie-indent-fixindent): * lisp/cedet/semantic/doc.el (semantic-doc-snarf-comment-for-tag): * lisp/progmodes/fortran.el (fortran-previous-statement) (fortran-next-statement) (fortran-fill-statement): * lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-statement): Bracket comment-start-skip and comment-end-skip to avoid unexpected regexp operator precedence. --- lisp/cedet/semantic/doc.el | 3 ++- lisp/emacs-lisp/smie.el | 4 ++-- lisp/progmodes/fortran.el | 9 ++++++--- lisp/progmodes/vhdl-mode.el | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/cedet/semantic/doc.el b/lisp/cedet/semantic/doc.el index 5611629c14..4f98cf4102 100644 --- a/lisp/cedet/semantic/doc.el +++ b/lisp/cedet/semantic/doc.el @@ -103,7 +103,8 @@ (defun semantic-doc-snarf-comment-for-tag (nosnarf) nil ;; ok, try to clean the text up. ;; Comment start thingy - (while (string-match (concat "^\\s-*" comment-start-skip) ct) + (while (string-match (concat "^\\s-*\\(?:" comment-start-skip "\\)") + ct) (setq ct (concat (substring ct 0 (match-beginning 0)) (substring ct (match-end 0))))) ;; Arbitrary punctuation at the beginning of each line. diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index 92b639d71e..e0293c3cbb 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -1446,9 +1446,9 @@ (defun smie-indent-fixindent () (and (smie-indent--bolp) (save-excursion (comment-normalize-vars) - (re-search-forward (concat comment-start-skip + (re-search-forward (concat "\\(?:" comment-start-skip "\\)" "fixindent" - comment-end-skip) + "\\(?:" comment-end-skip "\\)") ;; 1+ to account for the \n comment termination. (1+ (line-end-position)) t)) (current-column))) diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index 152667040f..f01e866f55 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -1275,7 +1275,8 @@ (defun fortran-previous-statement () (concat "[ \t]*" (regexp-quote fortran-continuation-string))) (looking-at "[ \t]*$\\| \\{5\\}[^ 0\n]\\|\t[1-9]") - (looking-at (concat "[ \t]*" comment-start-skip))))) + (looking-at (concat "[ \t]*\\(?:" + comment-start-skip "\\)"))))) (cond ((and continue-test (not not-first-statement)) (message "Incomplete continuation statement.")) @@ -1298,7 +1299,8 @@ (defun fortran-next-statement () (or (looking-at fortran-comment-line-start-skip) (looking-at fortran-directive-re) (looking-at "[ \t]*$\\| [^ 0\n]\\|\t[1-9]") - (looking-at (concat "[ \t]*" comment-start-skip))))) + (looking-at (concat "[ \t]*\\(?:" + comment-start-skip "\\)"))))) (if (not not-last-statement) 'last-statement))) @@ -2146,7 +2148,8 @@ (defun fortran-fill-statement () (or (looking-at "[ \t]*$") (looking-at fortran-comment-line-start-skip) (and comment-start-skip - (looking-at (concat "[ \t]*" comment-start-skip))))) + (looking-at (concat "[ \t]*\\(?:" + comment-start-skip "\\)"))))) (save-excursion ;; Find beginning of statement. (fortran-next-statement) diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 1dc0c61d06..13d0cfa67e 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -6699,7 +6699,7 @@ (defun vhdl-beginning-of-statement (&optional count lim interactive) (if (and interactive (or (nth 3 state) (nth 4 state) - (looking-at (concat "[ \t]*" comment-start-skip)))) + (looking-at (concat "[ \t]*\\(?:" comment-start-skip "\\)")))) (forward-sentence (- count)) (while (> count 0) (vhdl-beginning-of-statement-1 lim) -- 2.11.0 --=-=-=--