help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: command-separator char


From: Andreas Röhler
Subject: Re: command-separator char
Date: Tue, 23 Jun 2015 20:43:13 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


Am 23.06.2015 um 19:00 schrieb Stefan Monnier:
Seems still no idea or definition what a sexp should be.
Nope.  It's only a UI issue.

Sexp navigation is basically navigation within the AST, but a given
buffer position corresponds to several different spots in the AST, so
there's an ambiguity.  Take your example line:

     echo "foo"; echo "asdf";

the AST looks like

            echo
          /
      cmd
     /    \
    /       "foo"
   ;
    \       echo
     \     /
       cmd
          \
            "asdf"

Thanks a lot for your care!

The position at BOL can be take to be right before the "echo" node, or
right before the first "cmd" node or right before the toplevel composite
instruction that comprises the whole line.

You can mostly tell SMIE which one you want if you call smie-forward-sexp,
by passing it a token explaining the level you care about.

But forward-sexp is called by the user without any extra info, so it has
to make an arbitrary choice.  For compatibility with the usual
forward-sexp semantics, the choice it makes is to consider the "deepest"
position in the tree.

That would be plausible. Unfortunatly can't see that.
From end of first string jumps into second string. While there is an expression of three minor expressions:

echo _ "foo"_ ;

WRT to deepest it should keep the level and end after ";"


But as explained earlier, if you put point *before* a semi-colon, and then use
M-C-f, then SMIE's forward-sexp will take this as a clue that you want
to skip over whatever belongs to the right-hand of this semi-colon.
So with point right after "foo", C-M-f will jump to right after "asdf".

Along the same lines, you say:

   With cursor inside first string --> end of first string

meaning that this is inconsistent,

No, didn't say that. That behaviour is expected - inconsistence was shown by the relation of examples.


but it's perfectly consistent, since
forward-sexp does not jump to "the end of the currently enclosing
entity" but instead to "the end of the entity that starts right after
point".

SMIE's forward-sexp could very well check syntax-ppss to see we're
inside a string (or comment) and move outside of that string, but then
it would be a different command.


IMHO a much more usefull one :)


         Stefan


PS: That doesn't mean that it always works right either, of course.
M-C-f with point right after the second "o" of "foo" (i.e. right before
the closing double quotes) should signal an error

Think navigation shouldn't signal an error. Rather return nil - as at EOB.


but will instead jump
to right after the opening double quotes of "asdf".
PPS: And `up-list' doesn't use SMIE quite right either.

IMO grammar oriented commands are needed - starting with token maybe.

Languages commonly know expressions, compositions of them - and so upwards.

Thanks,

Andreas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]