[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/edit-indirect e3d86416bc 26/28: Offer to commit edit-indir
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/edit-indirect e3d86416bc 26/28: Offer to commit edit-indirect buffers on save-buffers-kill-emacs |
Date: |
Thu, 7 Jul 2022 11:59:15 -0400 (EDT) |
branch: elpa/edit-indirect
commit e3d86416bcf8ddca951d7d112e57ad30c5f9a081
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Offer to commit edit-indirect buffers on save-buffers-kill-emacs
Fixes #20.
---
edit-indirect.el | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/edit-indirect.el b/edit-indirect.el
index 887b837cd2..88ec9f0bed 100644
--- a/edit-indirect.el
+++ b/edit-indirect.el
@@ -2,7 +2,7 @@
;; Author: Fanael Linithien <fanael4@gmail.com>
;; URL: https://github.com/Fanael/edit-indirect
-;; Version: 0.1.7
+;; Version: 0.1.8
;; Package-Requires: ((emacs "24.3"))
;; This file is NOT part of GNU Emacs.
@@ -279,6 +279,7 @@ VARIABLE shall be a symbol."
BEG..END is the parent buffer region to insert.
OVERLAY is the overlay, see `edit-indirect--overlay'."
+ (add-hook 'after-change-major-mode-hook #'edit-indirect--rebind-save-hooks)
(let ((buffer (generate-new-buffer (format "*edit-indirect %s*"
(buffer-name))))
(parent-buffer (current-buffer)))
(overlay-put overlay 'edit-indirect-buffer buffer)
@@ -349,7 +350,8 @@ No error is signaled if `inhibit-read-only' or
(edit-indirect--run-hook-with-positions
'edit-indirect-after-commit-functions beg-marker (point))
(set-marker beg-marker nil)
- (set-marker end-marker nil))))))
+ (set-marker end-marker nil))))
+ (set-buffer-modified-p nil)))
(defun edit-indirect--run-hook-with-positions (hook beg end)
"Run HOOK with the specified positions BEG and END.
@@ -382,6 +384,19 @@ called with updated positions."
(quit-window t)
(kill-buffer)))
+(defun edit-indirect--rebind-save-hooks ()
+ "Bind our `save-buffer' hooks in the current buffer.
+Does nothing if the current buffer is not an edit-indirect buffer."
+ (when (edit-indirect-buffer-indirect-p)
+ (setq buffer-offer-save t)
+ (add-hook 'write-contents-functions #'edit-indirect--commit-on-save nil
t)))
+
+(defun edit-indirect--commit-on-save ()
+ "Commit the indirect edit.
+Should only be called from `write-contents-functions'."
+ (edit-indirect--commit)
+ t)
+
(defun edit-indirect--abort-on-kill-buffer ()
"Abort indirect edit.
Should be called only from `kill-buffer-hook'."
- [nongnu] elpa/edit-indirect f80f63822f 28/28: Make edit-indirect--should-quit-window persistent, (continued)
- [nongnu] elpa/edit-indirect f80f63822f 28/28: Make edit-indirect--should-quit-window persistent, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 03b6ac9ed1 25/28: Use a remap binding for save-buffer instead of hardcoded C-x C-s, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 7fffd87ac3 24/28: Don't modify buffer if nothing changed, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 16bcdbdae6 27/28: Add an overlay keymap for easy switching to active edit-indirect buffers, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect b461e559e1 05/28: Don't retrieve the buffer-local hook values before actual uses., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 7d9bcfced3 06/28: Extract buffer-local value handling into a macro., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 6fa78ff6f1 07/28: Prohibit modification at the beginning of the overlay., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect f43936b3a4 12/28: Use `quit-window' instead of `kill-buffer-and-window`., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect d1ab87fdfb 14/28: Release version 0.1.2., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 032ac0ec69 20/28: Try to preserve markers when committing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect e3d86416bc 26/28: Offer to commit edit-indirect buffers on save-buffers-kill-emacs,
ELPA Syncer <=
- [nongnu] elpa/edit-indirect ce6e60c705 08/28: Require Emacs 24.3, for user-error., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect a28aba75f8 13/28: Don't separate sentences with double spaces., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 523f84cb7e 10/28: Release version 0.1.1., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 45c4c72864 09/28: Use our own error signals inheriting from user-error., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect c6b08f5cd7 15/28: Call quit-window only when a window is created, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 99a88e9590 17/28: Make edit-indirect-quit-window a buffer-local variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 1d1dae8425 18/28: Release version 0.1.4, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 935ded353b 22/28: Add SPDX license identifier for easy license identification, ELPA Syncer, 2022/07/07