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: Wed, 20 Jun 2018 20:19:16 -0400 Message-ID: <87zhzpq9dn.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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1529540290 5676 195.159.176.226 (21 Jun 2018 00:18:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 21 Jun 2018 00:18:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Dmitry Gutov , 18764@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 21 02:18:06 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 1fVnIb-0001N5-ID for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jun 2018 02:18:05 +0200 Original-Received: from localhost ([::1]:52290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVnKi-00025I-KC for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Jun 2018 20:20:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVnKZ-00023x-2k for bug-gnu-emacs@gnu.org; Wed, 20 Jun 2018 20:20:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVnKU-0000Jf-Jx for bug-gnu-emacs@gnu.org; Wed, 20 Jun 2018 20:20:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVnKU-0000JU-Fb for bug-gnu-emacs@gnu.org; Wed, 20 Jun 2018 20:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fVnKU-0002EY-9V for bug-gnu-emacs@gnu.org; Wed, 20 Jun 2018 20:20: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: Thu, 21 Jun 2018 00:20: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: confirmed Original-Received: via spool by 18764-submit@debbugs.gnu.org id=B18764.15295403668421 (code B ref 18764); Thu, 21 Jun 2018 00:20:02 +0000 Original-Received: (at 18764) by debbugs.gnu.org; 21 Jun 2018 00:19:26 +0000 Original-Received: from localhost ([127.0.0.1]:58088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fVnJu-0002Bf-1x for submit@debbugs.gnu.org; Wed, 20 Jun 2018 20:19:26 -0400 Original-Received: from mail-it0-f51.google.com ([209.85.214.51]:54592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fVnJr-0002Ao-Ef; Wed, 20 Jun 2018 20:19:23 -0400 Original-Received: by mail-it0-f51.google.com with SMTP id 76-v6so2192560itx.4; Wed, 20 Jun 2018 17:19:23 -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=Q2Re/iEG/1NJXA4EZb4H5waOwTDk1sh1//QZOOXTO5A=; b=p5lALNpXg3MLwdxT5Mv045cLm7u/DtmjqqNhtr2HuJiu3nwR2AQocqotwevaVonVP4 DACdNY0A7826aFmEOKpPdEA7Gi/jOJXtEys0H3Cx9Y6ofy6GOPfgw2xWSiohJK9nJUol EFwBMCI4uf5OYwceCrs9S4pA4OePugm96Vj/xzvU9b9/ugH04n6rwre7FUkm5YpilI58 XaLRUMKtBBAiFF8uayIXiGlln0ZinYNldd+7QanFQdC90lcNvDP7TOH1VAPjmBxiHWP7 aLF2NVLMed9EncwS/O6m0+nhNUkFd5EI9XYyQb+c5l+mNbcI58QSgnDCKeM81wxLkZy0 /W8g== 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=Q2Re/iEG/1NJXA4EZb4H5waOwTDk1sh1//QZOOXTO5A=; b=srX8f0rkTBapBMOqKQfBm5oN2ooqzTEUZrhFSyRPS9I+LYjeV5ItLntMHdwbSjs6hl trQzKHoBfNE5urTaRVz5h3fd4z3xPuLWyHII4+rpny3jUu+hC5qGWjURbuZRwXYHFonn LaozptB8Bsk4RfOXlaoQR7PYJCYpe9wReKIcudN44iBFon+mWSr7mskbBSWOP253x+M6 H+k6pIXfACjPib0+J4fjZ3Tsho5IIiZJkoa+oNQCPzsRv87kPRJenfduT2UGAmSCDyy9 zsQVdb7h90CDJLCPPKmBNVYRs5zhnKwgoEatKVLrH7ym9azsPXjbZLnVyL47d5KCgsHJ Th3Q== X-Gm-Message-State: APt69E1pLmueqoCIhKiO/agwFfS3yVYcPkcf5V0sbf5S1Ijkphk3FkYU SJJv9TUmjJ4eiufmZWHVboQViA== X-Google-Smtp-Source: ADUXVKLW1k6Ovnm+W1k3tFfhFla5Q7vfvhmVgVEm8nqTmGh+svqgs1NrFEdJe6GsQzFVzQvE2a0wFQ== X-Received: by 2002:a24:470b:: with SMTP id t11-v6mr3485341itb.26.1529540358065; Wed, 20 Jun 2018 17:19:18 -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 63-v6sm1714464ioz.71.2018.06.20.17.19.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 17:19:17 -0700 (PDT) In-Reply-To: <83602gt9bw.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 18 Jun 2018 18:15:15 +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:147680 Archived-At: --=-=-= Content-Type: text/plain tags 18764 + patch quit Eli Zaretskii writes: >> That's going to make user complaints like "why it doesn't indent" or "it >> doesn't indent right" harder to debug and address. > > IMO, this is a lesser evil. And if it turns out to be a real problem, > we could always add a variable to control whether such errors are > silently ignored. We can be a little more discriminating than my initial blanket `ignore-errors', see commit message in the attached patch: --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v2-0001-Suppress-indent-errors-during-electric-indentatio.patch Content-Description: patch >From 4aa45c829f8be801f626d169ac412185e5c9c509 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 20 Jun 2018 20:12:23 -0400 Subject: [PATCH v2] 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 | 59 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/lisp/electric.el b/lisp/electric.el index c00e7c00a5..7a998c0ff3 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -260,32 +260,41 @@ 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, give up, but don't suppress errors + ;; from elsewhere in *this* function (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 () + (indent-according-to-mode) + ((debug 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 () + (indent-according-to-mode) + ((debug error) (throw 'indent-error nil))))))))) (put 'electric-indent-post-self-insert-function 'priority 60) -- 2.11.0 --=-=-=--