aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2004-03-08 01:20:53 +0000
committerStefan Monnier2004-03-08 01:20:53 +0000
commitf5f95edfe3828fb1352778fdd16d1a545b32c717 (patch)
treec4092cd72782ce979e93cbf36f6eedd353fa816c
parent5895f7fd1a20b2197951395a3c33d4e90ca7f992 (diff)
downloademacs-f5f95edfe3828fb1352778fdd16d1a545b32c717.tar.gz
emacs-f5f95edfe3828fb1352778fdd16d1a545b32c717.zip
(comment-use-global-state): New var.
(comment-search-forward): Use it.
-rw-r--r--lisp/newcomment.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 1c9c0dfd4b6..924cf0ed8c4 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -345,6 +345,13 @@ If UNP is non-nil, unquote nested comment markers."
345;;;; Navigation 345;;;; Navigation
346;;;; 346;;;;
347 347
348(defvar comment-use-global-state nil
349 "Non-nil means that the global syntactic context is used.
350More specifically, it means that `syntax-ppss' is used to find out whether
351point is within a string or not. Major modes whose syntax is faithfully
352described by the syntax-tables can set this to non-nil so comment markers
353in strings will not confuse Emacs.")
354
348(defun comment-search-forward (limit &optional noerror) 355(defun comment-search-forward (limit &optional noerror)
349 "Find a comment start between point and LIMIT. 356 "Find a comment start between point and LIMIT.
350Moves point to inside the comment and returns the position of the 357Moves point to inside the comment and returns the position of the
@@ -357,8 +364,10 @@ and raises an error or returns nil of NOERROR is non-nil."
357 (unless noerror (error "No comment"))) 364 (unless noerror (error "No comment")))
358 (let* ((pt (point)) 365 (let* ((pt (point))
359 ;; Assume (at first) that pt is outside of any string. 366 ;; Assume (at first) that pt is outside of any string.
360 (s (parse-partial-sexp pt (or limit (point-max)) nil nil nil t))) 367 (s (parse-partial-sexp pt (or limit (point-max)) nil nil
361 (when (and (nth 8 s) (nth 3 s)) 368 (if comment-use-global-state (syntax-ppss pt))
369 t)))
370 (when (and (nth 8 s) (nth 3 s) (not comment-use-global-state))
362 ;; The search ended inside a string. Try to see if it 371 ;; The search ended inside a string. Try to see if it
363 ;; works better when we assume that pt is inside a string. 372 ;; works better when we assume that pt is inside a string.
364 (setq s (parse-partial-sexp 373 (setq s (parse-partial-sexp