GNU bug report logs - #14350
24.3; octave mode comment indentation

Previous Next

Package: emacs;

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

Date: Sun, 5 May 2013 15:19:01 UTC

Severity: normal

Found in version 24.3

Done: Leo Liu <sdl.web <at> gmail.com>

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 14350 in the body.
You can then email your comments to 14350 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#14350; Package emacs. (Sun, 05 May 2013 15:19:01 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. (Sun, 05 May 2013 15:19:01 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 mode comment indentation
Date: Sun, 05 May 2013 23:17:36 +0800
Hello Stefan,

Some user from the Octave community has noticed the following change:

x = 12;                         # abc abc abc abc abc abc abc abc abc
                                # abc abc abc

If you TAB in the second comment line, that line will be moved to column
0.

I tested the example in emacs 22.1 and the second comment is supposed to
be aligned to a certain column (similar to ; and ;; in lisp-mode). Will
you be able to bend smie to do this? Thanks.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14350; Package emacs. (Fri, 10 May 2013 01:31:02 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: 14350 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Fri, 10 May 2013 09:29:47 +0800
On 2013-05-05 23:17 +0800, Leo Liu wrote:
> x = 12;                         # abc abc abc abc abc abc abc abc abc
>                                 # abc abc abc

matlab.el also does the comment alignment well. Stefan, do you think
this is possible to do with smie?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14350; Package emacs. (Fri, 10 May 2013 19:59:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14350 <at> debbugs.gnu.org
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Fri, 10 May 2013 15:57:47 -0400
>> x = 12;                         # abc abc abc abc abc abc abc abc abc
>>                                 # abc abc abc
> matlab.el also does the comment alignment well. Stefan, do you think
> this is possible to do with smie?

Of course.  In the very worst case you can change (buffer-locally)
smie-indent-functions to add any ad-hoc rule.
But maybe this can be fixed globally in smie-indent-comment.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14350; Package emacs. (Sat, 11 May 2013 02:06:01 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 14350 <at> debbugs.gnu.org
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Sat, 11 May 2013 10:04:59 +0800
On 2013-05-11 03:57 +0800, Stefan Monnier wrote:
> Of course.  In the very worst case you can change (buffer-locally)
> smie-indent-functions to add any ad-hoc rule.
> But maybe this can be fixed globally in smie-indent-comment.

Thanks for the comment (did I just use a pun?).

Unfortunately I have little knowledge of smie so I have to rely on
others to get this to behave. Thanks in advance.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14350; Package emacs. (Sat, 11 May 2013 03:36:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14350 <at> debbugs.gnu.org
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Fri, 10 May 2013 23:35:14 -0400
>> Of course.  In the very worst case you can change (buffer-locally)
>> smie-indent-functions to add any ad-hoc rule.
>> But maybe this can be fixed globally in smie-indent-comment.
> Thanks for the comment (did I just use a pun?).
> Unfortunately I have little knowledge of smie so I have to rely on
> others to get this to behave. Thanks in advance.

No, no, you don't.  smie-indent-functions is just a hook that runs
functions that come up with some indentation choice.  It basically sits
between line-indent-function and smie proper.  You can add your own
function which will not itself need to use anything from smie.
Look at its docstring.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14350; Package emacs. (Sat, 11 May 2013 05:15:01 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14350 <at> debbugs.gnu.org
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Sat, 11 May 2013 13:14:24 +0800
On 2013-05-11 11:35 +0800, Stefan Monnier wrote:
> No, no, you don't.  smie-indent-functions is just a hook that runs
> functions that come up with some indentation choice.  It basically sits
> between line-indent-function and smie proper.  You can add your own
> function which will not itself need to use anything from smie.
> Look at its docstring.

I intend to fix the bug with this patch. Comments?

diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 780bb2f5..5d8186f5 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -414,6 +414,13 @@ (defun octave-smie-rules (kind token)
        ;; (if (smie-parent-p "switch") 4)
        0))))
 
+(defun octave-indent-comment ()
+  "A function for `smie-indent-functions'."
+  (save-excursion
+    (back-to-indentation)
+    (when (and (looking-at-p "\\s<") (not (looking-at-p "\\s<\\s<")))
+      (comment-choose-indent))))
+
 
 (defvar octave-font-lock-keywords
   (list
@@ -488,6 +495,7 @@ (define-derived-mode octave-mode prog-mode "Octave"
               :forward-token  #'octave-smie-forward-token
               :backward-token #'octave-smie-backward-token)
   (setq-local smie-indent-basic 'octave-block-offset)
+  (add-hook 'smie-indent-functions #'octave-indent-comment nil t)
 
   (setq-local smie-blink-matching-triggers
               (cons ?\; smie-blink-matching-triggers))




Reply sent to Leo Liu <sdl.web <at> gmail.com>:
You have taken responsibility. (Mon, 13 May 2013 11:17:01 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Mon, 13 May 2013 11:17:01 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: 14350-done <at> debbugs.gnu.org
Subject: Re: bug#14350: 24.3; octave mode comment indentation
Date: Mon, 13 May 2013 19:15:29 +0800
Fixed in trunk.





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

This bug report was last modified 10 years and 329 days ago.

Previous Next


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