From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Leo Liu Newsgroups: gmane.emacs.bugs Subject: bug#31772: 26.1; (thing-at-point 'list) regression Date: Thu, 06 Sep 2018 18:37:11 +0800 Message-ID: References: <838t7msmy1.fsf@gnu.org> <87k1r6acqo.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1536230171 6231 195.159.176.226 (6 Sep 2018 10:36:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Sep 2018 10:36:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (macOS 10.12.6) Cc: Tino Calancha To: 31772@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 06 12:36:07 2018 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 1fxrdu-0001Uk-QS for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Sep 2018 12:36:07 +0200 Original-Received: from localhost ([::1]:60702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxrg0-0002xI-Sm for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Sep 2018 06:38:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxrfs-0002vF-1i for bug-gnu-emacs@gnu.org; Thu, 06 Sep 2018 06:38:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxrfm-00020Y-ES for bug-gnu-emacs@gnu.org; Thu, 06 Sep 2018 06:38:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxrfm-0001zL-8h for bug-gnu-emacs@gnu.org; Thu, 06 Sep 2018 06:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fxrfl-0007m3-OF for bug-gnu-emacs@gnu.org; Thu, 06 Sep 2018 06:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Sep 2018 10:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31772 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31772-submit@debbugs.gnu.org id=B31772.153623024529834 (code B ref 31772); Thu, 06 Sep 2018 10:38:01 +0000 Original-Received: (at 31772) by debbugs.gnu.org; 6 Sep 2018 10:37:25 +0000 Original-Received: from localhost ([127.0.0.1]:47708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fxrfA-0007l5-8x for submit@debbugs.gnu.org; Thu, 06 Sep 2018 06:37:25 -0400 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:37989) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fxrf7-0007kr-Ig for 31772@debbugs.gnu.org; Thu, 06 Sep 2018 06:37:22 -0400 Original-Received: by mail-pl1-f169.google.com with SMTP id u11-v6so4788045plq.5 for <31772@debbugs.gnu.org>; Thu, 06 Sep 2018 03:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:face:date:in-reply-to:message-id :user-agent:mime-version; bh=lR3dKhVExgtMSo3wc3q/QZL+EvctYIK9RK+xzFvb6QQ=; b=UZ91EBlS0wBPXFm7rYlMaNP5mOCwDOwCAXuUO522/6leeF/hZFPXhg8hoqxt1nyp8s MKArFmrAz9/IK65c+vTdLdamUJZLXv5NJASRmJDCLp8+weUogK00q98vF6K5ooW192jf PT3pkSCY4Yw13UuTKZQkk/zFrWlxUhTtyrvikCUPGfrVvldSvspjWHlTcdLxZIzwfqlv 2urM7lTj0j7hfhybasJKS134J8Qex+Tzfrbk98FJ6Yr2HGuVpXHaq4kY61X1Dj+IHtmU Qbu5xVQE+YuxhiPX3K6LVVvDVKkEXAQU1Wb5IUSSwtYCzuY2VA+Tj3OBnbyJsJEtsztH l8MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:face:date :in-reply-to:message-id:user-agent:mime-version; bh=lR3dKhVExgtMSo3wc3q/QZL+EvctYIK9RK+xzFvb6QQ=; b=hndqbcZLGYOmnL1a7kWsY171MjrEkm3QhwQQK5P//cPh97mvtJyhATmpoKqErjyzXf iaVenrWuDiD/OJx+6RQKpSWNfvnXnGci0RkyQV+NE9fhw8li5C+vBw/U8Stdwb8Yzu/y DCjJGEFt5x18pzfLQUWhQxFO51LEQ4DlKMiMmBoFSlLxLI7xFdTN0rWTroxZqsplXSAU lr6kMZee1O4aRJDfPvsYVcpli+ODH5jHfEeLfYQfT+FMItMmykBPtr5mxvxYQHnrhHjc CEJjaAeGCiDaJSIVrawW54uZOP5A64Lslf8AZlFpSr+p74w1/ZwA6acNTfkvr3dlCrg/ mlFw== X-Gm-Message-State: APzg51AfgQHbu4UEh98gQc2FSmVQNJL3XQwd8KqG+3dnQkmF7vEUvqcs LqxzFHor2gkN52JtYKnxQ8I= X-Google-Smtp-Source: ANB0VdaiZ9hnXi0Kt3QmLS6SGV+W+HCG87WRs6ZgicMoRW8f9hR+KtcBgwQV1gRKdawUBE6eQtisWg== X-Received: by 2002:a17:902:b40c:: with SMTP id x12-v6mr1979263plr.163.1536230235541; Thu, 06 Sep 2018 03:37:15 -0700 (PDT) Original-Received: from Zeuss-MacBook-Air.local ([112.208.219.22]) by smtp.gmail.com with ESMTPSA id k69-v6sm4797747pgd.9.2018.09.06.03.37.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 03:37:14 -0700 (PDT) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoAgMAAADxkFD+AAAADFBMVEUvT09qWs3/pQD///+J kUVcAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cBBwMLOd3veKQA AACuSURBVBjTldE9CgIxEAXgB+lEyFUC2wo5ikdZ8DSypxhMY7H9VuIVwlqkGRgnm59VsHGafIQ3 CZlAtmKIRaHETgYa12lqvEsPYKf8wXHsPGfqPaUM0g9aJPKFXkmNQmSDqwzz4Fpgpz+6WAPY2z5o uPJJpu0uypcl4nyCibMLQ8lCiVjayLoQvw5LsVKQuHPRR958HZbOcVsKeepcLxpByjycGvnKmY+c MBvrtyjfe0vmuLvdq/kAAAAASUVORK5CYII= In-Reply-To: (Tino Calancha's message of "Tue, 12 Jun 2018 01:25:12 +0900 (JST)") 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:150077 Archived-At: --=-=-= Content-Type: text/plain Hi there, I have been using 26.1 as my main editor for the last few months and this breakage remains a pain point in my day-to-day editing. For example whenever I rewrite a function, I normally comment out the old one (to keep the linter, pretty-printer or whatnot happy) and write the new one from scratch, occasionally copy things from the old one to save typing and this bug gets in the way many times a day. I propose a patch that doesn't divert too much from the old and tried behaviour. The idea that is currently in thing-at-point-bounds-of-list-at-point is fine for a higher level function such as list-at-point but doing it there affects all functions that build on it including some from thingatpt.el itself. I hope you can find time to review the patch and come to a solution for 26.2 which I very much look forward to. Thanks, Leo --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=thing.diff Content-Description: thing.diff diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 6a978fe9..8da31a03 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -221,15 +221,12 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." "Return the bounds of the list at point. \[Internal function used by `bounds-of-thing-at-point'.]" (save-excursion - (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)))))) + (if (ignore-errors (up-list -1)) + (ignore-errors (cons (point) (progn (forward-sexp) (point)))) + (let ((bound (bounds-of-thing-at-point 'sexp))) + (and bound + (<= (car bound) (point)) (< (point) (cdr bound)) + bound))))) ;; Defuns diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el index cfb57de6..6093c209 100644 --- a/test/lisp/thingatpt-tests.el +++ b/test/lisp/thingatpt-tests.el @@ -84,20 +84,18 @@ position to retrieve THING.") (goto-char (nth 1 test)) (should (equal (thing-at-point (nth 2 test)) (nth 3 test)))))) -;; These tests reflect the actual behavior of -;; `thing-at-point-bounds-of-list-at-point'. -(ert-deftest thing-at-point-bug24627 () - "Test for https://debbugs.gnu.org/24627 ." +;; See bug#24627 and bug#31772. +(ert-deftest thing-at-point-bounds-of-list-at-point () (let ((string-result '(("(a \"b\" c)" . (a "b" c)) - (";(a \"b\" c)") + (";(a \"b\" c)" . (a "b" c)) ("(a \"b\" c\n)" . (a "b" c)) - ("\"(a b c)\"") + ("\"(a b c)\"" . (a b c)) ("(a ;(b c d)\ne)" . (a e)) - ("(foo\n(a ;(b c d)\ne) bar)" . (a e)) + ("(foo\n(a ;(b c d)\ne) bar)" . (foo (a e) bar)) ("(foo\na ;(b c d)\ne bar)" . (foo a e bar)) - ("(foo\n(a \"(b c d)\"\ne) bar)" . (a "(b c d)" e)) - ("(b\n(a ;(foo c d)\ne) bar)" . (a e)) - ("(princ \"(a b c)\")" . (princ "(a b c)")) + ("(foo\n(a \"(b c d)\"\ne) bar)" . (foo (a "(b c d)" e) bar)) + ("(b\n(a ;(foo c d)\ne) bar)" . (b (a e) bar)) + ("(princ \"(a b c)\")" . (a b c)) ("(defun foo ()\n \"Test function.\"\n ;;(a b)\n nil)" . (defun foo nil "Test function." nil)))) (file (expand-file-name "lisp/thingatpt.el" source-directory)) --=-=-=--