emacs-devel
[Top][All Lists]
Advanced

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

Misunderstanding set-buffer-modified-p?


From: Eric Abrahamsen
Subject: Misunderstanding set-buffer-modified-p?
Date: Fri, 01 Jan 2021 16:39:34 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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




reply via email to

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