GNU logs - #31361, boring messages


Message sent to monnier@HIDDEN, bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#31361: 25.3; Issue when advising `indent-line-function'
Resent-From: Nicolas Goaziou <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: monnier@HIDDEN, bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 03 May 2018 21:17:02 +0000
Resent-Message-ID: <handler.31361.B.152538216419967 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 31361
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 31361 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier@HIDDEN>
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
X-Debbugs-Original-Xcc: Stefan Monnier <monnier@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.152538216419967
          (code B ref -1); Thu, 03 May 2018 21:17:02 +0000
Received: (at submit) by debbugs.gnu.org; 3 May 2018 21:16:04 +0000
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>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
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-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




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Nicolas Goaziou <mail@HIDDEN>
Subject: bug#31361: Acknowledgement (25.3; Issue when advising
 `indent-line-function')
Message-ID: <handler.31361.B.152538216419967.ack <at> debbugs.gnu.org>
References: <87sh78phj1.fsf@HIDDEN>
X-Gnu-PR-Message: ack 31361
X-Gnu-PR-Package: emacs
Reply-To: 31361 <at> debbugs.gnu.org
Date: Thu, 03 May 2018 21:17:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

As you requested using X-Debbugs-CC, your message was also forwarded to
  Stefan Monnier <monnier@HIDDEN>
(after having been given a bug report number, if it did not have one).

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 31361 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
31361: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D31361
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#31361: 25.3; Issue when advising `indent-line-function'
Resent-From: Nicolas Goaziou <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 05 May 2018 14:27:02 +0000
Resent-Message-ID: <handler.31361.B31361.15255303952586 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 31361
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 31361 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier@HIDDEN>
Received: via spool by 31361-submit <at> debbugs.gnu.org id=B31361.15255303952586
          (code B ref 31361); Sat, 05 May 2018 14:27:02 +0000
Received: (at 31361) by debbugs.gnu.org; 5 May 2018 14:26:35 +0000
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>
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-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.





Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.