unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 14350@debbugs.gnu.org
Subject: bug#14350: 24.3; octave mode comment indentation
Date: Sat, 11 May 2013 13:14:24 +0800	[thread overview]
Message-ID: <m1r4he9jyn.fsf@gmail.com> (raw)
In-Reply-To: <jwvd2sy9op0.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 10 May 2013 23:35:14 -0400")

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))))
+
 \f
 (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	other threads:[~2013-05-11  5:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-05 15:17 bug#14350: 24.3; octave mode comment indentation Leo Liu
2013-05-10  1:29 ` Leo Liu
2013-05-10 19:57   ` Stefan Monnier
2013-05-11  2:04     ` Leo Liu
2013-05-11  3:35       ` Stefan Monnier
2013-05-11  5:14         ` Leo Liu [this message]
2013-05-13 11:15           ` Leo Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1r4he9jyn.fsf@gmail.com \
    --to=sdl.web@gmail.com \
    --cc=14350@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).