Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Customized magit-run-gitk #379

Closed
wants to merge 8 commits into from

2 participants

@mgutekunst

Hi,

I wrote the function "magit-run-visual-program" to open gitk or gitg or similar programs. Also I adopted magit-run-gitk to use this function and added magit-run-gitg.

Additionally gitk and gitg are now callable by pressing l-k / l-g in the magit status buffer.

Manuel Gutek... added some commits
@sigma sigma closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 22, 2012
  1. * Provides magit-run-visual-program that allows to run gitk or gitg o…

    Manuel Gutekunst authored
    …r any other similar program
    
    * Open gitg/gitk by pressing l-g / l-k in the magit status buffer
  2. Merge branch 'gitg'

    Manuel Gutekunst authored
Commits on Mar 22, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Manuel Gutekunst authored
Commits on Apr 18, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Manuel Gutekunst authored
Commits on May 9, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Manuel Gutekunst authored
Commits on Jun 1, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Manuel Gutekunst authored
  2. merge upstream

    Manuel Gutekunst authored
Commits on Aug 24, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Manuel Gutekunst authored
This page is out of date. Refresh to see the latest.
View
0  bin/authors.pl 100755 → 100644
File mode changed
View
0  bin/mk_rel.bash 100755 → 100644
File mode changed
View
0  contrib/magit 100755 → 100644
File mode changed
View
5 magit-key-mode.el
@@ -27,7 +27,10 @@
("h" "Reflog" magit-reflog)
("rl" "Ranged short" magit-log-ranged)
("rL" "Ranged long" magit-log-long-ranged)
- ("rh" "Ranged reflog" magit-reflog-ranged))
+ ("rh" "Ranged reflog" magit-reflog-ranged)
+ ("g" "open gitg" magit-run-gitg)
+ ("k" "open gitk" magit-run-gitk))
+
(switches
("-m" "Only merge commits" "--merges")
("-f" "First parent" "--first-parent")
View
64 magit.el
@@ -115,6 +115,12 @@
:group 'magit
:type 'string)
+(defcustom magit-gitg-executable (concat (file-name-directory magit-git-executable)
+ "gitg")
+ "The name of the gitg executable."
+ :group 'magit
+ :type 'string)
+
(defcustom magit-git-standard-options '("--no-pager")
"Standard options when running Git."
:group 'magit
@@ -5931,33 +5937,43 @@ With a prefix arg, do a submodule update --init"
(let* ((default-directory (magit-get-top-dir default-directory)))
(magit-start-process "Git Gui" nil magit-git-executable "gui")))
+(defun magit-run-visual-program (name executable args)
+ "Run a visual program like `gitk, gitg' or similar for the current git repository"
+ (let ((default-directory (magit-get-top-dir default-directory)))
+ (cond
+ ((eq system-type 'windows-nt)
+ ;; Gitk is a shell script, and Windows doesn't know how to
+ ;; "execute" it. The Windows version of Git comes with an
+ ;; implementation of "sh" and everything else it needs, but
+ ;; Windows users might not have added the directory where it's
+ ;; installed to their path
+ (let ((git-bin-dir (file-name-directory executable))
+ (exec-path exec-path)
+ (process-environment process-environment))
+ (when git-bin-dir
+ ;; Adding it onto the end so that anything the user
+ ;; specified will get tried first. Emacs looks in
+ ;; exec-path; PATH is the environment variable inherited by
+ ;; the process. I need to change both.
+ (setq exec-path (append exec-path (list git-bin-dir)))
+ (push (format "PATH=%s;%s"
+ (getenv "PATH")
+ (replace-regexp-in-string "/" "\\\\" git-bin-dir))
+ process-environment))
+ (magit-start-process name nil "sh" executable args)))
+ (t
+ (magit-start-process name nil executable args)))))
+
+
(defun magit-run-gitk ()
"Run `gitk --all' for the current git repository"
(interactive)
- (let ((default-directory (magit-get-top-dir default-directory)))
- (cond
- ((eq system-type 'windows-nt)
- ;; Gitk is a shell script, and Windows doesn't know how to
- ;; "execute" it. The Windows version of Git comes with an
- ;; implementation of "sh" and everything else it needs, but
- ;; Windows users might not have added the directory where it's
- ;; installed to their path
- (let ((git-bin-dir (file-name-directory magit-gitk-executable))
- (exec-path exec-path)
- (process-environment process-environment))
- (when git-bin-dir
- ;; Adding it onto the end so that anything the user
- ;; specified will get tried first. Emacs looks in
- ;; exec-path; PATH is the environment variable inherited by
- ;; the process. I need to change both.
- (setq exec-path (append exec-path (list git-bin-dir)))
- (push (format "PATH=%s;%s"
- (getenv "PATH")
- (replace-regexp-in-string "/" "\\\\" git-bin-dir))
- process-environment))
- (magit-start-process "Gitk" nil "sh" magit-gitk-executable "--all")))
- (t
- (magit-start-process "Gitk" nil magit-gitk-executable "--all")))))
+ (magit-run-visual-program "gitk" magit-gitk-executable "--all"))
+
+(defun magit-run-gitg ()
+ "Run `gitg' for the current git repository"
+ (interactive)
+ (magit-run-visual-program "gitg" magit-gitg-executable ""))
(defun magit-load-config-extensions ()
"Try to load magit extensions that are defined at git config
Something went wrong with that request. Please try again.