emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/dired-git-info d8b777d 31/33: Cleanup


From: Clemens Radermacher
Subject: [elpa] scratch/dired-git-info d8b777d 31/33: Cleanup
Date: Sun, 17 Feb 2019 13:03:32 -0500 (EST)

branch: scratch/dired-git-info
commit d8b777d9290070cbd7875bf0d82eb5ffd60598cd
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Cleanup
---
 README.org        |  6 ++---
 dired-git-info.el | 77 +++++++++++++++++++++++++++----------------------------
 2 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/README.org b/README.org
index 9f2386c..6dbbff5 100644
--- a/README.org
+++ b/README.org
@@ -1,7 +1,7 @@
 * Description
 
-This Emacs packages provides a command to show git information inside the
-dired buffer:
+This Emacs packages provides a minor mode which shows git information inside
+the dired buffer:
 
 [[./images/screenshot2.png]]
 
@@ -15,7 +15,7 @@ For manual installation, clone the repository and call:
 
 * Config
 
-Bind the minor mode command in direds mode map:
+Bind the minor mode command in dired:
 
 #+BEGIN_SRC elisp
 (with-eval-after-load 'dired
diff --git a/dired-git-info.el b/dired-git-info.el
index 40b0de9..7ae2a89 100644
--- a/dired-git-info.el
+++ b/dired-git-info.el
@@ -23,8 +23,8 @@
 
 ;;; Commentary:
 ;;
-;; Command to show last commit message and date (info shown is configurable)
-;; of git project files in dired.
+;; Minor mode which shows last commit message and date (info shown is
+;; configurable) for git project files in dired.
 ;;
 
 ;;; Code:
@@ -178,43 +178,42 @@ info format and defaults to `dgi-commit-message-format'."
 (define-minor-mode dired-git-info-mode
   "Toggle git message info in current dired buffer."
   :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))))
+  (if (not dired-git-info-mode)
+      (dgi--cleanup)
+    (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))))))
 
 
 (provide 'dired-git-info)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]