diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2001-03-02 20:31:48 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2001-03-02 20:31:48 +0000 |
commit | 75ed43a6a2c1fe63f0021e2aa4a42942a2fbc522 (patch) | |
tree | fa8142a819133786a236638cc2d98413c8377e1d | |
parent | b1f865ae18a7c04e37c0e2dddab79b586265afb8 (diff) | |
download | emacs-75ed43a6a2c1fe63f0021e2aa4a42942a2fbc522.tar.gz |
(comment-normalize-vars): Use [ \t] for the trailing
spaces in default comment-start-skip settings rather than \s-.
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/newcomment.el | 27 |
2 files changed, 21 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 12abcfb2502..ddd6105ccad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2001-03-02 Stefan Monnier <monnier@cs.yale.edu> + + * newcomment.el (comment-normalize-vars): Use [ \t] for the trailing + spaces in default comment-start-skip settings rather than \s-. + 2001-03-02 Eli Zaretskii <eliz@is.elta.co.il> * term/pc-win.el (msdos-handle-reverse-video): Look for reverse in diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 09b928dea26..9ddcda42769 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -5,7 +5,7 @@ ;; Author: code extracted from Emacs-20's simple.el ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> ;; Keywords: comment uncomment -;; Revision: $Id: newcomment.el,v 1.29 2000/12/18 03:17:31 monnier Exp $ +;; Revision: $Id: newcomment.el,v 1.30 2001/02/22 01:47:40 monnier Exp $ ;; This file is part of GNU Emacs. @@ -233,7 +233,9 @@ This is obsolete because you might as well use \\[newline-and-indent]." (set (make-local-variable 'comment-start-skip) (concat "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(\\s<+\\|" (regexp-quote (comment-string-strip comment-start t t)) - "+\\)\\s-*"))) + ;; Let's not allow any \s- but only [ \t] since \n + ;; might be both a comment-end marker and \s-. + "+\\)[ \t]*"))) (unless comment-end-skip (let ((ce (if (string= "" comment-end) "\n" (comment-string-strip comment-end t t)))) @@ -346,15 +348,18 @@ and raises an error or returns nil of NOERROR is non-nil." "Find the beginning of the enclosing comment. Returns nil if not inside a comment, else moves point and returns the same as `comment-search-forward'." - (let ((pt (point)) - (cs (comment-search-backward nil t))) - (when cs - (if (save-excursion - (goto-char cs) - (if (comment-forward 1) (> (point) pt) (eobp))) - cs - (goto-char pt) - nil)))) + ;; HACK ATTACK! + ;; We should really test `in-string-p' but that can be expensive. + (unless (eq (get-text-property (point) 'face) 'font-lock-string-face) + (let ((pt (point)) + (cs (comment-search-backward nil t))) + (when cs + (if (save-excursion + (goto-char cs) + (if (comment-forward 1) (> (point) pt) (eobp))) + cs + (goto-char pt) + nil))))) (defun comment-forward (&optional n) "Skip forward over N comments. |