emacs-devel
[Top][All Lists]
Advanced

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

Re: master e8488bcc9c: Avoid having font locking triggering unnecessary


From: Lars Ingebrigtsen
Subject: Re: master e8488bcc9c: Avoid having font locking triggering unnecessary auto-saving
Date: Tue, 10 May 2022 03:51:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +         (when (or (not ,modified)
>> +                   (eq ,modified 'autosaved))
>> +           (restore-buffer-modified-p ,modified))))))
>
> [ I'd use `(unless (eq ,modified t)`  ]

The return value is now defined as nil/`autosaved'/non-nil, so assuming
t is no longer the thing.

> But... hmm... what if `body` caused the modified-p status to change from
> `autosaved` to `nil`.  With the old code, we'd leave `nil` untouched,
> but with the new code we'd re-set it to `autosaved`.
>
> Admittedly, it's quite unlikely for `body` to save the buffer (and hence
> cause the modified-p status to change from `autosaved` to `nil`), so I'm
> not sure how important this is.

I think that's probably outside the scope for this macro.

>> +      if (EQ (flag, Qautosaved))
>> +       BUF_AUTOSAVE_MODIFF (b) = MODIFF;
>> +      /* If SAVE_MODIFF == auto_save_modified == MODIFF, we can either
>> +        decrease SAVE_MODIFF and auto_save_modified or increase
>> +        MODIFF.  */
>> +      else if (SAVE_MODIFF >= MODIFF)
>> +       SAVE_MODIFF = modiff_incr (&MODIFF);
>> +    }
>
> I think this will not do the right thing if you call
> `(restore-buffer-modified-p 'autosaved)` when modified-p is `nil`.

Yeah, the semantics are slightly obscure now, but you're not supposed to
call the function with `autosaved' when it hasn't been modified.

Perhaps it should just signal an error in that case?

It might also make sense to just add a new function that only does
auto-save modiff stuff, because things are somewhat un-orthogonal now.
restore-buffer-modified-p can set modification status to nil/t, but
can't set autosave status to t, only to nil.

But anyway, I've now pushed the changes.  (And will be removing
internal--set-buffer-modified-tick a bit later, but I'm gonna wait a
bit, because removing it will require everybody to say "make boostrap".)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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