Commit e9155c4a authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

* lisp/newcomment.el (comment-beginning): When `comment-use-syntax' is

non-nil, use `syntax-ppss'.

Fixes: debbugs:15251
parent 481a8e0f
2013-10-01 Dmitry Gutov <>
* newcomment.el (comment-beginning): When `comment-use-syntax' is
non-nil, use `syntax-ppss' (Bug#15251).
2013-09-30 Rüdiger Sonderfeld <>
* progmodes/octave.el (inferior-octave-startup-file): Prefer
......@@ -515,8 +515,14 @@ Ensure that `comment-normalize-vars' has been called before you use this."
"Find the beginning of the enclosing comment.
Returns nil if not inside a comment, else moves point and returns
the same as `comment-search-backward'."
;; We should really test `in-string-p' but that can be expensive.
(if comment-use-syntax
(let ((state (syntax-ppss)))
(when (nth 4 state)
(goto-char (nth 8 state))
(prog1 (point)
(when (looking-at comment-start-skip)
(goto-char (match-end 0))))))
;; Can't rely on the syntax table, let's guess based on font-lock.
(unless (eq (get-text-property (point) 'face) 'font-lock-string-face)
(let ((pt (point))
(cs (comment-search-backward nil t)))
......@@ -538,7 +544,7 @@ the same as `comment-search-backward'."
(if (comment-forward 1) (> (point) pt) (eobp))))
(goto-char pt)
(defun comment-forward (&optional n)
"Skip forward over N comments.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment