unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Misunderstanding set-buffer-modified-p?
@ 2021-01-02  0:39 Eric Abrahamsen
  2021-01-02  6:02 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2021-01-02  0:39 UTC (permalink / raw)
  To: emacs-devel

Hi all,

A while ago I added a call to `set-buffer-modified-p' at the end of
`sieve-upload' (in ./lisp/net/sieve.el), to provide a better visual cue
to the user that the sieve script upload had succeeded (it suffers from
the "returns suspiciously fast" syndrome).

It "doesn't work", in the sense that the buffer modeline is still marked
modified after the function completes. It's not just a redisplay issue,
either: running M-: (buffer-modified-p) returns t.

However, manually running M-: (set-buffer-modified-p nil) after the
script is uploaded *does* successfully set the modified flag to nil and
update the modeline.

Can anyone tell me if I'm doing something wrong, or I've understood
something incorrectly?

(defun sieve-upload (&optional name)
  (interactive)
  (when (or (get-buffer sieve-buffer)
            (save-current-buffer (call-interactively 'sieve-manage)))
    (let ((script (buffer-string))
          (script-name (file-name-sans-extension (buffer-name)))
          err)
      (with-current-buffer (get-buffer sieve-buffer)
	(setq err (sieve-manage-putscript
                   (or name sieve-buffer-script-name script-name)
                   script sieve-manage-buffer))
        (if (not (sieve-manage-ok-p err))
            (message "Sieve upload failed: %s" (nth 2 err))
          (message "Sieve upload done.  Use %s to manage scripts."
                   (substitute-command-keys "\\[sieve-manage]"))
          (set-buffer-modified-p nil))))))




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Misunderstanding set-buffer-modified-p?
  2021-01-02  0:39 Misunderstanding set-buffer-modified-p? Eric Abrahamsen
@ 2021-01-02  6:02 ` Lars Ingebrigtsen
  2021-01-02 19:04   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-02  6:02 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-devel

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> It "doesn't work", in the sense that the buffer modeline is still marked
> modified after the function completes. It's not just a redisplay issue,
> either: running M-: (buffer-modified-p) returns t.

[...]

> Can anyone tell me if I'm doing something wrong, or I've understood
> something incorrectly?

I think what you're doing should work, so I'm wondering whether
something in the code is changing the current buffer, and you're calling
(set-buffer-modified-p nil) in the wrong buffer?  Not that any of the
functions between `with-current-buffer' and setting the modified flag
look suspicious, but...

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Misunderstanding set-buffer-modified-p?
  2021-01-02  6:02 ` Lars Ingebrigtsen
@ 2021-01-02 19:04   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2021-01-02 19:04 UTC (permalink / raw)
  To: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> It "doesn't work", in the sense that the buffer modeline is still marked
>> modified after the function completes. It's not just a redisplay issue,
>> either: running M-: (buffer-modified-p) returns t.
>
> [...]
>
>> Can anyone tell me if I'm doing something wrong, or I've understood
>> something incorrectly?
>
> I think what you're doing should work, so I'm wondering whether
> something in the code is changing the current buffer, and you're calling
> (set-buffer-modified-p nil) in the wrong buffer?  Not that any of the
> functions between `with-current-buffer' and setting the modified flag
> look suspicious, but...

Sheesh, that was the right hint, and I should have been able to see that
myself. `sieve-buffer' isn't the script buffer, it's the "control panel"
buffer, so the call to `set-buffer-modified-p' belongs outside the
`with-current-buffer'. Thanks for the nudge.

Eric




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-02 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02  0:39 Misunderstanding set-buffer-modified-p? Eric Abrahamsen
2021-01-02  6:02 ` Lars Ingebrigtsen
2021-01-02 19:04   ` Eric Abrahamsen

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).