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: Stefan Monnier
Subject: Re: master e8488bcc9c: Avoid having font locking triggering unnecessary auto-saving
Date: Mon, 09 May 2022 14:29:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> -         ;; We restore the buffer tick count, too, because otherwise
> -         ;; we'll trigger a new auto-save.
> -         (internal--set-buffer-modified-tick ,tick)
> -         (unless ,modified
> -           (restore-buffer-modified-p nil))))))
> +         (when (or (not ,modified)
> +                   (eq ,modified 'autosaved))
> +           (restore-buffer-modified-p ,modified))))))

[ I'd use `(unless (eq ,modified t)`  ]

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.

> -  return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil;
> +  if (BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf))
> +    {
> +      if (BUF_AUTOSAVE_MODIFF (buf) == BUF_MODIFF (buf))
> +     return Qautosaved;
> +      else
> +     return Qt;
> +    }
> +  else
> +    return Qnil;

I'd use ?: for both tests :-)

> +  else
> +    {
> +      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`.


        Stefan




reply via email to

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