emacs quick open and jump file (or buffer) which name is current word
Sometime, we need to open a file or buffer which name begin with current word in emacs.
Here I give the solution as follows.
;; -----------------------------------------------------------------------------
;; quick-file-jump.el
;; Why this module?
;; Sometimes, we need to open a file or buffer which name
;; began with current word in emacs.
;; Here is the solution.
;;
;; Install.
;; put this file (quick-file-jump.el) in your load path and
;; add follow codes into your initial emacs files (.emacs or init.el)
;; (require 'quick-file-jump)
;; (global-set-key (kbd "<M-return>") 'ab/quick-buffer-jump)
;;
;; Author:
;; Aborn Jiang (aborn.jiang@foxmail.com)
;; 2014-05-13
;; ----------------------------------------------------------------------------- (provide 'quick-file-jump)
(defun ab/quick-buffer-jump ()
"Quickly jump to buffer/file which name is current word"
(interactive)
(setq fname (current-word))
(setq blist (buffer-list))
(setq status nil)
(setq switchedbuffer "nil")
(dolist (value blist)
(when (and (bufferp value)
(buffer-file-name value)
(not status)
(string-match (concat "^" (regexp-quote fname))
(buffer-name value)))
(progn (switch-to-buffer (buffer-name value))
(setq status t)
(setq switchedbuffer (buffer-name value)))
))
(if status ;; success search in buffer list.
(message "skip to %s buffer" switchedbuffer)
(ab/quick-file-jump))) ;; find files in current path. (defun ab/quick-file-jump ()
"Quickly open and jump file with name begin with current word"
(interactive)
(setq fname (current-word))
(setq switchedfile "nil")
(setq dflist (directory-files (ab/get-current-path)))
(dolist (value dflist)
(when (and (file-regular-p value)
(string-match
(concat "^" (regexp-quote fname)) value))
(find-file value)
(setq switchedfile value)
(setq status t)))
(if status ;; success search in file list
(message "open and skip to %s file." switchedfile)
(message "not find file name begin %s" fname))) (defun ab/get-current-path ()
"Get the current path"
(interactive)
(message (file-name-directory (buffer-file-name)))) ;; default global key setting
(global-set-key (kbd "<M-return>") 'ab/quick-buffer-jump)
版权声明:本文博主原创文章,博客,未经同意不得转载。
emacs quick open and jump file (or buffer) which name is current word的更多相关文章
- [daily] emacs显示file name buffer的全路径
在用emacs看代码的时候,在文件间跳来跳去,如果工程太大的话,很可能会有重名文件,这个时候, 你就不知道自己在什么的地方了.需要一个查看当前正在编辑区的文件的名字的方法. emacs在这个地方,存储 ...
- linux 下 Emacs dired 模式 隐藏 dot file ".filename" 文件
有时候 emacs 下调用 C-x dired 是挺方便的一个事,但是一堆的点文件(linux下以"."为前缀的文件,即隐藏文件)让人目不暇接,打算隐藏之. 参考如下: 最主要的是 ...
- 关于之前玩emacs记的些笔记
移动 C-v 向前翻页 M-v 向后翻页 C-l 当前行居中显示 继续按会依次到上,下,中 C-x C-c 退出 C-g 退出一个正在运行的命令,还可以取消数字参数和只输入到一半的命令 ...
- emacs 操作集锦
1.C-k 的功能并不是剪切当前行,而是剪切当前行从光标到行末的内容. Emacs 中的剪切不叫剪切(cut),叫kill,复制(copy)不叫copy ,叫kill-ring-save (这个可以理 ...
- Emacs Lisp 功能扩展集锦
http://docs.huihoo.com/homepage/shredderyin/emacs_elisp.html Emacs 具有超强的扩展性.这是当今没有任何其它编辑器可以比拟 的强大特点. ...
- GNU Emacs命令速查表
GNU Emacs命令速查表 第一章 Emacs的基本概念 表1-1:Emacs编辑器的主模式 模式 功能 基本模式(fundamental mode) 默认模式,无特殊行为 文本模式(text m ...
- NASM mode for Emacs
NASM mode for Emacs Quick post for those Emacs users out there. The common assembler used on GNU ...
- Emacs 快速指南(中文翻译)
Emacs 快速指南 目录 1. 小结(SUMMARY) 2. 基本的光标控制(BASIC CURSOR CONTROL) 3. 如果 EMACS 失去响应(IF EMACS STOPS RESP ...
- Emacs快速入门
Emacs 快速入门 Emacs 启动: 直接打emacs, 如果有X-windows就会开视窗. 如果不想用X 的版本, 就用 emacs -nw (No windows)起动. 符号说明 C-X ...
随机推荐
- Codeforces Round#309 C Kyoya and Colored Balls
给定一个k表示颜色的种类从1到k 然后接下来k行, 每行一个数字, 代表该颜色的球有多少个 这些球都放在一个包中,然后依次拿出. 要求颜色i的最后一个球, 必须要排在颜色i+1的最后一个球前面, ...
- Nagios监控生产环境redis群集服务战
前言: 曾经做了cacti上展示redis性能报表图.能够看到redis的性能变化趋势图,可是还缺了实时报警通知的功能,如今补上这一环节. 在redis服务瓶颈或者异常时候即使报警通知,方便d ...
- Google Maps Android API v2 (1)- 入门
才可以开始工作的API,你将需要下载的API,并确保你有一个谷歌地图Android的API V2关键.API和关键是免费提供的. 概观 获得谷歌地图Android的API V2 谷歌地图API密钥 显 ...
- Oracle GoldenGate (以下简称ogg)在异种移植os同一种db之间的数据同步。
Oracle GoldenGate (以下简称ogg)在异种移植os同一种db之间的数据同步. ogg要实现的功能: 同步可以细化到单个表,满足特定的where条件rows同步,称号column同步. ...
- 解决 下载 CM-12.0 源代码出现 Fatal: duplicate project .....问题
在使用 repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0 初始化代码库的时候出现如下错误: fatal: manifes ...
- 20140719中国互联网公司市值排名TOP20
近期在找工作.关注了一下中国互联网公司的市值,实际情况跟想象的区别非常大. 比方异军突起的小米.京东.唯品会.聚美优品. 比方乐视网由于政策原因,市值两日缩水10亿$.停牌了. 搜房网市值90天蒸发3 ...
- 详细说明XML分解(两)—DOM4J
第一部分关于博客XML三接口,同时也为学习DOM4J该分析工具做准备.一般解析器基本上都实现了DOM和SAX这两组接口,DOM4J自然也不例外..DOM4J仅仅是经常使用解析器的当中一种,只是既然是实 ...
- js多物体任意值运动
假如有两个div,一个div要变宽,一个div要变高,你怎么写呢? 哎呀,写2个方法啊,一个控制div1变宽,一个控制div2变高啊 那么你的代码,是不是下面这样的呢! 示例:Div变宽和变高 现象: ...
- appendChild的用法
appendChild的用法 1,先把元素从原有父级上删除 2,再把元素添加到新父级上
- 一个不错的 png压缩工具 pngquant 使用介绍 批量压缩png
1.Png 简介. 我们知道Png 有4个通道,RGBA, 多了一个表示透明的.png 有 png 32, 24, 8 等. 大致我理解的是表示颜色的多少. 数字越小,文件就越小.常见的压缩方式是导入 ...