emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112623: * newcomment.el (comment-sea


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112623: * newcomment.el (comment-search-backward): Stricter in finding
Date: Sat, 18 May 2013 06:46:10 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112623
fixes bug: http://debbugs.gnu.org/14303
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sat 2013-05-18 06:46:10 +0800
message:
  * newcomment.el (comment-search-backward): Stricter in finding
  comment start. 
  
  * progmodes/octave.el (octave-comment-start): Remove the SPC char.
  (octave-comment-start-skip): Properly anchored.
modified:
  lisp/ChangeLog
  lisp/newcomment.el
  lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-17 04:33:12 +0000
+++ b/lisp/ChangeLog    2013-05-17 22:46:10 +0000
@@ -1,5 +1,13 @@
 2013-05-17  Leo Liu  <address@hidden>
 
+       * newcomment.el (comment-search-backward): Stricter in finding
+       comment start.  (Bug#14303)
+
+       * progmodes/octave.el (octave-comment-start): Remove the SPC char.
+       (octave-comment-start-skip): Properly anchored.
+
+2013-05-17  Leo Liu  <address@hidden>
+
        * emacs-lisp/smie.el (smie-highlight-matching-block-mode): Clean
        up when turned off.  (Bug#14395)
        (smie--highlight-matching-block-overlay): No longer buffer-local.

=== modified file 'lisp/newcomment.el'
--- a/lisp/newcomment.el        2013-01-11 23:08:55 +0000
+++ b/lisp/newcomment.el        2013-05-17 22:46:10 +0000
@@ -485,27 +485,29 @@
 Moves point to inside the comment and returns the position of the
 comment-starter.  If no comment is found, moves point to LIMIT
 and raises an error or returns nil if NOERROR is non-nil."
-  ;; FIXME: If a comment-start appears inside a comment, we may erroneously
-  ;; stop there.  This can be rather bad in general, but since
-  ;; comment-search-backward is only used to find the comment-column (in
-  ;; comment-set-column) and to find the comment-start string (via
-  ;; comment-beginning) in indent-new-comment-line, it should be harmless.
-  (if (not (re-search-backward comment-start-skip limit t))
-      (unless noerror (error "No comment"))
-    (beginning-of-line)
-    (let* ((end (match-end 0))
-          (cs (comment-search-forward end t))
-          (pt (point)))
-      (if (not cs)
-         (progn (beginning-of-line)
-                (comment-search-backward limit noerror))
-       (while (progn (goto-char cs)
-                     (comment-forward)
-                     (and (< (point) end)
-                          (setq cs (comment-search-forward end t))))
-         (setq pt (point)))
-       (goto-char pt)
-       cs))))
+  (let (found end)
+    (while (and (not found)
+               (re-search-backward comment-start-skip limit t))
+      (setq end (match-end 0))
+      (unless (and comment-use-syntax
+                  (nth 8 (syntax-ppss (or (match-end 1)
+                                          (match-beginning 0)))))
+       (setq found t)))
+    (if (not found)
+       (unless noerror (error "No comment"))
+      (beginning-of-line)
+      (let ((cs (comment-search-forward end t))
+           (pt (point)))
+       (if (not cs)
+           (progn (beginning-of-line)
+                  (comment-search-backward limit noerror))
+         (while (progn (goto-char cs)
+                       (comment-forward)
+                       (and (< (point) end)
+                            (setq cs (comment-search-forward end t))))
+           (setq pt (point)))
+         (goto-char pt)
+         cs)))))
 
 (defun comment-beginning ()
   "Find the beginning of the enclosing comment.

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-05-17 02:43:41 +0000
+++ b/lisp/progmodes/octave.el  2013-05-17 22:46:10 +0000
@@ -62,12 +62,11 @@
 (defvar octave-comment-char ?#
   "Character to start an Octave comment.")
 
-(defvar octave-comment-start
-  (string octave-comment-char ?\s)
-  "String to insert to start a new Octave in-line comment.")
+(defvar octave-comment-start (char-to-string octave-comment-char)
+  "Octave-specific `comment-start' (which see).")
 
-(defvar octave-comment-start-skip "\\(?:%!\\|\\s<+\\)\\s-*"
-  "Regexp to match the start of an Octave comment up to its body.")
+(defvar octave-comment-start-skip "\\(^\\|\\S<\\)\\(?:%!\\|\\s<+\\)\\s-*"
+  "Octave-specific `comment-start-skip' (which see).")
 
 (defvar octave-begin-keywords
   '("classdef" "do" "enumeration" "events" "for" "function" "if" "methods"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]