all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Barry Margolin'" <barmar@alum.mit.edu>, <help-gnu-emacs@gnu.org>
Subject: RE: thing-at-point: inconsistent behaviour?
Date: Thu, 16 Aug 2012 21:38:38 -0700	[thread overview]
Message-ID: <EE76A13573714D9EBA876D4A8E29E432@us.oracle.com> (raw)
In-Reply-To: <barmar-787F27.21462616082012@news.eternal-september.org>

> > In the case of a symbol, IMO most programs really want/need 
> > to grab a symbol _name_, often for use as the default value
> > in an interactive spec.  Most do not really want/need a Lisp
> > symbol.  And even when they do, they can call `intern'
> > or `intern-soft' or `make-symbol' themselves.
> 
> Then they should call (thing-at-point 'symbol), not 
> (symbol-at-point).

Yes.

On the other hand, for many such use cases it is not very useful to obtain a
value of `nil' (a symbol, not a string) when there is no symbol name at point
(not even "nil").  Function `non-nil-symbol-name-at-point' returns "" in that
case.  It is, in effect, (or (thing-at-point 'symbol) "").
 
> It seems like this tangent is because someone thought that the
> latter should just be a shorthand for the former, but they do 
> different things and are intended for different situations.  If 
> symbol-at-point doesn't do what you want (e.g. it interns things
> when you would prefer it didn't), don't use it. No one's forcing
> you to.

Exactly.  And not just "someone" - such confusion does not seem that rare.

You might have come to understand that (thing-at-point 'symbol) returns a
string, and you correctly distinguish it from what `symbol-at-point' does, but
it is easy for others not to get this.

Especially since `thing-at-point' does NOT always return a string - it returns a
list for (thing-at-point 'list), for instance.  There is nothing in the name,
i.e., on the surface of it, that tells you that (thing-at-point 'symbol) returns
either a symbol name or the symbol `nil'.  It looks every bit like it might
return the thing at point that is a symbol.

This confusion wrt symbols is why it is helpful to provide a function that has
`symbol-name' and not just `symbol' in its name, the former doing, in effect,
what (or (thing-at-point 'symbol) "") does.

BTW, I don't think most use cases really care whether or not the name has been
interned.  What is more important usually is what kind of value is returned: a
symbol or a string (symbol name).

The other thing that can be important for some use cases is to distinguish the
absence of any symbol name at point from the presence of the symbol name "nil"
at point.  When picking up a symbol name to serve as a completion candidate for
some input, it is often the case that "nil" is not appropriate.

FWIW, this 2007 Emacs Devel thread discusses exactly what is being discussed in
the present thread, and a bit more:

http://lists.gnu.org/archive/html/emacs-devel/2007-07/msg01520.html




  reply	other threads:[~2012-08-17  4:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 18:08 thing-at-point: inconsistent behaviour? Raffaele Ricciardi
2012-08-15 18:34 ` Barry Margolin
2012-08-15 18:44   ` Drew Adams
2012-08-15 19:00   ` Raffaele Ricciardi
2012-08-16 11:52     ` Andreas Röhler
     [not found]     ` <mailman.7107.1345117968.855.help-gnu-emacs@gnu.org>
2012-08-16 15:48       ` Barry Margolin
2012-08-16 16:24         ` Andreas Röhler
     [not found]         ` <mailman.7114.1345134264.855.help-gnu-emacs@gnu.org>
2012-08-16 17:12           ` Raffaele Ricciardi
2012-08-16 23:19             ` Barry Margolin
2012-08-17  0:46             ` Drew Adams
     [not found]             ` <mailman.7128.1345164390.855.help-gnu-emacs@gnu.org>
2012-08-17  1:46               ` Barry Margolin
2012-08-17  4:38                 ` Drew Adams [this message]
     [not found]                 ` <mailman.7135.1345178331.855.help-gnu-emacs@gnu.org>
2012-08-17  9:23                   ` Raffaele Ricciardi
2012-08-20  0:15                     ` 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

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

  git send-email \
    --in-reply-to=EE76A13573714D9EBA876D4A8E29E432@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=barmar@alum.mit.edu \
    --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.