summaryrefslogtreecommitdiff
path: root/lisp/thingatpt.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r--lisp/thingatpt.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index df5c52d4d61..6d1014bb92d 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -586,9 +586,11 @@ Signal an error if the entire string was not used."
"This is an internal thingatpt function and should not be used.")
(defun form-at-point (&optional thing pred)
- (let ((sexp (ignore-errors
- (thing-at-point--read-from-whole-string
- (thing-at-point (or thing 'sexp))))))
+ (let* ((obj (thing-at-point (or thing 'sexp)))
+ (sexp (if (stringp obj)
+ (ignore-errors
+ (thing-at-point--read-from-whole-string obj))
+ obj)))
(if (or (not pred) (funcall pred sexp)) sexp)))
;;;###autoload