From 7a382383ac7912541bcceea16676ade20cc6b9ba Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 5 Apr 2019 08:00:09 -0400 Subject: [PATCH] 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 5611629c14d..4f98cf41027 100644 --- a/lisp/cedet/semantic/doc.el +++ b/lisp/cedet/semantic/doc.el @@ -103,7 +103,8 @@ If NOSNARF is `lex', then return the lex token." 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 92b639d71e2..e0293c3cbb4 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -1446,9 +1446,9 @@ in order to figure out the indentation of some other (further down) point." (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 152667040fa..f01e866f557 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -1275,7 +1275,8 @@ Directive lines are treated as comments." (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 @@ Directive lines are treated as comments." (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 @@ Always returns non-nil (to prevent `fill-paragraph' being called)." (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 1dc0c61d063..13d0cfa67e8 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -6699,7 +6699,7 @@ search, and an argument indicating an interactive call." (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.39.2