unknown
2014-06-29 14:10:15 UTC
Previously it was just a certain[1] function in rebar.erl which got
mis-indented when you did a whole-buffer indent, but now there's also
a second[2] function which gets mis-indented.
In both cases indenting the function itself separately works, and the
bug happens if you select the whole buffer and indent that with
erlang.el (C-x C-q).
I'm using Emacs 24.3.1 with latest erlang.el from maint.
Is it possible to fix this in the existing indenter?
[1] https://github.com/rebar/rebar/blob/620c4b01c/src/rebar.erl#L318-L365
[2] https://github.com/rebar/rebar/blob/620c4b01c/src/rebar_erlc_compiler.erl#L92-L112
It seems like this happens when the code being indented has not yet beenmis-indented when you did a whole-buffer indent, but now there's also
a second[2] function which gets mis-indented.
In both cases indenting the function itself separately works, and the
bug happens if you select the whole buffer and indent that with
erlang.el (C-x C-q).
I'm using Emacs 24.3.1 with latest erlang.el from maint.
Is it possible to fix this in the existing indenter?
[1] https://github.com/rebar/rebar/blob/620c4b01c/src/rebar.erl#L318-L365
[2] https://github.com/rebar/rebar/blob/620c4b01c/src/rebar_erlc_compiler.erl#L92-L112
made visible, and thus lazy syntax highlighting has not yet happened.
The syntax table for erlang-mode is unable to handle some combinations
of characters; in particular, when a string ends with a dollar sign (as
in "foo$"), the dollar sign plus the double quote would be treated as a
character constant were it not for some magic regexps in
font-lock-syntactic-keywords. Manually scrolling through the buffer
before reindenting seems to make the problem go away.
This is less than satisfactory, of course. Looking up online help for
This variable is obsolete since 24.1;
use `syntax-propertize-function' instead.
*** New variable `syntax-propertize-function'.
This replaces `font-lock-syntactic-keywords' which is now obsolete.
just call syntax-propertize to make sure the text is propertized.
Together with this new variable come a new hook
syntax-propertize-via-font-lock to reuse old font-lock-syntactic-keywords
as-is; and syntax-propertize-rules which provides a new way to specify
syntactic rules.
This sounds like the right way to solve the problem, though of course
you won't know until you try...
solution: explicitly run syntax highlighting before indenting; that way
all syntax properties will be set.
git fetch git://github.com/legoscia/otp.git fontify-before-indentation
https://github.com/legoscia/otp/compare/fontify-before-indentation
Regards,
Magnus