all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 28412@debbugs.gnu.org
Subject: bug#28412: Acknowledgement (26.0.50; Let save-some-buffers accept write-contents-functions)
Date: Mon, 11 Sep 2017 14:41:08 -0700	[thread overview]
Message-ID: <87poawhq17.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <83zia1s2f6.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 11 Sep 2017 18:03:25 +0300")

> Thanks.  Can we have some simple tests for this, both with and without
> visiting a file?

Is this sufficient, do you think?


(ert-deftest files-test-no-file-write-contents ()
  "Test that `write-contents-functions' permits saving a file.
Usually `basic-save-buffer' will prompt for a file name if the
current buffer has none.  It should first call the functions in
`write-contents-functions', and if one of them returns non-nil,
consider the buffer saved, without prompting for a file
name (Bug#28412)."
  (let ((read-file-name-function
         (lambda (&rest _ignore)
           (error "Prompting for file name"))))
    ;; With contents function, and no file.
    (with-temp-buffer
      (setq write-contents-functions
            (list (lambda () t)))
      (set-buffer-modified-p t)
      (should (null (save-buffer))))
    ;; With no contents function and no file.  This should reach the
    ;; `read-file-name' prompt.
    (with-temp-buffer
      (set-buffer-modified-p t)
      (should-error (save-buffer) :type 'error))
    ;; Then a buffer visiting a file: should save normally.
    (files-tests--with-temp-file temp-file-name
      (with-current-buffer (find-file-noselect temp-file-name)
        (setq write-contents-functions nil)
        (insert "p")
        (should (null (save-buffer)))
        (should (eq (buffer-size) 1))))))






  reply	other threads:[~2017-09-11 21:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 21:50 bug#28412: 26.0.50; Let save-some-buffers accept write-contents-functions Eric Abrahamsen
     [not found] ` <handler.28412.B.15050803219580.ack@debbugs.gnu.org>
2017-09-10 22:01   ` bug#28412: Acknowledgement (26.0.50; Let save-some-buffers accept write-contents-functions) Eric Abrahamsen
2017-09-11 15:03     ` Eli Zaretskii
2017-09-11 21:41       ` Eric Abrahamsen [this message]
2017-09-12 14:41         ` Eli Zaretskii
2017-09-12 23:18           ` Eric Abrahamsen
2017-09-18 16:16 ` bug#28412: 26.0.50; Let save-some-buffers accept write-contents-functions Kaushal Modi
2017-09-18 18:04   ` Eli Zaretskii
2017-09-18 18:14     ` Eric Abrahamsen
2017-09-18 19:25       ` Eli Zaretskii
2017-09-18 20:30         ` Eric Abrahamsen
2017-09-18 19:12     ` Eric Abrahamsen
2017-09-18 19:23       ` Kaushal Modi
2017-09-18 20:53         ` Eric Abrahamsen
2017-09-18 21:48           ` Kaushal Modi
2017-09-19 16:13             ` Eli Zaretskii
2017-09-25 14:46               ` Kaushal Modi
2017-10-19 15:25               ` Eric Abrahamsen
2017-09-19 16:09         ` Eli Zaretskii
2017-09-18 19:28       ` Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87poawhq17.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=28412@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.