[Top][All Lists]

[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: Sun, 26 Jun 2016 14:23:27 +0200

(Sorry I haven't had time to play with emacs for a while)

What I have is the following:

    (smie-setup factor-smie-grammar #'factor-smie-rules)
    (setq-local smie-indent-basic 'factor-block-offset)

I have pieced together a factor-smie-rules func by looking at
elixir-mode and octave-mode:

    (defun factor-smie-rules (kind token)
      (pcase (cons kind token)
        (`(:elem . basic) 4)
        (`(:after . ,(or `"HELLO")) 4)

The intent is that if a line contains the token HELLO, indent is
increased for subsequent lines by four. I'm also planning to add a BYE
token, pairing HELLO and decreasing indent by four. Something happens
when I type HELLO<tab> and emacs says (error "Please avoid it"). So my
rules function is triggered, which is good but the result isn't what I

2016-06-20 5:21 GMT+02:00 Stefan Monnier <address@hidden>:
>> I'm trying to implement SMIE support for a language's major mode. So
>> I've been reading the documentation and looking at how SMIE is used in
>> octave-mode, but it is not easy to understand how it works. Does any
>> friendlier sources for learning how to use SMIE exist? Like smaller
>> examples, how tos or smie guides?
> There are several modes using SMIE, beside octave-mode.  They don't tend
> to be very small, sadly, because indentation is pretty much always
> tricky business, so even if it starts small, it quickly grows.
> I suggest you post what you've tried and the problems you encountered,
> and someone (mostly likely me) will help you out.  In return, hopefully
> you can provide some suggestions for how to improve the doc.
>         Stefan

mvh/best regards Björn Lindqvist

reply via email to

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