[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eldoc-diffstat 0481f4f5a7 3/6: Add minor mode
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eldoc-diffstat 0481f4f5a7 3/6: Add minor mode |
Date: |
Sat, 14 Dec 2024 19:00:48 -0500 (EST) |
branch: elpa/eldoc-diffstat
commit 0481f4f5a7ca89822faf94bd345161a8f0903f38
Author: Johann Klähn <johann@jklaehn.de>
Commit: Johann Klähn <johann@jklaehn.de>
Add minor mode
Cf. https://lists.gnu.org/archive/html/emacs-devel/2024-12/msg00589.html
Suggested-by: Stefan Kangas <stefankangas@gmail.com>
---
NEWS.md | 6 ++++++
README.md | 12 +++---------
eldoc-diffstat.el | 44 +++++++++++++++++++++++++++++++++++++-------
3 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/NEWS.md b/NEWS.md
new file mode 100644
index 0000000000..2d69c24cc6
--- /dev/null
+++ b/NEWS.md
@@ -0,0 +1,6 @@
+## unreleased
+
+- `eldoc-diffstat-setup` has been replaced by a minor mode
+ `eldoc-diffstat-mode`; there's also a globalized minor mode
+ `global-eldoc-diffstat-mode` that (by default) will turn on diffstat output
in
+ all supported major modes.
diff --git a/README.md b/README.md
index 732407ac2b..c438435d67 100644
--- a/README.md
+++ b/README.md
@@ -5,15 +5,9 @@ It supports Git and Mercurial repositories.
![A screenshot showing diffstat information in the echo area of a magit-log
buffer.](screenshot.webp "diffstat information is available in the echo area.")
-To use, call `eldoc-diffstat-setup` in the desired buffer or mode hook, e.g.:
-
-```elisp
-(add-hook 'git-rebase-mode-hook #'eldoc-diffstat-setup)
-(add-hook 'log-view-mode-hook #'eldoc-diffstat-setup)
-(add-hook 'magit-log-mode-hook #'eldoc-diffstat-setup)
-(add-hook 'magit-status-mode-hook #'eldoc-diffstat-setup)
-(add-hook 'vc-annotate-mode-hook #'eldoc-diffstat-setup)
-```
+To turn on diffstat output in all supported major modes, enable
+`global-eldoc-diffstat-mode`. You can instead also enable
+`eldoc-diffstat-mode` in individual buffers or via mode hooks.
You might also want to add the following to your config:
diff --git a/eldoc-diffstat.el b/eldoc-diffstat.el
index 04636a906c..db2cf864f7 100644
--- a/eldoc-diffstat.el
+++ b/eldoc-diffstat.el
@@ -47,6 +47,11 @@
;; These slots are used in git-rebase-action (see git-rebase.el).
(eieio-declare-slots action-type target)
+(defgroup eldoc-diffstat nil
+ "Show VCS diffstat information in echo area."
+ :group 'eldoc
+ :group 'vc)
+
(defvar eldoc-diffstat--process nil
"The latest async process used for fetching diffstat information.
Only one active process at a time; new requests terminate previous ones.
@@ -79,13 +84,38 @@ a property to the process object.")
Has to match `eldoc-diffstat--commands'.")
;;;###autoload
-(defun eldoc-diffstat-setup ()
- "Configure eldoc buffer-locally to display diffstat for revision at point."
- (interactive)
- (add-hook 'eldoc-documentation-functions
- #'eldoc-diffstat--docstring nil 'local)
- (unless (bound-and-true-p eldoc-mode)
- (eldoc-mode)))
+(define-obsolete-function-alias 'eldoc-diffstat-setup 'eldoc-diffstat-mode
+ "1.0" "Configure eldoc buffer-locally to display diffstat for revision at
point.")
+
+;;;###autoload
+(define-minor-mode eldoc-diffstat-mode
+ "Toggle echo area display of VCS diffstat information in the local buffer.
+
+When enabled, diffstat information is shown in supported major modes if
+point is on a revision."
+ :group 'eldoc-diffstat
+ :lighter nil
+ (if eldoc-diffstat-mode
+ (progn
+ (add-hook 'eldoc-documentation-functions
+ #'eldoc-diffstat--docstring nil 'local)
+ (eldoc-mode))
+ (remove-hook 'eldoc-documentation-functions
+ #'eldoc-diffstat--docstring 'local)
+ ;; Disable eldoc if diffstat was the only information source.
+ (unless (eldoc--supported-p)
+ (eldoc-mode -1))))
+
+;;;###autoload
+(define-globalized-minor-mode global-eldoc-diffstat-mode
+ eldoc-diffstat-mode eldoc-diffstat-mode
+ :group 'eldoc-diffstat
+ :predicate
+ '(git-rebase-mode
+ log-view-mode
+ magit-log-mode
+ magit-status-mode
+ vc-annotate-mode))
(defun eldoc-diffstat--docstring (callback &rest _ignored)
"Display diffstat for revision at point by calling CALLBACK.
- [nongnu] elpa/eldoc-diffstat updated (99b49c9793 -> 33aa6d7ee5), ELPA Syncer, 2024/12/14
- [nongnu] elpa/eldoc-diffstat 98e0e18a41 1/6: Fix potential race condition, ELPA Syncer, 2024/12/14
- [nongnu] elpa/eldoc-diffstat 0481f4f5a7 3/6: Add minor mode,
ELPA Syncer <=
- [nongnu] elpa/eldoc-diffstat e954a705f1 2/6: Address review comments (on emacs-devel), ELPA Syncer, 2024/12/14
- [nongnu] elpa/eldoc-diffstat bd7fcae4c1 5/6: Always register magit commands with eldoc, ELPA Syncer, 2024/12/14
- [nongnu] elpa/eldoc-diffstat 33aa6d7ee5 6/6: Release version 1.0, ELPA Syncer, 2024/12/14
- [nongnu] elpa/eldoc-diffstat 50c1c5ebb8 4/6: Add option to truncate / pad output, ELPA Syncer, 2024/12/14