From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: thing-at-point: inconsistent behaviour? Date: Sun, 19 Aug 2012 17:15:15 -0700 Message-ID: <4D47EAF5678D42D1944AA2A2D49F3290@us.oracle.com> References: 14343615082012@@ews.eternal-sepppppppppppp NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1345421746 21643 80.91.229.3 (20 Aug 2012 00:15:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2012 00:15:46 +0000 (UTC) To: "'Raffaele Ricciardi'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 20 02:15:46 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T3Fei-00021v-92 for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Aug 2012 02:15:44 +0200 Original-Received: from localhost ([::1]:37396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3Feg-0005vl-GU for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Aug 2012 20:15:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3Feb-0005vX-3P for help-gnu-emacs@gnu.org; Sun, 19 Aug 2012 20:15:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3FeZ-0006Rq-Or for help-gnu-emacs@gnu.org; Sun, 19 Aug 2012 20:15:37 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:49619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3FeZ-0006Qy-Hh for help-gnu-emacs@gnu.org; Sun, 19 Aug 2012 20:15:35 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q7K0FXk1014828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Aug 2012 00:15:33 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q7K0FVtF012466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 20 Aug 2012 00:15:31 GMT Original-Received: from abhmt113.oracle.com (abhmt113.oracle.com [141.146.116.65]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q7K0FVIZ013029; Sun, 19 Aug 2012 19:15:31 -0500 Original-Received: from dradamslap1 (/10.159.171.244) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 19 Aug 2012 17:15:30 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Ac18WjO0a4blefJWTaiEdAbyWP2RYQCBUBSw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 148.87.113.117 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86426 Archived-At: > > Especially since `thing-at-point' does NOT always return a string - > > it returns a list for (thing-at-point 'list), for instance. > > On my GNU Emacs 24.1, `thing-at-point' always returns a (propertized) > string, including when used with 'list. Yes, my bad about that one. I think my point there was (or should have been) that vanilla `thing-at-point' can return anything at all. You cannot depend on it to return a string or nil. The version in `thingatpt+.el' ensures that the function returns a string or nil, but the vanilla version does not. This is because the vanilla version just returns whatever the function that is the value of (get THING 'thing-at-point) returns (if that property is non-nil). It does not convert that (if non-nil) to a string. Since it is user-developers who put that property on THING symbols, they can use whatever function they like, returning anything they like. It is unfortunate that the terminology and function names suggest that any kind of Lisp object (any THING) is returned by `thing-at-point', whereas its mission, according to the doc (but not actually enforced) is to return only a string (or nil). It is really about giving you a buffer substring that _represents_ a Lisp object (e.g. a list or a symbol). It is all the more confusing because `thingatpt.el' also defines other functions, such as `sexp-at-point', `symbol-at-point', `number-at-point', and `list-at-point', which _do_ return Lisp objects. It is further confusing because the function used to do that is `form-at-point'. The Elisp manual gives "form" as "a Lisp object that is intended for evaluation." So user-developers should think to use `form-at-point' and not `thing-at-point' if they want to return a Lisp object. The difference is that `form-at-point' reads the string returned by `thing-at-point', to obtain a Lisp object. Function `thing-at-point' is about source-code representations of Lisp things. Function `form-at-point' is about Lisp things. And because it is so easy to just put a function on a symbol as property `thing-at-point', users can wind up with perfectly workable calls to `thing-at-point' which do just what they want but which do not, as the doc says, return a string (or nil). There are thus a few things to keep straight, starting with (1) the difference between (thing-at-point 'symbol), which returns a symbol name and not a symbol (likewise, for other THINGs - lists etc.), and ending with (2) the difference between `thing-at-point' and `form-at-point' and (3) the caveat that `thing-at-point' (a) is not intended to do what its name suggests (return a Lisp THING) and (b) is not guaranteed to do what its doc says (return a string representing a Lisp THING, or nil).