EDITOR-学会 EMACS
Table of Contents
- 学会 emacs
- 学会 emacs 1 (Day one)
- 学会 emacs 2 (Day two)
- 学会 emacs 3 (Day three)
- 学会 emacs 4 (Day four)
- 学会 emacs 5 (Day five)
- 学会 emacs 6 (Day six)
- 学会 emacs 7 (Day seven)
- 学会 emacs 8 (Day eight)
- 学会 emacs 9 (Day nine)
- 学会 emacs 10 (Day ten)
- 学会 emacs 11 (Day eleven)
- 学会 emacs 12 (Day twelve)
- 学会 emacs 13 (Day thirteen)
- 学会 emacs 14 (Day fourteen)
- 学会 emacs 15 (Day fifteen)
- 学会 emacs 16 (Day sixteen)
- 学会 emacs 17 (Day seventeen)
- 学会 emacs 18 (Day eighteen)
- I want a feature from other editors, How could I implement it in Emacs?
- Emacs don’t behavior like the other editors I used before
- I have a full time job, I can’t bear the efficiency lose when editing with Emacs/Spacemacs
- Don’t try to make the perfect GTD tool with Org-mode
- Some tips for beginners to avoid common issues
- I have lots unknown of Emacs..
- 学会 emacs 19 (Day nineteen)
- 学会 emacs 20 (Day twenty)
- 学会 emacs 21 (Day twenty one)
学会 emacs
学会 emacs 1 (Day one)
Install Emacs
- Mac
- Windows
- Linux(apt get install emacs)
Go over the Emacs tutorial at least once
- C-h t to open the tutorial.
- You need be familiar with cursor movement(C-f/C-b/C-n/C-p/C-a/C-e) and basic editing (C-k)
- You should be familiar with M(eta), s(uper, command key), S(hift), C(trl) M-x s-p S-p C-p
- Prefix key(c-h is a prefix key) and C-g (C-x c-f)
Learn to active some built-in functionality (org-mode)
- linum-mode to display line numbers (M-x linum-mode)
- C-x C-f(find/file) to open files, C-x C-s(ave) to save files. (You could also use your mouse to do all the file operations.)
- you should always ask Emacs the right question
- C-h k/ C-h v / C-h f (Emacs is a self document, extensiable editor.)
- The key bindings are actually a quick way to command Emacs.
Learn some elisp(emacs lisp)
- use learnxinyminutes website to learn emacs lisp.
- at least you know how to define variable, functions
- You should know how to make a function callable and how to set a key binding for the function.
Start to hacking Emacs from the day one!
- turn off tool-bar
- turn off scroll-bar
- show linum-mode
- turn off splash screen
- save your config
- define a function to quickly open your config file.
Emacs package system in the first glance.
- How to use the built-in Package system of Emacs.
- Install company mode and active it.
- Major mode and minor mode (C-h m)
- Happy hacking. :)
Bonus(org-mode basics)
TODO 3rd level
- use * to define headings
- C-c C-t to toggle TODO states
GTD(getting things done)
学会 emacs 2 (Day two)
Fixes some annoying stuff
- make cursor style to bar
disable backup file
(setq make-backup-files nil)
use C-’ to open another buffer to edit source code.
Make source code fancy in the org file.
(require 'org) (setq org-src-fontify-natively t)
enable recentf-mode
(require 'recentf) (recentf-mode 1) (setq recentf-max-menu-items 25) (global-set-key "\C-x\ \C-r" 'recentf-open-files)
- bring electric-indent-mode back
- add delete selection mode
(delete-selection-mode t)
- bring electric-indent-mode back
Make Emacs more fancy
Open with full screen
(setq initial-frame-alist (quote ((fullscreen . maximized))))
show match parents
(add-hook 'emacs-lisp-mode-hook 'show-paren-mode)
It has a flaw, we will use more powerful package in the future.
- Highlight current line (global-hl-line-mode)
(global-hl-line-mode t)
- Highlight current line (global-hl-line-mode)
Improve built-in package system
make package system more powerful with Melpa
(when (>= emacs-major-version 24) (require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) ) (require 'cl) ;;add whatever packages you want here (defvar zilongshanren/packages '( company ) "Default packages") (defun zilongshanren/packages-installed-p () (loop for pkg in zilongshanren/packages when (not (package-installed-p pkg)) do (return nil) finally (return t))) (unless (zilongshanren/packages-installed-p) (message "%s" "Refreshing package database...") (package-refresh-contents) (dolist (pkg zilongshanren/packages) (when (not (package-installed-p pkg)) (package-install pkg))))
- install a theme (monokai)
- install hungry delete mode
- package-list-packages (add/delete/update packages)
- install and configure smex and ivy mode
- use customize-group to customize the package settings
- install and configure smartparens mode
Don’t try to update the package daily, the updating process might failed.
(tips: press M-RET to fix the order, you could also use M-RET to add new headings, cheers!)
- install a theme (monokai)
Setup a javascript IDE
- Install js2-mode and start to write javascript
- Install nodejs-repl to execute code inside Emacs
Learn more from Emacs itself
- c-h c-f(find-function), c-h c-v(find-variable), c-h c-k(find-function-on-key)
- Tell users to learn more about elisp(M-x info)
Org-mode(Bonus Time)
Agenda files and agenda view
one gtd.org file
(setq org-agenda-files '("~/org")) (global-set-key (kbd "C-c a") 'org-agenda)
Learn how to schedule items and set deadline
- c-c c-s to schedule item
- c-c c-d to set deadline of item.
Excercise
the difference between .emacs and .emacs.d/init.el file
try to configure company mode via customize-group
学会 emacs 3 (Day three)
Split your configs into multiple files
- use Git to management your init file
- load-file, load-path and load
- features, provide and require, autoload
- naming conventions
all of the names should have a prefix, such that the naming conflicts could be minimal. define your abbrevs
(abbrev-mode t) (define-abbrev-table 'global-abbrev-table '(("8hr" "haoran") ("8ms" "Macrosoft")))
- organize your configs
- use `counsel-git` to find file in git managed project
Major mode and minor mode in details
- conventions
text-mode/special-mode/prog-mode
Better defaults
Dired mode and file related operators
Bouns Time. Use Org-mode Iterate programming to organize your Emacs configurations
学会 emacs 4 (Day four)
Better buffer
Indent-region or buffer
;;C-M-\能够直接对全文格式化,不使用这个函数与下面一个函数的话,只能对选中的地方格式化 (defun ogmc/indent-buffer () "Indent the currently visited buffer." (interactive) (indent-region (point-min) (point-max))) (defun ogmc/indent-region-or-buffer () ;;一键格式化 "Indent a region if selected, otherwise the whole buffer." (interactive) (save-excursion;;记忆光标位置 (if (region-active-p) (progn (indent-region (region-beginning) (region-end)) (message "Indented selected region.")) (progn (ogmc/indent-buffer) (message "Indented buffer.")))))
another way to complete things in Emacs.
(global-set-key (kbd "s-/") 'hippie-expand);;windows-/,一个代码补全函数 ;;好像是增强补全,而且还很不错的样子,绑定了一个快捷键s-/ (setq hippie-expand-try-functions-list '(try-expand-dabbrev ;;路径补全 try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-complete-lisp-symbol-partially try-complete-lisp-symbol))
Dired mode and related operations
(setq dired-recursive-deletes 'always);;对目录删除操作时始终递归 (setq dired-recursive-copies 'always);;对目录复制操作时始终递归 (put 'dired-find-alternate-file 'disabled nil);;buffer共用 (with-eval-after-load 'dired;;所以使用这一句 (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file));;配合上上一条使用,不共用buffer
- copy, delete and rename file
- +
- 创建新目录
- C-x C-f
- 创建新文件
- D
- 删除光标下文件或文件夹
- d
- 标记为删除
- u
- 删除标记
- C
- 复制
- add new file and folder
- open dired of current buffer
Bouns Time. Use Org-mode Iterate programming to organize your Emacs configurations
(package-initiate) (require 'org-install) (require 'ob-tangle) (org-babel-load-file (expand-file-name "emacs.org" user-emacs-directory))
学会 emacs 5 (Day five)
Fix smartparen quote issue
(sp-local-pair 'emacs-lisp-mode "'" nil :actions nil) (sp-local-pair 'emacs-lisp-mode "`" nil :actions nil) (sp-local-pair 'lisp-interaction-mode "'" nil :actions nil) ;;使光标在括号中间的内容也能高亮最近的匹配括号,不过后面会改成下面的 (define-advice show-paren-function (:around (fn) fix-show-paren-function) "Highlight enclosing parens." (cond ((looking-at-p "\\s(") (funcall fn)) (t (save-excursion (ignore-errors (backward-up-list)) (funcall fn))))) ;; normal模式下仍然匹配邻近括号 (defadvice show-paren-function (around fix-show-paren-function activate) (cond ((looking-at-p "\\s(") ad-do-it) (t (save-excursion (ignore-errors (backward-up-list)) ad-do-it))))
Editing large web page
#+begin_src emacs-lisp
#+end_sr
Add more useful package for web development
隐藏,删除 DOS 系统下的^M
(defun haoran/hidden-dos-eol () ;;隐藏DOS系统下的^M "Do not show ^M in files containing mixed UNIX and DOS line endings." (interactive) (setq buffer-display-table (make-display-table)) (aset buffer-display-table ?\^M [])) (defun haoran/remove-dos-eol () ;;删除DOS系统下的^M "Replace DOS eolns CR LF with Unix eolns CR" (interactive) (goto-char (point-min));;跳转到文件开头 (while (search-forward "\r" nil t) (replace-match "")));;windows下的换行符替换为空字符串
web-mode
;;js2-mode,这是先前使用js2-mode时就学到的东西 (setq auto-mode-alist (append '(("\\.js\\'" . js2-mode) ("\\.html\\'" . web-mode)) auto-mode-alist)) (defun my-web-mode-indent-setup() ;;这里我们直接设置默认为两个缩进 (setq web-mode-markup-indent-offset 2) ; web-mode, html tag in html file (setq web-mode-css-indent-offset 2) ; web-mode, css in html file (setq web-mode-code-indent-offset 2)) ; web-mode, js code in html file (add-hook 'web-mode-hook 'my-web-mode-indent-setup) (defun my-toggle-web-indent();;为了适应所有人的喜好,还写了一个切换缩进长度的函数 (interactive) ;; web development (if (or (eq major-mode 'js-mode) (eq major-mode 'js2-mode)) (progn (setq js-indent-level (if (= js-indent-level 2) 4 2)) (setq js2-basic-offset (if (= js2-basic-offset 2) 4 2)))) (if (eq major-mode 'web-mode) (progn (setq web-mode-markup-indent-offset (if (= web-mode-markup-indent-offset 2) 4 2)) (setq web-mode-css-indent-offset (if (= web-mode-css-indent-offset 2) 4 2)) (setq web-mode-code-indent-offset (if (= web-mode-code-indent-offset 2) 4 2)))) (if (eq major-mode 'css-mode) (setq css-indent-offset (if (= css-indent-offset 2) 4 2))) (setq indent-tabs-mode nil)) (global-set-key (kbd "C-c t i") 'my-toggle-web-indent)
js2-refactor
major-mode 还是 js2-mode,多了一个 minor-mode js2-refactor
;;js2-refactor (add-hook 'js2-mode-hook #'js2-refactor-mode) (js2r-add-keybindings-with-prefix "C-c C-m")
occur and imenu
- 视频中使用了 popwin,而我没有使用,所以设置 occur 的 window 在右边我不能和他一样做
- 视频中是 customize 了 powin,我就不搞了
设置窗口大小也不搞了
这个 occur-mode 是 emacs 自带的,默认按键绑定到了 M-s o
;;自动抓取光标停留的单词,至于为什么叫这个函数名,dwim = do what I mean (defun occur-dwim() "Call `occur' with a sane default." (interactive) (push (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) (let ((sym (thing-at-point 'symbol))) (when (stringp sym) (regexp-quote sym)))) regexp-history) (call-interactively 'occur)) (global-set-key (kbd "M-s o") 'occur-dwim);;本来就是这个按键,优化了这个函数而已
;;下面的是增强了counsel-imenu功能,能够找到隐藏较深的函数 (defun js2-imenu-make-index () (interactive) (save-excursion ;; (setq imenu-generic-expression '((nil "describe\\(\"\\(.+\\)\"" 1))) (imenu--generic-function '(("describe" "\\s-*describe\\s-*(\\s-*[\"']\\(.+\\)[\"']\\s-*,.*" 1) ("it" "\\s-*it\\s-*(\\s-*[\"']\\(.+\\)[\"']\\s-*,.*" 1) ("test" "\\s-*test\\s-*(\\s-*[\"']\\(.+\\)[\"']\\s-*,.*" 1) ("before" "\\s-*before\\s-*(\\s-*[\"']\\(.+\\)[\"']\\s-*,.*" 1) ("after" "\\s-*after\\s-*(\\s-*[\"']\\(.+\\)[\"']\\s-*,.*" 1) ("Function" "function[ \t]+\\([a-zA-Z0-9_$.]+\\)[ \t]*(" 1) ("Function" "^[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*=[ \t]*function[ \t]*(" 1) ("Function" "^var[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*=[ \t]*function[ \t]*(" 1) ("Function" "^[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*()[ \t]*{" 1) ("Function" "^[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*:[ \t]*function[ \t]*(" 1) ("Task" "[. \t]task([ \t]*['\"]\\([^'\"]+\\)" 1))))) (add-hook 'js2-mode-hook (lambda () (setq imenu-create-index-function 'js2-imenu-make-index))) (global-set-key (kbd "M-s i") 'counsel-imenu);;列出函数 (global-set-key (kbd "M-s e") 'iedit-mode);;同时编辑
expand-region, and iedit mode
这是两个包,一个是 C-=来可视化最近范围区域的代码,一个是 M-s e,来同时编辑多个相同的单词,但是我觉得没用
前一个可以使用 viw-vim 中的方式选中,后一个可以使用:%s//g
Bonus Time. Org export
C-c C-e export
学会 emacs 6 (Day six)
Bonus Time
Use org-capture to take notes
(setq org-capture-templates '(("t" "Todo" entry (file+headline "~/.emacs.d/org/gtd.org" "工作安排") "* TODO [#B] %?\n %i\n" :empty-lines 1)))
Further reading
install Org pomodoro to track my time
Batch rename files
- press C-x C-q in dired mode
- C-c C-c 保存更改
- use expand-region and iedit to batch change files
search and replace
install helm-ag
at first, you should install ag
search speed: ag > pt > ack > grep
#从网上找ag的安装命令 MacOS: brew install the_silver_searcher Debian/Ubuntu: sudo apt-get install silversearcher-ag CentOS: sudo yum install the_silver_searcher Fedora: sudo dnf install the_silver_searcher ArchLinux: sudo pacman -S the_silver_searcher
- install package helm-ag
- 绑定快捷键 C-c p s(p 是项目的意思,后面用 vim 后就用<leader>了)
- 这里我没有下载这个 package,感觉现在还用不到,我现在只想要一个清爽的 emacs
- install package helm-ag
show javascript errors with flycheck
- 首先要先系统安装 eslint(代码检错)
然后安装 flycheck 这个包
;;flycheck ;;(global-flycheck-mode t) (add-hook 'js2-mode-hook 'flycheck-mode)
Snippets and auto snippet
auto-yasnippet
学会 emacs 7 (Day seven)
Tweak C-w to delete backword
(global-set-key (kbd “C-w”) ’backward-kill-word);;回退删除
Evil Turn Emacs into Vim in one second
install Evil pluein
(setcdr evil-insert-state-map nil);;这句与下面一句的作用是使insert下是emacs-state,否则有些emacs的快捷键不能用 (define-key evil-insert-state-map [escape] 'evil-normal-state) (setq-default evil-want-C-u-scroll t);;这里的设置无效,放在这只是提醒这个功能需要自己改 ;; '(evil-want-C-u-scroll t);;在custom中加入这句才可以
- press C-z to toggle Normal and Emacs state
- 我不需要,我使用 C-[
- 我不需要,我使用 C-[
- Evil state = vim mode
- evil-insert-state
- evil-normal-state
- evil-visual-state
- evil-motion-state
- evil-emacs-state
- evil-operator-state
- evil-insert-state
- configure Evil leader key
- 需要安装一个 evil-leader
- 需要安装一个 evil-leader
- powerline
- 我使用 doomline
- 我使用 doomline
- evil-sround
- evil-nerdcommer
made some modes to use emacs state
;;暂时不加,这个的作用就是在一些mode下使用emacs-state,因为normal-state可能做的不好 (dolist (mode '(ag-mode flycheck-error-list-mode occur-mode git-rebase-mode)) (add-to-list 'evil-emacs-state-modes mode)) ;;将occur-mode中的按键调整 (add-hook 'occur-mode-hook (lambda () (evil-add-hjkl-bindings occur-mode-map 'emacs (kbd "/") 'evil-search-forward (kbd "n") 'evil-search-next (kbd "N") 'evil-search-previous (kbd "C-d") 'evil-scroll-down (kbd "C-u") 'evil-scroll-up))) (evil-add-hjkl-bindings package-menu-mode-map 'emacs) ;;还是觉得这个occur-mode没啥用
- whitch-key
- 重复,我想要的是简单清爽的 emacs
- 重复,我想要的是简单清爽的 emacs
学会 emacs 8 (Day eight)
mwe-log-command
用于显示 log
cask
这是系统层面的,装在系统里,用来干什么的就不知道了
pallet
pallet 是基于 cask 的
smart-paren
;;在第4天中的函数换成了这个 ;; normal模式下仍然匹配邻近括号,但是我的不行 (defadvice show-paren-function (around fix-show-paren-function activate) (cond ((looking-at-p "\\s(") ad-do-it) (t (save-excursion (ignore-errors (backward-up-list)) ad-do-it))))
学会 emacs 9 (Day nine)
What is macro?
What’s the differen between function and macro?
Why macro
Use-package and basic usage
a more safe require
group config into one place
autoload and bind keys easily
make your config load faster
and more? Spaceemacs use it a lot…
Bonus Time
学会 emacs 10 (Day ten)
Topic: Company-mode and auto-completion
Cask and macro/use-package
Fix previous issous
How company-mode works?
- backend for the completion sources and front end to display the candidates
- C-h v company-backends
- try company-file and company-ispell, M-x
- C-h C-f to view the backend implementation
Why my company sucks?
- Python anaconda-mode not works
- some backend require build with a server-client architecture: company-anaconda, company-jedi, company-ycmd, company-tern etc
- At first, you should make sure the server side is working properly and then you want to make sure you use the right backend
- how to fix anaconda on Mac
Group backend
Write a Simple company backend
又介绍了 cask,但是我暂时用不到,我又不开发 package
还介绍了 company-backend,暂时不想学
学会 emacs 11 (Day eleven)
下载 spacemacs
更换源
(setq configuration-layer–elpa-archives
’((“melpa-cn” . “http://elpa.emacs-china.org/melpa/”)
(“org-cn” . “http://elpa.emacs-china.org/org/”)
(“gnu-cn” . “http://elpa.emacs-china.org/gnu/”)))
开启全屏
dotspacemacs-maximized-at-startup t
custom.el
(setq custom-file (expand-file-name “custom.el” dotspacemacs-directory))
(load custom-file ’no-error ’no-message)
字体
source code pro
学会 emacs 12 (Day twelve)
Topic: Create layer for your own configs
More tweaks of the builit layers
- config variables (chinese layer)
Write your first layer
学会 emacs 13 (Day thirteen)
Topic: More tweaks of your own layers
Fix ivy 0.8 issues
post-init and pre-init
location: builtin, elpa and github
layers.el
学会 emacs 14 (Day fourteen)
文件
- SPC p f
- 在 git 管理的文件夹下查找文件
- SPC f f
- 查找文件、创建新文件
- SPC f o
- 使用系统的外部软件打开当前文件
- SPC f E
- 使用 sudo 打开这个文件
- SPC f D
- 删除当前文件
- SPC f j
- 打开当前文件的 dired-mode
- SPC f r
- 打开 recent 文件
- SPC f R
- 重命名当前文件
- SPC f v
- 给目录添加特殊的变量
- SPC f y
- 复制当前文件的全路径
- SPC f C u/d
- 转换编码 unix/dos
- SPC f e d
- 打开.spacemacs 文件
- SPC f e i
- 打开.emacs.d/init.el 文件
- SPC f e l
- 打开 elpa 下面的文件
- SPC f c
- 复制当前文件
- SPC f b
- 显示当前的 bookmarks
- SPC f s/S
- 保存当前文件,所有 buffer 中的文件
buffer
- SPC b .
- hydra
- SPC p b
- 开启的被 git 仓库管理的 buffer
- SPC b b
- 选择已开启的 buffer
- SPC b d
- 把这个 buffer 删除,当这个文件还是存在的
- SPC b i
- ibuffer
- SPC b h
- home
- SPC b k
- 通过正则表达式删除 buffer
- SPC b N
- 一系列添加新 buffer 的命令
- SPC b m
- 打开 message buffer
- SPC b R
- 从备份文件中还原文件
- SPC b s
- scratch buffer
- SPC b w
- toggle 文件为只读
- SPC b Y
- 将整个 buffer 中的内容复制
- SPC f P
- 将系统剪切板中的内容粘贴到 buffer 中
- SPC TAB
- toggle 上一个 buffer
学会 emacs 15 (Day fifteen)
layout related operations
What’s layout in spacemacs? How to use layout in spacemacs
- SPC l L
- load layout file(zilong)
- SPC l l
- to switch between layouts
- SPC l s
- to save layout to file
- SPC l TAB
- switch between the last layout and the current layout
- SPC l o
- custom layout
- SPC l R
- rename layout
- SPC l ?
- to open the help window, learn more operation about layout
Window related operations
- SPC w -
- split window below
- SPC w /
- split window right
- SPC w .
- window micro state
- SPC w 2/3
- use prediefined window layout
- SPC w =
- balance window
- SPC w b
- switch to minibuffer
- SPC w d
- delete the current window
- SPC w h/j/k/l
- move to window
- SPC w m
- maximize window
- SPC w H/J/K/L
- move window to position with evil direction key
- SPC w u/U
- window undo/redo
- SPC w o
- switch to other frame
- SPC w F
- make a new frame
- SPC w 1/2/3/4
- goto window with window number
- SPC w w
- goto other window one by one
- SPC w W
- ace window
- SPC t g
- toggle golden ratio
- SPC t -
- center point
project related operations
- SPC p f
- visit files in project
- SPC p b
- visit buffer sin project
- SPC p p
- switch to project
- SPC p l
switch to project and create a new layout
find-file-in-project is a really handy package
学会 emacs 16 (Day sixteen)
Topic: Ctags and company mode for auto completion
Why use Ctags for auto completion?
Some dynamic languages don’t support syntax-aware auto completion.
For example:
Javascript(though tern-mode could do some sort of auto completion, but
the configuration is complex and it’s not always reliable) && Lua
I also use Ctags for C/C++, I usually use Emacs for writing and navigatng C/C++ code, but
use IDE to debug and profiling.
- Ctags is very fast and reliable.
How to configure ctags and auto completion?
ctags -eR .
company-etags (company-etags can’t used for every major mode)
How to use Ctags effectively?
- project wide configurations for auto generating the Tags file.
- Configure the ctags rules for generate more tags
- use etags-select to quickly navigate a large code base
Final thoughts
When syntax-aware auto completion is not available, consider to use Ctags instead.
学会 emacs 17 (Day seventeen)
Topic: How to use Lispy to write lisp code (emacs-lisp/clojure/clojurescript/scheme/common lisp etc)
Introduction to Lispy
- vim like Paredit
- It even has some IDE features
- how to install
Basic usage of Lispy
- barf and slurp
- raise sexp
- kill/copy/yank
- ace
- swap/w/s
- navigation hjkl/[]
- split
- splice
- wrap
学会 emacs 18 (Day eighteen)
Topic: How to survive in Spacemacs
I want a feature from other editors, How could I implement it in Emacs?
Emacs don’t behavior like the other editors I used before
https://emacs-china.org/t/emacs/905
Some defaults are worth learning, but some are not
Ask in emacs-china.org
Stick to the defaults will help in the long run
I think Mac is the best platform. You could easily adapt yourself to Emacs
(CMD A/C/X)
I have a full time job, I can’t bear the efficiency lose when editing with Emacs/Spacemacs
I want to setup a IDE to do the job for me.
Suggestions:
- C/C++/Java/C# IDE is not worth the time
- Javascript/HTML/CSS don’t need a IDE
Python/Ruby/Go/PHP/Clojure/Erlang could have some IDE feature in Emacs
In the first beginning, try to use the right tool for the right job.
Now: I’m using XCode for C++/OC programming, Android Studio for Java programming.
(No plugin, no keybindings change)
I also use iTerm2/tmux for the shell stuff, the shell in Emacs is slow…
Don’t try to make the perfect GTD tool with Org-mode
It’s very hard for beginners, I also spent too much time to configure the workflow I’m using now.
Learn Org-mode feature step by step, don’t try to become the master in the first day.
Some tips for beginners to avoid common issues
my emacs is frozen, how?
Because Emacs is a single thread app, sometimes you just trigger some time consuming task.
pkill -SIGUSR2 -i emacs toggle-debug-on-quit
My Emacs is very slow
Use the following two commands to profile the CPU
profiler-start profiler-report
- My Emacs start-up time is long…
/Applications/Emacs.app/Contents/MacOS/Emacs --timed-requires --profile
- My Emacs start-up time is long…
I have lots unknown of Emacs..
- Take it easy and don’t panic, Emacs is a lifelong text editor
- Learning Emacs one piece a time everyday.
- Visit reddit/emacs-china.org regularly for keeping update with the community
- Keep using Emacs daily and reshaping your secret weapon gradually.
学会 emacs 19 (Day nineteen)
Topic: Elisp Hacking Tips
Generic tips
- hooks
- write elisp functions
Advice
;;mimic "nzz" behaviou in vim (defadvice evil-search-next (after advice-for-evil-search-next activate) (evil-scroll-line-to-center (line-number-at-pos))) (defadvice evil-search-previous (after advice-for-evil-search-previous activate) (evil-scroll-line-to-center (line-number-at-pos)))
Debug elisp functions
http://www.jianshu.com/p/f509c9a9cac0?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io
(defun aborn/debug-demo () "debug demo function" (interactive) (let ((a "a") (b "value b") (c 1)) (message "middle") (setq c (+ 1 c)) (xyz "a") (message "ggg") ))
Write your own minor mode
http://nullprogram.com/blog/2013/02/06/
(define-minor-mode shadowsocks-proxy-mode :global t :init-value nil :lighter " SS" (if shadowsocks-proxy-mode (setq url-gateway-method 'socks) (setq url-gateway-method 'native))) (define-global-minor-mode global-shadowsocks-proxy-mode shadowsocks-proxy-mode shadowsocks-proxy-mode :group 'shadowsocks-proxy)
https://emacs-china.org/t/ranger-golden-ratio/964
https://emacs-china.org/t/topic/945/2
https://emacs-china.org/t/spaceline/389
https://emacs-china.org/t/topic/889/3
http://nullprogram.com/blog/2013/02/06/
http://stackoverflow.com/questions/21502367/elisp-defadvice-around-clarification
http://ergoemacs.org/emacs/emacs_avoid_lambda_in_hook.html
http://emacs-fu.blogspot.com/2008/12/hooks.html
学会 emacs 20 (Day twenty)
Topic: Revisit my Spacemacs config
The new layer design
- One aggregate layer with five other layers
- The generic keybindings are all in one place
- keep `user-config` minimal
- update constantly with the upstream
Revisit my configs layer by layer
学会 emacs 21 (Day twenty one)
Topic: How to master Emacs in one year?
Learn essential elisp
Introduction to elisp
Emacs manual
Evolve with the community
reddit/r/emacs
emacs-china.org
twitter/emacs
gihtub/spacemacs/prelude/purcell/abo-abo
RSS
Read the source code of daily used packages
- try to debug some elisp function
- get idea of how to do things in emacs
- Learn the configuration possibilities of each package
Keep using and shaping your be loved tools
Happy hacking!