emacs 插件开发
来源:互联网 发布:外汇托管知乎 编辑:程序博客网 时间:2024/06/06 08:29
;; global-set-key为函数 接收两个参数;; 一个字符串 "\M-r" 代表Alt+r;; 一个函数 前面用`符号表示该参数为函数(global-set-key "\M-r" `indent-buffer);; 等价于(global-set-key "\M-r" (quote indent-buffer))
string
,Numbers
, characters
, vectors
求值是 self-evaluating
, 不用加 quote
(defun other-window-backward () ;; interactive 让该函数变为可交互式函数 ALT+x 会看到 (interactive) (other-window -1))
(defun other-window-backward (n) ;; 有interactive "p" 这个标示的函数 n默认为1 指定次数调用的时候 n为指定的次数 (interactive "p") (other-window (- n)))
(defun other-window-backward (&optional n) ;; &optional 代表参数可选 (interactive "p") (if n (other-window (- n)) (other-window (- 1))))
(defun other-window-backward (&optional n) ;; &optional 代表参数可选 (interactive "p") (other-window (- (or n 1))));;(other-window (if n (- n ) -1)))
(defun other-window-backward (&optional n) ;; P 为大写 (interactive "P") ;; prefix-numeric-value 为emacs内置函数 等价于以上 (other-window (- (prefix-numeric-value n))))
(defalias `scroll-ahead `scroll-up)(defalias `scroll-behind `scroll-down)(defun scroll-n (&optional n) (interactive "P") (scroll-ahead (prefix-numeric-value n)))
hook
本质上是一个变量,值为一个列表,列表中有一个或多个函数,这些函数会在某个指定的条件下依次执行
(defun read-only-if-symlink () ;; file-symlink-p 函数返回一个文件是否为链接文件 p代表predicate(断言) ;; buffer-file-name 当前buffer的绝对路径 (if (file-symlink-p buffer-file-name) ;; progn 顺序解析其后的所有表达式 最终值为最后一个表达式的值 (progn (setq buffer-read-only t) (message "File is a symlink"))))(add-hook `find-file-hooks `read-only-if-symlink);; (remove-hook `find-file-hooks `read-only-if-symlink)
;; 只是演示 在hook中不用使用lambda(add-hook `find-file-hooks `(lambda () (if (file-symlink-p buffer-file-name) (progn (setq buffer-read-only t) (message "File is symlink")))))
;; 报错信息(error "This is error")
;; 使用局部变量(defun local-var (n) (let ((x 12)) (* n x)))(local-var 20)
;; global-set-key为函数 接收两个参数;; 一个字符串 "\M-r" 代表Alt+r;; 一个函数 前面用`符号表示该参数为函数(global-set-key "\M-r" `indent-buffer);; 等价于(global-set-key "\M-r" (quote indent-buffer))
string
,Numbers
, characters
, vectors
求值是 self-evaluating
, 不用加 quote
(defun other-window-backward () ;; interactive 让该函数变为可交互式函数 ALT+x 会看到 (interactive) (other-window -1))
(defun other-window-backward (n) ;; 有interactive "p" 这个标示的函数 n默认为1 指定次数调用的时候 n为指定的次数 (interactive "p") (other-window (- n)))
(defun other-window-backward (&optional n) ;; &optional 代表参数可选 (interactive "p") (if n (other-window (- n)) (other-window (- 1))))
(defun other-window-backward (&optional n) ;; &optional 代表参数可选 (interactive "p") (other-window (- (or n 1))));;(other-window (if n (- n ) -1)))
(defun other-window-backward (&optional n) ;; P 为大写 (interactive "P") ;; prefix-numeric-value 为emacs内置函数 等价于以上 (other-window (- (prefix-numeric-value n))))
(defalias `scroll-ahead `scroll-up)(defalias `scroll-behind `scroll-down)(defun scroll-n (&optional n) (interactive "P") (scroll-ahead (prefix-numeric-value n)))
hook
本质上是一个变量,值为一个列表,列表中有一个或多个函数,这些函数会在某个指定的条件下依次执行
(defun read-only-if-symlink () ;; file-symlink-p 函数返回一个文件是否为链接文件 p代表predicate(断言) ;; buffer-file-name 当前buffer的绝对路径 (if (file-symlink-p buffer-file-name) ;; progn 顺序解析其后的所有表达式 最终值为最后一个表达式的值 (progn (setq buffer-read-only t) (message "File is a symlink"))))(add-hook `find-file-hooks `read-only-if-symlink);; (remove-hook `find-file-hooks `read-only-if-symlink)
;; 只是演示 在hook中不用使用lambda(add-hook `find-file-hooks `(lambda () (if (file-symlink-p buffer-file-name) (progn (setq buffer-read-only t) (message "File is symlink")))))
;; 报错信息(error "This is error")
;; 使用局部变量(defun local-var (n) (let ((x 12)) (* n x)))(local-var 20)
0 0
- emacs 插件开发
- emacs js开发插件配置方法
- emacs插件
- emacs插件
- 针对Ruby on Rails开发的Emacs插件
- chrome的Emacs插件
- Emacs插件 - CEDET
- Emacs插件 - 安装ECB
- emacs插件管理
- emacs插件推荐
- vs扩展emacs插件
- emacs插件以及配置
- emacs插件目录配置
- emacs 安装ecb插件
- emacs添加cscope插件
- emacs添加yasnippet插件
- emacs 插件列表
- Chrome插件Edit with Emacs
- 鸟哥的linux私房菜读书笔记6
- 12、C++计算日历
- 自己动手搭建苹果推送Push服务器
- echarts 总结
- [Java] RTTI
- emacs 插件开发
- boolan——c++学习笔记之c++转换函数
- 鸟哥的linux私房菜读书笔记7
- python3使用builtwith识别网站使用相关技术
- java面试题(5)-Java框架部分
- SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
- ORA-01033:oracle initialization or shutdown in progress 解决办法
- python复习笔记[8]——I/O及文件处理
- 上传文件