diff --git a/emacs.el b/emacs.el index 60b1e57..5c3e874 100644 --- a/emacs.el +++ b/emacs.el @@ -889,10 +889,31 @@ 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) )) (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") + (if (eq 0 + (shell-command "git rev-parse --git-dir")) + (compilation-start (format "git --no-pager grep -nH -e '%s'" + word) + 'grep-mode) + ;; TODO: handle ack + (grep (format "%s '%s' -r ." + grep-command + word)))) + (message "No word at point.") + nil)) + (add-hook 'Man-mode-hook (lambda () (view-mode 1) @@ -1796,7 +1817,7 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." ;; misc funcs (defun my-grep () - "Use git-grep if avaliable.." + "Use git-grep if avaliable. Only called interactively." (interactive) (require 'grep) (let ((--grep-command-bak grep-command)