unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: emacs-orgmode@gnu.org, emacs-devel@gnu.org
Subject: Re: orgalist-mode: wrong indentation in message mode after recent change in emacs
Date: Tue, 23 Apr 2019 08:15:09 -0400	[thread overview]
Message-ID: <jwvr29tnd2a.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87wojldmcx.fsf@tcd.ie> (Basil L. Contovounesios's message of "Tue, 23 Apr 2019 11:53:02 +0100")

>>> The first is whether orgalist-mode couldn't use a custom
>>> indent-line-function instead of advising what may or may not be set to
>>> indent-relative by the user.
>> I don't know how that would work in practice.
> Me neither.
>> But a minor mode taking control over `indent-line-function' sounds
>> wrong.
> Well, orgalist already "takes control" over indent-line-function and
> indent-according-to-mode via advice, and the latter advice seems to
> assume that indent-line-function is set to the default indent-relative
> or indent-relative-first-indent-point.

I haven't bothered to look at the advice to have an opinion here, so
I'll let you guys figure out this part.

>>> The second is why advice--buffer-local does what it does.  Stefan, why
>>> does it behave differently depending on local-variable-p?  Why can't it
>>> simply call make-local-variable before returning the symbol-value?

Normally a hook runs both its local part and its global part, where the
global part is represented in the local list by the special element `t`.

When you do `make-local-variable` you're basically *copying* the global
part to the local part, with the usual implications: when the global
part is later modified those modifications won't be properly reflected
in the local copy.  That's why we had `make-local-hook` which is now
automatically performed by `add-hook` depending on the `local` arg.

The exact same thing goes for `add-function` when applied to a variable.

In the current case, I think calling `make-local-variable` is likely
harmless because *we* know the global value should likely never change,
but that's not something that `add-function` knows to be true in
general.  So instead, `add-function` sets the local value to a function
that looks up the global value and runs it, which is the moral
equivalent of the `t` element on normal hooks.

>>> The third is why indent-according-to-mode hard-codes the check for
>>> indent-relative and indent-relative-first-indent-point.

History.  Comparing functions is always a bad idea.
But I couldn't and still can't see how to avoid it here without
introducing worse problems.

>>> Wouldn't it be nice if this check instead looked up some variable
>>> akin to electric-indent-functions-without-reindent, that can be more
>>> easily customised?

Yes, tho it probably wouldn't help much here: not only we'd still be
comparing functions, but we'd also need for orgalist to go through the
trouble of manually adding the closure dynamically created by
`add-function` to this list.


        Stefan



  reply	other threads:[~2019-04-23 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 16:35 orgalist-mode: wrong indentation in message mode after recent change in emacs Gregor Zattler
2019-04-01 22:32 ` Basil L. Contovounesios
2019-04-02 11:08   ` Stefan Monnier
2019-04-11 20:32   ` Stefan Monnier
2019-04-23  8:20   ` Nicolas Goaziou
2019-04-23 10:53     ` Basil L. Contovounesios
2019-04-23 12:15       ` Stefan Monnier [this message]
2019-12-31 10:30       ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvr29tnd2a.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=contovob@tcd.ie \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).