Function: thing-at-point

thing-at-point is an autoloaded and byte-compiled function defined in thingatpt.el.gz.

Signature

(thing-at-point THING &optional NO-PROPERTIES)

Documentation

Return the THING at point.

THING should be a symbol specifying a type of syntactic entity. Possibilities include symbol, list, sexp, defun, filename, existing-filename, url, email, uuid, word, sentence, whitespace, line, number, face and page.

When the optional argument NO-PROPERTIES is non-nil, strip text properties from the return value.

See the file thingatpt.el for documentation on how to define a symbol as a valid THING.

View in manual

Probably introduced at or before Emacs version 20.1.

Source Code

;; Defined in /usr/src/emacs/lisp/thingatpt.el.gz
;;;###autoload
(defun thing-at-point (thing &optional no-properties)
  "Return the THING at point.
THING should be a symbol specifying a type of syntactic entity.
Possibilities include `symbol', `list', `sexp', `defun',
`filename', `existing-filename', `url', `email', `uuid', `word',
`sentence', `whitespace', `line', `number', `face' and `page'.

When the optional argument NO-PROPERTIES is non-nil,
strip text properties from the return value.

See the file `thingatpt.el' for documentation on how to define
a symbol as a valid THING."
  (let ((text
         (cond
          ((let ((alist thing-at-point-provider-alist)
                 elt result)
             (while (and alist (null result))
               (setq elt (car alist)
                     alist (cdr alist))
               (and (eq (car elt) thing)
                    (setq result (funcall (cdr elt)))))
             result))
          ((get thing 'thing-at-point)
           (funcall (get thing 'thing-at-point)))
          (t
           (let ((bounds (bounds-of-thing-at-point thing)))
             (when bounds
               (buffer-substring (car bounds) (cdr bounds))))))))
    (when (and text no-properties (sequencep text))
      (set-text-properties 0 (length text) nil text))
    text))