[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ztree 4879576 19/23: Issue #39: restore cursor position
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ztree 4879576 19/23: Issue #39: restore cursor position and window configuration |
Date: |
Thu, 17 Dec 2020 23:17:06 -0500 (EST) |
branch: externals/ztree
commit 487957664cedc61d70feccc881092eef6746977b
Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
Commit: Alexey Veretennikov <alexey.veretennikov@gmail.com>
Issue #39: restore cursor position and window configuration
- The window configurations are now stored as a stack rather
than one buffer-local variable
- Introduced global hook on window configuration change
to redraw the contents of visible ztree buffers
---
ztree-diff.el | 13 +++++++++----
ztree-view.el | 11 +++++++++++
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/ztree-diff.el b/ztree-diff.el
index 5629237..3ff39fb 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -28,6 +28,7 @@
;;; Commentary:
;;; Code:
+(eval-when-compile (require 'cl))
(require 'ztree-view)
(require 'ztree-diff-model)
@@ -101,8 +102,10 @@ By default paths starting with dot (like .git) are
ignored")
(defvar-local ztree-diff-wait-message nil
"Message showing while constructing the diff tree.")
-(defvar-local ztree-diff-ediff-previous-window-configuration nil
- "Window configuration prior to calling `ediff'.")
+(defvar ztree-diff-ediff-previous-window-configurations nil
+ "Window configurations prior to calling `ediff'.
+A queue of window configurations, allowing
+to restore last configuration even if there were a couple of ediff sessions")
;;;###autoload
(define-minor-mode ztreediff-mode
@@ -238,7 +241,8 @@ Argument NODE node containing paths to files to call a diff
on."
See the Info node `(ediff) hooks'.
This hook function removes itself."
- (setq ztree-diff-ediff-previous-window-configuration
(current-window-configuration))
+ (push (current-window-configuration)
ztree-diff-ediff-previous-window-configurations)
+ (setq ztree-prev-position (cons (line-number-at-pos (point))
(current-column)))
(remove-hook 'ediff-before-setup-hook
#'ztree-diff-ediff-before-setup-hook-function))
(defun ztree-diff-ediff-quit-hook-function ()
@@ -247,7 +251,8 @@ This hook function removes itself."
See the Info node `(ediff) hooks'.
This hook function removes itself."
- (set-window-configuration ztree-diff-ediff-previous-window-configuration)
+ (set-window-configuration (pop
ztree-diff-ediff-previous-window-configurations))
+ (ztree-refresh-buffer)
(remove-hook 'ediff-quit-hook #'ztree-diff-ediff-quit-hook-function))
(defun ztree-diff-ediff (file-a file-b &optional startup-hooks)
diff --git a/ztree-view.el b/ztree-view.el
index c539699..e053210 100644
--- a/ztree-view.el
+++ b/ztree-view.el
@@ -745,6 +745,16 @@ change the root node to the node specified."
(ztree-scroll-to-line
(+ count (line-number-at-pos))))
+;;;###autoload
+(defun ztree-view-on-window-configuration-changed ()
+ "Hook called then window configuration changed to resize buffer's contents"
+ ;; refresh visible ztree buffers
+ (walk-windows (lambda (win)
+ (with-current-buffer (window-buffer win)
+ (when (derived-mode-p 'ztree-mode)
+ (ztree-refresh-buffer))))
+ nil 'visible))
+
(defun ztree-view (
buffer-name
start-node
@@ -788,6 +798,7 @@ Optional argument NODE-SIDE-FUN Determines the side of the
node."
(setq ztree-node-face-fun face-fun)
(setq ztree-node-action-fun action-fun)
(setq ztree-node-side-fun node-side-fun)
+ (add-hook 'window-configuration-change-hook
#'ztree-view-on-window-configuration-changed)
(ztree-refresh-buffer)))
- [elpa] externals/ztree bf34366 04/23: Merge pull request #45 from xiongtx/ediff-restore, (continued)
- [elpa] externals/ztree bf34366 04/23: Merge pull request #45 from xiongtx/ediff-restore, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 20b9c93 05/23: toggle show orphaned files, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree febc2d0 06/23: Merge pull request #46 from Iurie/master, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 0e0a39d 09/23: Issue #56: Preserve line/column position on refresh, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 67a1d90 11/23: Issue #56: Dont preserve a cursor position on widen/narrow operations, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 369fd05 10/23: Issue #50: Show file permission differences, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 00d3318 12/23: Issue #59: Position curson on the beginning of the text, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 3273e1f 13/23: Issue #60: ztree-dir change Emacs default directory, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree a3e0442 14/23: Issue #59: Place cursor at the beginning of the text, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 2f62ba7 18/23: Issue #62: Cleared warnings, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 4879576 19/23: Issue #39: restore cursor position and window configuration,
Stefan Monnier <=
- [elpa] externals/ztree c54425a 21/23: Updated README for issue #65., Stefan Monnier, 2020/12/17
- [elpa] externals/ztree d078daf 08/23: Issue #54: Added (optional) number of directory entries, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree c5a1190 15/23: Issue #61: Error on unaccessible directory contents, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 0a5b25f 23/23: Merge pull request #68 from webzak/fix_ws_ignore, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 1ebb00c 07/23: Issue #52: Added 'd' hotkey for the ztree-dir to open dired., Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 30dbda7 16/23: Issue #62, #63, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 50412fa 20/23: Issue #65: added ztree-diff-additional-options variable, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 901c3e3 22/23: support -w for different file size, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 17f8f32 17/23: Update to issue #62, Stefan Monnier, 2020/12/17