emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] scratch/widen-less a4ba846: Replace prog-widen with co


From: Dmitry Gutov
Subject: Re: [Emacs-diffs] scratch/widen-less a4ba846: Replace prog-widen with consolidating widen calls
Date: Fri, 1 Dec 2017 18:59:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Thunderbird/57.0

On 12/1/17 4:26 PM, Stefan Monnier wrote:
The way your above situation would be handled is to say "the low level
function mentioned above assumes that the buffer has already been
properly widened".  This way, it doesn't need to know whether it's being
called (indirectly) from indent-line-function or b-o-d-function.

That one way, I'd call it "clean". But the change might take quite a bit of effort, depending on the size of the code base.

But some of its callers may need to be changed to do the widening, and
indeed, in order to know how far to widen, they'll need the help from
the multi-major-mode package.

That would be the "dirty" way.

So maybe we need something like:

     (defvar prog-widen-function #'widen)
     (defun prog-widen () (funcall prog-widen-function))

I don't know if we need that in the common API, but individual packages can define such shims if they find that convenient.

E.g.

(defvar cc-mode-inside-indent-line nil)

(defun cc-mode-maybe-widen ()
  ;; You can also throw in an Emacs version check here,
  ;; for good measure.
  (unless cc-mode-inside-indent-line (widen)))

And then the "low-level primitives" can call cc-mode-maybe-widen.

[ And maybe for the same reason, we need a function (rather than
   a variable) that returns the `first-column`, so we can get the info
   anywhere/anytime rather than only during indentation.  ]

Please elaborate.

How does using a function instead of a variable change the duration when prog-first-column is set?

And when else will we need this value?



reply via email to

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