[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/dired-git-info f9f8ab5 17/33: Cleanup
From: |
Clemens Radermacher |
Subject: |
[elpa] scratch/dired-git-info f9f8ab5 17/33: Cleanup |
Date: |
Sun, 17 Feb 2019 13:03:30 -0500 (EST) |
branch: scratch/dired-git-info
commit f9f8ab5b27335397f97932704dc7d77ea734eec5
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Cleanup
---
dired-git-info.el | 51 ++++++++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/dired-git-info.el b/dired-git-info.el
index 3c14f08..2a16dd1 100644
--- a/dired-git-info.el
+++ b/dired-git-info.el
@@ -29,7 +29,6 @@
;;; Code:
-
(defface dgi-commit-message-face
'((t (:inherit font-lock-comment-face)))
"Face for commit message overlays.")
@@ -74,36 +73,37 @@ are (see git-log PRETTY FORMATS for all):
(defvar-local dgi--commit-ovs nil
"Overlays which show the commit messages.")
+
(defun dgi--command-to-string (program &rest args)
"Execute PROGRAM with arguments ARGS and return output string."
(with-output-to-string
(with-current-buffer standard-output
(apply #'process-file program nil t nil args))))
+
(defun dgi--get-commit-info (&optional file gitf)
"Get commit message info.
FILE default to current dired file. GITF determines the commit
info format and defaults to `dgi-commit-message-format'."
- (if (not (locate-dominating-file "." ".git"))
- (user-error "Not inside a git repo")
- (let* ((file (or file (dired-get-file-for-visit)))
- (lfile (and (file-exists-p file)
- ;; get the actual displayed name, to make it work with
- ;; dired collapse for example
- (save-excursion
- (dired-goto-file file)
- (buffer-substring (point) (line-end-position))))))
- (when (and lfile (not (member lfile '(".." "."))))
- (let ((msg (dgi--command-to-string
- "git" "log" "-1"
- (concat "--pretty="
- (or gitf dgi-commit-message-format))
- lfile)))
- (when (and msg (not (string= "" msg)))
- (substring msg
- ;; skip newline
- 0 -1)))))))
+ (let* ((file (or file (dired-get-file-for-visit)))
+ (lfile (and (file-exists-p file)
+ ;; get the actual displayed name, to make it work with
+ ;; dired collapse for example
+ (save-excursion
+ (dired-goto-file file)
+ (buffer-substring (point) (line-end-position))))))
+ (when (and lfile (not (member lfile '(".." "."))))
+ (let ((msg (dgi--command-to-string
+ "git" "log" "-1"
+ (concat "--pretty="
+ (or gitf dgi-commit-message-format))
+ lfile)))
+ (when (and msg (not (string= "" msg)))
+ (substring msg
+ ;; skip newline
+ 0 -1))))))
+
(defmacro dgi--save-marked (&rest body)
"Execute BODY and restore marks afterwards."
@@ -119,6 +119,7 @@ info format and defaults to `dgi-commit-message-format'."
(dired-goto-file file)
(dired-mark 1))))))
+
(defun dgi--cleanup ()
"Remove commit overlays."
(when dgi-auto-hide-details
@@ -135,6 +136,7 @@ info format and defaults to `dgi-commit-message-format'."
(push (dgi--get-dired-file-length file)
dnames))))
+
(defun dgi--get-dired-file-length (file)
"Get lengths of FILE as displayed by dired."
(save-excursion
@@ -170,6 +172,8 @@ info format and defaults to `dgi-commit-message-format'."
(interactive)
(unless (eq major-mode '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
@@ -206,10 +210,3 @@ info format and defaults to `dgi-commit-message-format'."
(provide 'dired-git-info)
;;; dired-git-info.el ends here
-
-
-
-
-
-
-
- [elpa] scratch/dired-git-info cd60dd4 33/33: Check visible part of file names for right formatting, (continued)
- [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, 2019/02/17
- [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 <=
- [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
- [elpa] scratch/dired-git-info 740e1cf 27/33: Fix copyright, Clemens Radermacher, 2019/02/17
- [elpa] scratch/dired-git-info d8b777d 31/33: Cleanup, Clemens Radermacher, 2019/02/17