[erlang-questions] literal character syntax

Magnus Henoch magnus@REDACTED
Tue May 20 16:08:24 CEST 2014


zxq9 <zxq9@REDACTED> writes:

> On Thursday 15 May 2014 12:36:43 you wrote:
>> $ gg -i "stupid emacs" -- \*.erl
>> lib/compiler/src/cerl.erl:994:    io_lib:write_string(atom_name(Node), $').
>> %' stupid Emacs. lib/compiler/src/core_scan.erl:96:string_thing($') ->
>> "atom";    %' stupid emacs
>> lib/compiler/src/core_scan.erl:97:string_thing($") -> "string".  %" stupid
>> emacs
>> lib/dialyzer/test/opaque_SUITE_data/src/modules/opaque_erl_scan.erl:313:str
>> ing_thing($') -> "atom";   %' Stupid Emacs
>> lib/dialyzer/test/options1_SUITE_data/src/compiler/cerl.erl:843:   
>> io_lib:write_string(atom_name(Node), $'). %' stupi
>> lib/edoc/src/edoc_wiki.erl:238:expand_triple([$', $', $' | Cs], L, As, _L0)
>> ->      % ' stupid emacs lib/hipe/cerl/erl_types.erl:4798:        true ->
>> io_lib:write_string(atom_to_list(X), $'); % stupid emacs '
>> lib/stdlib/src/erl_scan.erl:331:string_thing($') -> "atom";   %' Stupid
>> Emacs lib/syntax_tools/src/erl_prettypr.erl:1011:              
>> lay_string_1([$" | S2], L - W + 1, W))  %" stupid emacs
>
> Some work in the emacs mode calling?

Most of these issues are fixed in the current version of erlang.el.
While looking through the Erlang/OTP sources, I found only two instances
of code with character literals that erlang-mode doesn't highlight
correctly.  From lib/compiler/src/core_scan.erl:

pre_scan($', Cs, SoFar, Pos) ->
    pre_string(Cs, $', '\'', Pos, [$'|SoFar], Pos);
pre_scan({'\'',Sp}, Cs, SoFar, Pos) ->		%Re-entering quoted atom
    pre_string(Cs, $', '\'', Sp, SoFar, Pos);
pre_scan($", Cs, SoFar, Pos) ->
    pre_string(Cs, $", '"', Pos, [$"|SoFar], Pos);

And from lib/gs/src/gstk_editor.erl:

p_index({Line, lineend}) -> [$",gstk:to_ascii(Line), ".1 lineend",$"];

It appears that it gets confused when there is a string or a quoted atom
earlier on the line.  This follows from the regexps used for
font-lock-syntactic-keywords in erlang.el.  They attempt to "disable"
the escaping function of the dollar sign when it is inside a string, but
do so somewhat naïvely.

Regards,
Magnus



More information about the erlang-questions mailing list