GNU bug report logs -
#16116
24.3.50; smie-indent-close aligns inner closing paren with the outer opening paren
Previous Next
Reported by: Dmitry Gutov <dgutov <at> yandex.ru>
Date: Thu, 12 Dec 2013 01:58:02 UTC
Severity: minor
Tags: patch
Found in version 24.3.50
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 15.12.2013 03:50, Stefan Monnier wrote:
>> I believe this argument also works against doing it in the rules
>> function, and in favor of adding a defvar.
>
> I don't think so: setting the var is a one-liner, adding the rule to the
> rule-function is also a one-liner. So either way is just as easy for
> the major-mode.
I mean in terms of code reuse: the rules function is also specific to a
major mode. The rule itself doesn't look like it'll take just one line
to me, AFAICS it'll have to duplicate most of the code in
`smie-indent-close':
(`(:before . ,(or `")" `"]" `"}"))
(save-excursion
(forward-char 1)
(condition-case nil
(progn
(backward-sexp 1)
(cons 'column . (smie-indent-virtual)))
(scan-error nil))))
If any other major mode wants to do the same, they have to duplicate
this, or extract this code to a helper function in smie.el.
Using the rules function will also add 2-3 lines to `smie-indent-close'.
> By contrast, setting smie-indent-functions buffer-locally, then
> removing smie-indent-close from it and adding some other function
> requires a lot more code, and a lot more brittle as well (the ordering
> in smie-indent-functions is important, the set of functions in there and
> their order is not guaranteed to stay unchanged in future versions, the
> replacement function needs to be written (delegating to
> smie-indent-close seems like it might not work), ...
Looks like three lines to me. :)
(setq-local smie-indent-functions (copy-sequence smie-indent-functions))
(setcar (memq 'smie-indent-close smie-indent-functions)
'ruby--smie-indent-close)
And the replacement function wouldn't be much longer than the added rule.
This bug report was last modified 11 years and 154 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.