GNU bug report logs - #14218
24.3; octave-insert-defun bad indentation since using smie

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Wed, 17 Apr 2013 02:01:02 UTC

Severity: normal

Found in version 24.3

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14218 in the body.
You can then email your comments to 14218 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#14218; Package emacs. (Wed, 17 Apr 2013 02:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Wed, 17 Apr 2013 02:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; octave-insert-defun bad indentation since using smie
Date: Wed, 17 Apr 2013 09:55:39 +0800
C-c C-f in octave-mode of emacs 22.1 normally inserts something like
this:

function B = hasWon (X, z, z0)

  ## usage:  B = hasWon (X, z, z0)                                              
  ##                                                                            
  ##                                                                            

endfunction


Now it inserts:

function B = hasWon (X, z, z0)
	 
	 ## usage: B = hasWon (X, z, z0)
	 ## 
	 ## 
	 
endfunction


i.e. it has wrong initial indentation. This might be a flaw of smie.

Leo




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Thu, 25 Apr 2013 03:32:03 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Thu, 25 Apr 2013 03:32:04 GMT) Full text and rfc822 format available.

Message #10 received at 14218-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14218-done <at> debbugs.gnu.org
Subject: Re: bug#14218: 24.3;
	octave-insert-defun bad indentation since using smie
Date: Wed, 24 Apr 2013 23:26:05 -0400
> Now it inserts:

> function B = hasWon (X, z, z0)
	 
> 	 ## usage: B = hasWon (X, z, z0)
> 	 ## 
> 	 ## 
	 
> endfunction

> i.e. it has wrong initial indentation. This might be a flaw of smie.

Indeed.  There were several bugs triggered here.
I installed the patch below which fixes this problem.


        Stefan






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14218; Package emacs. (Thu, 25 Apr 2013 05:42:01 GMT) Full text and rfc822 format available.

Message #13 received at 14218 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14218 <at> debbugs.gnu.org
Subject: Re: bug#14218: 24.3;
	octave-insert-defun bad indentation since using smie
Date: Thu, 25 Apr 2013 13:36:02 +0800
On 2013-04-25 11:26 +0800, Stefan Monnier wrote:
> Indeed.  There were several bugs triggered here.
> I installed the patch below which fixes this problem.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14218; Package emacs. (Fri, 26 Apr 2013 14:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 14218 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14218 <at> debbugs.gnu.org
Subject: Re: bug#14218: 24.3;
	octave-insert-defun bad indentation since using smie
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"





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14218; Package emacs. (Fri, 26 Apr 2013 19:19:02 GMT) Full text and rfc822 format available.

Message #19 received at 14218 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14218 <at> debbugs.gnu.org
Subject: Re: bug#14218: 24.3;
	octave-insert-defun bad indentation since using smie
Date: Sat, 27 Apr 2013 03:17:00 +0800
On 2013-04-26 22:34 +0800, Stefan Monnier wrote:
> Duh, thanks. I've installed the additional patch below which should
> fix it right this time.

Found an infinite loop.

In a new octave-mode buffer, insert "function" and make sure there is no
trailing newline. Now move to point-min and M-x forward-sexp to enter
infinite loop.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14218; Package emacs. (Tue, 07 May 2013 04:08:02 GMT) Full text and rfc822 format available.

Message #22 received at 14218-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14218-done <at> debbugs.gnu.org
Subject: Re: bug#14218: 24.3;
	octave-insert-defun bad indentation since using smie
Date: Tue, 07 May 2013 00:06:13 -0400
>> Duh, thanks. I've installed the additional patch below which should
>> fix it right this time.
> Found an infinite loop.

I think I fixed it now,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 Jun 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.