Subject: bug#14218: 24.3; octave-insert-defun bad indentation since using smie

From: Stefan Monnier <[email-masked]>
Date: Fri, 26 Apr 2013 10:34:42 -0400

> Thank you for the fix. However with this change: prog-indent-sexp with
> point on the first letter of 'function' gives me this funny indentation
> and extra whitespace:

>   function A = dox (n)
           
>     ## usage: A = dox (n)
>     ## 
>   ## 
           
>   endfunction

Duh, thanks.  I've installed the additional patch below which should fix
it right this time.

        Stefan

=== modified file 'lisp/progmodes/octave.el'
--- lisp/progmodes/octave.el	2013-04-26 04:16:37 +0000
+++ lisp/progmodes/octave.el	2013-04-26 14:25:15 +0000
@@ -461,11 +461,12 @@
     (forward-comment 1))
   (cond
    ((and (looking-at "$\\|[%#]")
-         (not (smie-rule-bolp))
-         ;; Ignore it if it's within parentheses.
-         (prog1 (let ((ppss (syntax-ppss)))
+         ;; 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))))))
+				 (eq ?\( (char-after (nth 1 ppss)))))))
            (forward-comment (point-max))))
     ;; Why bother distinguishing \n and ;?
     ";") ;;"\n"