From: Tino Calancha <tino.calancha@gmail.com>
To: 24605@debbugs.gnu.org
Cc: Tino Calancha <tino.calancha@gmail.com>
Subject: bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS
Date: Tue, 4 Oct 2016 15:22:39 +0900 (JST) [thread overview]
Message-ID: <alpine.DEB.2.20.1610041521480.19326@calancha-pc> (raw)
[-- Attachment #1: Type: text/plain, Size: 2532 bytes --]
Because `thing-at-point' doesn't return always a string, as
`form-at-point' currently assumes. It might return a different
type depending on what you have in
(get thing 'thing-at-point)
emacs -Q:
(with-temp-buffer
(require 'thingatpt)
(insert "1")
(let ((res
(cond ((and (number-at-point)
(form-at-point 'number)) 0)
((and (number-at-point)
(not (form-at-point 'number))) -1)
((and (not (number-at-point))
(form-at-point 'number)) -2)
((and (not (number-at-point))
(not (form-at-point 'number))) -3))))
(pcase res
('0 (message "OK, both 'number-at-point and 'form-at-point successfull"))
(-1 (message "'number-at-point' works but (form-at-point 'number) fails"))
(-2 (message "(form-at-point 'number) works but 'number-at-point' fails"))
(-3 (message "Both 'number-at-point' and (form-at-point 'number) fails")))))
=> "’number-at-point’ works but (form-at-point ’number) fails"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From d587d00fc1379b8bd2511d5491c0c664669fef87 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Tue, 4 Oct 2016 14:48:36 +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..304df7b 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 (ignore-errors
+ (if (stringp obj)
+ (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: 74b4f13842f3119f98797ea76d9be42457b330e1
next reply other threads:[~2016-10-04 6:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-04 6:22 Tino Calancha [this message]
2016-10-05 1:15 ` bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS npostavs
2016-10-05 3:35 ` Tino Calancha
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
List information: https://www.gnu.org/software/emacs/
* 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.1610041521480.19326@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=24605@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).