all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: command-separator char
Date: Tue, 23 Jun 2015 13:00:31 -0400	[thread overview]
Message-ID: <jwvk2uuz8hj.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: mailman.5495.1435067817.904.help-gnu-emacs@gnu.org

> 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"

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.

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, 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.


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


  parent reply	other threads:[~2015-06-23 17:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5354.1434868275.904.help-gnu-emacs@gnu.org>
2015-06-21 17:29 ` command-separator char Stefan Monnier
2015-06-21 18:18   ` Andreas Röhler
     [not found]   ` <mailman.5381.1434910741.904.help-gnu-emacs@gnu.org>
2015-06-22 20:00     ` Stefan Monnier
2015-06-23  6:19       ` Andreas Röhler
     [not found]       ` <mailman.5482.1435040400.904.help-gnu-emacs@gnu.org>
2015-06-23 12:45         ` Stefan Monnier
2015-06-23 13:56           ` Andreas Röhler
     [not found]           ` <mailman.5495.1435067817.904.help-gnu-emacs@gnu.org>
2015-06-23 17:00             ` Stefan Monnier [this message]
2015-06-23 18:43               ` Andreas Röhler
     [not found]               ` <mailman.5516.1435085009.904.help-gnu-emacs@gnu.org>
2015-06-23 19:33                 ` Stefan Monnier
2015-06-24  5:47                   ` Andreas Röhler
     [not found]                   ` <mailman.5548.1435124835.904.help-gnu-emacs@gnu.org>
2015-06-24 14:32                     ` Stefan Monnier
2015-06-22 20:47 ` Emanuel Berg
2015-06-21  6:31 Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk2uuz8hj.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.