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#24627: 24.5; (thing-at-point 'list) may return a non-empty string without a list Date: Wed, 12 Oct 2016 13:58:03 +0900 Message-ID: <87r37mupt0.fsf@gmail.com> 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1476248379 22190 195.159.176.226 (12 Oct 2016 04:59:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2016 04:59:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 24627@debbugs.gnu.org To: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 12 06:59:30 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 1buBdP-0003JZ-5y for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 06:59:19 +0200 Original-Received: from localhost ([::1]:59261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBdN-0007NE-HI for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 00:59:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBdD-0007Kt-5W for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 00:59:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buBd8-000643-6a for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 00:59:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBd8-00063y-39 for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 00:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1buBd7-0000I9-OM for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2016 00:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Oct 2016 04:59: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.14762482981065 (code B ref 24627); Wed, 12 Oct 2016 04:59:01 +0000 Original-Received: (at 24627) by debbugs.gnu.org; 12 Oct 2016 04:58:18 +0000 Original-Received: from localhost ([127.0.0.1]:52618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buBcQ-0000H7-Aq for submit@debbugs.gnu.org; Wed, 12 Oct 2016 00:58:18 -0400 Original-Received: from mail-pf0-f178.google.com ([209.85.192.178]:35960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buBcP-0000Gu-6b for 24627@debbugs.gnu.org; Wed, 12 Oct 2016 00:58:17 -0400 Original-Received: by mail-pf0-f178.google.com with SMTP id e6so12704313pfk.3 for <24627@debbugs.gnu.org>; Tue, 11 Oct 2016 21:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:cc:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=pZ2ttU+hgIS/59Are0ts0RlxdBevmYuRKY9bJQ03Gbc=; b=t8VHM3O5XWzKKXMkxqJ/Xo/685NliBibzvK5O/TMSypLpSwvIM2Jcng0LCCfRYRZTG pJ6UAImRPo8qdAq9zbnCxnBmfxgLIGcXRe9SBphoYD2isu2FS83H2pjevSre1kZLY452 SEe6gq8u90z7dBK2T4uRr3hYxD3t4vyzc+oqpkMhnaebobxtjcO29WW2UZO4nGvxiwHd y3Hp6atCwAXZceHX+dql9YbVX2aVv4g8nNKIrtEaufwlZhJsBYnqxs8QNjX1Hz2bRR0f diLZemPJW31l+IGh6rPA43AAq+qvmO3ZwZjTLkTBlGLi5z2+3+w572+QNQsJ1sWiHc5j Ky8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:cc:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=pZ2ttU+hgIS/59Are0ts0RlxdBevmYuRKY9bJQ03Gbc=; b=ICX9l5tFyXb7PsX2iKNFNfdKPPld6ogp/P1jQXjE0/DnZS8FIovU8Ana9A9VFwiEQ0 qU4q6eAljchk28KqqtYTwUCYTo6LhbXzwiwwXvseabkh0LQ1Ro4ApXHlh72e/p+4/RH/ WZLpbLX+pT3f4fxFUsq2zw9n/Mho5180/+WWR74G9yw6i05GsASxg3ZacQ0goQtBnZ3J ZS3GXNf6yvT2mCqLli98PN05sdfKRtE4owxhCBNQCBBYn2aAG/Ics286UNebn2v/TK/F 45/zi8B6CrfzXYo3A5XRCuVsdscPLRRw2YkFprwhFQNgX+zS1rJJIE1FHsJl1X0VC5eO ZsTg== X-Gm-Message-State: AA6/9Rnw9m2fn5Inq9LUlhGRwvamEEMs0u1Zre2er68iphifhWg9NSEx2qtFfWbxJGA9FA== X-Received: by 10.99.124.72 with SMTP id l8mr6116715pgn.63.1476248291260; Tue, 11 Oct 2016 21:58:11 -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 z6sm8057615pay.31.2016.10.11.21.58.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Oct 2016 21:58:10 -0700 (PDT) In-Reply-To: <781dea94-9f15-8bd2-66f5-055b55497471@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6hler\=22's\?\= message of "Tue, 11 Oct 2016 20:40:12 +0200") 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:124375 Archived-At: Andreas R=C3=B6hler 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 =20 (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 (>=3D opoint (point)) - (cons opoint end)))))))) + (when beg + (forward-sexp) + (cons beg (point))))))) =20 ;; Defuns =20 --=20 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;; In GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1) of 2016-10-12 Repository revision: 9640e9f4e95cd95c04875e90a4ff638e1e51f977