[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [COMMITED] etc/poke-mode.el: add experimental SMIE-based indent
From: |
Jose E. Marchesi |
Subject: |
Re: [COMMITED] etc/poke-mode.el: add experimental SMIE-based indent |
Date: |
Tue, 15 Sep 2020 13:42:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Aurelien.
> Got some help from Stephan Monier (SMIE author) to get something
> started but this is still mostly gibberish to me.
>
> Basic indentation is sort of working but sadly it often doesn't do
> what one would expect...
Looks like a nice start, thanks for working on this :)
We could focus first on getting expressions working (including
parenthesized expressions) and also assignment and compound
statements...
I think we will have to make the lexer more smart as well. I had to do
things like this while writing a68-mode.el:
(generator-1 ("[" unit ":" unit "]" mode))
(generator-2 ("[" unit ":" unit "]-gen" "[-gen" unit ":" unit "]" mode))
(generator-3 ("[" unit ":" unit "]-gen" "[-gen" unit ":" unit "]-gen" "[-gen"
unit ":" unit "]" mode))
i.e. I had to discriminate between "]" and "]-gen" tokens, because "]"
cannot be both a terminator token and a middle token.
The lexer takes care of determining the right context:
(defun a68-mode-smie-forward-token ()
(let ((case-fold-search nil)
(token (smie-default-forward-token)))
(cond
[...]
;; Detect ]-gen
((and (or (equal token "") (not token)) (looking-at "\\]"))
(if (looking-at "\\][ \t\n]*\\[")
(progn
(forward-char 1)
"]-gen")))
[...]
)