.emacs 添加
-
(require 'ack-and-a-half)
-
(defalias 'ack 'ack-and-a-half)
-
(defalias 'ack-same 'ack-and-a-half-same)
-
(defalias 'ack-find-file 'ack-and-a-half-find-file)
-
(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)
网上下载ack-and-a-half.el
ack-and-a-half.rar
使用方法:
M-x ack
提示输入正则表达式,ack会从当前文件夹搜索正则表达式的字符串
在windows上用ack需要额外的一些步骤
-
(defun ack-and-a-half-run (directory regexp pattern &rest arguments)
-
"Run ack in DIRECTORY with ARGUMENTS."
-
(let ((default-directory (if directory
-
(file-name-as-directory (expand-file-name directory))
-
default-directory)))
-
(setq arguments (append ack-and-a-half-arguments
-
(ack-and-a-half-arguments-from-options regexp)
-
arguments
-
(list "--")
-
(list (shell-quote-argument pattern))
-
(if system-type 'windows-nt
-
(list (concat " < " "/dev/null"))) ;;; THIS LINE WAS ADDED
-
-
))
-
(make-local-variable 'compilation-buffer-name-function)
-
(let ((compilation-buffer-name-function nil)
-
(compilation-disable-input t))
-
(setq compilation-buffer-name-function 'ack-buffer-name)
-
(compilation-start (mapconcat 'identity (nconc (list ack-and-a-half-executable) arguments) " ")
-
配置
(defcustom ack-and-a-half-executable (or (executable-find "ack")
(executable-find "ack-grep"))
"*The location of the ack executable."
:group 'ack-and-a-half
:type 'file)
M-x customize 配置 ack-and-a-half-executable 到 “ack”, windows下无法找到ack
阅读(2794) | 评论(0) | 转发(0) |