From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#18764: 24.4; electric-indent in *scratch* signals an error Date: Sat, 23 Jun 2018 21:40:25 -0400 Message-ID: <8736xdq7w6.fsf@gmail.com> References: <83a94te85b.fsf@gnu.org> <8736xowzes.fsf@gmail.com> <83tvq3ynmv.fsf@gnu.org> <87d0wqvo4d.fsf@gmail.com> <83muvuzsc8.fsf@gnu.org> <87lgbetjdy.fsf@gmail.com> <83vaaixed1.fsf@gnu.org> <772680b2-622b-6b67-3eb6-9baa02bd3621@yandex.ru> <83602gt9bw.fsf@gnu.org> <87zhzpq9dn.fsf@gmail.com> <83wousqk51.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1529804353 16686 195.159.176.226 (24 Jun 2018 01:39:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Jun 2018 01:39:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 18764@debbugs.gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 24 03:39:09 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 1fWtzg-0004Ff-5g for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jun 2018 03:39:08 +0200 Original-Received: from localhost ([::1]:40222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWu1n-0000Py-Gl for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Jun 2018 21:41:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWu1a-0000Ps-0v for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 21:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWu1W-0006hx-TS for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 21:41:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53897) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWu1W-0006hj-Hq for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 21:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fWu1W-0008Gs-5k for bug-gnu-emacs@gnu.org; Sat, 23 Jun 2018 21:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jun 2018 01:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18764 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch confirmed Original-Received: via spool by 18764-submit@debbugs.gnu.org id=B18764.152980443731750 (code B ref 18764); Sun, 24 Jun 2018 01:41:02 +0000 Original-Received: (at 18764) by debbugs.gnu.org; 24 Jun 2018 01:40:37 +0000 Original-Received: from localhost ([127.0.0.1]:33561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWu16-0008G2-Ic for submit@debbugs.gnu.org; Sat, 23 Jun 2018 21:40:36 -0400 Original-Received: from mail-io0-f175.google.com ([209.85.223.175]:33708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWu13-0008Fo-LW for 18764@debbugs.gnu.org; Sat, 23 Jun 2018 21:40:34 -0400 Original-Received: by mail-io0-f175.google.com with SMTP id d185-v6so9394006ioe.0 for <18764@debbugs.gnu.org>; Sat, 23 Jun 2018 18:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=PAAbO1ZMUn7xHM99qI2wSZM/A90SXAaDendZjXfp0ME=; b=n0v+rVoDa/UUGwG665XRb58yWPMB4Pzxm7fczIJTYvrRVOAH9/9mT44TWxfexSx2pk D+hVLUObPK20cHCgi+PwGv7YjhUsyWAeY2Ev65OniGoO6ai/z/I3awEft9wHl6aDklhK zKwIWMIgfJagCCLthbfK6dG7LIVYwGgZu50Vsh0WBstkDX91CDduByfWKKgQvf0y1nm0 pfsywpliTvDF645RatwpOtUoplVJxWkEmwefvygkRsJqtOcBZ2UbrWhigUFfOLNijPWI aSOweQWbU2IWskIy9zDJLljHtjzTqEsiL+10qmEOjEq5F4SPRMoj3eqVcT0L9P+TueL6 3VtA== 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:date:in-reply-to :message-id:user-agent:mime-version; bh=PAAbO1ZMUn7xHM99qI2wSZM/A90SXAaDendZjXfp0ME=; b=PuKh2+mepvnhilXQ50YNVth0rZxwPpr1m8ZJvBTksMxp3UtBfSv/r+Uj3VNNSKYac0 0vdo1Zm4lRI/RFjY+H1s9w9wUPVVeeDsC8CQwNAJktTJOS/myScx6TTxhyBEyP/85AAo k7mBcTcSrOlHSCzIZa/DZecFs/4XcdryG9LbNtaheb7bzJhljrLFuQrjjhHcCEV/2bpj VGUCrH3hnC2eHBhK2P2cx5uuzHdvgTNq9HiJ2PxBprRdMGaHQ6/YncnL5CV7CrBq3rUM qWxmcxeb64Dhww0AEM7NP+YAIRlAIJ234dYdRWeG73uygPZ0xlvDMExfXov33iRNT19J 0tig== X-Gm-Message-State: APt69E2yHh1mhMGoA2CXfxHneGidHWOusWzZb/nEgd+rhQ0VoFKhwpQ8 Ywt1fmCOV7DqSiD4heavt0M= X-Google-Smtp-Source: AAOMgpc0wTkVpyV2ROg+VScJ3lS5/vWfL1WzWAO/Za/KAqexfXJA2QRid9crz9LMVqm9XTWknCkVvw== X-Received: by 2002:a6b:9944:: with SMTP id b65-v6mr5957055ioe.199.1529804428143; Sat, 23 Jun 2018 18:40:28 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id m3-v6sm4725427ioc.70.2018.06.23.18.40.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 23 Jun 2018 18:40:26 -0700 (PDT) In-Reply-To: <83wousqk51.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 21 Jun 2018 17:39:06 +0300") 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:147782 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> We can be a little more discriminating than my initial blanket >> `ignore-errors', see commit message in the attached patch: > > Fine with me, but I'd prefer a comment in the code explaining why we > catch errors here. I added some more explanation in the comment over the `catch', and remembered to use condition-case-unless-debug. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v3-0001-Suppress-indent-errors-during-electric-indentatio.patch Content-Description: patch >From 5daa803e6e00445570f66116f7ec4681cfdccb92 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 20 Jun 2018 20:12:23 -0400 Subject: [PATCH v3] Suppress indent errors during electric indentation (Bug#18764) * lisp/electric.el (electric-indent-post-self-insert-function): Suppress errors from indent code, but don't suppress errors from elsewhere in this function. That way, if trouble is encountered with electric indent "not working", the error should be reproducible by calling indent directly (as is the case for Bug#18764), or else it's from the electric indent code and will be reported normally. --- lisp/electric.el | 61 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/lisp/electric.el b/lisp/electric.el index c00e7c00a5..a45faf2dbb 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -260,32 +260,43 @@ electric-indent-post-self-insert-function (or (memq act '(nil no-indent)) ;; In a string or comment. (unless (eq act 'do-indent) (nth 8 (syntax-ppss)))))))) - ;; For newline, we want to reindent both lines and basically behave like - ;; reindent-then-newline-and-indent (whose code we hence copied). - (let ((at-newline (<= pos (line-beginning-position)))) - (when at-newline - (let ((before (copy-marker (1- pos) t))) - (save-excursion - (unless (or (memq indent-line-function - electric-indent-functions-without-reindent) - electric-indent-inhibit) - ;; Don't reindent the previous line if the indentation function - ;; is not a real one. + ;; If we error during indent, silently give up since this is an + ;; automatic action that the user didn't explicitly request. + ;; But we don't want to suppress errors from elsewhere in *this* + ;; function, hence the `condition-case' and `throw' (Bug#18764). + (catch 'indent-error + ;; For newline, we want to reindent both lines and basically + ;; behave like reindent-then-newline-and-indent (whose code we + ;; hence copied). + (let ((at-newline (<= pos (line-beginning-position)))) + (when at-newline + (let ((before (copy-marker (1- pos) t))) + (save-excursion + (unless (or (memq indent-line-function + electric-indent-functions-without-reindent) + electric-indent-inhibit) + ;; Don't reindent the previous line if the + ;; indentation function is not a real one. + (goto-char before) + (condition-case-unless-debug () + (indent-according-to-mode) + (error (throw 'indent-error nil)))) + ;; We are at EOL before the call to + ;; `indent-according-to-mode', and after it we usually + ;; are as well, but not always. We tried to address + ;; it with `save-excursion' but that uses a normal + ;; marker whereas we need `move after insertion', so + ;; we do the save/restore by hand. (goto-char before) - (indent-according-to-mode)) - ;; We are at EOL before the call to indent-according-to-mode, and - ;; after it we usually are as well, but not always. We tried to - ;; address it with `save-excursion' but that uses a normal marker - ;; whereas we need `move after insertion', so we do the - ;; save/restore by hand. - (goto-char before) - (when (eolp) - ;; Remove the trailing whitespace after indentation because - ;; indentation may (re)introduce the whitespace. - (delete-horizontal-space t))))) - (unless (and electric-indent-inhibit - (not at-newline)) - (indent-according-to-mode)))))) + (when (eolp) + ;; Remove the trailing whitespace after indentation because + ;; indentation may (re)introduce the whitespace. + (delete-horizontal-space t))))) + (unless (and electric-indent-inhibit + (not at-newline)) + (condition-case-unless-debug () + (indent-according-to-mode) + (error (throw 'indent-error nil))))))))) (put 'electric-indent-post-self-insert-function 'priority 60) -- 2.11.0 --=-=-=--