Sfoglia il codice sorgente

add func my-grep-global

pull/1/head
10sr 11 anni fa
parent
commit
d45e5154c4
1 ha cambiato i file con 52 aggiunte e 22 eliminazioni
  1. +52
    -22
      emacs.el

+ 52
- 22
emacs.el Vedi File

@@ -1046,22 +1046,22 @@ found, otherwise returns nil."
(define-key view-mode-map "?" 'isearch-backward-regexp)
(define-key view-mode-map "n" 'isearch-repeat-forward)
(define-key view-mode-map "N" 'isearch-repeat-backward)
(define-key view-mode-map (kbd "C-m") 'my-view-mode-search-word)
(define-key view-mode-map (kbd "C-m") 'my-rgrep-symbol-at-point)
))
(global-set-key "\M-r" 'view-mode)
(setq view-read-only t)

(defun my-view-mode-search-word (word)
"Search for word current directory and subdirectories.
If called intearctively, find word at point."
(interactive (list (thing-at-point 'symbol)))
(if word
(if (and (require 'gtags nil t)
(gtags-get-rootpath))
(gtags-goto-tag word "s")
(my-rgrep word))
(message "No word at point.")
nil))
;; (defun my-view-mode-search-word (word)
;; "Search for word current directory and subdirectories.
;; If called intearctively, find word at point."
;; (interactive (list (thing-at-point 'symbol)))
;; (if word
;; (if (and (require 'gtags nil t)
;; (gtags-get-rootpath))
;; (gtags-goto-tag word "s")
;; (my-rgrep word))
;; (message "No word at point.")
;; nil))

(add-hook 'Man-mode-hook
(lambda ()
@@ -1123,14 +1123,20 @@ If called intearctively, find word at point."
;; (local-set-key "\M-r" 'gtags-find-rtag)
;; (local-set-key "\M-s" 'gtags-find-symbol)
;; (local-set-key "\C-t" 'gtags-pop-stack)
(define-key gtags-mode-map (kbd "C-x t h") 'gtags-find-tag-from-here)
(define-key gtags-mode-map (kbd "C-x t h")
'gtags-find-tag-from-here)
(define-key gtags-mode-map (kbd "C-x t t") 'gtags-find-tag)
(define-key gtags-mode-map (kbd "C-x t r") 'gtags-find-rtag)
(define-key gtags-mode-map (kbd "C-x t s") 'gtags-find-symbol)
(define-key gtags-mode-map (kbd "C-x t p") 'gtags-find-pattern)
(define-key gtags-mode-map (kbd "C-x t f") 'gtags-find-file)
(define-key gtags-mode-map (kbd "C-x t b") 'gtags-pop-stack) ;back
)))
))
(add-hook 'gtags-select-mode-hook
(lambda ()
(define-key gtags-select-mode-map (kbd "C-m") 'gtags-select-tag)
))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; term mode
@@ -1998,6 +2004,10 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."
"ack --nocolor --nogroup --nopager "
"grep command for ack")

(defvar my-rgrep-global
"global --result grep"
"grep command for global")

(defvar my-rgrep-grep
(concat "find . "
"-path '*/.git' -prune -o "
@@ -2008,14 +2018,17 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."

(defun my-rgrep-grep-command ()
"Return recursive grep command for current directory."
(if (eq 0
(shell-command "git rev-parse --git-dir"))
my-rgrep-gitgrep
(if (executable-find "ag")
my-rgrep-ag
(if (executable-find "ack")
my-rgrep-ack
my-rgrep-grep))))
(if (and (require 'gtags nil t)
(gtags-get-rootpath))
my-rgrep-global
(if (eq 0
(shell-command "git rev-parse --git-dir"))
my-rgrep-gitgrep
(if (executable-find "ag")
my-rgrep-ag
(if (executable-find "ack")
my-rgrep-ack
my-rgrep-grep)))))

(defun my-rgrep (command-args)
"My recursive grep."
@@ -2025,6 +2038,16 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."
(compilation-start command-args
'grep-mode))

(defun my-rgrep-symbol-at-point (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
(concat (my-rgrep-grep-command)
" "
(thing-at-point 'symbol))
'grep-find-history)))
(compilation-start command-args
'grep-mode))

(defun my-rgrep-ack (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "
@@ -2039,6 +2062,13 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."
'grep-find-history)))
(my-rgrep command-args))

(defun my-rgrep-global (command-args)
"My recursive grep by gnu global."
(interactive (list (read-shell-command "grep command: "
my-rgrep-global
'grep-find-history)))
(my-rgrep command-args))

(defun my-rgrep-grep (command-args)
"My recursive grep."
(interactive (list (read-shell-command "grep command: "


Caricamento…
Annulla
Salva