From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#24627: 24.5; (thing-at-point 'list) may return a non-empty string without a list Date: Wed, 12 Oct 2016 09:10:42 +0200 Message-ID: References: <48df5626-be32-ffb0-55f5-1b6f116a6940@easy-emacs.de> <87fuo3r1p0.fsf@gmail.com> <08d6c55e-f060-fabc-5657-2e80a1d06ab0@easy-emacs.de> <878ttu97e3.fsf@gmail.com> <781dea94-9f15-8bd2-66f5-055b55497471@easy-emacs.de> <87r37mupt0.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1476255862 27410 195.159.176.226 (12 Oct 2016 07:04:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2016 07:04:22 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Icedove/45.4.0 Cc: 24627@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 12 09:04:18 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 1buDaK-0006cx-Q7 for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 09:04:17 +0200 Original-Received: from localhost ([::1]:59599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buDaJ-0000Uq-Ee for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 03:04:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buDa9-0000Tl-8Z for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 03:04:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buDa6-0005mc-2k for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 03:04:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buDa5-0005mW-Vh for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 03:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1buDa5-0003KG-Mg for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 03:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Oct 2016 07:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24627 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24627-submit@debbugs.gnu.org id=B24627.147625579712729 (code B ref 24627); Wed, 12 Oct 2016 07:04:01 +0000 Original-Received: (at 24627) by debbugs.gnu.org; 12 Oct 2016 07:03:17 +0000 Original-Received: from localhost ([127.0.0.1]:52660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buDZM-0003JE-Q8 for submit@debbugs.gnu.org; Wed, 12 Oct 2016 03:03:16 -0400 Original-Received: from mout.kundenserver.de ([217.72.192.74]:50367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buDZI-0003Ix-Sm for 24627@debbugs.gnu.org; Wed, 12 Oct 2016 03:03:15 -0400 Original-Received: from [192.168.178.35] ([77.12.110.26]) by mrelayeu.kundenserver.de (mreue104) with ESMTPSA (Nemesis) id 0MAuhQ-1bkHvy0XEy-00A0Jb; Wed, 12 Oct 2016 09:03:06 +0200 In-Reply-To: <87r37mupt0.fsf@gmail.com> X-Provags-ID: V03:K0:5L0gbUjONshu7BPHjn3lb5eksTeBHtrQaQHt2UAfYMBMj/M/hB1 j7fXPmtkUirhxpRGiYGmX1J43CiG64jdwOqfRIdeilg+fZ50ROT6oDI056seJc+zEB4W5A2 EG8KtX5qcjoMJUT8Y8c8vffEm0RdW1WgcUT8qmlmybObzsuPxRxg+gR9zBdECZUUoV/bG7D XP2OMwyr7Zg3t2eOYluaA== X-UI-Out-Filterresults: notjunk:1;V01:K0:udoZiQbxaS0=:vBE87xaoKNQbGtKE9w+iBl Hxe5faeJPNxX/RfA15jMuHExn5y2H30h6dNAJYmCT2jNt57359NO8MvihPper8QtVRmgmVaHa MVg//ZTtCrUIc20ox09Z4lHJJKoKUEmkHgtDO/AA/u0ndW1pt5rzcLgAcD1urlVDCj5+YckzG wcQQsGQ5JcnavJsOtP4Jg46LNUNsgigeJCWStyMulAlm5+mqua0PF7Y06xkjK5xBDyCXKfyrz cU7qgsiX+37Ws11SjIxJYdcqTzn8Y6wZjLnqeVqpNB30AvS/j30pYAPc8WEFsih34flpfMoZG syVSvGBFdmf/RFg13c+QD06EFumjbZ2YznUgslV8rCs8Z6bOpVDJ1cCAvEm7wzfOw+WaQYL11 +yUCjapDdrvZ5E023t7MPw2JmKPJyK4x04XRyjaTBXD1VSQ+tfui9/LjxNmfIqcLxfMfVcTHy hOrlQwC3p7cNYu1EUqvShBWJ0n+7YKWntgd208rYwCGp06raW0GUZoA2UjkXN7IAtd5mMzq4S jIwHtWi5/NYK8CWdXFnV3SQbpEDAAyDwP2loxxWfdy8Tfg0SsPzs93YZjHXXfkhdKuBCWLgEK hZZVQcY5myPhWZGd8eDpeMO/ByPZ1lP5oM9qfZKIDFdrS/hbfkbcKI+MjzkvpzPMZaL9BfXd3 Ki5+OgLBJ48Rn55JDL5WsKkAwzkaKmR/5NpbWWQPMe1ERPrfprajYTGdDkkdwhpdZ0vKyBKcG x1Tqdl1wm4+QQwTa 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:124378 Archived-At: On 12.10.2016 06:58, Tino Calancha wrote: > Andreas Röhler writes: > >> Hmm, what if cursor is inside a string or comment? > The list will be returned anyway as thingatpt always does. > AFAICT, skipping lists inside comments/strings would be a new feature > for this lib: better request that in a separated bug report. > > >> BTW "list" might be more universal if understood syntactically >> What about writing >> >> (eq 4 (car (syntax-after (point)))) > Agreed. Thank you! > Here is the new patch: > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > From 71da9ad4f6bbc307c5fb3f8bd0c6621312b2d4f4 Mon Sep 17 00:00:00 2001 > From: Tino Calancha > Date: Wed, 12 Oct 2016 13:49:32 +0900 > Subject: [PATCH] (thing-at-point 'list) return nil if no list at point > > * lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point): > Check first if we are at the beginning of a top-level sexp (Bug#24627). > Escape '[' in doc string. > --- > lisp/thingatpt.el | 22 +++++++++------------- > 1 file changed, 9 insertions(+), 13 deletions(-) > > diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el > index 6d1014b..421dcde 100644 > --- a/lisp/thingatpt.el > +++ b/lisp/thingatpt.el > @@ -219,22 +219,18 @@ 'beginning-of-sexp > > (defun thing-at-point-bounds-of-list-at-point () > "Return the bounds of the list at point. > -[Internal function used by `bounds-of-thing-at-point'.]" > +\[Internal function used by `bounds-of-thing-at-point'.]" > (save-excursion > (let ((opoint (point)) > - (beg (ignore-errors > - (up-list -1) > - (point)))) > + (beg (if (eq 4 (car (syntax-after (point)))) > + (point) > + (ignore-errors > + (up-list -1) > + (point))))) > (ignore-errors > - (if beg > - (progn (forward-sexp) > - (cons beg (point))) > - ;; Are we are at the beginning of a top-level sexp? > - (forward-sexp) > - (let ((end (point))) > - (backward-sexp) > - (if (>= opoint (point)) > - (cons opoint end)))))))) > + (when beg > + (forward-sexp) > + (cons beg (point))))))) > > ;; Defuns > beg still needs a check like (not (nth 8 (parse-partial-sexp (point-min) (point)))) otherwise it could match inside a string or comment