Mercurial > emacs
comparison lisp/vc-git.el @ 93240:231f72336aed
(vc-git-extra-menu-map): New key map.
(vc-git-extra-menu, vc-git-extra-status-menu, vc-git-grep):
New functions.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 26 Mar 2008 06:35:55 +0000 |
parents | 019e6794fecf |
children | 53eee5c271f4 |
comparison
equal
deleted
inserted
replaced
93239:3d37b67e5a01 | 93240:231f72336aed |
---|---|
106 ;; - delete-file (file) OK | 106 ;; - delete-file (file) OK |
107 ;; - rename-file (old new) OK | 107 ;; - rename-file (old new) OK |
108 ;; - find-file-hook () NOT NEEDED | 108 ;; - find-file-hook () NOT NEEDED |
109 ;; - find-file-not-found-hook () NOT NEEDED | 109 ;; - find-file-not-found-hook () NOT NEEDED |
110 | 110 |
111 (eval-when-compile (require 'cl) (require 'vc)) | 111 (eval-when-compile (require 'cl) (require 'vc) (require 'grep)) |
112 | 112 |
113 (defvar git-commits-coding-system 'utf-8 | 113 (defvar git-commits-coding-system 'utf-8 |
114 "Default coding system for git commits.") | 114 "Default coding system for git commits.") |
115 | 115 |
116 ;;; BACKEND PROPERTIES | 116 ;;; BACKEND PROPERTIES |
487 (vc-git-command nil 0 file "rm" "-f" "--")) | 487 (vc-git-command nil 0 file "rm" "-f" "--")) |
488 | 488 |
489 (defun vc-git-rename-file (old new) | 489 (defun vc-git-rename-file (old new) |
490 (vc-git-command nil 0 (list old new) "mv" "-f" "--")) | 490 (vc-git-command nil 0 (list old new) "mv" "-f" "--")) |
491 | 491 |
492 (defvar vc-git-extra-menu-map | |
493 (let ((map (make-sparse-keymap))) | |
494 (define-key map [git-grep] | |
495 '(menu-item "Git grep..." vc-git-grep | |
496 :help "Run the `git grep' command")) | |
497 map)) | |
498 | |
499 (defun vc-git-extra-menu () vc-git-extra-menu-map) | |
500 | |
501 (defun vc-git-extra-status-menu () vc-git-extra-menu-map) | |
502 | |
503 ;; Derived from `lgrep'. | |
504 (defun vc-git-grep (regexp &optional files dir) | |
505 "Run git grep, searching for REGEXP in FILES in directory DIR. | |
506 The search is limited to file names matching shell pattern FILES. | |
507 FILES may use abbreviations defined in `grep-files-aliases', e.g. | |
508 entering `ch' is equivalent to `*.[ch]'. | |
509 | |
510 With \\[universal-argument] prefix, you can edit the constructed shell command line | |
511 before it is executed. | |
512 With two \\[universal-argument] prefixes, directly edit and run `grep-command'. | |
513 | |
514 Collect output in a buffer. While git grep runs asynchronously, you | |
515 can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \ | |
516 in the grep output buffer, | |
517 to go to the lines where grep found matches. | |
518 | |
519 This command shares argument histories with \\[rgrep] and \\[grep]." | |
520 (interactive | |
521 (progn | |
522 (grep-compute-defaults) | |
523 (cond | |
524 ((equal current-prefix-arg '(16)) | |
525 (list (read-from-minibuffer "Run: " "git grep" | |
526 nil nil 'grep-history) | |
527 nil)) | |
528 (t (let* ((regexp (grep-read-regexp)) | |
529 (files (grep-read-files regexp)) | |
530 (dir (read-directory-name "In directory: " | |
531 nil default-directory t))) | |
532 (list regexp files dir)))))) | |
533 (require 'grep) | |
534 (when (and (stringp regexp) (> (length regexp) 0)) | |
535 (let ((command regexp)) | |
536 (if (null files) | |
537 (if (string= command "git grep") | |
538 (setq command nil)) | |
539 (setq dir (file-name-as-directory (expand-file-name dir))) | |
540 (setq command | |
541 (grep-expand-template "git grep -n -e <R> -- <F>" regexp files)) | |
542 (when command | |
543 (if (equal current-prefix-arg '(4)) | |
544 (setq command | |
545 (read-from-minibuffer "Confirm: " | |
546 command nil nil 'grep-history)) | |
547 (add-to-history 'grep-history command)))) | |
548 (when command | |
549 (let ((default-directory dir) | |
550 (compilation-environment '("PAGER="))) | |
551 ;; Setting process-setup-function makes exit-message-function work | |
552 ;; even when async processes aren't supported. | |
553 (compilation-start command 'grep-mode)) | |
554 (if (eq next-error-last-buffer (current-buffer)) | |
555 (setq default-directory dir)))))) | |
492 | 556 |
493 ;;; Internal commands | 557 ;;; Internal commands |
494 | 558 |
495 (defun vc-git-root (file) | 559 (defun vc-git-root (file) |
496 (vc-find-root file ".git")) | 560 (vc-find-root file ".git")) |