因为emacs自己就是emacs lisp编写的,因此在emacs中一个命令其实就是一个函数。html
(defun helm-M-x (_arg &optional command-name) "Preconfigured `helm' for Emacs commands. It is `helm' replacement of regular `M-x' `execute-extended-command'. Unlike regular `M-x' emacs vanilla `execute-extended-command' command, the prefix args if needed, can be passed AFTER starting `helm-M-x'. When a prefix arg is passed BEFORE starting `helm-M-x', the first `C-u' while in `helm-M-x' session will disable it. You can get help on each command by persistent action."
快捷键 | 命令 | 说明 |
---|---|---|
M-! | shell-command |
使用系统shell 运行命令并输出到buffer "Shell Command Output" |
M- | shell-command-on-region |
运行Shell命令并输出到编辑区域 |
M-x | helm-M-x |
运行emacs命令 |
- | term |
打开buffer "terminal",运行终端 |
- | eshell |
建立一个交互式的Elisp shell。 |
能够经过设置shell-file-name
变量的值来改变默认shellnode
(setq shell-file-name "/bin/bash")
eshell的用法shell
快速入门bash
掌握基本语法规则后就应该多看人家写的代码!
利用edebug更好更快地理解代码
假如想要知道打开文件是怎么操做的。session
首先定位函数的代码。函数
已知快捷键C-x C-f
。依次键入C-h k C-x C-f
。
而后就会显示函数的信息,点击helm-files.el
就能看到代码。工具
若是不知道快捷键,则键入C-h a
,利用命令的名称来搜索可能的选项。debug
(defun helm-find-files (arg) "Preconfigured `helm' for helm implementation of `find-file'. Called with a prefix arg show history if some. Don't call it from programs, use `helm-find-files-1' instead. This is the starting point for nearly all actions you can do on files." (interactive "P") (let* ((hist (and arg helm-ff-history (helm-find-files-history))) (smart-input (or hist (helm-find-files-initial-input))) (default-input (expand-file-name (helm-current-directory))) (input (cond (helm-find-file-ignore-thing-at-point default-input) ((and (eq major-mode 'org-agenda-mode) org-directory (not smart-input)) (expand-file-name org-directory)) ((and (eq major-mode 'dired-mode) smart-input) (file-name-directory smart-input)) ((and (not (string= smart-input "")) smart-input)) (t default-input))) (input-as-presel (null (nth 0 (file-attributes input)))) (presel (helm-aif (or hist (and input-as-presel input) (buffer-file-name (current-buffer)) (and (eq major-mode 'dired-mode) smart-input)) (if helm-ff-transformer-show-only-basename (helm-basename it) it)))) (set-text-properties 0 (length input) nil input) (helm-find-files-1 input (and presel (null helm-ff-no-preselect) (concat "^" (regexp-quote presel))))))
将光标放到函数名上,键入 C-u C-M-x
可添加中断入口。M-x edebug-mod
开启后会在菜单栏多出edebug的选项。code
使用命令C-x C-f
便会触发中断。regexp
n
可单步执行
这是一个很方便的工具。不一样于M-x
只能调用命令,IELM能够使用lisp语言,对于实现emacs扩展实在是太便捷了!
更多更详细的内容仍是得看文档!!