From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs 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) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1168939412-1475562161=:19326" X-Trace: blaine.gmane.org 1475562217 25310 195.159.176.226 (4 Oct 2016 06:23:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Oct 2016 06:23:37 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Tino Calancha To: 24605@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 04 08:23:34 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brJ8G-0003yC-QS for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Oct 2016 08:23:17 +0200 Original-Received: from localhost ([::1]:40377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ8F-00068f-EG for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Oct 2016 02:23:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ88-00068O-MV for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:23:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brJ82-000128-My for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:23:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ82-00011x-In for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1brJ82-00087Y-E0 for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Oct 2016 06:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24605 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.147556217831190 (code B ref -1); Tue, 04 Oct 2016 06:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Oct 2016 06:22:58 +0000 Original-Received: from localhost ([127.0.0.1]:43642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brJ7y-00086z-EI for submit@debbugs.gnu.org; Tue, 04 Oct 2016 02:22:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51161) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brJ7w-00086k-DV for submit@debbugs.gnu.org; Tue, 04 Oct 2016 02:22:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brJ7q-0000oC-2M for submit@debbugs.gnu.org; Tue, 04 Oct 2016 02:22:50 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:52298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ7p-0000mN-W1 for submit@debbugs.gnu.org; Tue, 04 Oct 2016 02:22:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ7n-00066b-Kx for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:22:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brJ7i-0000gK-LF for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:22:47 -0400 Original-Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]:36827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJ7i-0000fn-F2 for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 02:22:42 -0400 Original-Received: by mail-pa0-x242.google.com with SMTP id cd13so7657174pac.3 for ; Mon, 03 Oct 2016 23:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=xf4JOot9+RnU+IgM/5sBcDuWmvMruPcv7wSHbdM+0VY=; b=C4n0fqWhHpzMe/HlhtHSfjuoYLMOkqRm6QTXVUXTEuuMld7DRFbGcFtVn0j4HjnMrW 5d808tUY1GRbIFie0utGJWKqwCZujYnwyylytzSzOo446J71KCkirASPmrTKGBegIZwF adI2tInAbX5LE0YT7MUfy0w5iw+gscwiGFEpRbXx3oFXr1UKqYVKw8nXHXqwp72MVzo5 ne8eNvpjc9AAvyrTlnkXr4BcJAhvoToLhP3/twaaDi44UvZQWWZHMxPHMilN734V7oyK db7OyWrbfhAImAGi91XBE73xSexDK7L/nJmbqVGcAZHcncPmsM4MQ8lZxgFFkU87Tl7P b8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:message-id:user-agent :mime-version; bh=xf4JOot9+RnU+IgM/5sBcDuWmvMruPcv7wSHbdM+0VY=; b=V6xLrHtHQXSbETfbYb3Fv4fpy+mY3dFMdLki2hsLrXmkLc+jpd0wbq+LNjeTA9m81f FK5xfLMX1p4IRhzjML92Dlrnn3JoxuAx8inEy9zwQGtvetbYJBjII8h5v4o+JvPtOgMF gnnRwxABsVhhCEutZ3aKld6hPDRmxQT0Hx2m6II52l5esDcw74TTsu62Ww+7Ipq8qH78 GvicaI6T84dXvYsJrnYaFvEIoM40JqUCnNAO73VdkfX2dtWDvukj1d75traYg7EpOLis ukwfpIVteY7+0z4H6PS1qkFdNANXjzaY0ELK2ChdWKK9Nmbc65hcG/3RyGbHQ+9vzxeP nz5Q== X-Gm-Message-State: AA6/9RkL4O2Sji5zT1+pG4J1ddWI6uZXAM3JfPE3vBQ09NfYqIFpir3i7cHlEO9RHFw0HA== X-Received: by 10.66.132.79 with SMTP id os15mr2800917pab.84.1475562161579; Mon, 03 Oct 2016 23:22:41 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id l3sm40910434pfl.75.2016.10.03.23.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2016 23:22:41 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:124009 Archived-At: --8323329-1168939412-1475562161=:19326 Content-Type: text/plain; format=flowed; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT 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 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 --8323329-1168939412-1475562161=:19326--