From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Proposed patch for Bug#24627 Date: Thu, 27 Oct 2016 18:26:47 +0900 (JST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1477560441 3749 195.159.176.226 (27 Oct 2016 09:27:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Oct 2016 09:27:21 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Tino Calancha To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 27 11:27:17 2016 Return-path: Envelope-to: ged-emacs-devel@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 1bzgxh-00071O-FZ for ged-emacs-devel@m.gmane.org; Thu, 27 Oct 2016 11:27:01 +0200 Original-Received: from localhost ([::1]:39938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzgxk-0001Ty-0g for ged-emacs-devel@m.gmane.org; Thu, 27 Oct 2016 05:27:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzgxb-0001Tq-Pf for emacs-devel@gnu.org; Thu, 27 Oct 2016 05:26:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzgxX-0003zE-H4 for emacs-devel@gnu.org; Thu, 27 Oct 2016 05:26:55 -0400 Original-Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzgxX-0003yt-An for emacs-devel@gnu.org; Thu, 27 Oct 2016 05:26:51 -0400 Original-Received: by mail-pf0-x244.google.com with SMTP id s8so2131679pfj.2 for ; Thu, 27 Oct 2016 02:26:51 -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=Y4ZV1xGYecBpxg/517RYG2QLnzzaRVNnaSdnzUus++U=; b=uIMpIzU1sh33e1R8JeuBWBaGSPS7gkClhZ9oKe+q60Whh1jU/cjqMYN7QLxA7m7cEz 74yfXeG0LQVQY3IUj7xs3ermKPL38BYsPMw31opIrdmqVulFZu0WE9ygWz2K+07L5MPo xtpNo6WunXLH/jhfA7zjmSCiflLWhyPThpTvhCDYZ6VQKvmF80uM8LEqfbM1d2+6oJR0 NZpkzFCOGUjMvov6/88NzDdKTctQFes1k086/pBcymWQFH47hTDsWbbl4ISaDCTcvHvX 2m2VTVGPj8u1/5KyUfRwcy0AgGV7m9maDJ3u5dkLwa1z5M9f+nGNjnWwcbux/BKbBOOZ oZrg== 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=Y4ZV1xGYecBpxg/517RYG2QLnzzaRVNnaSdnzUus++U=; b=mx2QYoB5r2kHggsWyV1P6u0gho9bAG6s6J/318sfIHTJoZTSOPzfsNlzRWwvBI9cs8 8eqfe1l1PigPPiWjhqrHvp7pg8SpPtxIKlcmHtmDPxcT5BYVldePHncUSoMwbQvNWcN7 5cWYwtKMY0HjRYg6EyukjQv5m5xjry/Ujpc1IOT4C4zUQkhEeSXpV8Mj5dyiJUI9u2+E w0gIy8cZo+uNh1arGnnBaSEddZ1ZleC7afp3jXvWf8Z9/P/ypF+5xcTCZ1G5bQ/1IsBb Wy+dSDSLv7MeyG8eQ0Qx+MBiGt2l27za5WXV/l/V1WLMLoFoytvdxQKS1RJiOHUmWOpj pZQQ== X-Gm-Message-State: ABUngvfSkY+LpfhIspKtKV/ON0EtCTMez2s+cQvXlfGPzg4A0K56ZoLpmt10rZS7BYdv8A== X-Received: by 10.99.171.3 with SMTP id p3mr10517582pgf.119.1477560409987; Thu, 27 Oct 2016 02:26:49 -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 yp3sm10087429pac.22.2016.10.27.02.26.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 02:26:49 -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-Received-From: 2607:f8b0:400e:c00::244 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208867 Archived-At: Dear all, if no further comments in ~1 week, then i will push following fix into master branch. Thank you. Tino ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 2539012f0e3966874b5645d440ec9e23b7b528b5 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Thu, 27 Oct 2016 18:18:45 +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). If point is inside a comment or string, look for a list out of the comment/string. Escape '[' in doc string. * test/lisp/thingatpt-tests.el (thing-at-point-bug24627): Update expected test result as pass. --- lisp/thingatpt.el | 25 ++++++++++--------------- test/lisp/thingatpt-tests.el | 1 - 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 6d1014b..e423630 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -219,22 +219,17 @@ '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)))) - (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)))))))) + (let* ((st (parse-partial-sexp (point-min) (point))) + (beg (or (and (eq 4 (car (syntax-after (point)))) + (not (nth 8 st)) + (point)) + (nth 1 st)))) + (when beg + (goto-char beg) + (forward-sexp) + (cons beg (point)))))) ;; Defuns diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el index 71d2c88..9d72db4 100644 --- a/test/lisp/thingatpt-tests.el +++ b/test/lisp/thingatpt-tests.el @@ -88,7 +88,6 @@ thing-at-point-test-data ;; `thing-at-point-bounds-of-list-at-point'. (ert-deftest thing-at-point-bug24627 () "Test for http://debbugs.gnu.org/24627 ." - :expected-result :failed (let ((string-result '(("(a \"b\" c)" . (a "b" c)) (";(a \"b\" c)") ("(a \"b\" c\n)" . (a "b" c)) -- 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.8 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1) of 2016-10-27 Repository revision: 0465bf511521ea780a61f1a0eb67731280e689a5