Subject: Re: bug#12692: 24.1; thing-at-point in temp buffer

From: Glenn Morris <[email-masked]>
Date: Sat, 20 Oct 2012 22:05:13 -0400

tags 12692 notabug
close 12692
stop

Jerome Truong wrote:

> Why does the following return the whole string "this.is.an.example":
>
> (thing-at-point 'symbol)this.is.an.example
>                         ^
>                         |
>                 eval at point here
>
> but using a temp buffer only returns "this":
>
> (let ((type 'symbol)
>       (string "this.is.an.example"))
>   (with-temp-buffer
>     (insert string)
>     (goto-char 1)
>     (let ((thing (thing-at-point type)))
>       (message "%s" thing))))

Depends on the syntax table in use. Replace your second example with

(let ((type 'symbol)
      (string "this.is.an.example"))
  (with-temp-buffer
    (insert string)
    (goto-char 1)
    (with-syntax-table emacs-lisp-mode-syntax-table
      (let ((thing (thing-at-point type)))
        (message "%s" thing)))))

HTH; maybe try help-gnu-emacs first next time?