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 01:29:08 +0900 Message-ID: <878ttu97e3.fsf@gmail.com> References: <48df5626-be32-ffb0-55f5-1b6f116a6940@easy-emacs.de> <87fuo3r1p0.fsf@gmail.com> <08d6c55e-f060-fabc-5657-2e80a1d06ab0@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 1476203449 17244 195.159.176.226 (11 Oct 2016 16:30:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Oct 2016 16:30:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 24627@debbugs.gnu.org, tino.calancha@gmail.com To: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 11 18:30:45 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 1btzwY-0001mh-GY for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Oct 2016 18:30:18 +0200 Original-Received: from localhost ([::1]:56917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzwX-0002vx-6o for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Oct 2016 12:30:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzwO-0002rd-CP for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 12:30:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btzwJ-0006Fr-Dt for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 12:30:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzwJ-0006Fj-AZ for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 12:30:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1btzwJ-00069H-5K for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2016 12:30:03 -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, 11 Oct 2016 16:30:03 +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.147620336523557 (code B ref 24627); Tue, 11 Oct 2016 16:30:03 +0000 Original-Received: (at 24627) by debbugs.gnu.org; 11 Oct 2016 16:29:25 +0000 Original-Received: from localhost ([127.0.0.1]:52348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btzvh-00067t-Km for submit@debbugs.gnu.org; Tue, 11 Oct 2016 12:29:25 -0400 Original-Received: from mail-pa0-f44.google.com ([209.85.220.44]:35884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btzvf-00067f-PS for 24627@debbugs.gnu.org; Tue, 11 Oct 2016 12:29:24 -0400 Original-Received: by mail-pa0-f44.google.com with SMTP id ry6so17484783pac.3 for <24627@debbugs.gnu.org>; Tue, 11 Oct 2016 09:29:23 -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=WcHWNuRM4Iha7FDwNqOGjSy65XVjiIRapt9KftJKAhw=; b=nae+9T20dZkoalBBdHItqO+XUdjoVTUXJTFVfb+XiqHuCCq5HMK6O+9X7HpmxOpblV FNAz3r9j6r2YKj9SwjBduEwT5oNvIVs5vHG++aC+QmNncg/rw55p1TGX/NjNtVKtLWPx xjk48k22V8ZW4kADPYeIfeh2fJmbZo6F4WdFvxbUqF0yRfbPpZxCoSJHeqD8c/Q1ppnf y0iPW2HaAUGDq42jGsPZ26ULPuCHEHru53yUD2hHj352TaCpP4LIHS3BciCIfzPu2I6n Vb1iZLLYw33q9yfWXVM2r5ZEAPBbj4OVJe42ZDiBj+GX97EUx8BGufZJMS2NxYlcOZhJ yVZQ== 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=WcHWNuRM4Iha7FDwNqOGjSy65XVjiIRapt9KftJKAhw=; b=OV0jx+2xsw7Z30p6S0WAfZqPZrB6An0WY9MSuSqSMSIb9jQvR5T99ugk0vodJg7M3G EF4WaO8p+mk2D1gB5tgjYz3vL+tWokRRFen1xRsA088C+vMOI6Q7OCcBkZGwf15cMZL4 ILl2lbvmLvSDfUL36iHW+X37aFZNI+/Tub8xgjJSLuhAFcXcW/8TycFFpEHlW/fJFEIc UmZ5el9HY5V6oKLKROl1vn8kTKgXJLrz1z/olx58ChPLx4kZlSUGl3enPiJUoyzK6K0q +iK8Z1P1G4PmqvmHUx8AdOgEN8EcxioMNKnpN/jutJSZXiURKGrJ+Oo8s5ZydC+yt1gl RGlg== X-Gm-Message-State: AA6/9Rn50tnh27/aglldg9XdC7lf4dxxN8KKu3xA5QkWQd3KFO8POmBzdMu2Jp40kh0DNg== X-Received: by 10.66.72.225 with SMTP id g1mr8228555pav.166.1476203357931; Tue, 11 Oct 2016 09:29:17 -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 sa1sm5426295pac.34.2016.10.11.09.29.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Oct 2016 09:29:17 -0700 (PDT) In-Reply-To: <08d6c55e-f060-fabc-5657-2e80a1d06ab0@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6hler\=22's\?\= message of "Tue, 11 Oct 2016 17:37:14 +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:124346 Archived-At: Andreas R=C3=B6hler writes: > With > > (defun foo ()) > > at first open paren > > M-: (thing-at-point 'list t) RET > > returns the whole thing, right. > > But at second open paren returns the whole function too - where it > should return the empty arg-list Following patch do the right thing in my example and your example. Feel free to check it with some other examples that you may have: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;; >From dc2703a43a7b5dae60f7e88805971472253d4600 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 12 Oct 2016 01:16:52 +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 '[' and ']' 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..acacff2 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 (looking-at-p "(") + (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.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1) of 2016-10-11 Repository revision: 9640e9f4e95cd95c04875e90a4ff638e1e51f977