all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: npostavs@users.sourceforge.net
Cc: 24605@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
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)	[thread overview]
Message-ID: <alpine.DEB.2.20.1610051234150.7004@calancha-pc> (raw)
In-Reply-To: <877f9ny4sc.fsf@users.sourceforge.net>


Thank you for the e-mail.

On Tue, 4 Oct 2016, npostavs@users.sourceforge.net 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 <tino.calancha@gmail.com>
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)))

  ;;;###autoload
-- 
2.9.3

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






  reply	other threads:[~2016-10-05  3:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04  6:22 bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS Tino Calancha
2016-10-05  1:15 ` npostavs
2016-10-05  3:35   ` Tino Calancha [this message]
2016-10-05 11:50     ` Noam Postavsky
2016-10-05 12:30       ` Tino Calancha
2016-10-05 12:38         ` Tino Calancha
2016-10-05 13:09           ` Eli Zaretskii
2016-10-05 13:52             ` Tino Calancha
2016-10-05 15:59               ` Eli Zaretskii
2016-10-06  7:13 ` Andreas Röhler
2016-10-11  2:53 ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1610051234150.7004@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=24605@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.