2013-05-17 41 views
1

我写一个elisp的功能具有一个符号一个简短的帮助说明:在后台运行文件?

(defun set-up-tooltip() 
    ;; search for the text to be highlighted 
    ... 
    (add-text-properties (match-beginning 0) 
         (match-end 0) 
         '(mouse-face highlight 
             help-echo (get-help-text (match-beginning 0))) 

(get-help-text)功能需要打开另一个文件搜索的文本。问题是:我如何在后台打开这个文件,以便用户不会注意到?我想:

(defun get-help-text(
    (save-excursion 
     (with-temp-buffer 
     (find-file "lookup-file") 
     ;;search for the text 
     ... 
      ))))) 

这里这是在临时缓冲区打开的文件在我打电话的背景功能,而不是窗口打开。有这种任务的惯用方式吗?

回答

1

您正在寻找的功能insert-file-contents:不是find-filewith-temp-buffer里面,你应该实现你想要什么

insert-file-contents is a built-in function in `C source code'. 

(insert-file-contents FILENAME &optional VISIT BEG END REPLACE) 

Insert contents of file FILENAME after point. 

使用。

+0

哇90秒,就是这样,谢谢 – ProfHase85