Received: (at 31361) by debbugs.gnu.org; 5 May 2018 14:26:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 05 10:26:35 2018 Received: from localhost ([127.0.0.1]:50767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1fEy8x-0000fd-43 for submit <at> debbugs.gnu.org; Sat, 05 May 2018 10:26:35 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:50155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mail@HIDDEN>) id 1fEy8u-0000fT-VN for 31361 <at> debbugs.gnu.org; Sat, 05 May 2018 10:26:33 -0400 X-Originating-IP: 185.131.40.67 Received: from saiph (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@HIDDEN) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 03CAF1BF204; Sat, 5 May 2018 16:26:35 +0200 (CEST) Received: from ngz by saiph with local (Exim 4.89) (envelope-from <mail@HIDDEN>) id 1fEy8p-0007Ri-FX; Sat, 05 May 2018 16:26:27 +0200 From: Nicolas Goaziou <mail@HIDDEN> To: 31361 <at> debbugs.gnu.org Subject: Re: bug#31361: 25.3; Issue when advising `indent-line-function' In-Reply-To: <87sh78phj1.fsf@HIDDEN> (Nicolas Goaziou's message of "Thu, 03 May 2018 23:15:46 +0200") Message-ID: <87o9huci6b.fsf@HIDDEN> References: <87sh78phj1.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Date: Sat, 05 May 2018 16:26:27 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Level: X-Spam-Score: 1.6 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Nicolas Goaziou <mail@HIDDEN> writes: > When `indent-line-function' is advised, using `add-function', and the > variable contains `indent-relative', `indent-according-to-mode' has an > erratic behavior. > > In the following code, from `indent-according-to-mode', > > (if (memq indent-line-function > '(indent-relative indent-relative-maybe)) > ... > ;; The normal case. > (funcall indent-line-function)) > > the if branch is no longer executed because `indent-line-function' is no > longer `indent-relative' but a closure around it. [...] Content analysis details: (1.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [217.70.183.201 listed in list.dnswl.org] 2.3 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [217.70.183.201 listed in bl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_BL Mailspike blacklisted X-Debbugs-Envelope-To: 31361 Cc: Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.6 (/) Nicolas Goaziou <mail@HIDDEN> writes: > When `indent-line-function' is advised, using `add-function', and the > variable contains `indent-relative', `indent-according-to-mode' has an > erratic behavior. > > In the following code, from `indent-according-to-mode', > > (if (memq indent-line-function > '(indent-relative indent-relative-maybe)) > ... > ;; The normal case. > (funcall indent-line-function)) > > the if branch is no longer executed because `indent-line-function' is no > longer `indent-relative' but a closure around it. Thinking more about the problem, I think I can describe it differently. When `indent-line-function' is set to `indent-relative' -- or `indent-relative-maybe' -- the function `indent-relative' is not meant to be actually called to handle the indentation. Instead, some ad-hoc indentation is hard-coded into `indent-according-to-mode', which see. However, when `indent-line-function' is advised, according to my previous report, `indent-relative' is actually called for indentation, which is not the intent, per above. So basically, any call to `indent-according-to-mode', e.g., with `reindent-then-newline-and-indent' or through Electric Indent mode, is broken whenever `indent-relative' is advised. One idea, suggested by Stefan, would be to write `indent-according-to-mode' like the following: (if (memq (advice--cd*r indent-line-function) '(indent-relative indent-relative-maybe)) ... ;; The normal case. (funcall indent-line-function)) i.e., strip advices so that the ad-hoc code is executed, as intended, instead of ultimately calling `indent-relative'. Unfortunately, this is insufficient because the advices are not applied, which is also wrong. If this stripping is done, it should also ensure that advices are applied on the ad-hoc indentation code there. FWIW, my gut feeling is that `indent-relative' -- and `indent-relative-maybe' -- ought to be normalized to behave like a normal indentation function, i.e., a function actually called from `indent-according-to-mode'. This was the case before commit a17b712b4d812d28086ae9af02f9043b36cf3e19 (Oct 30 2001). Currently, `indent-relative' is two-sided. Therefore, the previous suggestion might entail to split `indent-relative' into two parts, one meant to be used as a value for `indent-line-function' -- maybe named `indent-relative-function' -- and the other one to be used like current `indent-relative', i.e., jumping from one indent point to the other.
bug-gnu-emacs@HIDDEN
:bug#31361
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 3 May 2018 21:16:04 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 03 17:16:04 2018 Received: from localhost ([127.0.0.1]:48658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1fELa7-0005Bz-TK for submit <at> debbugs.gnu.org; Thu, 03 May 2018 17:16:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mail@HIDDEN>) id 1fELa6-0005BF-So for submit <at> debbugs.gnu.org; Thu, 03 May 2018 17:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1fELa0-0007da-Hz for submit <at> debbugs.gnu.org; Thu, 03 May 2018 17:15:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1fELa0-0007d2-B9 for submit <at> debbugs.gnu.org; Thu, 03 May 2018 17:15:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1fELZy-0000uR-Jb for bug-gnu-emacs@HIDDEN; Thu, 03 May 2018 17:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1fELZv-0007Tg-FS for bug-gnu-emacs@HIDDEN; Thu, 03 May 2018 17:15:54 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:56783) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1fELZv-0007QQ-2o for bug-gnu-emacs@HIDDEN; Thu, 03 May 2018 17:15:51 -0400 X-Originating-IP: 185.131.40.67 Received: from saiph (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@HIDDEN) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 3FE88240007 for <bug-gnu-emacs@HIDDEN>; Thu, 3 May 2018 23:15:50 +0200 (CEST) Received: from ngz by saiph with local (Exim 4.89) (envelope-from <mail@HIDDEN>) id 1fELZq-0004C2-8C for bug-gnu-emacs@HIDDEN; Thu, 03 May 2018 23:15:46 +0200 From: Nicolas Goaziou <mail@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 25.3; Issue when advising `indent-line-function' User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) X-Debbugs-Cc: Stefan Monnier <monnier@HIDDEN> Date: Thu, 03 May 2018 23:15:46 +0200 Message-ID: <87sh78phj1.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -5.3 (-----) Hello, When `indent-line-function' is advised, using `add-function', and the variable contains `indent-relative', `indent-according-to-mode' has an erratic behavior. In the following code, from `indent-according-to-mode', (if (memq indent-line-function '(indent-relative indent-relative-maybe)) ... ;; The normal case. (funcall indent-line-function)) the if branch is no longer executed because `indent-line-function' is no longer `indent-relative' but a closure around it. You can reproduce the issue with the following recipe: - Open a new buffer in Fundamental mode (so `indent-line-function' is `indent-relative') - Insert : "-- Test" - From there, <RET> returns to column 0. However, upon evaluating the following: M-: (add-function :before-until (local 'indent-line-function) #'ignore) <RET> now moves point at the same column as the "T" from "Test", in the new line. Regards, -- Nicolas Goaziou 0x80A93738
Nicolas Goaziou <mail@HIDDEN>
:monnier@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.monnier@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#31361
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.