]> git.eshelyaron.com Git - emacs.git/commitdiff
form-at-point work for all kind of THINGS
authorTino Calancha <tino.calancha@gmail.com>
Tue, 11 Oct 2016 02:47:32 +0000 (11:47 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Tue, 11 Oct 2016 02:47:32 +0000 (11:47 +0900)
* lisp/thingatpt.el (form-at-point):
Use thing-at-point--read-from-whole-string only if thing-at-point
returns a string (Bug#24605).

lisp/thingatpt.el

index df5c52d4d618a9b6351fa121694a0244085e9a48..6d1014bb92d087aa7f717988be3c1f08126b70aa 100644 (file)
@@ -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