[erlang-bugs] erlang.el mis-indents whole-buffer selection
Sun Jun 29 18:47:19 CEST 2014
On Sun, Jun 29, 2014 at 4:10 PM, Magnus Henoch wrote:
> Magnus Henoch writes:
> > Tuncer Ayaz writes:
> > > Previously it was just a certain function in rebar.erl which
> > > got mis-indented when you did a whole-buffer indent, but now
> > > there's also a second 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?
> > >
> > >  https://github.com/rebar/rebar/blob/620c4b01c/src/rebar.erl#L318-L365
> > >  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 been 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 font-lock-syntactic-keywords in a modern Emacs gives:
> > This variable is obsolete since 24.1;
> > use `syntax-propertize-function' instead.
> > And the NEWS file for Emacs 24.1 contains:
> > *** New variable `syntax-propertize-function'.
> > This replaces `font-lock-syntactic-keywords' which is now
> > obsolete. This allows syntax-table properties to be set
> > independently from font-lock: just call syntax-propertize to
> > make sure the text is propertized. Together with this new
> > variable come a new hook
> > syntax-propertize-extend-region-functions, as well as two helper
> > functions: 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...
> While playing with the code, I realised that there's a much simpler
> 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
Nice, thanks Magnus!
Does the patch allow me to set (global-font-lock-mode 0) without
More information about the erlang-bugs