From: Noam Postavsky <npostavs@gmail.com>
To: Andrey Bondarenko <abone27@mail.ru>
Cc: 34805@debbugs.gnu.org
Subject: bug#34805: 25.2; smie-indent-fixindent wrong if comment-start-skip has alternatives
Date: Thu, 11 Apr 2019 23:52:16 -0400 [thread overview]
Message-ID: <87d0lranin.fsf@gmail.com> (raw)
In-Reply-To: <1552224185.548106836@f547.i.mail.ru> (Andrey Bondarenko's message of "Sun, 10 Mar 2019 16:23:05 +0300")
[-- Attachment #1: Type: text/plain, Size: 845 bytes --]
tags 34805 + patch
quit
Andrey Bondarenko <abone27@mail.ru> 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:
>
> (let ((comment-start-skip "#+\\s *\\|//+\\s *")
> (comment-end-skip ""))
> (concat comment-start-skip
> "fixindent"
> comment-end-skip)) → "#+\\s *\\|//+\\s *fixindent"
>
> This regexp would match "// fixindent" comments and any comment
> that starts with "#", which is wrong.
>
> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4582 bytes --]
From ea144b28028f6ef72d67d84f550e1798c61347e2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
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
next prev parent reply other threads:[~2019-04-12 3:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-10 13:23 bug#34805: 25.2; smie-indent-fixindent wrong if comment-start-skip has alternatives Andrey Bondarenko
2019-04-12 3:52 ` Noam Postavsky [this message]
2019-04-16 0:35 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d0lranin.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=34805@debbugs.gnu.org \
--cc=abone27@mail.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.