[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS

From: Tino Calancha
Subject: bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS
Date: Wed, 5 Oct 2016 12:35:45 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

Thank you for the e-mail.

On Tue, 4 Oct 2016, address@hidden wrote:

Well, it looks like `form-at-point' was assumed to be used only for
implementing the foo-at-point functions, (form-at-point 'sexp 'numberp)
does work fine for this.  But we may as well let (form-at-point 'number)
work too, since it's the more obvious way to call it.

In my case i use lib thingatpt+, so i have:
(get 'list 'thing-at-point)
=> tap-list-at-point

That causes `list-at-point' always fails regardless on where
it is the point, for the same reason: `tap-list-at-point' returns
a cons not an string.

I suggest keeping the `ignore-errors' strictly around the
`thing-at-point--read-from-whole-string' call.

Ok, corrected the patch:

From ea4c09df929451f4268ea4d608ee11bb4249854f Mon Sep 17 00:00:00 2001
From: Tino Calancha <address@hidden>
Date: Wed, 5 Oct 2016 12:25:07 +0900
Subject: [PATCH] form-at-point work for all kind of THINGS

* 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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index df5c52d..6d1014b 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -586,9 +586,11 @@ 'read-from-whole-string
   "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)))


In GNU Emacs (x86_64-pc-linux-gnu, GTK+ Version 3.22.0)
 of 2016-10-04 built on calancha-pc
Repository revision: e2913dc880b9843bf69cf885270551bafeb46120

reply via email to

[Prev in Thread] Current Thread [Next in Thread]