emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lifting all buffer restrictions in indentation functions


From: Stephen Leake
Subject: Re: Lifting all buffer restrictions in indentation functions
Date: Fri, 08 Dec 2017 16:40:27 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (windows-nt)

Eli Zaretskii <address@hidden> writes:

> Hi, Emacs.
>
> The issue I raise here is a spin-off from discussing the changes on
> the widen-less branch, but I think it is largely independent and has
> more broad effect, so IMO it should be discussed separately.
>
> The widen-less branch proposes to have indent-according-to-mode,
> indent-for-tab-command, and indent-region call 'widen' before calling
> indent-line-function.  This call is unconditional, so for example the
> following
>
>   (save-excursion
>     (narrow-to-region START END)
>     (indent-for-tab-command))
>
> will not do what the caller expects, because indent-line-function will
> not run restricted to the region bounds, but will instead be able to
> access the whole buffer.
>
> The rationale for this change seems to be twofold:
>
>   . it is TRT for indentation operations
>   . MMM and similar features need that, and will apply the restriction
>     as appropriate before calling the mode-specific indentation
>     function
>
> I'm worried by widening unconditionally, because some strange mode
> could need to run its indentation function restricted, and the
> indentation function itself might not have enough context to narrow by
> itself.
>
> IOW, widening unconditionally seems to invalidate potentially
> legitimate uses of this functionality, so I wonder whether we should
> have some "fire escape", or maybe condition this widening only on MMM
> and similar modes being active.
>
> I'd like to hear opinions about this.  If I'm the only one who is
> bothered by this, then I will defer to Stefan's and Dmitry's opinions.
>
> TIA

As I understand it, what MMM will do in these functions is change the
buffer bounds to the current chunk.

Since MMM needs to change the buffer bounds, why can't it just disregard
the current bounds, instead of relying on the caller to widen first?

-- 
-- Stephe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]