From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#43489: [PATCH] Don't signal scan-error when moving by sexp interactively Date: Fri, 18 Sep 2020 13:31:16 +0200 Message-ID: <64C7CB3A-36F2-4988-9FF9-B99115C9ED13@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_6A20E3B3-1DC1-411D-8325-49328451627C" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22480"; mail-complaints-to="usenet@ciao.gmane.io" To: 43489@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 18 13:32:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJEcb-0005jJ-MX for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 13:32:09 +0200 Original-Received: from localhost ([::1]:53914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJEca-0001Yz-Er for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 07:32:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJEcU-0001Ys-RJ for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 07:32:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJEcU-00049M-Hz for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 07:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJEcU-0005k7-Eq for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 07:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Sep 2020 11:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43489 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160042868820441 (code B ref -1); Fri, 18 Sep 2020 11:32:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Sep 2020 11:31:28 +0000 Original-Received: from localhost ([127.0.0.1]:41071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJEbv-0005JF-Dv for submit@debbugs.gnu.org; Fri, 18 Sep 2020 07:31:27 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:48578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJEbt-0005HE-JO for submit@debbugs.gnu.org; Fri, 18 Sep 2020 07:31:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJEbt-0001We-Cc for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 07:31:25 -0400 Original-Received: from mail1467c50.megamailservers.eu ([91.136.14.67]:55840 helo=mail268c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJEbr-00046F-El for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 07:31:25 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1600428679; bh=5i/z15+IHh7OOtvJQsIyXVO3aaegnNVo29O3QfSoPvU=; h=From:Subject:Date:To:From; b=ZNT5AjbMpYf+3AvEiTjNLe/NeV1HUVxRN7tfxL+FVnMWfNwp/KFE3/nKaPJYY8cOi iNsOWhHsXQOJZDb2v95b4V5/uUd5DvZ8md6BEbqE6WqWK9BkIY0Ll+r6Gby70FJhIS hFeL5oMxpmODGmzZSvCXczlOk3CXC9MSmrRFNQyE= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail268c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08IBVHPZ012209 for ; Fri, 18 Sep 2020 11:31:19 +0000 X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F19.5F649A87.0055, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=BZ+mLYl2 c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=M51BFTxLslgA:10 a=JC4bn7cTM7qGctUrLuYA:9 a=CjuIK1q_8ugA:10 a=xG116jtGo4NxAXRApYYA:9 a=B2y7HmGcmWMA:10 a=tclcd6dtLQvEqt9_mmAA:9 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.14.67; envelope-from=mattiase@acm.org; helo=mail268c50.megamailservers.eu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 07:31:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188291 Archived-At: --Apple-Mail=_6A20E3B3-1DC1-411D-8325-49328451627C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii When moving by sexp (C-M-f, C-M-u and so on) and point is already at a = boundary preventing further movement, Emacs currently signals an = internal error such as Scan error: "Containing expression ends prematurely", 5010, 5010 or Scan error: "Unbalanced parentheses", 5010, 1 which is unhelpful and rather looks as if something went wrong in the = internal machinery. The attached patch does away with this error when the commands are = invoked interactively; programmatic use of the functions will get the = scan-error just like before. There didn't seem to be much point in = replacing the errors with new messages so the current version of the = patch doesn't. --Apple-Mail=_6A20E3B3-1DC1-411D-8325-49328451627C Content-Disposition: attachment; filename=0001-Don-t-signal-scan-error-when-moving-by-sexp-interact.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Don-t-signal-scan-error-when-moving-by-sexp-interact.patch" Content-Transfer-Encoding: quoted-printable =46rom=2025a03c7ec547984b2e500d4e5be7855290ae95ff=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=2018=20Sep=202020=2012:49:33=20+0200=0A= Subject:=20[PATCH]=20Don't=20signal=20scan-error=20when=20moving=20by=20= sexp=20interactively=0A=0A*=20lisp/emacs-lisp/lisp.el=20(forward-sexp,=20= backward-sexp,=20forward-list)=0A(backward-list,=20down-list,=20= up-list):=20Remove=20unsightly=20scan-error=0Awhen=20running=20= interactively=20and=20no=20further=20movement=20by=20sexp=20can=20be=20= made.=0A---=0A=20lisp/emacs-lisp/lisp.el=20|=2084=20= +++++++++++++++++++++++++----------------=0A=201=20file=20changed,=2052=20= insertions(+),=2032=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/lisp.el=20b/lisp/emacs-lisp/lisp.el=0Aindex=20= 8c18557c79..2b0ed76633=20100644=0A---=20a/lisp/emacs-lisp/lisp.el=0A+++=20= b/lisp/emacs-lisp/lisp.el=0A@@=20-55,7=20+55,7=20@@=20= forward-sexp-function=0A=20=20=20"If=20non-nil,=20`forward-sexp'=20= delegates=20to=20this=20function.=0A=20Should=20take=20the=20same=20= arguments=20and=20behave=20similarly=20to=20`forward-sexp'.")=0A=20=0A= -(defun=20forward-sexp=20(&optional=20arg)=0A+(defun=20forward-sexp=20= (&optional=20arg=20noerror)=0A=20=20=20"Move=20forward=20across=20one=20= balanced=20expression=20(sexp).=0A=20With=20ARG,=20do=20it=20that=20many=20= times.=20=20Negative=20arg=20-N=20means=20move=0A=20backward=20across=20= N=20balanced=20expressions.=20=20This=20command=20assumes=0A@@=20-64,23=20= +64,29=20@@=20forward-sexp=0A=20If=20unable=20to=20move=20over=20a=20= sexp,=20signal=20`scan-error'=20with=20three=0A=20arguments:=20a=20= message,=20the=20start=20of=20the=20obstacle=20(usually=20a=0A=20= parenthesis=20or=20list=20marker=20of=20some=20kind),=20and=20end=20of=20= the=0A-obstacle."=0A-=20=20(interactive=20"^p")=0A-=20=20(or=20arg=20= (setq=20arg=201))=0A-=20=20(if=20forward-sexp-function=0A-=20=20=20=20=20= =20(funcall=20forward-sexp-function=20arg)=0A-=20=20=20=20(goto-char=20= (or=20(scan-sexps=20(point)=20arg)=20(buffer-end=20arg)))=0A-=20=20=20=20= (if=20(<=20arg=200)=20(backward-prefix-chars))))=0A-=0A-(defun=20= backward-sexp=20(&optional=20arg)=0A+obstacle.=20=20If=20NOERROR=20is=20= non-nil,=20as=20it=20is=20interactively,=0A+do=20not=20signal=20an=20= error."=0A+=20=20(interactive=20"^p\nd")=0A+=20=20(if=20noerror=0A+=20=20= =20=20=20=20(condition-case=20_=0A+=20=20=20=20=20=20=20=20=20=20= (forward-sexp=20arg=20nil)=0A+=20=20=20=20=20=20=20=20(scan-error=20= (ding)))=0A+=20=20=20=20(or=20arg=20(setq=20arg=201))=0A+=20=20=20=20(if=20= forward-sexp-function=0A+=20=20=20=20=20=20=20=20(funcall=20= forward-sexp-function=20arg)=0A+=20=20=20=20=20=20(goto-char=20(or=20= (scan-sexps=20(point)=20arg)=20(buffer-end=20arg)))=0A+=20=20=20=20=20=20= (if=20(<=20arg=200)=20(backward-prefix-chars)))))=0A+=0A+(defun=20= backward-sexp=20(&optional=20arg=20noerror)=0A=20=20=20"Move=20backward=20= across=20one=20balanced=20expression=20(sexp).=0A=20With=20ARG,=20do=20= it=20that=20many=20times.=20=20Negative=20arg=20-N=20means=0A=20move=20= forward=20across=20N=20balanced=20expressions.=0A=20This=20command=20= assumes=20point=20is=20not=20in=20a=20string=20or=20comment.=0A-Uses=20= `forward-sexp'=20to=20do=20the=20work."=0A-=20=20(interactive=20"^p")=0A= +Uses=20`forward-sexp'=20to=20do=20the=20work.=0A+If=20NOERROR=20is=20= non-nil,=20as=20it=20is=20interactively,=20do=20not=20signal=20an=20= error."=0A+=20=20(interactive=20"^p\nd")=0A=20=20=20(or=20arg=20(setq=20= arg=201))=0A-=20=20(forward-sexp=20(-=20arg)))=0A+=20=20(forward-sexp=20= (-=20arg)=20noerror))=0A=20=0A=20(defun=20mark-sexp=20(&optional=20arg=20= allow-extend)=0A=20=20=20"Set=20mark=20ARG=20sexps=20from=20point.=0A@@=20= -108,41=20+114,52=20@@=20mark-sexp=0A=20=09=20=20=20=20(point))=0A=20=09=20= =20nil=20t))))=0A=20=0A-(defun=20forward-list=20(&optional=20arg)=0A= +(defun=20forward-list=20(&optional=20arg=20noerror)=0A=20=20=20"Move=20= forward=20across=20one=20balanced=20group=20of=20parentheses.=0A=20This=20= command=20will=20also=20work=20on=20other=20parentheses-like=20= expressions=0A=20defined=20by=20the=20current=20language=20mode.=0A=20= With=20ARG,=20do=20it=20that=20many=20times.=0A=20Negative=20arg=20-N=20= means=20move=20backward=20across=20N=20groups=20of=20parentheses.=0A= -This=20command=20assumes=20point=20is=20not=20in=20a=20string=20or=20= comment."=0A-=20=20(interactive=20"^p")=0A-=20=20(or=20arg=20(setq=20arg=20= 1))=0A-=20=20(goto-char=20(or=20(scan-lists=20(point)=20arg=200)=20= (buffer-end=20arg))))=0A-=0A-(defun=20backward-list=20(&optional=20arg)=0A= +This=20command=20assumes=20point=20is=20not=20in=20a=20string=20or=20= comment.=0A+If=20NOERROR=20is=20non-nil,=20as=20it=20is=20interactively,=20= do=20not=20signal=20an=20error."=0A+=20=20(interactive=20"^p\nd")=0A+=20=20= (if=20noerror=0A+=20=20=20=20=20=20(condition-case=20_=0A+=20=20=20=20=20= =20=20=20=20=20(forward-list=20arg=20nil)=0A+=20=20=20=20=20=20=20=20= (scan-error=20(ding)))=0A+=20=20=20=20(or=20arg=20(setq=20arg=201))=0A+=20= =20=20=20(goto-char=20(or=20(scan-lists=20(point)=20arg=200)=20= (buffer-end=20arg)))))=0A+=0A+(defun=20backward-list=20(&optional=20arg=20= noerror)=0A=20=20=20"Move=20backward=20across=20one=20balanced=20group=20= of=20parentheses.=0A=20This=20command=20will=20also=20work=20on=20other=20= parentheses-like=20expressions=0A=20defined=20by=20the=20current=20= language=20mode.=0A=20With=20ARG,=20do=20it=20that=20many=20times.=0A=20= Negative=20arg=20-N=20means=20move=20forward=20across=20N=20groups=20of=20= parentheses.=0A-This=20command=20assumes=20point=20is=20not=20in=20a=20= string=20or=20comment."=0A-=20=20(interactive=20"^p")=0A+This=20command=20= assumes=20point=20is=20not=20in=20a=20string=20or=20comment.=0A+If=20= NOERROR=20is=20non-nil,=20as=20it=20is=20interactively,=20do=20not=20= signal=20an=20error."=0A+=20=20(interactive=20"^p\nd")=0A=20=20=20(or=20= arg=20(setq=20arg=201))=0A-=20=20(forward-list=20(-=20arg)))=0A+=20=20= (forward-list=20(-=20arg)=20noerror))=0A=20=0A-(defun=20down-list=20= (&optional=20arg)=0A+(defun=20down-list=20(&optional=20arg=20noerror)=0A=20= =20=20"Move=20forward=20down=20one=20level=20of=20parentheses.=0A=20This=20= command=20will=20also=20work=20on=20other=20parentheses-like=20= expressions=0A=20defined=20by=20the=20current=20language=20mode.=0A=20= With=20ARG,=20do=20this=20that=20many=20times.=0A=20A=20negative=20= argument=20means=20move=20backward=20but=20still=20go=20down=20a=20= level.=0A-This=20command=20assumes=20point=20is=20not=20in=20a=20string=20= or=20comment."=0A-=20=20(interactive=20"^p")=0A-=20=20(or=20arg=20(setq=20= arg=201))=0A-=20=20(let=20((inc=20(if=20(>=20arg=200)=201=20-1)))=0A-=20=20= =20=20(while=20(/=3D=20arg=200)=0A-=20=20=20=20=20=20(goto-char=20(or=20= (scan-lists=20(point)=20inc=20-1)=20(buffer-end=20arg)))=0A-=20=20=20=20=20= =20(setq=20arg=20(-=20arg=20inc)))))=0A+This=20command=20assumes=20point=20= is=20not=20in=20a=20string=20or=20comment.=0A+If=20NOERROR=20is=20= non-nil,=20as=20it=20is=20interactively,=20do=20not=20signal=20an=20= error."=0A+=20=20(interactive=20"^p\nd")=0A+=20=20(if=20noerror=0A+=20=20= =20=20=20=20(condition-case=20_=0A+=20=20=20=20=20=20=20=20=20=20= (down-list=20arg=20nil)=0A+=20=20=20=20=20=20=20=20(scan-error=20= (ding)))=0A+=20=20=20=20(or=20arg=20(setq=20arg=201))=0A+=20=20=20=20= (let=20((inc=20(if=20(>=20arg=200)=201=20-1)))=0A+=20=20=20=20=20=20= (while=20(/=3D=20arg=200)=0A+=20=20=20=20=20=20=20=20(goto-char=20(or=20= (scan-lists=20(point)=20inc=20-1)=20(buffer-end=20arg)))=0A+=20=20=20=20=20= =20=20=20(setq=20arg=20(-=20arg=20inc))))))=0A=20=0A=20(defun=20= backward-up-list=20(&optional=20arg=20escape-strings=20= no-syntax-crossing)=0A=20=20=20"Move=20backward=20out=20of=20one=20level=20= of=20parentheses.=0A@@=20-229,7=20+246,10=20@@=20up-list=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(or=20(<=20inc=200)=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(forward-comment=20= 1))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setf=20arg=20= (+=20arg=20inc)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20(signal=20(car=20= err)=20(cdr=20err))))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20(if=20= no-syntax-crossing=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= Assume=20called=20interactively;=20don't=20signal=20an=20error.=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(ding)=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(signal=20(car=20err)=20(cdr=20err)))))))=0A=20=20=20= =20=20=20=20(setq=20arg=20(-=20arg=20inc)))))=0A=20=0A=20(defun=20= kill-sexp=20(&optional=20arg)=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_6A20E3B3-1DC1-411D-8325-49328451627C Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_6A20E3B3-1DC1-411D-8325-49328451627C--