浏览代码

add view-mode-search-word, not tested with gtags yet

pull/1/head
10sr 11 年前
父节点
当前提交
541caed66a
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. +22
    -1
      emacs.el

+ 22
- 1
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)


正在加载...
取消
保存