unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
Subject: Re: master e8488bcc9c: Avoid having font locking triggering unnecessary auto-saving
Date: Tue, 10 May 2022 03:51:53 +0200	[thread overview]
Message-ID: <87k0aunohy.fsf@gnus.org> (raw)
In-Reply-To: <jwvlevapoa0.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 09 May 2022 14:29:05 -0400")

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	other threads:[~2022-05-10  1:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <165191796540.22789.3432288633082546349@vcs2.savannah.gnu.org>
     [not found] ` <20220507100605.B7CA7C051FF@vcs2.savannah.gnu.org>
2022-05-07 16:06   ` master e8488bcc9c: Avoid having font locking triggering unnecessary auto-saving Stefan Monnier
2022-05-07 16:10     ` Eli Zaretskii
2022-05-07 16:27       ` Stefan Monnier
2022-05-07 16:40         ` Eli Zaretskii
2022-05-07 17:21           ` Stefan Monnier
2022-05-07 17:26             ` Eli Zaretskii
2022-05-07 16:49     ` Lars Ingebrigtsen
2022-05-09 12:37   ` Lars Ingebrigtsen
2022-05-09 13:22     ` Stefan Monnier
2022-05-09 13:35       ` Lars Ingebrigtsen
2022-05-09 13:47         ` Lars Ingebrigtsen
2022-05-09 15:43           ` Stefan Monnier
2022-05-09 16:05             ` Lars Ingebrigtsen
2022-05-09 16:30               ` Eli Zaretskii
2022-05-09 16:45                 ` Lars Ingebrigtsen
2022-05-09 17:40                   ` Lars Ingebrigtsen
2022-05-09 18:29                     ` Stefan Monnier
2022-05-10  1:51                       ` Lars Ingebrigtsen [this message]
2022-05-10  2:11                         ` Stefan Monnier
2022-05-10 11:45                           ` Lars Ingebrigtsen
2022-05-10 11:55                             ` Stefan Monnier
2022-05-11 11:22                               ` Lars Ingebrigtsen
2022-05-11 13:19                                 ` Stefan Monnier
2022-05-12  0:18                                   ` Lars Ingebrigtsen
2022-05-09 17:00               ` Lars Ingebrigtsen

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=87k0aunohy.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).