# HG changeset patch # User Stefan Monnier # Date 1078708853 0 # Node ID 597fb06dcddab9e151fed3da360d0ea446f2fb11 # Parent 487c9b84c975562a20dc0351a6c97e2de405f20a (comment-use-global-state): New var. (comment-search-forward): Use it. diff -r 487c9b84c975 -r 597fb06dcdda lisp/newcomment.el --- a/lisp/newcomment.el Mon Mar 08 01:10:23 2004 +0000 +++ b/lisp/newcomment.el Mon Mar 08 01:20:53 2004 +0000 @@ -345,6 +345,13 @@ ;;;; 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 @@ (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