From: "Björn Lindqvist" <bjourne@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: SMIE examples or guides
Date: Sun, 26 Jun 2016 14:23:27 +0200 [thread overview]
Message-ID: <CALG+76ef5ibX0ii7WR=msQPtV-67gdWbSjThgtK-EDJd=NuwZQ@mail.gmail.com> (raw)
In-Reply-To: <jwvmvmg35ui.fsf-monnier+gmane.emacs.help@gnu.org>
(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
want.
2016-06-20 5:21 GMT+02:00 Stefan Monnier <monnier@iro.umontreal.ca>:
>> 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
next prev parent reply other threads:[~2016-06-26 12:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-19 2:57 SMIE examples or guides Björn Lindqvist
2016-06-20 3:21 ` Stefan Monnier
2016-06-26 12:23 ` Björn Lindqvist [this message]
2016-06-27 8:31 ` Stefan Monnier
2016-06-27 12:32 ` Björn Lindqvist
2016-06-27 22:02 ` Stefan Monnier
2016-06-28 11:34 ` Björn Lindqvist
2016-06-28 21:42 ` Stefan Monnier
2016-06-28 22:30 ` Björn Lindqvist
2016-06-29 7:37 ` Stefan Monnier
2016-06-29 16:48 ` Björn Lindqvist
2016-06-30 7:23 ` Stefan Monnier
2016-06-30 11:27 ` Björn Lindqvist
2016-06-30 18:49 ` Stefan Monnier
2016-07-01 0:49 ` Björn Lindqvist
2016-07-01 7:13 ` Stefan Monnier
2016-07-01 19:28 ` Björn Lindqvist
2016-07-01 23:09 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALG+76ef5ibX0ii7WR=msQPtV-67gdWbSjThgtK-EDJd=NuwZQ@mail.gmail.com' \
--to=bjourne@gmail.com \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.