Skip to content

Latest commit

 

History

History
1613 lines (1208 loc) · 49.3 KB

emacs.org

File metadata and controls

1613 lines (1208 loc) · 49.3 KB

Cheatsheet

Key StrokeEffect
------------------------------------------

C-h v < variable-name > | display the contents of a variable C-x C-e | evaluate an expression: position the cursor after a list and type

Search recursive

C-A-fpick root directory
*filename wildcard
tselect all files
Afind pattern
A-,goto next found

Search and Replace (recursive)

To search and replace recursively from a root directory on down.

C-A-fpick root directory
*filename wildcard
tselect all files
Qbegin Search/Replace
SPACEreplace and move to next

W3M

bookmarks

aadd current page to bookmarks
A-aadd url under point
vbrowse bookmarks
C-kkill bookmark under point
Evisit bookmarks file
C-_undo the last changes

emacs-w3m

gfollow url under point
Gfollow url in new tab

movement

SPCScroll Downwards
DELScroll upwards
>/<right/left
./,slow left/right
TAB/S-TABforward/back URL
]/[forward form
{/}forward/back img

page movement

Bback
Nforward
Hhome
^parent directory
SPCbottom of page, then next page

Misc

Ttoggle images

Going back in time

<- / ->prev/next viewed page in history
sshow browsing history
C-c C-@record pos in history
C-c C-vmove to rec. position

tabs

C-c C-tcreate copy of current buffer
C-c C-wclose current w3m buffer
C-c A-wclose other buffers
C-c C-pprev buff
C-c C-nnext buff

daily

tabgo to inputs/links
S-bback
S-uurl prompt
S-hhelp
S-topen tab
Hhelp
ucopy url under point

install

sudo pacman -S w3m emacs-w3m-cvs 

In your .emacs file:

;; W3M.  I'm using for hyperspec lookup for lisp documentation
(require 'w3m-load)
(setq browse-url-browser-function 'w3m-browse-url)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; optional keyboard short-cut
(global-set-key "\C-xm" 'browse-url-at-point)
(setq w3m-use-cookies t)

rest

https://www.youtube.com/results?search_query=painting

SPC,C-vForward page
b,ESC vBackward page
l,C-fCursor right
h,C-bCursor left
j,C-nCursor down
k,C-pCursor up
JRoll up one line
KRoll down one line
^,C-aGo to the beginning of line
$,C-eGo to the end of line
wGo to next word
WGo to previous word
>Shift screen right
<Shift screen left
.Shift screen one column right
,Shift screen one column left
g,M-<Go to the first line
G,M->Go to the last line
ESC gGo to specified line
ZMove to the center line
zMove to the center column
TABMove to next hyperlink
C-u,ESCMove to previous hyperlink
[Move to the first hyperlink
]Move to the last hyperlink

Hyperlink operation

RETFollow hyperlink
a, ESCSave link to file
RET
uPeek link URL
iPeek image URL
IView inline image
ESC ISave inline image to file
:Mark URL-like strings as anchors
ESC :Mark Message-ID-like strings as news anchors
cPeek current URL
=Display information about current document
C-gShow current line number
C-hView history of URL
FRender frame
MBrowse current document using external browser (use 2M and 3M to invoke second and third browser)
ESC MBrowse link using external browser (use 2ESC M and 3ESC M to invoke second and third browser)

File/Stream operation

UOpen URL
VView new file
@Execute shell command and load
#Execute shell command and browse

Buffer operation

B Back to the previous buffer v View HTML source s Select buffer E Edit buffer source C-l Redraw screen R Reload buffer S Save buffer ESC s Save source ESC e Edit buffer image

Buffer selection mode

k, C-p Select previous buffer j, C-n Select next buffer D Delect current buffer RET Go to the selected buffer

Bookmark operation

ESC b Load bookmark ESC a Add current to bookmark

Search

/,C-s Search forward /,C-s Search forward ?,C-r Search backward n Search next N Search previous C-w Toggle wrap search mode

Mark operation

C-SPC Set/unset mark ESC p Go to previous mark ESC n Go to next mark ” Mark by regular expression

Miscellany

! Execute shell command H Help (load this file) o Set option C-k Show cookie jar C-c Stop C-z Suspend q Quit (with confirmation, if you like) Q Quit without confirmation

Line-edit mode

C-f Move cursor forward C-b Move cursor backward C-h Delete previous character C-h Delete previous character C-d Delete current character C-k Kill everything after cursor C-u Kill everything before cursor C-a Move to the top of line C-e Move to the bottom of line C-p Fetch the previous string from the history list C-n Fetch the next string from the history list TAB,SPC Complete filename RETURN Accept


Lynx-like key binding

If you have chosen `Lynx-like key binding’ at the compile time, you can use the following key binding.

Page/Cursor motion

SPC,C-v,+ Forward page b,ESC v,- Previous page l Cursor right h Cursor left j Cursor down k Cursor up J Roll up one line K Roll down one line ^ Go to the beginning of line $ Go to the end of line

$ Go to the end of line > Shift screen right < Shift screen left C-a Go to the first line C-e Go to the last line G Go to the specified line Z Move to the center line z Move to the center column TAB,C-n,Down Move to next hyperlink arrow ESC TAB,C-p,Up Move to previous link arrow C-g Show current page position

Hyperlink operation

RET, C-f, Follow hyperlink Right arrow d, ESC Save link to file RET u Peek link URL i Peek image URL I View inline image ESC I Save inline image to file

       Mark URL-like strings as anchors

ESC : Mark Message-ID-like strings as news anchors

input text into forms

Press ENTER

Mark Ring

C-SPC C-SPCpush mark
C-u C-SPCreturn to last mark
C-x C-dkill current mark (custom function)

Reference

[GNU Emacs Manuals Online](http://www.gnu.org/software/emacs/manual/)

Super Useful

Key Stroke | Effect ---------- | -------------------------------- A-\ | Delete horizontal space C-h a | Will find all functions that have string in it

Files

Key StrokeEffect
------------------------------------------

C-x C-f | Open a new file C-x s | Save buffer(s) C-x C-w | Save As C-x C-c | Close emacs C-x C-r | Open file read only C-x C-c | Exit Emacs

Navigation, Search & Replace

Key StrokeEffect
-------------------------------------------------

A-> | Go to the beginning of the file A-< | Go to the end of the file A-g A-g | Goto line * A-(L/R) arrows | Move word forward/backwards A-f, A-b | Move word forward/backwards C-s | Incremental Search Forward C-A-s | Regular Expression incremental search C-r | Incremental Search Backwards A-% | Replace A-x | query-replace-regexp Regex Replace C-q C-j | Keystroke for Carriage Return C-q | Keystroke for space character C-x (, C-x ), C-x e | Start, stop, playback macro C-u 25 C-x e | Replay macro 25 times C-u C-space | Return to previous position

Special Characters

NameASCII Codestring notationCaret NotationInput method
-------------------------------------------------------------------
horizontal tab9\tICtrl+q Ctrl+i or Ctrl+q Tab
line feed10\nJCtrl+q Ctrl+j
carriage return13\rMCtrl+q Ctrl+m or Ctrl+q Enter

Buffers, Regions, & Windows

Key StrokeEffect
---------------------------------------------------

C-x 1 | Unsplit window (keep this) C-x 0 | Unsplit window (keep others) C-x 2 | Split window horizontal C-x 3 | Split window vertical C-x o | Move to the next window C-x 1 | Collapse other window C-x 0 | Collapse this window C-x b | Load previous buffer C-x C-b | List all buffers. e to edit buffer C-x k | Close buffer C-x C-v Ret | Reload buffer from file system C-x b **scratch** RET | re-open scratch buffer d | In buffer list, mark buffer for deletion, happens when hit x A-^ | Join this line to previous and fix up whitespace at join. If there is a fill prefix, delete it from the beginning of this line.

Edit, Selection, Cut & Paste

Key StrokeEffect
------------------------------------------

C-x u | Undo A-q | Reformat Paragraph, take first line to 0 indent, then A-q, rest of paragraph is now 0 indent C-A-\ | Auto indent selected region A-^ | Remove indentation, brings current line up one C-c C-c, M-x comment-region | Comment out a marked region C-u C-c C-c | Un-comment out the marked region C-x h | Select wHole buffer C-x 0 | Delete the current window A-w | Copy C-w | Cut C-y, Esc-y | Yank (paste), successive Esc-y get clipboard history A-x cua-mode | Column Edit, C-Ret. begin selection

Calculator

to start the Calculator:

A-x calc

to quit type: `q`

Misc

Automatic word wrap

Toggle auto word wrap with: `M-x auto-fill-mode`

Truncate long lines

When u dont want emacs to wrap long lines do one of the following:

M-x <RET> toggle-truncate-lines <RET> M-x <RET> set-variable <RET> truncate-lines <RET> t

or put the following in your .emacs to have on by default

(setq-default truncate-lines t)

Sort selection

M-x sort-lines

XML Formatting

In sgml-mode, a built-in pretty printing function called (sgml-pretty-print …)

Exuberant ctags

go to the root of your source and enter:

“`bash ctags -Re “`

coffee

create .ctags in PROJECT root dir

--langdef=CoffeeScript
--langmap=CoffeeScript:.coffee
--regex-CoffeeScript=/(^|=[ \t])*class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\2/c,class/
--regex-CoffeeScript=/^[ \t]*@?([A-Za-z.]+):.*[-=]>.*$/\1/f,function/
--regex-CoffeeScript=/^[ \t]*([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\1/f,function/
--regex-CoffeeScript=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/

run from project root:

ctags -e -R .

tell emacs to use the resulting TAGS file:

M-x visit-tags-table

Diff

CommandMeaning
----------------------------------------
C-c C-nonly show current diff
C-x n wTo widen again
A-nMove to the next hunk-start (diff-hunk-next).
A-pMove to the previous hunk-start (diff-hunk-prev).
C-c C-aApply current diff
C-c C-bincrease granularity diff (show just characters)

Additional commands:

“` diff-buffer-with-file “`

Flyspell

Command | Meaning -------- | -------------------------------- F8 | ispell for word the cursor is on C-S-F8 | disable flyspell C-A-F8 | run flyspell C-F8 | ispell for flyspell highlighted word PRIOR to cursor position A-F8 | ispell for flyspell highlighted work AFTER the cursor position

Latex

Key StrokeEffect
------------------------------------------

C-c C-c | to compile to **.dvi/**.pdf, again to view C-c C-t C-p | to toggle into PDF mode. C-c = | show TOC

Overview

Put your code into `*.el` files. Then put `*.el` into a directory on your load-path, `/usr/local/share/emacs/site-lisp` or `/usr/share/emacs/site-lisp/`, are reasonable locations. Then you can put a line like the following into your .emacs file:

(require ‘textile-mode)

Put following into .emacs file, so you can reload your .emacs file without closing and reopenning emacs.

;; Reload .emacs file by typing: A-x reload. (defun reload () “Reloads .emacs interactively.” (interactive) (load “~/.emacs”))

Reference

[GNU Emacs Manuals Online](http://www.gnu.org/software/emacs/manual/)

C-SP set-mark-command C-q quoted-insert C-a beginning-of-line C-r isearch-backward C-b backward-char C-s isearch-forward C-c exit-recursive-edit C-t transpose-chars C-d delete-char C-u universal-argument C-e end-of-line C-v scroll-up C-f forward-char C-w kill-region C-h help-command C-x Control-X-prefix TAB indent-for-tab-command C-y yank LFD newline-and-indent C-z suspend-emacs C-k kill-line ESC ESC-prefix C-l recenter C-] abort-recursive-edit RET newline C-_ undo C-n next-line SPC .. ~ self-insert-command C-o open-line DEL delete-backward-char C-p previous-line

C-h v describe-variable C-h d describe-function C-h w where-is C-h k describe-key C-h t help-with-tutorial C-h c describe-key-briefly C-h s describe-syntax C-h b describe-bindings C-h n view-emacs-news C-h a command-apropos C-h C-n view-emacs-news C-h C-d describe-distribution C-h m describe-mode C-h C-c describe-copying C-h l view-lossage C-h ? help-for-help C-h i info C-h C-h help-for-help C-h f describe-function

C-x C-a add-mode-abbrev C-x 5 split-window-horizontally C-x C-b list-buffers C-x ; set-comment-column C-x C-c save-buffers-kill-emacs C-x < scroll-left C-x C-d list-directory C-x = what-cursor-position C-x C-e eval-last-sexp C-x > scroll-right C-x C-f find-file C-x [ backward-page C-x C-h inverse-add-mode-abbrev C-x ] forward-page C-x TAB indent-rigidly C-x ^ enlarge-window C-x C-l downcase-region C-x ` next-error C-x C-n set-goal-column C-x a append-to-buffer C-x C-o delete-blank-lines C-x b switch-to-buffer C-x C-p mark-page C-x d dired C-x C-q toggle-read-only C-x e call-last-kbd-macro C-x C-r find-file-read-only C-x f set-fill-column C-x C-s save-buffer C-x g insert-register C-x C-t transpose-lines C-x h mark-whole-buffer C-x C-u upcase-region C-x i insert-file C-x C-v find-alternate-file C-x j register-to-dot C-x C-w write-file C-x k kill-buffer C-x C-x exchange-dot-and-mark C-x l count-lines-page C-x C-z suspend-emacs C-x m mail C-x ESC repeat-complex-command C-x n narrow-to-region C-x $ set-selective-display C-x o other-window C-x ( start-kbd-macro C-x p narrow-to-page C-x ) end-kbd-macro C-x q kbd-macro-query C-x + add-global-abbrev C-x r copy-rectangle-to-register C-x - inverse-add-global-abbrev C-x s save-some-buffers C-x . set-fill-prefix C-x u advertised-undo C-x / dot-to-register C-x w widen C-x 0 delete-window C-x x copy-to-register C-x 1 delete-other-windows C-x { shrink-window-horizontally C-x 2 split-window-vertically C-x } enlarge-window-horizontally C-x 4 ctl-x-4-prefix C-x DEL backward-kill-sentence

Alt C-SP mark-sexp Alt = count-lines-region Alt C-a beginning-of-defun Alt > end-of-buffer Alt C-b backward-sexp Alt @ mark-word Alt C-c exit-recursive-edit Alt O ?? Alt C-d down-list Alt [ backward-paragraph Alt C-e end-of-defun Alt \ delete-horizontal-space Alt C-f forward-sexp Alt ] forward-paragraph Alt C-h mark-defun Alt ^ delete-indentation Alt LFD indent-new-comment-line Alt a backward-sentence Alt C-k kill-sexp Alt b backward-word Alt C-n forward-list Alt c capitalize-word Alt C-o split-line Alt d kill-word Alt C-p backward-list Alt e forward-sentence Alt C-s isearch-forward-regexp Alt f forward-word Alt C-t transpose-sexps Alt g fill-region Alt C-u backward-up-list Alt h mark-paragraph Alt C-v scroll-other-window Alt i tab-to-tab-stop Alt C-w append-next-kill Alt j indent-new-comment-line Alt Alt ?? Alt k kill-sentence Alt C-\ indent-region Alt l downcase-word Alt SPC just-one-space Alt m back-to-indentation Alt ! shell-command Alt q fill-paragraph Alt $ spell-word Alt r move-to-window-line Alt % query-replace Alt t transpose-words Alt ’ abbrev-prefix-mark Alt u upcase-word Alt ( insert-parentheses Alt v scroll-down Alt ) move-past-close-and-reindent Alt w copy-region-as-kill Alt , tags-loop-continue Alt x execute-extended-command Alt - negative-argument Alt y yank-pop Alt . find-tag Alt z zap-to-char Alt 0 .. Alt 9 digit-argument Alt | shell-command-on-region Alt ; indent-for-comment Alt ~ not-modified Alt < beginning-of-buffer Alt DEL backward-kill-word

C-x 4 C-f find-file-other-window C-x 4 d dired-other-window C-x 4 . find-tag-other-window C-x 4 f find-file-other-window C-x 4 b pop-to-buffer C-x 4 m mail-other-window

Dos to unix

M-x set-buffer-file-coding-system RET undecided-unix

save the file (`C-x C-s`), or

C-x RET f undecided-unix C-x C-f

Unix to dos

M-x set-buffer-file-coding-system RET undecided-dos

save the file (`C-x C-s`), or

C-x RET f undecided-dos C-x C-f

Setup ELPA

Emacs Lisp Package Archive

Eval (C-x C-e) the following in an emacs buffer:

“` (let ((buffer (url-retrieve-synchronously “http://tromey.com/elpa/package-install.el”))) (save-excursion (set-buffer buffer) (goto-char (point-min)) (re-search-forward “^$” nil ‘move) (eval-region (point) (point-max)) (kill-buffer (current-buffer)))) “`

Then do:

M-x package-list-packages

Emacs mail reader (incomplete)

notmuch is, like, [0] an emacs mail-reader frontend over a xapian database; see http://keithp.com/blogs/notmuch/ or http://notmuchmail.org │ Athas 11:33:21 fsbot | [1] see *notmuch │ atrus` 11:35:06 * | bremner looks around shiftily │ avar 11:36:35 * | homie needles bremner vodoo wise! │ axrfnu 11:37:31 * | bremner nods knowingly │ az 11:46:56 krishnab | @fenton It took me a few tries, but I got it to work. I have many IMAP gmail email addresses, so it works pretty good with those. I think I tried setting it up for one address first │ b0ef

and got it working. Then I added extra addresses. I think I modeled my final config files based on http://www.gnumonk.com/my-config/my-emacs . Just make the appropriate changes based │ barik
on your own config.

Use Cases

Kill whole sentence in text mode.

So there are two functions `kill-sentence`, and `backwards-kill-sentence` but I want a single function that executes both action, and I want to map that to a key in the text-mode.

First lets look at how to bind a key in a certain major-mode.

“`lisp (add-hook ‘html-mode-hook (lambda () (local-set-key (kbd “C-c w”) ‘bold-word) (local-set-key (kbd “C-c b”) ‘blue-word) (local-set-key (kbd “C-c p”) ‘insert-p) (local-set-key (kbd “M-4”) ‘tag-image) (local-set-key (kbd “M-5”) ‘wrap-url) ) ) “`

I want to bind this function to the key combo: `M-k` or `Alt-k`. So maybe i should make a function from these two functions now.

Here is an example:

“`lisp (defun multiply-by-seven (number) “Multiply NUMBER by seven.” (* 7 number)) “`

So we might do something like:

“`lisp (defun kill-whole-sentence () (backwards-kill-sentence) (kill-sentence)) “`

However, in order for a function to be ‘callable’ it needs to be a ‘command’ or ‘interactive’ function. We remedy this by inserting the `interactive` keyword:

“`lisp (defun kill-whole-sentence () (interactive) (backwards-kill-sentence) (kill-sentence)) “`

Now typing: `M-x kill-whole [TAB]` reveals that this function is defined.

Now lets assign it properly with:

“`lisp (add-hook ‘text-mode-hook (lambda () (local-set-key (kbd “M-k”) ‘kill-whole-sentence))) “`

Workgroups

Frequent Use

--------------+--------------------------w
<prefix> uUpdate base from working
<prefix> C-sSave

Set the prefix key with:

(setq wg-prefix-key (kbd “C-c w”))

You can create a workgroup, rename it, switch to a named workgroup. You can go to the previous or next workgroups, or you can go to the workgroup number (0-9).

KeysDescription
<prefix> cCreate
<prefix> ARename
<prefix> vSwitch ***
<prefix> pPrevious
<prefix> nNext
<prefix> 0-9Goto

Workgroups actually consist of two workgroups. The base workgroup, and the working workgroup. The base config is the one that you have saved. The working one is the current one. So if you move your cursor, adjust buffer windows, etc…, your current config is now different from your base config.

KeysDescription
<prefix> rRevert working from base
<prefix> uUpdate base from working
<prefix> RRevert ALL
<prefix> UUpdate ALL

Save workgroups to a file, or load them with:

KeysDescription
<prefix> C-sSave
<prefix> C-lLoad

Killing a workgroup deletes it from the list of workgroups, and copies its working config to the kill ring. You can yank killed wconfigs into the current frame.

KeysDescription
<prefix> kKill
<prefix> yYank
<prefix> A-wSave current -> kill ring
<prefix> A-WSave base -> kill ring

You can move a workgroup leftward or rightward in the workgroups list.

KeysDescription
<prefix> C-,Offset Left
<prefix> C-.Offset Right

Clone a workgroup

KeysDescription
CClone a workgroup

Coding Workgroups

I want, when i go to kill emacs for it to ask me if i want to save the current buffer layout to the active workgroup.

“`elisp ;; try to write function that will allow the prompting ;; of updating AND saving the current workspace. (defun ft-uw () “function to ask user if they’d like to update their current workgroup” (progn (if (y-or-n-p “Update workgroup?”) (progn (wg-update-workgroup (wg-current-workgroup)) (wg-save wg-file)) 1))) (add-hook ‘kill-emacs-query-functions ‘ft-uw ) “`elisp

I think the function I want is: `wg-update-workgroup`, however it is not interactive. Looks like something like the following might work:

“` (defun foo (str bool) (interactive (list (read-string “Some text: “) (y-or-n-p “Update workgroup with current buffer layout?”))) (some-func str) (if bool (some-other-func str))) “`

workgroups2

Not using workgroups 2 seemed to have too many bugs.

ccreate workgroup
kkill workgroup
vswitch to workgroup
C-ssave session
C-fload session

Syntax Highlighting

I want to highlight code that falls between:

“` and the next “`

So above: ‘and the next’ would be highlighted. Can look at markdown-mode.el, but for now it’s a bit too complex, so leave it for later.

Emacs installed packages

auto-complete 1.4 installed Auto Completion for GNU Emacs bookmark+ 20111214 installed Bookmark Plus color-theme 6.5.5 installed install color themes findr 0.7 installed Breadth-first file-finding facility for (X)Emacs haskell-mode 2.8.0 installed Haskell editing mode highlight-paren… 1.0.1 installed highlight surrounding parentheses hl-sexp 1.0.0 installed highlight the current sexp inf-ruby 2.2.4 installed Run a ruby process in a buffer inflections 1.1 installed convert english words between singular and plural jump 2.2 installed build functions which contextually jump between files org 20130318 installed Outline-based notes management and organizer org-cua-dwim 0.5 installed Org-mode and Cua mode compatibility layer paredit 22 installed minor mode for editing parentheses -*- Mode: Emacs-Lisp -*- popup 0.5 installed Visual Popup User Interface rinari 2.10 installed Rinari Is Not A Rails IDE ruby-compilation 0.9 installed run a ruby process in a compilation buffer ruby-mode 1.1 installed ruby-mode package workgroups 0.2.0 installed workgroups for windows (for Emacs)

wg-list

GIT

ref

http://alexott.net/en/writings/emacs-vcs/EmacsGit.html#sec7

vc-git

KeysDescription
git-statusStart VC-GIT
n, pnext,previous lines
m, u, SPCmark, unmark, toggle mark
a, radd, remove
v, oview, open
iignore file > .gitignore
=see what has changed
ccommit changes
C-c C-cfinish commit message
git-mergeMerge from another branch
!resolve conflicts
git-log
git-history
kgitk

magit

Start Magit:

A-x magit-status

Adding Files

key/commandEffect
s, ustage (add), unstage
S, Ustage, unstage ALL
TABToggle display changes
n/pnext/prev change
cCOMMIT, free form message
CCOMMIT, files changed added
P PPush
F FPull (Fetch)
RETopen file

Ignore / delete files

key/commandEffect
kfile unknown > delete
kfile modified > drop changes
iIGNORE
z, a, kstash, apply, kill

z will stash changes, a will take stashed changes and ‘a’pply them to the current repo. k will ‘k’ill the stashd changes.

A-SShow all
A-HHide All
ddiff working tree to another version
Ddiff two arbitrary versions
SPCScroll DOWN
DELscroll UP
xrollback to changeset
Xrollback to last commit
lhistory current branch
Lhistory range
RETGet Detailed INFO
.mark changeset
=display changes

When moving through history can get detailed info with `RET` key. To do this, he need to move to first changeset and mark it with the . key (magit-mark-item), and than, move to the other changeset, and display the changes by pressing the = key (magit-diff-with-mark).

aapply changeset under point
Aapply and COMMIT
vreVert changes
hlocal history
Hspecify versions in local history

Movement between sections

key/commandEffect
grefresh buffer
1goto untracked
2unstaged
3staged
4unpushed

Tags, branches, and remote repositories

ttag
Tannotated tag
Bcreate and switch to new BRANCH
bswitch to existing BRANCH
Rrebase
MMERGE
mmanual merge
ffetch remote updates
FPULL
PPUSH

VCS

Prefix: C-x v

vnext logical action
iadd (insert)
+pull
=diff
uundo checkout
cdelete latest version
dshow files not up to date
mmerge

ERC

org2blog

Create a new blog entry

login > new entry > compose blog entry > ???

functioneffect
org2blog/wp-loginlogin
org2blog/wp-logoutlogout
org2blog/wp-new-entrynew entry

NOTE: login to word press to be able to see drafts etc…

keyeffect
C-c dpost buffer as draft (doesn’t work?)
C-c ppublish
C-c Dpost as page draft
C-c Ppost as page

Keymaps & Function bindings

Function:

describe-bindings

will list all keys, what they are bound to, and which mode bound it.

Variables:

global-map            

holds in play regardless of mode

minor-mode-map-alist 

the preferred means of specifying the keymaps for minor modes

Functions:

(current-local-map) 
(current-global-map)
(current-minor-mode-maps)

Emacs mode-map search order:

(i) the keymap specified by the keymap property (ii) the keymaps of enabled minor modes (iii) the current buffer’s local keymap (iv) the global keymap, in that order.

These keymaps, if any, are specified by the variables

emulation-mode-map-alists minor-mode-overriding-map-alist minor-mode-map-alist

overriding-terminal-local-map
overriding-local-map
(get-char-property (point) 'keymap)
emulation-mode-map-alists
minor-mode-overriding-map-alist
minor-mode-map-alist
(get-text-property (point) 'local-map)
(current-local-map)
(current-global-map)

C-h b

VERY USEFUL

ref: http://www.masteringemacs.org/articles/2011/02/08/mastering-key-bindings-emacs/

keywords: keybind

Listing all the Mode Maps

If you type this Emacs will give you an apropos buffer with all the known mode maps that follow the major mode naming scheme:

C-u M-x apropos-variable RET -mode-map$ RET

Define for a given mode map

(define-key paredit-mode-map (kbd “C-<left>”) ‘windmove-left)

Global Def

(global-set-key “\C-c\C-s” ‘fold-dwim-show-all)

Using mode hooks

“` (defun mp-add-python-keys () (local-set-key (kbd “C-c q”) ‘shell)) (add-hook ‘python-mode-hook ‘mp-add-python-keys) “`

example 2

I want to bind the key-chord C-A-n to ‘other-window’. First I find what it is bound to with:

C-h k C-A-n

I find that when paredit mode is on it’s bound to the wrong thing. So I check the mode maps setup for the file with:

C-h m

And sure enough paredit is a minor mode.

Now list all mode maps:

C-u M-x apropos-variable RET -mode-map$ RET

Then searching for paredit I find:

paredit-mode-map

Finally use the define-key function whose template is:

(define-key <mode-map> <key> <function>)

We want this called after the mode is enabled so we use the add hook function:

(add-hook <mode> <function>)

Since we want to call two functions, define-key twice, We use a lambda expression to wrap both calls in one function:

(lambda (<args>) <functions>)

So the lambda will look like:

(add-hook ‘paredit-mode-hook (lambda () (define-key paredit-mode-map (kbd “C-M-n”) ‘other-window)))

example (incomplete)

Ctrl-right when i was working on *.el files was not define to be `windmove-right` as I wished but bound to: `paredit-forward-slurp-sexp`, by paredit minor mode.

Install the function

Install the function by putting the cursor at the end of the function and typing C-x C-e. This will install the function for the life of your current emacs session. To install more permanently put it in your ~/.emacs file.

To make the above function interactive do:

(defun multiply-by-seven (number) “Multiply NUMBER by seven.” (interactive “p”) (message “The result is %d” (* 7 number)))

Invoke with `C-u` some number `A-x multiply-by-seven`.

Installing *.el files

One time

Ensure you have the following in your ~/.emacs file:

(add-to-list ‘load-path “~/projects/elisp”)

For each new *.el file

Ensure you have the following in your ~/.emacs file:

(require ‘foo)

where foo means foo.el

And put your foo.el file in: `~/projects/elisp`

Programming

Try the interactive elisp buffer with: `A-x ielm`

functioneffect
ielminteractive elisp buffer REPL
type-oftell you type of variable
carfirst part of cons
cdrsecond part of cons

let expression

(let ((variable value) (variable value) …) body…)

Info Mode

Across Nodes

nnext node
pprev node
^up
mpick menu
ddirectory
<top node of file
>final node of file
]forward node
[backward node
TABnext menu or link
ffollow link
lgo back last node
rfoRward node
Lmenu of visited nodes
TTOC for file

Move within node:

SPCforward page
DELbackwards page
bbeginning of node

Search

function: info-apropos

will search ALL info docs. The rest of the commands below are only for one doc at a time (blech!). :(

A-x info RET C-h i

sregex search
Scase sensitive regex search
C-s, C-A-sIsearch through multiple nodes
isearch index
,next match from ‘i’ command
I

Org Mode

Common

bold italic underline code verbatim strike through

A-Left/Rightpull up / push down level
S-Left/Righttodo/done/nothing
S-Tabexpand whole tree
C-Tabexpand this node
A-Up/Downmove item up/down
S-Up/Downraise/lower priority
=inline fixed width code

surround text with ‘=’ signs.

< s TABCode block
C-c a aagenda view
C-c / tsparse todo list
C-c [add org to agenda
C-c ]remove from agenda
C-c a tglobal todo list
C-c C-sschedule
C-c C-ctag

Agenda View

lshow log

Tables

KeysDescription
C-c RETHorizontal Rule

To recalculate one of the formulas, go onto the line like: #+TBLFM: and press C-c C-c.

$ = column
@ = row 

tips

find the cell coordinates: C-c ? recalculate row: C-c * recalculate table: C-u C-c *

row formula

sum a column of numbers:

The following sums the rows 1->10.

=vsum(@1..@10)
23
24
7

This means in column 2 $2, vector sum vsum whats between the first divider @I and second divider @II.

studentchemistryphysicsAVG
joe728377.5
bill489471
6088.574.25
#+TBLFM: @4$2..$4=vmean(@I..@II)

At row 4, @4, columns 2 through 4, $2..$4, set them to be the vector mean, vmean, of what is above between separator 1, @I, and separator 2, @II.

#+TBLFM: $4=($2+$3)/2

Column 4, $4, is equal to columns 2 plus 3 divided by 2.

re-calculate formulas: C-c *

Export as HTML

KeysDescription
C-c C-e hExport to HTML

Quickies

KeysEffect
C-c ^sort all subentries of the current entry
C-c .add a timestamp to the current entry

Use Shift and arrows to skip days or weeks. Use the mouse on the calendar or press Enter on a specific day to choose it.

Links

Visit another file (target) and type: `C-c l`. Then go back to the source file and insert the link to the target with: `C-c C-l`.

KeysEffect
C-c lClipboard link to current file
C-c C-lPaste link to file
C-c C-oOpen URL / follow link
[[link][description]] or alternatively [[link]]

Escape double square brackets [[ code

ref: http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-Source-Code

shell code often uses double square brackets ]] to display these in org mode without creating a link use:

if [[ -z file ]]

Move entries

Move entry up or down:

M-(up or down arrow)

Promote/Demote:

M-(left/right arrow)

Global Agenda

First you must set the variable org-agenda-files so that org-mode will know which files to search for TODOs and scheduled items.

“`elisp (setq org-agenda-files (list “~/org/work.org” “~/org/school.org” “~/org/home.org”)) “`

C-c a t

Schedule a Task

Go to line after a todo and do:

C-c C-s

Can use syntax like: `+2w` for two weeks from now.

Get agenda

C-c a a

clocking time

Prefix key: C-c C-x

KeyAction
C-iClock in
C-xClock in to the last clocked task
C-oClock out
C-jJump to whatever you are currently clocked in to
C-qCancel the current clock (removes all of it’s current time)
C-dDisplay clock times for headlines in current file
C-rGenerate a report for clock activity
C-zResolve any half-open clocks

evil-org-mode

key function explanation TAB org-cycle change folding level of current heading 0 evil-org-beginning-of-line like 0 but can be special* $ evil-org-end-of-line like $ but can be special* I evil-org-insert-line like I but can be special* A evil-org-append-line like A but can be special* o evil-org-open-below like o but continue tables and items* O evil-org-open-above like O but continue tables and items* d evil-org-delete like d but keep tags aligned and fix lists x evil-org-delete-char like x but keep tables and tags aligned X evil-org-delete-previous-char like X but keep tables and tags aligned ( org-forward-sentence next cell in table ) org-backward-sentence previous cell in table { org-backward-paragraph beginning of table } org-forward-paragraph end of table

project search and replace

<SPC>-/start helm silver searcher
enter your search textsearch results incrementally appear
C-c C-eedit search results
:%s/find/replace/g <ENTER>run vim global search/replace in that file
C-c C-csave changes

clomacs

running clojure from elisp and vice versa

A normal use case of this would be to have a single restart key in emacs that first shutsdown your server. Then calls cider-restart. Then a call is made to your clojure server code to startup the server again.

To call clojure from elisp

In you elisp code do:

(clomacs-defun this-calls-cloj-fn
               my-ns.core/the-clj-fn)

This creates an elisp function called `this-calls-cloj-fn`, which we can call from any elisp code now. The clojure code in the file

<project>/src/my_ns/core.clj

should be loaded via cider and have a function called `the-clj-fn`.

get output of clojure function into emacs buffer

we just change

Two Window open from ediff session

Mod-Shift-c while having ediff control window open to kill via awesome.

Open file as root, (tramp)

using ivy

/sudo::/ 

(the rest of the path will autocomplete). You can also tramp to another system with:

/sudo:root@archlinux:/

or

/ssh:root@archlinux:/

Ediff

tiny - number ranges

simple range

m[range start][separator(s)][range end]
m1\n5  

m1\n5 1 2 3 4 5

The initial m is mandatory.

Next is the initial value of the range, in this case one. But this is optional and will default to zero.

Then comes any separator characters to insert between each number. I use \n to add a newline after each number.

And finally is the final value for the range, five in this example.

formatting

m1\n\n4|%d.

1.

2.

3.

This demonstrates that you can have multiple separator characters; here I use two \n’s for the extra space. But there is that |%d. at the end. Tiny lets you use Emacs Lisp format strings, which you write at the end of your expression and delimit with a vertical bar. The formatting string %d. prints each number as a digit (%d) with a period after it.

simple lisp

m1, 10*xx

start with 1 separate with comma space ‘, ’ end with 10

Immediately following the end-range value we can write abbreviated Lisp. The current value is bound to x, so for example m1, 10*xx will expand to 1, 4, 9, 16, 25, 36, 49, 64, 81, 100. That is, the markup loops from one to ten, and at every step executes the Lisp expression (* x x) where x is each number in the range.

combining

Format strings can follow any Lisp expressions, and those strings can themselves contain Lisp expressions wrapped in %(…). Here we see Tiny at its most complete syntax. One way I’ve found this functionality useful is for easily generating numeric data in code, using a combination of Lisp to calculate values and format strings to create the desired output. For example, consider this:

m1,\n3|    [%d] = %(exp x)

expands to:

[1] = 2.718281828459045,
[2] = 7.38905609893065,
[3] = 20.085536923187668,

EXWM

See file

~/dotfiles/emacs/.emacs.d/exwm/exwm.org

speedup load

Use use-package. Defer installation with one of the following methods.

package loaded

:hook - after one of the hooks is invoked :bind - when bound key pressed :command - when command used :mode - a mode is invoked :after - another package is loaded :defer - catch-all load after init process

(use-package highlight-parentheses :after evil)
(use-package highlight-parentheses :after (evil general))