emacs配置文件中比较好用的函数
2013-04-27 19:00
405 查看
(声明:这些函数非本人原创,是本人从各处收集的,后期还会更新)
1.在当前行之前,之后插入新行(类似与vim在normal模式下的a和o键)
出处(http://whattheemacsd.com/);;C-return 在当前行上新开一行 ;;C-S-return 在当前行下新开一行 (defun open-line-below () (interactive) (end-of-line) (newline) (indent-for-tab-command)) (defun open-line-above () (interactive) (beginning-of-line) (newline) (forward-line -1) (indent-for-tab-command)) (global-set-key (kbd "<C-return>") 'open-line-below) (global-set-key (kbd "<C-S-return>") 'open-line-above)
C即ctrl键,S即shift键盘;
使用elisp语言定义了两个函数,open-line-below和open-line-above.
open-line-below是在当前行之下插入新行,open-line-above实在当前行之上插入新行
将这两个函数分别映射到了<C-return>和<C-S-return>两个快捷键上.
2.emacs全屏
出处(Deepin linux emacs中的配置);;; fullscreen.el --- Full screen ;; Filename: fullscreen.el ;; Description: Full screen ;; Author: Andy Stewart <lazycat.manatee@gmail.com> ;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com> ;; Copyright (C) 2009, Andy Stewart, all rights reserved. ;; Created: 2009-02-11 21:05:32 ;; Version: 0.1 ;; Last-Updated: 2009-02-11 21:05:32 ;; By: Andy Stewart ;; URL: http://www.emacswiki.org/emacs/download/fullscreen.el ;; Keywords: fullscreen ;; Compatibility: GNU Emacs 23.0.60.1 ;; ;; Features that might be required by this library: ;; ;; ;; ;;; This file is NOT part of GNU Emacs ;;; License ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;;; Commentary: ;; ;; Full screen. ;; ;; Below are commands you can use: ;; ;; `fullscreen' Full screen. ;; `fullscreen-toggle' Toggle full screen status. ;; ;;; Installation: ;; ;; Put fullscreen.el to your load-path. ;; The load-path is usually ~/elisp/. ;; It's set in your ~/.emacs like this: ;; (add-to-list 'load-path (expand-file-name "~/elisp")) ;; ;; And the following to your ~/.emacs startup file. ;; ;; (require 'fullscreen) ;; ;; No need more. ;;; Customize: ;; ;; ;; ;; All of the above can customize by: ;; M-x customize-group RET fullscreen RET ;; ;;; Change log: ;; ;; 2009/02/11 ;; * First released. ;; ;;; Acknowledgements: ;; ;; ;; ;;; TODO ;; ;; ;; ;;; Require ;;; Code: (defun fullscreen () "Fullscreen." (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 ;; if first parameter is '1', can't toggle fullscreen status '(1 "_NET_WM_STATE_FULLSCREEN" 0))) (defun fullscreen-toggle () "Toggle fullscreen status." (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 ;; if first parameter is '2', can toggle fullscreen status '(2 "_NET_WM_STATE_FULLSCREEN" 0))) (provide 'fullscreen) ;;; fullscreen.el ends here将上面这段代码复制下来,保存为fullscreen.el,在.emacs中加入fullscreen.el的路径,在.emacs加入以下代码:
(require 'fullscreen) (global-set-key [f11] 'fullscreen-toggle)绑定到了快捷键F11上,按一次最大化,再按一次又恢复了,很方便
效果图:
3.重命名当前缓冲区
;;快捷键 C-x C-r重命名当前缓冲区 (defun rename-current-buffer-file () "Renames current buffer and file it is visiting." (interactive) (let ((name (buffer-name)) (filename (buffer-file-name))) (if (not (and filename (file-exists-p filename))) (error "Buffer '%s' is not visiting a file!" name) (let ((new-name (read-file-name "New name: " filename))) (if (get-buffer new-name) (error "A buffer named '%s' already exists!" new-name) (rename-file filename new-name 1) (rename-buffer new-name) (set-visited-file-name new-name) (set-buffer-modified-p nil) (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))) (global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)快捷键绑定到了ctrl-x ctrl-r上
相关文章推荐
- c/c++写的比较好的读写配置文件的函数或者类
- c/c++写的比较好的读写配置文件的函数或者类
- ThinkPHP第七天(F函数使用,项目分组配置,项目分组模板文件放置规则配置)
- 大灰狼的ASP工具箱——用ASP读INI配置文件的函数。
- 【新手向】emacs配置文件
- php.ini配置文件详解(为了安全,禁止一些高风险的函数)
- emacs配置文件
- emacs配置文件
- Emacs 的配置文件和插件文件的管理
- 一份比较好用的vim配置文件
- 6月5日 smarty变量调节器 函数 配置文件
- c++ 实现对配置文件的读写 根据windows API 函数简单改写
- 我的Emacs配置文件
- 我的emacs配置文件
- windows系统中Emacs的HOME目录及配置文件的正确路径
- 配置文件读取函数笔记(非通用)
- windows下,emacs的配置文件在哪儿?
- php读取配置文件函数
- [Emacs] 我的Emacs配置文件 for OI
- OI 用 Emacs 配置文件