Skip to content

Instantly share code, notes, and snippets.

@iamwrm
Last active February 6, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamwrm/644ebd260a2449515a42871ac3021bd2 to your computer and use it in GitHub Desktop.
Save iamwrm/644ebd260a2449515a42871ac3021bd2 to your computer and use it in GitHub Desktop.
emacs hints

Keybidings

File related operations

SPC f f to find a file start from the current directory

SPC f L find the file across the whole Mac system

SPC f l find file literally(I also enhance this func with ffap)

SPC f h find file in hex mode(I also enhance this func with ffap)

SPC f o open with external program

SPC f E sudo edit

SPC f D delete current file and buffer

SPC f j open the current file's dired mode

SPC f r find the recent file with ivy

SPC f R rename the current file
SPC f v add local variables

SPC f y yank current buffer's full path

SPC f a d find the current visited directory with fasd.

SPC f C d/u convert file encoding between unix and dos

SPC f e d find the .spacemacs/.spacemacs.d/init.el file

SPC f e i find the .emacs/.emacs.d/init.el init file

SPC f e l helm locate library file

SPC f c copy file

SPC f b show bookmarks

SPC f s/S save buffers
buffer related operations
SPC b . buffer micro state (hydra)
SPC b b switch buffers, i rebind it to ivy-switch-buffer, because I could see recent use file in buffer
SPC b d kill a buffer
SPC b f find buffer file in finder
SPC b B/i I bind it to ibuffer
SPC b h go to home
SPC b k kill matching buffers
SPC b N new empty buffer
SPC b m kill others
SPC b R safe revert buffer
SPC b s switch to scratch buffer
SPC b w toggle buffer read-only
SPC b Y copy the whole buffer to clipboard, the content could be used in other programs
SPC b P paste to the whole buffer
SPC <tab> switch between the current buffer and the last opened buffer

Org mode

org export

#+TITLE:       the title to be shown (default is the buffer name)
#+AUTHOR:      the author (default taken from user-full-name)
#+DATE:        a date, fixed, of a format string for format-time-string
#+EMAIL:       his/her email address (default from user-mail-address)
#+DESCRIPTION: the page description, e.g. for the XHTML meta tag
#+KEYWORDS:    the page keywords, e.g. for the XHTML meta tag
#+LANGUAGE:    language for HTML, e.g. ‘en’ (org-export-default-language)
#+TEXT:        Some descriptive text to be inserted at the beginning.
#+TEXT:        Several lines may be given.
#+OPTIONS:     H:2 num:t toc:t \n:nil @:t ::t |:t ^:t f:t TeX:t ...
#+LINK_UP:     the ``up'' link of an exported page
#+LINK_HOME:   the ``home'' link of an exported page
#+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage{xyz}

头参数

运行和导出代码时的很多选项都通过头参数来设置。选项可以指定为全局的,文件级别的,大纲子树级别的,或者只是用于一个代码块。下面解释部分头参数。

:var :var头参数用来将参数传递给代码块。能用来传递给参数的值可以是直接量,org模式表格中的值,文字实例块(literal example blocks)中的值,或者一个已命名代码块的结果。

:results :result头参数控制代码块结果的收集、类型和处理。output和value(默认)的值指定怎样在运行代码块时收集结果。vector,scalar,file, raw, html, latex 和 code的值指定代码块结果的类型并以此确定将结果并入Org缓冲区的方式。silent, replace, prepend和 append指定处理代码块结果的方式,明确是否以及如何将结果插入Org缓冲区中。

:session :session头参数将会使代码块在Emacs的一个持续交互的底层进程(persistent interactive inferior process)中执行。这考虑到了代码运行的持续状态和运行结果的人工检查。

:exports 代码和块结果的任何组合在导出时都可以保持,这可以通过设置:results头参数为code results none或者both来指定。

:tangle 头参数:tangle yes将使代码块的内容到保存到一个以Org模式缓冲区命名的文件中。也可以通过:tangle filename指明文件名。

:cache 头参数:cache yes将使繁杂的代码块和结果关联,确保输入改变时代码块重运行。

:noweb 头参数:noweb将扩展运行和混合时的”noweb“样式的引用。

:file 将代码块结果输出到文件时(比如,图形,表格,图表)可以用头参数:file filename,结果会被保存至指定的文件中,在Org缓冲区中插入一个到该文件的链接。

Links

basics

[[link][description]] 或者 [[link]]

advances

4.3 外部链接

Org 支持的链接格式包括文件、网页、新闻组、BBDB 数据库项、IRC 会话和记录。外部链接是 URL 格式的定位器。以识别符开头,后面跟着一个冒号,冒号后面不能有空格。下面是一些例子:

http://www.astro.uva.nl/~dominik            on the web
file:/home/dominik/images/jupiter.jpg       file, absolute path
/home/dominik/images/jupiter.jpg            same as above
file:papers/last.pdf                        file, relative path
file:projects.org                           another Org file
docview:papers/last.pdf::NNN                open file in doc-view mode at page NNN
id:B7423F4D-2E8A-471B-8810-C40F074717E9     Link to heading by ID
news:comp.emacs                             Usenet link
mailto:adent@galaxy.net                     Mail link
vm:folder                                   VM folder link
vm:folder#id                                VM message link
wl:folder#id                                WANDERLUST message link
mhe:folder#id                               MH-E message link
rmail:folder#id                             RMAIL message link
gnus:group#id                               Gnus article link
bbdb:R.*Stallman                            BBDB link (with regexp)
irc:/irc.com/#emacs/bob                     IRC link
info:org:External%20links                   Info node link (with encoded space)

Org Mobile

下面的代码设置空闲600秒后自动同步:

(defvar org-mobile-sync-timer nil)
(defvar org-mobile-sync-idle-secs (* 60 10))
(defun org-mobile-sync ()
  (interactive)
  (org-mobile-pull)
  (org-mobile-push))
(defun org-mobile-sync-enable ()
  "enable mobile org idle sync"
  (interactive)
  (setq org-mobile-sync-timer
        (run-with-idle-timer org-mobile-sync-idle-secs t
                             'org-mobile-sync)));
(defun org-mobile-sync-disable ()
  "disable mobile org idle sync"
  (interactive)
  (cancel-timer org-mobile-sync-timer))
(org-mobile-sync-enable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment