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 ...
随机推荐
- RedGate 工具SQLMultiScript1.1
原文:RedGate 工具SQLMultiScript1.1 RedGate 工具SQLMultiScript1.1 SQLMultiScript是一个脚本分发工具,当你写好了一个SQL脚本之后,你需 ...
- Google的Guava它Collection升华
至于Guava这是不是在这里说.一个已被提上一个非常特殊的! 这主要是为了分享Guava对于一些升华处理组.井,不多说了,直接在代码: package com.joyce.guava.bean; /* ...
- sql dateDiff函数
当月的数据select * from MOPICK where dateDiff(m,getdate(),START_DATE)=0
- jQuery来源学习笔记:扩展的实用功能
// 扩展的实用功能 jQuery.extend({ // http://www.w3school.com.cn/jquery/core_noconflict.asp // 释放$的 jQuery 控 ...
- HDU1237 简单的计算器 【堆】+【逆波兰式】
简单的计算器 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- Linux中查看socket状态(转)
Linux中查看socket状态:cat /proc/net/sockstat #(这个是ipv4的) sockets: used 137 TCP: inuse 49 orphan 0 tw 3272 ...
- java提高篇(六)-----关键字static
一. static代表着什么 在Java中并不存在全局变量的概念,但是我们可以通过static来实现一个"伪全局"的概念,在Java中static表示"全局"或 ...
- main thread starting…
例的结果,下面的: main thread starting- Thrad 2 staring- Thrad 2 end- Thrad 4 staring- Thrad 4 end- Thrad 1 ...
- Android - 用Fragments实现动态UI - 使用Android Support Library
Android Support Library提供了一个带有API库的JAR文件来让你可以在使用最新的Android API的同时也也已在早期版本的Android上运行.例如,Support Libr ...
- 【C语言探索之旅】 第一部分第六课:条件表达式
内容简介 1.课程大纲 2.第一部分第六课:条件表达式 3.第一部分第七课预告:循环语句 课程大纲 我们的课程分为四大部分,每一个部分结束后都会有练习题,并会公布答案.还会带大家用C语言编写三个游戏. ...