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.

Full log


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




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

Previous Next


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