[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/edit-indirect 16bcdbdae6 27/28: Add an overlay keymap for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/edit-indirect 16bcdbdae6 27/28: Add an overlay keymap for easy switching to active edit-indirect buffers |
Date: |
Thu, 7 Jul 2022 11:59:15 -0400 (EDT) |
branch: elpa/edit-indirect
commit 16bcdbdae610fbaacfb7165785a218c0e1972238
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Add an overlay keymap for easy switching to active edit-indirect buffers
Fixes #22.
---
edit-indirect.el | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/edit-indirect.el b/edit-indirect.el
index 88ec9f0bed..a17f8bcf1e 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.8
+;; Version: 0.1.9
;; Package-Requires: ((emacs "24.3"))
;; This file is NOT part of GNU Emacs.
@@ -139,6 +139,8 @@ properties, which happens surprisingly often when the
font-lock
mode is used.
Edit-indirect buffers use the `edit-indirect-mode-map' keymap.
+Regions with active edit-indirect buffers use the
+`edit-indirect-overlay-map' keymap.
If there's already an edit-indirect buffer for BEG..END, use that.
If there's already an edit-indirect buffer active overlapping any
@@ -156,9 +158,7 @@ In any case, return the edit-indirect buffer."
(user-error "No region")))
(let ((buffer (edit-indirect--get-edit-indirect-buffer beg end)))
(when display-buffer
- (with-current-buffer buffer
- (setq-local edit-indirect--should-quit-window t))
- (select-window (display-buffer buffer)))
+ (edit-indirect--display-buffer buffer))
buffer))
(defvar edit-indirect-mode-map
@@ -172,6 +172,14 @@ In any case, return the edit-indirect buffer."
\\{edit-indirect-mode-map}")
+(defvar edit-indirect-overlay-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "RET") #'edit-indirect-display-active-buffer)
+ map)
+ "Keymap for regions with active edit-indirect buffers.
+
+\\{edit-indirect-overlay-map}")
+
(defun edit-indirect-commit ()
"Commit the modifications done in an edit-indirect buffer.
That is, replace the original region in the parent buffer with the
@@ -219,6 +227,16 @@ BUFFER defaults to the current buffer."
It's done by calling `normal-mode'."
(normal-mode))
+(defun edit-indirect-display-active-buffer ()
+ "Display the active edit-indirect buffer of the region the point is in."
+ (interactive)
+ (let ((overlay
+ (let ((p (point)))
+ (edit-indirect--search-for-edit-indirect p (1+ p)))))
+ (unless overlay
+ (signal 'edit-indirect-not-indirect '()))
+ (edit-indirect--display-buffer (overlay-get overlay
'edit-indirect-buffer))))
+
(defvar edit-indirect--overlay nil
"The overlay spanning the region of the parent buffer being edited.
@@ -238,6 +256,13 @@ OVERLAY is the value to set `edit-indirect--overlay' to."
(add-minor-mode
'edit-indirect--overlay " indirect" edit-indirect-mode-map nil #'ignore))
+(defun edit-indirect--display-buffer (buffer)
+ "Display the given BUFFER in some window and select it."
+ (with-current-buffer buffer
+ (setq-local edit-indirect--should-quit-window t))
+ (select-window (display-buffer buffer))
+ nil)
+
(defun edit-indirect--get-edit-indirect-buffer (beg end)
"Return an edit-indirect buffer for the region BEG..END.
If there's already an edit-indirect buffer active overlapping any
@@ -315,6 +340,7 @@ BEG and END specify the region the overlay should
encompass."
(overlay-put overlay 'face 'edit-indirect-edited-region)
(overlay-put overlay 'modification-hooks '(edit-indirect--barf-read-only))
(overlay-put overlay 'insert-in-front-hooks
'(edit-indirect--barf-read-only))
+ (overlay-put overlay 'keymap edit-indirect-overlay-map)
overlay))
(defvar edit-indirect--inhibit-read-only nil
- [nongnu] elpa/edit-indirect ac56a2ff8d 03/28: Add C-c C-c binding for edit-indirect-commit., (continued)
- [nongnu] elpa/edit-indirect ac56a2ff8d 03/28: Add C-c C-c binding for edit-indirect-commit., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect e01e7eeb79 04/28: Extract a nested let into a function., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 273910a944 11/28: Ensure commit hooks are always called with the correct region., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 215d3a714a 16/28: Release version 0.1.3, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect de645d8144 21/28: Add edit-indirect-save function and keybinding, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 2fc8f382ee 19/28: Add before-commit-hook, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect bdc8f542fe 23/28: Don't run buffer-local after-creation-hook twice, ELPA Syncer, 2022/07/07
- [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 <=
- [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, 2022/07/07
- [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