From ceb57e59976a540dd38b1122507b75af31a103c3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 7 May 2013 00:05:43 -0400 Subject: [PATCH] * lisp/progmodes/octave.el (octave-smie-forward-token): Be more careful about implicit semi-colons. Fixes: debbugs:14218 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/octave.el | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 676e428639..a6eed51b9b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-05-07 Stefan Monnier + + * progmodes/octave.el (octave-smie-forward-token): Be more careful + about implicit semi-colons (bug#14218). + 2013-05-07 YAMAMOTO Mitsuharu * frame.el (display-monitor-attributes-list) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index ebefcef0c7..7e14e59af5 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -370,16 +370,18 @@ Non-nil means always go to the next Octave code line after sending." (goto-char (match-end 1)) (forward-comment 1)) (cond - ((and (looking-at "$\\|[%#]") - ;; Ignore it if it's within parentheses or if the newline does not end - ;; some preceding text. - (prog1 (and (not (smie-rule-bolp)) - (let ((ppss (syntax-ppss))) - (not (and (nth 1 ppss) - (eq ?\( (char-after (nth 1 ppss))))))) - (forward-comment (point-max)))) + ((and (looking-at "[%#\n]") + (not (or (save-excursion (skip-chars-backward " \t") + ;; Only add implicit ; when needed. + (or (bolp) (eq (char-before ?\;)))) + ;; Ignore it if it's within parentheses. + (let ((ppss (syntax-ppss))) + (and (nth 1 ppss) + (eq ?\( (char-after (nth 1 ppss)))))))) + (if (eolp) (forward-char 1) (forward-comment 1)) ;; Why bother distinguishing \n and ;? ";") ;;"\n" + ((progn (forward-comment (point-max)) nil)) ((looking-at ";[ \t]*\\($\\|[%#]\\)") ;; Combine the ; with the subsequent \n. (goto-char (match-beginning 1)) -- 2.20.1