]> git.eshelyaron.com Git - emacs.git/commitdiff
(c++-backward-to-noncomment): Don't loop forever
authorRichard M. Stallman <rms@gnu.org>
Sat, 25 Feb 1995 07:49:39 +0000 (07:49 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 25 Feb 1995 07:49:39 +0000 (07:49 +0000)
if first line of buffer starts with ` #'.

lisp/progmodes/cplus-md.el

index fd7f224969e3edd54ff0cef98b77a3dbb65ffc40..c88e299f7dff5d95d23ff5082dbb1c1c2048898d 100644 (file)
@@ -586,12 +586,16 @@ Returns nil if line starts inside a string, t if in a comment."
            ((and
              (search-backward "//" (max (c++-point-bol) lim) 'move)
              (not (c++-within-string-p (point) opoint))))
-         (t (beginning-of-line)
-            (skip-chars-forward " \t")
-            (if (looking-at "#")
-                (setq stop (<= (point) lim))
-              (setq stop t)
-              (goto-char opoint)))))))
+           ;; No comment to be found.
+           ;; If there's a # command on this line,
+           ;; move back to it.
+           (t (beginning-of-line)
+              (skip-chars-forward " \t")
+              ;; But don't get fooled if we are already before the #.
+              (if (and (looking-at "#") (< (point) opoint))
+                  (setq stop (<= (point) lim))
+                (setq stop t)
+                (goto-char opoint)))))))
 
 (defun indent-c++-exp ()
   "Indent each line of the C++ grouping following point."