unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
@ 2013-04-17  1:55 Leo Liu
  2013-04-25  3:26 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2013-04-17  1:55 UTC (permalink / raw)
  To: 14218

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
  2013-04-17  1:55 bug#14218: 24.3; octave-insert-defun bad indentation since using smie Leo Liu
@ 2013-04-25  3:26 ` Stefan Monnier
  2013-04-25  5:36   ` Leo Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-04-25  3:26 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14218-done

> 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







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
  2013-04-25  3:26 ` Stefan Monnier
@ 2013-04-25  5:36   ` Leo Liu
  2013-04-26 14:34     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2013-04-25  5:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14218

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
  2013-04-25  5:36   ` Leo Liu
@ 2013-04-26 14:34     ` Stefan Monnier
  2013-04-26 19:17       ` Leo Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-04-26 14:34 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14218

> 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"






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
  2013-04-26 14:34     ` Stefan Monnier
@ 2013-04-26 19:17       ` Leo Liu
  2013-05-07  4:06         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2013-04-26 19:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14218

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14218: 24.3; octave-insert-defun bad indentation since using smie
  2013-04-26 19:17       ` Leo Liu
@ 2013-05-07  4:06         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2013-05-07  4:06 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14218-done

>> 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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-07  4:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-17  1:55 bug#14218: 24.3; octave-insert-defun bad indentation since using smie Leo Liu
2013-04-25  3:26 ` Stefan Monnier
2013-04-25  5:36   ` Leo Liu
2013-04-26 14:34     ` Stefan Monnier
2013-04-26 19:17       ` Leo Liu
2013-05-07  4:06         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).