summaryrefslogtreecommitdiff
path: root/lisp/newcomment.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2004-03-08 01:20:53 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2004-03-08 01:20:53 +0000
commitf5f95edfe3828fb1352778fdd16d1a545b32c717 (patch)
treec4092cd72782ce979e93cbf36f6eedd353fa816c /lisp/newcomment.el
parent5895f7fd1a20b2197951395a3c33d4e90ca7f992 (diff)
downloademacs-f5f95edfe3828fb1352778fdd16d1a545b32c717.tar.gz
(comment-use-global-state): New var.
(comment-search-forward): Use it.
Diffstat (limited to 'lisp/newcomment.el')
-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."
;;;; Navigation
;;;;
+(defvar comment-use-global-state nil
+ "Non-nil means that the global syntactic context is used.
+More specifically, it means that `syntax-ppss' is used to find out whether
+point is within a string or not. Major modes whose syntax is faithfully
+described by the syntax-tables can set this to non-nil so comment markers
+in strings will not confuse Emacs.")
+
(defun comment-search-forward (limit &optional noerror)
"Find a comment start between point and LIMIT.
Moves 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."
(unless noerror (error "No comment")))
(let* ((pt (point))
;; Assume (at first) that pt is outside of any string.
- (s (parse-partial-sexp pt (or limit (point-max)) nil nil nil t)))
- (when (and (nth 8 s) (nth 3 s))
+ (s (parse-partial-sexp pt (or limit (point-max)) nil nil
+ (if comment-use-global-state (syntax-ppss pt))
+ t)))
+ (when (and (nth 8 s) (nth 3 s) (not comment-use-global-state))
;; The search ended inside a string. Try to see if it
;; works better when we assume that pt is inside a string.
(setq s (parse-partial-sexp