]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
new version of git-timemachine.
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Jul 2015 06:08:54 +0000 (08:08 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Jul 2015 06:08:54 +0000 (08:08 +0200)
elpa/git-timemachine-20140825.951/git-timemachine-autoloads.el [deleted file]
elpa/git-timemachine-20140825.951/git-timemachine-pkg.el [deleted file]
elpa/git-timemachine-20140825.951/git-timemachine.el [deleted file]
elpa/git-timemachine-20150624.1446/git-timemachine-autoloads.el [new file with mode: 0644]
elpa/git-timemachine-20150624.1446/git-timemachine-pkg.el [new file with mode: 0644]
elpa/git-timemachine-20150624.1446/git-timemachine.el [new file with mode: 0644]

diff --git a/elpa/git-timemachine-20140825.951/git-timemachine-autoloads.el b/elpa/git-timemachine-20140825.951/git-timemachine-autoloads.el
deleted file mode 100644 (file)
index 1bd506c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-;;; git-timemachine-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-
-\f
-;;;### (autoloads (git-timemachine) "git-timemachine" "git-timemachine.el"
-;;;;;;  (21593 9364 0 0))
-;;; Generated autoloads from git-timemachine.el
-
-(autoload 'git-timemachine "git-timemachine" "\
-Enable git timemachine for file of current buffer.
-
-\(fn)" t nil)
-
-;;;***
-\f
-;;;### (autoloads nil nil ("git-timemachine-pkg.el") (21593 9364
-;;;;;;  475894 0))
-
-;;;***
-\f
-(provide 'git-timemachine-autoloads)
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; coding: utf-8
-;; End:
-;;; git-timemachine-autoloads.el ends here
diff --git a/elpa/git-timemachine-20140825.951/git-timemachine-pkg.el b/elpa/git-timemachine-20140825.951/git-timemachine-pkg.el
deleted file mode 100644 (file)
index 7f1c0c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-(define-package "git-timemachine" "20140825.951" "Walk through git revisions of a file" (quote ((cl-lib "0.5"))))
diff --git a/elpa/git-timemachine-20140825.951/git-timemachine.el b/elpa/git-timemachine-20140825.951/git-timemachine.el
deleted file mode 100644 (file)
index 48407cf..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-;;; git-timemachine.el --- Walk through git revisions of a file
-
-;; Copyright (C) 2014 Peter Stiernström
-
-;; Author: Peter Stiernström <peterNOSPAMstiernstrom.se>
-;; Version: 20140825.951
-;; X-Original-Version: 1.8
-;; URL: https://github.com/pidu/git-timemachine
-;; Package-Requires: ((cl-lib "0.5"))
-;; Keywords: git
-
-;; This file is not part of GNU Emacs
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;; Use git-timemachine to browse historic versions of a file with p
-;;; (previous) and n (next).
-
-;;; Code:
-
-(require 'cl-lib)
-(require 'vc-git)
-
-(defcustom git-timemachine-abbreviation-length 12
- "Number of chars from the full sha1 hash to use for abbreviation."
- :group 'git-timemachine)
-
-(defvar git-timemachine-directory nil)
-(defvar git-timemachine-revision nil)
-(defvar git-timemachine-file nil)
-
-(make-variable-buffer-local 'git-timemachine-directory)
-(make-variable-buffer-local 'git-timemachine-revision)
-(make-variable-buffer-local 'git-timemachine-file)
-
-(defun git-timemachine--revisions ()
- "List git revisions of current buffers file."
- (let ((default-directory git-timemachine-directory)
-       (file git-timemachine-file))
-  (with-temp-buffer
-   (unless (zerop (process-file vc-git-program nil t nil "--no-pager" "log" "--pretty=format:%H" file))
-    (error "Failed: 'git log --pretty=format:%%H' %s" file))
-   (goto-char (point-min))
-   (let (lines)
-    (while (not (eobp))
-     (push (buffer-substring-no-properties (line-beginning-position) (line-end-position)) lines)
-     (forward-line 1))
-    (nreverse lines)))))
-
-(defun git-timemachine-show-current-revision ()
- "Show last (current) revision of file."
- (interactive)
- (git-timemachine-show-revision (car (git-timemachine--revisions))))
-
-(defun git-timemachine-show-previous-revision ()
- "Show previous revision of file."
- (interactive)
- (git-timemachine-show-revision (cadr (member git-timemachine-revision (git-timemachine--revisions)))))
-
-(defun git-timemachine-show-next-revision ()
- "Show next revision of file."
- (interactive)
- (git-timemachine-show-revision (cadr (member git-timemachine-revision (reverse (git-timemachine--revisions))))))
-
-(defun git-timemachine-show-revision (revision)
- "Show a REVISION (commit hash) of the current file."
- (when revision
-  (let ((current-position (point)))
-   (setq buffer-read-only nil)
-   (erase-buffer)
-   (let ((default-directory git-timemachine-directory))
-    (process-file vc-git-program nil t nil "--no-pager" "show"
-     (concat revision ":" git-timemachine-file)))
-   (setq buffer-read-only t)
-   (set-buffer-modified-p nil)
-   (let* ((revisions (git-timemachine--revisions))
-          (n-of-m (format "(%d/%d)" (- (length revisions) (cl-position revision revisions :test 'equal)) (length revisions))))
-    (setq mode-line-buffer-identification
-     (list (propertized-buffer-identification "%12b") "@"
-      (propertize (git-timemachine-abbreviate revision) 'face 'bold) " " n-of-m)))
-   (setq git-timemachine-revision revision)
-   (goto-char current-position))))
-
-(defun git-timemachine-abbreviate (revision)
- "Return REVISION abbreviated to `git-timemachine-abbreviation-length' chars."
- (substring revision 0 git-timemachine-abbreviation-length))
-
-(defun git-timemachine-quit ()
- "Exit the timemachine."
- (interactive)
- (kill-buffer))
-
-(defun git-timemachine-kill-revision ()
- "Kill the current revisions abbreviated commit hash."
- (interactive)
- (message git-timemachine-revision)
- (kill-new git-timemachine-revision))
-
-(defun git-timemachine-kill-abbreviated-revision ()
- "Kill the current revisions full commit hash."
- (interactive)
- (let ((revision (git-timemachine-abbreviate git-timemachine-revision)))
-  (message revision)
-  (kill-new revision)))
-
-(define-minor-mode git-timemachine-mode
- "Git Timemachine, feel the wings of history."
- :init-value nil
- :lighter " Timemachine"
- :keymap
- '(("p" . git-timemachine-show-previous-revision)
-   ("n" . git-timemachine-show-next-revision)
-   ("q" . git-timemachine-quit)
-   ("w" . git-timemachine-kill-abbreviated-revision)
-   ("W" . git-timemachine-kill-revision))
- :group 'git-timemachine)
-
-(defun git-timemachine-validate (file)
- "Validate that there is a FILE and that it belongs to a git repository.
-Call with the value of 'buffer-file-name."
- (unless file
-  (error "This buffer is not visiting a file"))
- (unless (vc-git-registered file)
-  (error "This file is not git tracked")))
-
-;;;###autoload
-(defun git-timemachine ()
- "Enable git timemachine for file of current buffer."
- (interactive)
- (git-timemachine-validate (buffer-file-name))
- (let ((git-directory (expand-file-name (vc-git-root (buffer-file-name))))
-       (file-name (buffer-file-name))
-       (timemachine-buffer (format "timemachine:%s" (buffer-name)))
-       (cur-line (line-number-at-pos))
-       (mode major-mode))
-  (with-current-buffer (get-buffer-create timemachine-buffer)
-   (setq buffer-file-name file-name)
-   (funcall mode)
-   (git-timemachine-mode)
-   (setq git-timemachine-directory git-directory
-         git-timemachine-file (file-relative-name file-name git-directory)
-         git-timemachine-revision nil)
-   (git-timemachine-show-current-revision)
-   (switch-to-buffer timemachine-buffer)
-   (goto-char (point-min))
-   (forward-line (1- cur-line)))))
-
-(provide 'git-timemachine)
-
-;;; git-timemachine.el ends here
diff --git a/elpa/git-timemachine-20150624.1446/git-timemachine-autoloads.el b/elpa/git-timemachine-20150624.1446/git-timemachine-autoloads.el
new file mode 100644 (file)
index 0000000..d4faa6f
--- /dev/null
@@ -0,0 +1,27 @@
+;;; git-timemachine-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
+\f
+;;;### (autoloads nil "git-timemachine" "git-timemachine.el" (21908
+;;;;;;  14267 0 0))
+;;; Generated autoloads from git-timemachine.el
+
+(autoload 'git-timemachine-toggle "git-timemachine" "\
+Toggle git timemachine mode.
+
+\(fn)" t nil)
+
+(autoload 'git-timemachine "git-timemachine" "\
+Enable git timemachine for file of current buffer.
+
+\(fn)" t nil)
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; git-timemachine-autoloads.el ends here
diff --git a/elpa/git-timemachine-20150624.1446/git-timemachine-pkg.el b/elpa/git-timemachine-20150624.1446/git-timemachine-pkg.el
new file mode 100644 (file)
index 0000000..70635be
--- /dev/null
@@ -0,0 +1 @@
+(define-package "git-timemachine" "20150624.1446" "Walk through git revisions of a file" 'nil :url "https://github.com/pidu/git-timemachine" :keywords '("git"))
diff --git a/elpa/git-timemachine-20150624.1446/git-timemachine.el b/elpa/git-timemachine-20150624.1446/git-timemachine.el
new file mode 100644 (file)
index 0000000..deb874a
--- /dev/null
@@ -0,0 +1,241 @@
+;;; git-timemachine.el --- Walk through git revisions of a file
+
+;; Copyright (C) 2014 Peter Stiernström
+
+;; Author: Peter Stiernström <peterNOSPAMstiernstrom.se>
+;; Version: 2.7
+;; Package-Version: 20150624.1446
+;; URL: https://github.com/pidu/git-timemachine
+;; Keywords: git
+
+;; This file is not part of GNU Emacs
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Use git-timemachine to browse historic versions of a file with p
+;;; (previous) and n (next).
+
+;;; Code:
+
+(require 'vc-git)
+(require 'cl-lib)
+
+(defcustom git-timemachine-abbreviation-length 12
+ "Number of chars from the full sha1 hash to use for abbreviation."
+ :group 'git-timemachine)
+
+(defcustom git-timemachine-show-minibuffer-details t
+ "Non-nil means that details of the commit (its hash and date)
+will be shown in the minibuffer while navigating commits."
+ :group 'git-timemachine)
+
+(defface git-timemachine-commit
+ '((default :weight bold))
+ "Face for git timemachine commit sha"
+ :group 'git-timemachine)
+
+(defface git-timemachine-minibuffer-detail-face
+ '((t (:foreground "yellow")))
+ "How to display the minibuffer detail"
+ :group 'git-timemachine)
+
+(defcustom git-timemachine-minibuffer-detail
+ 'subject
+ "What to display when `git-timemachine-show-minibuffer-details` is t.
+Available values are:
+`commit` : The SHA hash of the commit
+`subject`: The subject of the commit message"
+ :type '(radio (const :tag "Commit SHA" commit) (const :tag "Commit Subject" subject))
+ :group 'git-timemachine)
+
+(defvar-local git-timemachine-directory nil)
+(defvar-local git-timemachine-revision nil)
+(defvar-local git-timemachine-file nil)
+(defvar-local git-timemachine--revisions-cache nil)
+
+(defun git-timemachine--revisions ()
+ "List git revisions of current buffers file."
+ (if git-timemachine--revisions-cache
+  git-timemachine--revisions-cache
+  (setq git-timemachine--revisions-cache
+   (prog2
+    (message "Fetching Revisions...")
+    (let ((default-directory git-timemachine-directory)
+          (file git-timemachine-file))
+     (with-temp-buffer
+      (unless (zerop (process-file vc-git-program nil t nil "--no-pager" "log" "--name-only" "--follow" "--pretty=format:%H:%ar:%ad:%s" file))
+       (error "Git log command exited with non-zero exit status for file: %s" file))
+      (goto-char (point-min))
+      (let ((lines)
+            (commit-number (/ (1+ (count-lines (point-min) (point-max))) 3)))
+       (while (not (eobp))
+        (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
+         (string-match "\\([^:]*\\):\\([^:]*\\):\\(.*\\):\\(.*\\)" line)
+         (let ((commit (match-string 1 line))
+               (date-relative (match-string 2 line))
+               (date-full (match-string 3 line))
+               (subject (match-string 4 line)))
+          (forward-line 1)
+          (let ((file-name (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
+           (push (list commit file-name commit-number date-relative date-full subject) lines))))
+        (setq commit-number (1- commit-number))
+        (forward-line 2))
+       (nreverse lines))))
+    (message "Fetching Revisions...done")))))
+
+(defun git-timemachine-show-current-revision ()
+ "Show last (current) revision of file."
+ (interactive)
+ (git-timemachine-show-revision (car (git-timemachine--revisions))))
+
+(defun git-timemachine--next-revision (revisions)
+ "Return the revision following the current revision in REVISIONS."
+ (cadr (cl-member (car git-timemachine-revision) revisions :key #'car :test #'string=)))
+
+(defun git-timemachine-show-previous-revision ()
+ "Show previous revision of file."
+ (interactive)
+ (git-timemachine-show-revision (git-timemachine--next-revision (git-timemachine--revisions))))
+
+(defun git-timemachine-show-next-revision ()
+ "Show next revision of file."
+ (interactive)
+ (git-timemachine-show-revision (git-timemachine--next-revision (reverse (git-timemachine--revisions)))))
+
+(defun git-timemachine-show-nth-revision (rev-number)
+ "Show the REV-NUMBER revision."
+ (interactive "nEnter revision number: ")
+ (let* ((revisions (reverse (git-timemachine--revisions)))
+        (revision (nth (1- rev-number) revisions))
+        (num-revisions (length revisions)))
+  (if revision (git-timemachine-show-revision revision)
+   (message "Only %d revisions exist." num-revisions))))
+
+(defun git-timemachine-show-revision (revision)
+ "Show a REVISION (commit hash) of the current file."
+ (when revision
+  (let ((current-position (point))
+        (commit (car revision))
+        (revision-file-name (nth 1 revision))
+        (commit-index (nth 2 revision))
+        (date-relative (nth 3 revision))
+        (date-full (nth 4 revision))
+        (subject (nth 5 revision)))
+   (setq buffer-read-only nil)
+   (erase-buffer)
+   (let ((default-directory git-timemachine-directory))
+    (process-file vc-git-program nil t nil "--no-pager" "show"
+     (concat commit ":" revision-file-name)))
+   (setq buffer-read-only t)
+   (set-buffer-modified-p nil)
+   (let* ((revisions (git-timemachine--revisions))
+          (n-of-m (format "(%d/%d %s)" commit-index (length revisions) date-relative)))
+    (setq mode-line-buffer-identification
+     (list (propertized-buffer-identification "%12b") "@"
+      (propertize (git-timemachine-abbreviate commit) 'face 'git-timemachine-commit) " name:" revision-file-name" " n-of-m)))
+   (setq git-timemachine-revision revision)
+   (goto-char current-position)
+   (when git-timemachine-show-minibuffer-details
+    (git-timemachine--show-minibuffer-details revision)))))
+
+(defun git-timemachine--show-minibuffer-details (revision)
+ "Show details for REVISION in minibuffer."
+ (let ((detail
+        (if (eq git-timemachine-minibuffer-detail 'commit)
+         (car revision)
+         (nth 5 revision)))
+       (date-relative (nth 3 revision))
+       (date-full (nth 4 revision)))
+  (message (format "%s [%s (%s)]" (propertize detail 'face 'git-timemachine-minibuffer-detail-face) date-full date-relative))))
+
+(defun git-timemachine-abbreviate (revision)
+ "Return REVISION abbreviated to `git-timemachine-abbreviation-length' chars."
+ (substring revision 0 git-timemachine-abbreviation-length))
+
+(defun git-timemachine-quit ()
+ "Exit the timemachine."
+ (interactive)
+ (kill-buffer))
+
+(defun git-timemachine-kill-revision ()
+ "Kill the current revisions abbreviated commit hash."
+ (interactive)
+ (let ((revision (car git-timemachine-revision)))
+  (message revision)
+  (kill-new revision)))
+
+(defun git-timemachine-kill-abbreviated-revision ()
+ "Kill the current revisions full commit hash."
+ (interactive)
+ (let ((revision (git-timemachine-abbreviate (car git-timemachine-revision))))
+  (message revision)
+  (kill-new revision)))
+
+(define-minor-mode git-timemachine-mode
+ "Git Timemachine, feel the wings of history."
+ :init-value nil
+ :lighter " Timemachine"
+ :keymap
+ '(("p" . git-timemachine-show-previous-revision)
+   ("n" . git-timemachine-show-next-revision)
+   ("g" . git-timemachine-show-nth-revision)
+   ("q" . git-timemachine-quit)
+   ("w" . git-timemachine-kill-abbreviated-revision)
+   ("W" . git-timemachine-kill-revision))
+ :group 'git-timemachine)
+
+(defun git-timemachine-validate (file)
+ "Validate that there is a FILE and that it belongs to a git repository.
+Call with the value of 'buffer-file-name."
+ (unless file
+  (error "This buffer is not visiting a file"))
+ (unless (vc-git-registered file)
+  (error "This file is not git tracked")))
+
+;;;###autoload
+(defun git-timemachine-toggle ()
+ "Toggle git timemachine mode."
+ (interactive)
+ (if (bound-and-true-p git-timemachine-mode)
+  (git-timemachine-quit)
+  (git-timemachine)))
+
+;;;###autoload
+(defun git-timemachine ()
+ "Enable git timemachine for file of current buffer."
+ (interactive)
+ (setq git-timemachine--revisions-cache nil)
+ (git-timemachine-validate (buffer-file-name))
+ (let ((git-directory (expand-file-name (vc-git-root (buffer-file-name))))
+       (file-name (buffer-file-name))
+       (timemachine-buffer (format "timemachine:%s" (buffer-name)))
+       (cur-line (line-number-at-pos))
+       (mode major-mode))
+  (with-current-buffer (get-buffer-create timemachine-buffer)
+   (switch-to-buffer timemachine-buffer)
+   (setq buffer-file-name file-name)
+   (funcall mode)
+   (setq git-timemachine-directory git-directory
+         git-timemachine-file (file-relative-name file-name git-directory)
+         git-timemachine-revision nil)
+   (git-timemachine-show-current-revision)
+   (goto-char (point-min))
+   (forward-line (1- cur-line))
+   (git-timemachine-mode))))
+
+(provide 'git-timemachine)
+
+;;; git-timemachine.el ends here