]> git.eshelyaron.com Git - emacs.git/commitdiff
* newcomment.el (comment-search-backward): Revert last change.
authorLeo Liu <sdl.web@gmail.com>
Fri, 7 Jun 2013 11:48:28 +0000 (19:48 +0800)
committerLeo Liu <sdl.web@gmail.com>
Fri, 7 Jun 2013 11:48:28 +0000 (19:48 +0800)
* emacs-lisp/smie.el (smie--matching-block-data): Minor simplification.

* progmodes/octave.el (octave-mode): Set comment-use-global-state
to t.  (Bug#14303)

Fixes: debbugs:14434 debbugs:14303
lisp/ChangeLog
lisp/emacs-lisp/smie.el
lisp/newcomment.el
lisp/progmodes/octave.el

index 50e4647b4383a08589698a3537c9059c2bbc114d..b6d934e95c40117b5604c2c0b9e9725023b43d41 100644 (file)
@@ -1,3 +1,13 @@
+2013-06-07  Leo Liu  <sdl.web@gmail.com>
+
+       * progmodes/octave.el (octave-mode): Set comment-use-global-state
+       to t.  (Bug#14303)
+
+       * newcomment.el (comment-search-backward): Revert last change.
+       (Bug#14434)
+
+       * emacs-lisp/smie.el (smie--matching-block-data): Minor simplification.
+
 2013-06-07  Eli Zaretskii  <eliz@gnu.org>
 
        * Makefile.in (TAGS TAGS-LISP): Pass the (long) list of *.el files
index f4eda606ad602a4221b89515d6335654c9022996..e97e9d066fd31bf1718345a0faf7126047b8a85b 100644 (file)
@@ -1057,24 +1057,24 @@ This uses SMIE's tables and is expected to be placed on `post-self-insert-hook'.
                                (funcall smie-forward-token-function)))))))
         (unless (nth 8 (syntax-ppss))
           (condition-case nil
-              (let ((here (funcall tok-at-pt)))
+              (let ((here (funcall tok-at-pt))
+                    there pair)
                 (when here
-                  (let (pair there)
-                    (cond
-                     ((assoc (car here) smie-closer-alist) ; opener
-                      (forward-sexp 1)
-                      (setq there (funcall tok-at-pt))
-                      (setq pair (cons (car here) (car there))))
-                     ((rassoc (car here) smie-closer-alist) ; closer
-                      (funcall smie-forward-token-function)
-                      (forward-sexp -1)
-                      (setq there (funcall tok-at-pt))
-                      (setq pair (cons (car there) (car here)))))
-                    ;; Update the cache
-                    (setcdr smie--matching-block-data-cache
-                            (list (nth 1 here) (nth 2 here)
-                                  (nth 1 there) (nth 2 there)
-                                  (not (member pair smie-closer-alist)))))))
+                  (cond
+                   ((assoc (car here) smie-closer-alist) ; opener
+                    (forward-sexp 1)
+                    (setq there (funcall tok-at-pt))
+                    (setq pair (cons (car here) (car there))))
+                   ((rassoc (car here) smie-closer-alist) ; closer
+                    (funcall smie-forward-token-function)
+                    (forward-sexp -1)
+                    (setq there (funcall tok-at-pt))
+                    (setq pair (cons (car there) (car here)))))
+                  ;; Update the cache
+                  (setcdr smie--matching-block-data-cache
+                          (list (nth 1 here)  (nth 2 here)
+                                (nth 1 there) (nth 2 there)
+                                (not (member pair smie-closer-alist))))))
             (scan-error))
           (goto-char (car smie--matching-block-data-cache))))
       (apply #'smie--matching-block-data orig args))))
index e10b96f97f9d77bdc6d274c8bef12e302801bee8..bcb5f721ae81706da0d7f13980b7da47f9b14e57 100644 (file)
@@ -485,29 +485,27 @@ and raises an error or returns nil if NOERROR is non-nil."
 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."
-  (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)))))
+  ;; 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))))
 
 (defun comment-beginning ()
   "Find the beginning of the enclosing comment.
index efa735e99b981e335170f00f155676424bb24fde..14d04b0d03cb7e9a63c8b1229839812e505ef652 100644 (file)
@@ -540,6 +540,7 @@ definitions can also be stored in files and used in batch mode."
   ;; a ";" at those places where it's correct (i.e. outside of parens).
   (setq-local electric-layout-rules '((?\; . after)))
 
+  (setq-local comment-use-global-state t)
   (setq-local comment-start octave-comment-start)
   (setq-local comment-end "")
   (setq-local comment-start-skip octave-comment-start-skip)
@@ -664,6 +665,7 @@ in the Inferior Octave buffer.")
   :abbrev-table octave-abbrev-table
   (setq comint-prompt-regexp inferior-octave-prompt)
 
+  (setq-local comment-use-global-state t)
   (setq-local comment-start octave-comment-start)
   (setq-local comment-end "")
   (setq comment-column 32)