(add-to-list 'load-path "~/.emacs.d/magit")
(require 'magit)
-(require 'advice)
(require 'cl)
-(setf (symbol-function 'builtin-process-file) (symbol-function 'process-file))
+(when (eq system-type 'windows-nt)
-(defvar my-magit-shell "c:\\Program Files (x86)\\Git\\bin\\sh")
+ (require 'advice)
-(defun my-magit-process-file (program &optional infile buffer display &rest args)
- (builtin-process-file my-magit-shell infile buffer display
- "-c" (mapconcat 'shell-quote-argument (cons "/bin/git" args) " ")))
+ (setf (symbol-function 'builtin-process-file) (symbol-function 'process-file))
-(defadvice magit-cmd-output (around my-magit-process-file activate)
- (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
- ad-do-it))
+ (defvar my-magit-shell "c:\\Program Files (x86)\\Git\\bin\\sh")
-(defadvice magit-git-exit-code (around my-magit-process-file activate)
- (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
- ad-do-it))
+ (defun my-magit-process-file (program &optional infile buffer display &rest args)
+ (builtin-process-file my-magit-shell infile buffer display
+ "-c" (mapconcat 'shell-quote-argument (cons "/bin/git" args) " ")))
-(defadvice magit-run (around activate)
- (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
- ad-do-it))
+ (defadvice magit-cmd-output (around my-magit-process-file activate)
+ (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
+ ad-do-it))
+
+ (defadvice magit-git-exit-code (around my-magit-process-file activate)
+ (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
+ ad-do-it))
+
+ (defadvice magit-run (around activate)
+ (letf (((symbol-function 'process-file) (symbol-function 'my-magit-process-file)))
+ ad-do-it))
+
+); End Windows-NT
(global-set-key "\C-cGS" 'magit-status)
(let ((default-directory (magit-get-top-dir default-directory)))
(if (not default-directory)
(error "not a Git directory"))
- (grep (format "git ls-files -z | xargs -r0 grep -nH -E %s | cat -" (shell-quote-argument regexp)))))
+ (grep (format "git ls-files -z | xargs -r0 grep -nH -E %s | cat -"
+ (shell-quote-argument regexp)))))
+
+(setenv "GIT_PAGER" "cat")
+(setenv "GIT_MAN_VIEWER" "woman")
+(setenv "GIT_EDITOR" "emacsclient")
(defun find-file-maybe-git (&optional nogit)
(interactive "P")
(global-set-key "\C-x\C-f" 'find-file-maybe-git)
(global-set-key "\C-cGG" 'grep-in-git-repo)
-(defun git-files-find-symbol (&optional arg)
- (interactive "P")
- (let ((symbol (current-word))
- (dir (magit-get-top-dir default-directory)))
+(defun git-files-find-symbol (symbol)
+ (interactive (list (read-string "Symbol: " (current-word))))
+ (let ((dir (magit-get-top-dir default-directory)))
(if (not dir) (error "No git repository"))
- (if arg (setq symbol (read-string "Symbol: " nil nil symbol)))
(let ((default-directory dir))
- (grep (format "git ls-files -z | xargs -r0 grep -nHF %s | cat -" symbol)))))
+ (grep (format "git ls-files -z | xargs -r0 grep -nwHF %s | cat -" symbol)))))
(global-set-key "\C-cGF" 'git-files-find-symbol)
+
+(defun dired-git-files ()
+ (interactive)
+ (let ((default-directory (magit-get-top-dir default-directory))
+ (ls-lisp-use-insert-directory-program t))
+ (dired (cons default-directory (split-string (shell-command-to-string "git ls-files") "\n")))))
+
+(global-set-key "\C-cGD" 'dired-git-files)