Chinaunix首页 | 论坛 | 博客
  • 博客访问: 228256
  • 博文数量: 3
  • 博客积分: 2673
  • 博客等级: 少校
  • 技术积分: 93
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-01 13:02
个人简介

hi there

文章分类

全部博文(3)

文章存档

2009年(3)

我的朋友

分类: LINUX

2009-01-30 22:49:02

Emacs技巧:快速打开最近打开过的文件

Created: Fang lungang(Ark) 01/30/2009 Modified: Fang lungang(Ark) 01/30/2009 01:49>

home

recentf.el (Emacs 22 以后都自带了)提供了常见的“recent files”功能,可 以从菜单栏选择打开一个最近访问过的文件。稍作扩展后,则非常方便。

基本配置

它的基本配置如下

;;; recently opened file
(require 'recentf)
(setq recentf-max-saved-items 100)
(recentf-mode 1)

远程文件

如果 recentfdesktop-save-mode 功能都激活了,访问过远程文件(另一台 服务器上的文件)之后,每次启动都会试图去访问那个服务器。这个特别烦人, 尤其是要输入密码。做如下配置告诉 recentf 不要去检查远程文件:

;; add at the front of list, don't conncect to remote hosts
(add-to-list 'recentf-keep 'file-remote-p)

快捷方式

Emacs 老手都知道“键盘+自动补齐”比“鼠标点击”要方便且高效很多。此处也一 样,设想一下列表有一百个文件,要从中挑选一个,是用鼠标快还是键盘快?用 下面的配置,几乎 100% 是键盘快。只要输入文件名中包含的任意几个字符(不 区分大小写)就可以迅速定位到想打开的文件了。

;;; refer to lgfang-init.el for latest update

(define-key global-map [f5] 'my-recentf-open)

(setq ido-enable-flex-matching t)

(defun my-recentf-open ()
"open recent files. In ido style if applicable --lgfang"
(interactive)
(let* ((path-table (mapcar
(lambda (x) (cons (file-name-nondirectory x) x))
recentf-list))
(file-list (mapcar (lambda (x) (file-name-nondirectory x))
recentf-list))
(complete-fun (if (require 'ido nil t)
'ido-completing-read
'completing-read))
(fname (funcall complete-fun "File Name: " file-list)))
(find-file (cdr (assoc fname path-table)))))
阅读(6611) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~