[Top][All Lists]

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

Re: SMIE examples or guides

From: Stefan Monnier
Subject: Re: SMIE examples or guides
Date: Thu, 30 Jun 2016 14:49:55 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> HELLO three one
>     four ten BYE
> eleven HELLO
>     twelve
>     BYE

This goes a bit against SMIE's default indentation principles, so it's
going to take more efforts (IOW adding support for this kind of
indentation is still on the todo list).

Maybe something along the following lines would work:

   (defun my-indent-foo ()
     (unless (looking-at "BYE\\_>")
         (let ((x nil))
           (while (progn (setq x (smie-backward-sexp))
                         (null (car-safe x))))
           (when (equal "HELLO" (nth 2 x))
             (goto-char (nth 1 x))
             (+ 4 (smie-indent-virtual)))))))
and add

     (add-hook 'smie-indent-functions #'my-indent-foo nil t)

in your major mode function.


reply via email to

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