有了cperl-perldoc,在Emacs里面看perl文档很方便,但有时候想看看代码,只好切换到命令行下面执行:
$ emacsclient --no-wait `perldoc -l A::Module`
如果使用下面的Emacs Lisp代码,可以省掉切换的麻烦,像使用cperl-perldoc看文档一样,直接在Emacs里面代开源代码文件。
(defun wl-cperl-find-module (module)
"View source code of CPAN module."
(interactive
(list (let* ((default-module (cperl-word-at-point))
(input (read-string
(format "CPAN module%s: "
(if (string= default-module "")
""
(format " (default %s)" default-module))))))
(if (string= input "")
(if (string= default-module "")
(error "No module given")
default-module)
input))))
(let ((perldoc-output
(with-temp-buffer
(call-process "perldoc" nil t nil "-l" module)
(buffer-substring-no-properties (point-min) (1- (point-max))))))
(if (string-match "no documentation found" perldoc-output)
(message "%s" perldoc-output)
(find-file-other-window perldoc-output))))
(cperl-define-key (kbd "C-c m") 'wl-cperl-find-module)






我在VISTA里面用EMACS,执行cperl-perldoc出现错误如下:
Debugger entered–Lisp error: (error "*Man say*: process exited abnormally with code 255")
signal(error ("*Man say*: process exited abnormally with code 255"))
error("%s" "*Man say*: process exited abnormally with code 255")
但我在公司的XP电脑上可以正常使用这个命令,不知道为什么?
我一般都是在Linux下用Emacs,对Windows没有什么经验,手上也没有VISTA。
你可以尝试联系一下cperl-mode的作者,或者cperl-perldoc的作者(如果两个作者不是同一个人的话)。