help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: SMIE examples or guides


From: Björn Lindqvist
Subject: Re: SMIE examples or guides
Date: Fri, 1 Jul 2016 02:49:32 +0200

Many thanks! That appears to work. But there is one problem. In a
buffer with just this content:

    [
    \
    ]

I get the error: (error "Bumped into unknown token")

And another problem I'm having is trying to support multiple
indentation start tokens:

    (deconst factor-smie-grammar
     (smie-prec2->grammar
      (smie-bnf->prec2
       '((exp (("HELLO" "HALLO" "CIAO" "SALUT") exp "BYE"))))))

My intent is to allow either of those four words to be used to start
the indented block. I only need one ending token so there will be no
alternative to BYE. Seems like it should be trivial to extend the BNF
grammar in this way, but I can't figure out what syntax
smie-bnf->prec2 expects for it.

2016-06-30 20:49 GMT+02:00 Stefan Monnier <monnier@iro.umontreal.ca>:
>> 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\\_>")
>        (save-excursion
>          (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.
>
>
>         Stefan



-- 
mvh/best regards Björn Lindqvist



reply via email to

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