From a175bf337ae1cb146bf01f69648cd5cbe35d4384 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Fri, 7 Jun 2013 19:48:28 +0800 Subject: [PATCH] * newcomment.el (comment-search-backward): Revert last change. * 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 | 10 +++++++++ lisp/emacs-lisp/smie.el | 34 +++++++++++++++---------------- lisp/newcomment.el | 44 +++++++++++++++++++--------------------- lisp/progmodes/octave.el | 2 ++ 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 50e4647b438..b6d934e95c4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2013-06-07 Leo Liu + + * 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 * Makefile.in (TAGS TAGS-LISP): Pass the (long) list of *.el files diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index f4eda606ad6..e97e9d066fd 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -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)))) diff --git a/lisp/newcomment.el b/lisp/newcomment.el index e10b96f97f9..bcb5f721ae8 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -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. diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index efa735e99b9..14d04b0d03c 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -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) -- 2.39.5