* Bug in orgalist mode's advice on indent-according-to-mode
@ 2022-04-28 5:32 Eric Abrahamsen
2022-04-28 6:06 ` Tim Cross
0 siblings, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2022-04-28 5:32 UTC (permalink / raw)
To: emacs-orgmode
In Emacs commit f596f0db82c0b1ff3fe8e8f1d8b07d2fe7504ab6, from Nov 2021,
the function `indent-according-to-mode' was given an optional
inhibit-widen argument. That argument being passed causes orgalist's
advice to fail, as the lambda doesn't accept any additional arguments.
One way to fix it would be like that:
(unless (advice-member-p 'orgalist-fix-bug:31361 'indent-according-to-mode)
(advice-add 'indent-according-to-mode
:around (lambda (old &optional inhibit-widen)
"Workaround bug#31361."
(or (orgalist--indent-line)
(let ((indent-line-function
(advice--cd*r indent-line-function)))
(funcall old inhibit-widen))))
'((name . orgalist-fix-bug:31361)))))
Or I suppose a more future-proof approach might be to use a &rest and
then `apply' instead of `funcall'.
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in orgalist mode's advice on indent-according-to-mode
2022-04-28 5:32 Bug in orgalist mode's advice on indent-according-to-mode Eric Abrahamsen
@ 2022-04-28 6:06 ` Tim Cross
2022-04-28 15:39 ` Eric Abrahamsen
0 siblings, 1 reply; 4+ messages in thread
From: Tim Cross @ 2022-04-28 6:06 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> In Emacs commit f596f0db82c0b1ff3fe8e8f1d8b07d2fe7504ab6, from Nov 2021,
> the function `indent-according-to-mode' was given an optional
> inhibit-widen argument. That argument being passed causes orgalist's
> advice to fail, as the lambda doesn't accept any additional arguments.
> One way to fix it would be like that:
>
> (unless (advice-member-p 'orgalist-fix-bug:31361 'indent-according-to-mode)
> (advice-add 'indent-according-to-mode
> :around (lambda (old &optional inhibit-widen)
> "Workaround bug#31361."
> (or (orgalist--indent-line)
> (let ((indent-line-function
> (advice--cd*r indent-line-function)))
> (funcall old inhibit-widen))))
> '((name . orgalist-fix-bug:31361)))))
>
> Or I suppose a more future-proof approach might be to use a &rest and
> then `apply' instead of `funcall'.
>
A better solution would probably be to fix this without using
add-advice. While advice can be a useful escape hatch, it really is best
avoided, especially given that it doesn't always play nice with lexical
binding. I note this one is also calling an undocumented internal
function.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in orgalist mode's advice on indent-according-to-mode
2022-04-28 6:06 ` Tim Cross
@ 2022-04-28 15:39 ` Eric Abrahamsen
2022-05-09 15:18 ` Eric Abrahamsen
0 siblings, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2022-04-28 15:39 UTC (permalink / raw)
To: emacs-orgmode
Tim Cross <theophilusx@gmail.com> writes:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> In Emacs commit f596f0db82c0b1ff3fe8e8f1d8b07d2fe7504ab6, from Nov 2021,
>> the function `indent-according-to-mode' was given an optional
>> inhibit-widen argument. That argument being passed causes orgalist's
>> advice to fail, as the lambda doesn't accept any additional arguments.
>> One way to fix it would be like that:
>>
>> (unless (advice-member-p 'orgalist-fix-bug:31361 'indent-according-to-mode)
>> (advice-add 'indent-according-to-mode
>> :around (lambda (old &optional inhibit-widen)
>> "Workaround bug#31361."
>> (or (orgalist--indent-line)
>> (let ((indent-line-function
>> (advice--cd*r indent-line-function)))
>> (funcall old inhibit-widen))))
>> '((name . orgalist-fix-bug:31361)))))
>>
>> Or I suppose a more future-proof approach might be to use a &rest and
>> then `apply' instead of `funcall'.
>>
>
> A better solution would probably be to fix this without using
> add-advice. While advice can be a useful escape hatch, it really is best
> avoided, especially given that it doesn't always play nice with lexical
> binding. I note this one is also calling an undocumented internal
> function.
In principle I quite agree! But orgalist is basically built on top of
add-function/advice-add, so I didn't think that was an option. And
also assumed that, given what Orgalist is trying to do, there isn't a
cleaner solution right now.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in orgalist mode's advice on indent-according-to-mode
2022-04-28 15:39 ` Eric Abrahamsen
@ 2022-05-09 15:18 ` Eric Abrahamsen
0 siblings, 0 replies; 4+ messages in thread
From: Eric Abrahamsen @ 2022-05-09 15:18 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Nicolas Goaziou
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Tim Cross <theophilusx@gmail.com> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>> In Emacs commit f596f0db82c0b1ff3fe8e8f1d8b07d2fe7504ab6, from Nov 2021,
>>> the function `indent-according-to-mode' was given an optional
>>> inhibit-widen argument. That argument being passed causes orgalist's
>>> advice to fail, as the lambda doesn't accept any additional arguments.
>>> One way to fix it would be like that:
>>>
>>> (unless (advice-member-p 'orgalist-fix-bug:31361 'indent-according-to-mode)
>>> (advice-add 'indent-according-to-mode
>>> :around (lambda (old &optional inhibit-widen)
>>> "Workaround bug#31361."
>>> (or (orgalist--indent-line)
>>> (let ((indent-line-function
>>> (advice--cd*r indent-line-function)))
>>> (funcall old inhibit-widen))))
>>> '((name . orgalist-fix-bug:31361)))))
>>>
>>> Or I suppose a more future-proof approach might be to use a &rest and
>>> then `apply' instead of `funcall'.
>>>
>>
>> A better solution would probably be to fix this without using
>> add-advice. While advice can be a useful escape hatch, it really is best
>> avoided, especially given that it doesn't always play nice with lexical
>> binding. I note this one is also calling an undocumented internal
>> function.
>
> In principle I quite agree! But orgalist is basically built on top of
> add-function/advice-add, so I didn't think that was an option. And
> also assumed that, given what Orgalist is trying to do, there isn't a
> cleaner solution right now.
What do you think, Nicolas? Can I patch this to use &rest and `apply'?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-09 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-28 5:32 Bug in orgalist mode's advice on indent-according-to-mode Eric Abrahamsen
2022-04-28 6:06 ` Tim Cross
2022-04-28 15:39 ` Eric Abrahamsen
2022-05-09 15:18 ` Eric Abrahamsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).