diff options
| author | Juri Linkov | 2022-01-11 19:34:54 +0200 |
|---|---|---|
| committer | Juri Linkov | 2022-01-11 19:34:54 +0200 |
| commit | c8ea3f09e09b18b909f5a6c5434185b8dbf2fa63 (patch) | |
| tree | e56f120b6a6998d803c7c67e8cd94c1ca28039c4 | |
| parent | ecdda194a82c8c52bdb948160f55ebbabe733d79 (diff) | |
| download | emacs-c8ea3f09e09b18b909f5a6c5434185b8dbf2fa63.tar.gz emacs-c8ea3f09e09b18b909f5a6c5434185b8dbf2fa63.zip | |
* lisp/vc/vc.el (vc-shrink-buffer-window): New function (bug#51062).
(vc-diff-finish-functions): New variable.
(vc-diff-finish): Use it.
(vc-log-finish-functions): New variable.
(vc-log-internal-common): Use it.
| -rw-r--r-- | lisp/vc/vc.el | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 6f5c2f0934c..ef3354701c2 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -1730,12 +1730,22 @@ to override the value of `vc-diff-switches' and `diff-switches'." | |||
| 1730 | ;; any switches in diff-switches. | 1730 | ;; any switches in diff-switches. |
| 1731 | (when (listp switches) switches)))) | 1731 | (when (listp switches) switches)))) |
| 1732 | 1732 | ||
| 1733 | (defun vc-shrink-buffer-window (&optional buffer) | ||
| 1734 | "Call `shrink-window-if-larger-than-buffer' only when BUFFER is visible. | ||
| 1735 | BUFFER defaults to the current buffer." | ||
| 1736 | (let ((window (get-buffer-window buffer t))) | ||
| 1737 | (when window | ||
| 1738 | (shrink-window-if-larger-than-buffer window)))) | ||
| 1739 | |||
| 1740 | (defvar vc-diff-finish-functions '(vc-shrink-buffer-window) | ||
| 1741 | "Functions run at the end of the diff command. | ||
| 1742 | Each function runs in the diff output buffer without args.") | ||
| 1743 | |||
| 1733 | (defun vc-diff-finish (buffer messages) | 1744 | (defun vc-diff-finish (buffer messages) |
| 1734 | ;; The empty sync output case has already been handled, so the only | 1745 | ;; The empty sync output case has already been handled, so the only |
| 1735 | ;; possibility of an empty output is for an async process. | 1746 | ;; possibility of an empty output is for an async process. |
| 1736 | (when (buffer-live-p buffer) | 1747 | (when (buffer-live-p buffer) |
| 1737 | (let ((window (get-buffer-window buffer t)) | 1748 | (let ((emptyp (zerop (buffer-size buffer)))) |
| 1738 | (emptyp (zerop (buffer-size buffer)))) | ||
| 1739 | (with-current-buffer buffer | 1749 | (with-current-buffer buffer |
| 1740 | (and messages emptyp | 1750 | (and messages emptyp |
| 1741 | (let ((inhibit-read-only t)) | 1751 | (let ((inhibit-read-only t)) |
| @@ -1744,8 +1754,7 @@ to override the value of `vc-diff-switches' and `diff-switches'." | |||
| 1744 | (diff-setup-whitespace) | 1754 | (diff-setup-whitespace) |
| 1745 | (diff-setup-buffer-type) | 1755 | (diff-setup-buffer-type) |
| 1746 | (goto-char (point-min)) | 1756 | (goto-char (point-min)) |
| 1747 | (when window | 1757 | (run-hooks 'vc-diff-finish-functions)) |
| 1748 | (shrink-window-if-larger-than-buffer window))) | ||
| 1749 | (when (and messages (not emptyp)) | 1758 | (when (and messages (not emptyp)) |
| 1750 | (message "%sdone" (car messages)))))) | 1759 | (message "%sdone" (car messages)))))) |
| 1751 | 1760 | ||
| @@ -2498,6 +2507,10 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)." | |||
| 2498 | (put 'vc-log-view-type 'permanent-local t) | 2507 | (put 'vc-log-view-type 'permanent-local t) |
| 2499 | (defvar vc-sentinel-movepoint) | 2508 | (defvar vc-sentinel-movepoint) |
| 2500 | 2509 | ||
| 2510 | (defvar vc-log-finish-functions '(vc-shrink-buffer-window) | ||
| 2511 | "Functions run at the end of the log command. | ||
| 2512 | Each function runs in the log output buffer without args.") | ||
| 2513 | |||
| 2501 | (defun vc-log-internal-common (backend | 2514 | (defun vc-log-internal-common (backend |
| 2502 | buffer-name | 2515 | buffer-name |
| 2503 | files | 2516 | files |
| @@ -2529,11 +2542,11 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)." | |||
| 2529 | (vc-run-delayed | 2542 | (vc-run-delayed |
| 2530 | (let ((inhibit-read-only t)) | 2543 | (let ((inhibit-read-only t)) |
| 2531 | (funcall setup-buttons-func backend files retval) | 2544 | (funcall setup-buttons-func backend files retval) |
| 2532 | (shrink-window-if-larger-than-buffer) | ||
| 2533 | (when goto-location-func | 2545 | (when goto-location-func |
| 2534 | (funcall goto-location-func backend) | 2546 | (funcall goto-location-func backend) |
| 2535 | (setq vc-sentinel-movepoint (point))) | 2547 | (setq vc-sentinel-movepoint (point))) |
| 2536 | (set-buffer-modified-p nil))))) | 2548 | (set-buffer-modified-p nil) |
| 2549 | (run-hooks 'vc-log-finish-functions))))) | ||
| 2537 | 2550 | ||
| 2538 | (defun vc-incoming-outgoing-internal (backend remote-location buffer-name type) | 2551 | (defun vc-incoming-outgoing-internal (backend remote-location buffer-name type) |
| 2539 | (vc-log-internal-common | 2552 | (vc-log-internal-common |