Subject: Re: bug#21391: 24.5; `thing-at-point' should return a string

From: Andreas Röhler <[email-masked]>
Date: Tue, 15 Nov 2016 08:18:47 +0100

On 14.11.2016 16:36, Eli Zaretskii wrote:
>> From: Andreas Röhler <[email-masked]>
>> Date: Mon, 14 Nov 2016 11:26:54 +0100
>>
>> IMHO the current design is really confusing and shouldn't be kept.
> IMNSHO it would be madness to make incompatible changes 20 years after
> the code was admitted into Emacs.
>
>> if (get thing 'thing-at-point)
>>                (funcall (get thing 'thing-at-point))
>>
>> AFAIU an arbitrary function might  be stored here, no real relation to
>> thing-at-point at all.
> Correct.  We have gobs of functions that can return several different
> kinds of objects.
>
>> Next clause deals with buffer-substring - which is thing-at-point about
>> in my understanding.
> IMO, your understanding is wrong at least since 1997.

So lets have closer a look at thing-at-point, which under the hood is 
called also by list-at-point, form-at-point:

((text
          (if (get thing 'thing-at-point)
              (funcall (get thing 'thing-at-point))
            (let ((bounds (bounds-of-thing-at-point thing)))
              (when bounds
                (buffer-substring (car bounds) (cdr bounds)))))))

The second clause returns a string. All further deals with this 
string-var text AFAICS.
That's why I'm calling the string the native return type here.

The first clause was discussed above. Seeing just one use-case for now:

(put 'email 'thing-at-point
      (lambda ()
        (let ((boundary-pair (bounds-of-thing-at-point 'email)))
          (if boundary-pair
              (buffer-substring-no-properties
               (car boundary-pair) (cdr boundary-pair))))))

However, also returning a string. And definitely dressed up from behind.