unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: RE: `read--expression' and `read-minibuffer'
Date: Tue, 6 Sep 2016 20:01:45 -0700 (PDT)	[thread overview]
Message-ID: <91f3ab85-e033-4e1d-a3c2-66c964ea82bc@default> (raw)
In-Reply-To: <jwva8fkfuwr.fsf-monnier+Inbox@gnu.org>

I wasn't as clear as I should have been. 

> > That's not a real problem, but that's the only place/case where I
> > can see an argument for a "variant" behavior (completion against
> > both function and variable names at that position too).
> 
> For S-exps in general, we can't provide much completion, and we
> certainly shouldn't provide completion against function names and
> variable names.
> 
> An S-exp is like an XML tree.  An Elisp expression is like a XHTML tree
> (i.e. it's a particular kind of XML that is expected to follow
> a particular schema).  Yes, it's also an XML tree, but if all you know
> is that you're typing an XML tree, providing any completion based on
> XHTML identifiers is just bogus.

Your analogy is OK.  I wouldn't speak of an "Elisp expression" here,
since to me that just means any expression - sexp that you can
construct with Emacs Lisp.  But now I know what you mean.  It's not
about any intention to evaluate; your speaking of that was throwing
me off.

I was really asking only about getting the extra hyphen removed
from `read--expression'. ;-)  Use cases I have for it do involve
sometimes immediately evaluating the sexp read, but sometimes they
involve putting such sexps together to form larger sexps (which
sometimes might be evaluated at some point).

I don't have a problem with the completion that `read-expression'
provides, and in many such use cases the names to complete are
indeed names of program parts - in particular names of functions
and variables.  This, in spite of the fact that the sexps read
need not be evaluable without error.

For more general sexps - your XML (S-exp) level of generality,
there is completion against an obarray.  And in some intermediate
cases `dabbrev' completion (names from one or more buffers) can
be helpful.  When Elisp buffers are involved, it too can be about
reading bits of potential code.

In this thread I was really only talking about `read--expression'
and what it does.  What it does is useful also to ordinary Emacs
user-programmers, not just "internally".

> > The non-"internal" function `read-minibuffer' is not very
> > reasonable, and is essentially a vestige, at this point.
> 
> Ah, so that's your complaint.  Why don't you make a bug-report about
> that one, pointing out exactly what are its shortcomings.  But do
> remember: it's a function meant for S-exps, i.e. random data represented
> in a form suitable for the Lisp reader, with no assumption like an
> expectation that it be related to Elisp code.

See above.  Any Lisp sexp can be related to Elisp code.  Any data
can be a piece of some code.  But yes, I was interested here in
what `read--expression' does already.

> > We can do better, and better is already available:
> > `read--expression'.  Some such function should now be
> > available non-"internally".
> 
> Now I'm confused.  If you want a function to read an Elisp expression,
> indeed read--expression might be your solution.  Then make a bug report
> asking for it to be renamed.
> 
> > If you want to (1) rename the current `read--expression' to
> > `read-expression-for-eval' and (2) create a variant `read-expression'
> > (which is for both eval and not), please go ahead.
> 
> I have no idea what a "read-expression not for eval" would mean or look
> like.

It's what Davis was trying to distinguish `read--expression' as:
reading an expression "intended for evaluation" (paraphrasing).
Likewise, you.  You both tried to distinguish what it does as
reading an expression that might be evaluated (even though it can
also read expressions that cannot, without raising an error).

Creating variants of the behavior was his idea.  I'm fine with
the current behavior (which I don't associate directly with
evaluation, but which I recognize provides completion against
known functions and variables).

> `read--expression' already couldn't care less whether you'll
> pass the result to `eval' or not.

Thank you.  That's what I was saying.  It is you (and Davis) who
used "evaluation" to characterize it.

> All it cares about is that it provides useful
> behavior (eldoc, completion, indentation) under the assumption that the
> user is typing something that is (more or less) valid Elisp code, rather
> than random data.

Even that assumption is too strong (see above), but I don't know a
great way to characterize it.  I'd say that the completion against
existing function (after `(' ) and variable names sums it up, but
I don't have a name for that.  "Expression" doesn't say more than
"sexp", to me - it's just as general.

> > 1. That's not a good reason to make it "internal".
> 
> I already said that it's internal for no particular reason.

Not really.  You said that it's internal because it's easier to
later make a name non-internal than the reverse.  Which is true,
but which is not a great reason, in itself: it would apply to
every new function.

I submitted bug report #24386 to get rid of the "internal"
characterization.



  reply	other threads:[~2016-09-07  3:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03 18:20 `read--expression' and `read-minibuffer' Drew Adams
2016-09-04  4:40 ` Stefan Monnier
2016-09-04  5:53   ` Drew Adams
2016-09-04  6:27     ` Stefan Monnier
2016-09-04 15:39       ` Drew Adams
2016-09-05  2:36         ` Stefan Monnier
2016-09-06 19:02         ` Davis Herring
2016-09-06 20:29           ` Drew Adams
2016-09-07  0:04             ` Stefan Monnier
2016-09-07  3:01               ` Drew Adams [this message]
2016-09-07  3:46                 ` Stefan Monnier
2016-09-07  5:54                   ` Drew Adams
2016-09-07 12:12                     ` Stefan Monnier
2016-09-09 21:41                       ` Drew Adams
2016-09-07 13:25                     ` Herring, Davis
2016-09-07 16:02                       ` Drew Adams
2016-09-07 17:01                         ` Davis Herring
2016-09-07 21:01                           ` Drew Adams
2016-09-07 22:17               ` Michael Heerdegen
2016-09-07 22:30                 ` Stefan Monnier
2016-09-07 22:50                   ` Michael Heerdegen
2016-09-08  0:19                     ` Stefan Monnier
2016-09-06 21:05           ` Stefan Monnier
2016-09-06 21:35             ` Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=91f3ab85-e033-4e1d-a3c2-66c964ea82bc@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).