aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2014-03-18 08:06:33 +0200
committerDmitry Gutov2014-03-18 08:06:33 +0200
commit2b7858ecbd57f16d0a20906dd792fd96049c5952 (patch)
tree8514ab26cdcaa7b1c20bef830438969bc94538ac
parent1917cf46bba74cdd0bcd1d0545cbd688db4e76f9 (diff)
downloademacs-2b7858ecbd57f16d0a20906dd792fd96049c5952.tar.gz
emacs-2b7858ecbd57f16d0a20906dd792fd96049c5952.zip
Further tweaks for comment-start-skip behavior
* lisp/newcomment.el (comment-normalize-vars): Only add escaping check to `comment-start-skip' if not `comment-use-syntax'. (comment-beginning): Use `narrow-to-region' instead of moving back one character. (http://lists.gnu.org/archive/html/emacs-devel/2014-03/msg00488.html) (comment-start-skip): Update the docstring. Fixes: debbugs:16971
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/newcomment.el21
2 files changed, 21 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3cec8c34a2c..e6155d7237a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12014-03-18 Dmitry Gutov <dgutov@yandex.ru>
2
3 * newcomment.el (comment-normalize-vars): Only add escaping check
4 to `comment-start-skip' if not `comment-use-syntax'. (Bug#16971)
5 (comment-beginning): Use `narrow-to-region' instead of moving back
6 one character.
7 (http://lists.gnu.org/archive/html/emacs-devel/2014-03/msg00488.html)
8 (comment-start-skip): Update the docstring.
9
12014-03-18 Daniel Colascione <dancol@dancol.org> 102014-03-18 Daniel Colascione <dancol@dancol.org>
2 11
3 * startup.el (tty-handle-args): Remove debug message from 2007. 12 * startup.el (tty-handle-args): Remove debug message from 2007.
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 44e270a66ea..2d798494b8b 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -120,8 +120,9 @@ Comments might be indented to a different value in order not to go beyond
120;;;###autoload 120;;;###autoload
121(defvar comment-start-skip nil 121(defvar comment-start-skip nil
122 "Regexp to match the start of a comment plus everything up to its body. 122 "Regexp to match the start of a comment plus everything up to its body.
123If there are any \\(...\\) pairs, the comment delimiter text is held to begin 123If there are any \\(...\\) pairs and `comment-use-syntax' is nil,
124at the place matched by the close of the first pair.") 124the comment delimiter text is held to begin at the place matched
125by the close of the first pair.")
125;;;###autoload 126;;;###autoload
126(put 'comment-start-skip 'safe-local-variable 'stringp) 127(put 'comment-start-skip 'safe-local-variable 'stringp)
127 128
@@ -378,7 +379,10 @@ function should first call this function explicitly."
378 ;; In case comment-start has changed since last time. 379 ;; In case comment-start has changed since last time.
379 (string-match comment-start-skip comment-start)) 380 (string-match comment-start-skip comment-start))
380 (set (make-local-variable 'comment-start-skip) 381 (set (make-local-variable 'comment-start-skip)
381 (concat "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(\\s<+\\|" 382 (concat (unless (eq comment-use-syntax t)
383 ;; `syntax-ppss' will detect escaping.
384 "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)")
385 "\\(\\s<+\\|"
382 (regexp-quote (comment-string-strip comment-start t t)) 386 (regexp-quote (comment-string-strip comment-start t t))
383 ;; Let's not allow any \s- but only [ \t] since \n 387 ;; Let's not allow any \s- but only [ \t] since \n
384 ;; might be both a comment-end marker and \s-. 388 ;; might be both a comment-end marker and \s-.
@@ -523,12 +527,11 @@ the same as `comment-search-backward'."
523 (when (nth 4 state) 527 (when (nth 4 state)
524 (goto-char (nth 8 state)) 528 (goto-char (nth 8 state))
525 (prog1 (point) 529 (prog1 (point)
526 (when (or (looking-at comment-start-skip) 530 (when (save-restriction
527 ;; Some older modes use regexps that check the 531 ;; `comment-start-skip' sometimes checks that the
528 ;; char before the comment for quoting. (Bug#16971) 532 ;; comment char is not escaped. (Bug#16971)
529 (save-excursion 533 (narrow-to-region (point) (point-max))
530 (forward-char -1) 534 (looking-at comment-start-skip))
531 (looking-at comment-start-skip)))
532 (goto-char (match-end 0)))))) 535 (goto-char (match-end 0))))))
533 ;; Can't rely on the syntax table, let's guess based on font-lock. 536 ;; Can't rely on the syntax table, let's guess based on font-lock.
534 (unless (eq (get-text-property (point) 'face) 'font-lock-string-face) 537 (unless (eq (get-text-property (point) 'face) 'font-lock-string-face)