[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/dired-git-info b5551e7 30/33: Convert entry command to mi
From: |
Clemens Radermacher |
Subject: |
[elpa] scratch/dired-git-info b5551e7 30/33: Convert entry command to minor mode |
Date: |
Sun, 17 Feb 2019 13:03:32 -0500 (EST) |
branch: scratch/dired-git-info
commit b5551e72f40680e5dab296549f17105972527aef
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Convert entry command to minor mode
---
README.org | 4 +--
dired-git-info.el | 79 +++++++++++++++++++++++++++++--------------------------
2 files changed, 43 insertions(+), 40 deletions(-)
diff --git a/README.org b/README.org
index 0e0a891..9f2386c 100644
--- a/README.org
+++ b/README.org
@@ -15,9 +15,9 @@ For manual installation, clone the repository and call:
* Config
-Bind the command in direds mode map:
+Bind the minor mode command in direds mode map:
#+BEGIN_SRC elisp
(with-eval-after-load 'dired
- (define-key dired-mode-map ")" 'dgi-toggle-git-info))
+ (define-key dired-mode-map ")" 'dired-git-info-mode))
#+END_SRC
diff --git a/dired-git-info.el b/dired-git-info.el
index 5638afe..40b0de9 100644
--- a/dired-git-info.el
+++ b/dired-git-info.el
@@ -29,6 +29,7 @@
;;; Code:
+(require 'dired)
(defgroup dired-git-info nil
"Show git info in dired."
@@ -174,47 +175,49 @@ info format and defaults to `dgi-commit-message-format'."
;;;###autoload
-(defun dgi-toggle-git-info ()
+(define-minor-mode dired-git-info-mode
"Toggle git message info in current dired buffer."
- (interactive)
- (unless (derived-mode-p 'dired-mode)
- (user-error "Not in a dired buffer"))
- (unless (locate-dominating-file "." ".git")
- (user-error "Not inside a git repository"))
- (if dgi--commit-ovs
- (dgi--cleanup)
- (when dgi-auto-hide-details-p
- (unless dired-hide-details-mode
- (setq dgi--restore-no-details t)
- (dired-hide-details-mode 1)))
- (let* ((files (dgi--save-marked
- (dired-unmark-all-marks)
- (dired-toggle-marks)
- (dired-get-marked-files)))
- (minspc (1+ (apply #'max (dgi--get-dired-files-length files))))
- (messages (dgi--get-commit-messages files)))
- (save-excursion
- (dolist (file files)
- (let ((msg (pop messages)))
- (when msg
- (dired-goto-file file)
- (let ((spc (make-string
- (- minspc (dgi--get-dired-file-length file))
- ?\s)))
- (goto-char (line-end-position))
- (let ((ov (make-overlay (point) (1+ (point))))
- (ovs (concat spc
- (propertize
- msg 'face 'dgi-commit-message-face)
- "\n")))
- (push ov dgi--commit-ovs)
- ;; I don't use after-string because I didn't get it to work
- ;; in combination with hl-line-mode overlay
- (overlay-put ov 'display ovs)
- ;; hl line mode should have priority
- (overlay-put ov 'priority -60))))))))))
+ :lighter " dgi"
+ (cond (dired-git-info-mode
+ (unless (derived-mode-p 'dired-mode)
+ (user-error "Not in a dired buffer"))
+ (unless (locate-dominating-file "." ".git")
+ (user-error "Not inside a git repository"))
+ (let* ((files (dgi--save-marked
+ (dired-unmark-all-marks)
+ (dired-toggle-marks)
+ (dired-get-marked-files)))
+ (minspc (1+ (apply #'max (dgi--get-dired-files-length
files))))
+ (messages (dgi--get-commit-messages files)))
+ (save-excursion
+ (dolist (file files)
+ (let ((msg (pop messages)))
+ (when msg
+ (dired-goto-file file)
+ (let ((spc (make-string
+ (- minspc (dgi--get-dired-file-length file))
+ ?\s)))
+ (goto-char (line-end-position))
+ (let ((ov (make-overlay (point) (1+ (point))))
+ (ovs (concat spc
+ (propertize
+ msg 'face 'dgi-commit-message-face)
+ "\n")))
+ (push ov dgi--commit-ovs)
+ ;; I don't use after-string because I didn't get it to
work
+ ;; in combination with hl-line-mode overlay
+ (overlay-put ov 'display ovs)
+ ;; hl line mode should have priority
+ (overlay-put ov 'priority -60)))))))
+ (when dgi-auto-hide-details-p
+ (unless dired-hide-details-mode
+ (setq dgi--restore-no-details t)
+ (dired-hide-details-mode 1)))))
+ (t
+ (dgi--cleanup))))
(provide 'dired-git-info)
;;; dired-git-info.el ends here
+
- [elpa] scratch/dired-git-info 11a6cce 05/33: Update install instructions, (continued)
- [elpa] scratch/dired-git-info 11a6cce 05/33: Update install instructions, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 7803b82 16/33: Only mention some common options for message format docstring, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info f2117c8 28/33: Add .gitignore, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 1c4ff64 23/33: Remove redundant :group declarations, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info cd60dd4 33/33: Check visible part of file names for right formatting, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 3280075 22/33: Update descriptions, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 069695c 10/33: Update screenshot, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 51135d8 07/33: Use actual displayed width of filename to determine spacing, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 16c7a1a 15/33: Hide details when showing git info, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 2ea5107 29/33: Rephrase commentary, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info b5551e7 30/33: Convert entry command to minor mode,
Clemens Radermacher <=
- [elpa] scratch/dired-git-info 7755019 32/33: Get commit info from real file name, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info f539ba5 08/33: Align message parts of commit messages, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 8afe378 09/33: Update docstring for message format, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info f9f8ab5 17/33: Cleanup, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 0f7625c 14/33: Make overlays buffer local, to allow multiple dired buffers, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info aa8248a 21/33: Use temp buffer, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info c8e3b2e 13/33: Add docstrings, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 95688b3 20/33: Add group, keywords and make options customizeable, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 4f6d0ca 24/33: Boolean vars shouldn't have a -p suffix, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info 6115ae1 03/33: Fix package name in comment, Clemens Radermacher, 2019/02/17