[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14350: 24.3; octave mode comment indentation

From: Leo Liu
Subject: bug#14350: 24.3; octave mode comment indentation
Date: Sat, 11 May 2013 13:14:24 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.8.3)

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)
+(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
@@ -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 via email to

[Prev in Thread] Current Thread [Next in Thread]