minor fixes
[dot-emacs] / my-init.org
1 #+title: My Personal Init Customization
2 #+OPTIONS: toc:nil num:nil ^:nil
3
4
5
6 * key binds. keep at end of file
7 this should come at the end because it depends on key maps being
8 created in earlier sections.
9
10 ** emacs keys notes
11 commands not needed in ido mode and their replacement in ido mode
12 spell check fix -> use current pattern and start new one
13 narrow -> create subdirectory
14 org-cycle -> M-s search recently used directory
15 vert split Window -> create file instead of select match
16 delete-other-windows -> open dired buffer
17 delete current window -> delete buffer/file
18 find file -> search within all subdirectories
19
20 forward/back error
21
22 buffer select -> toggle find file / buffer
23 up/down -> next/previous history
24 forward/back -> ido-forward/back
25
26
27 right keyboard attributes: movement, involve typing words
28 left keyboard attributes: non-typing universal non-movement
29
30
31
32
33 todo
34 fix global unpop mark ring
35 setup helm
36 learn cedet and projectile and helm
37 setup key for pop-global-mark
38 try out C-M-\ indent region
39 set quoted insert to some obscure keybind
40 make currently overrided M-u uppercase word into something obscure
41 remember mode
42 bind shell-command to something better
43 investigate tags
44 investigate keys in isearch mode and find file mode
45 try out occur. M-s o
46 investigate programming modes. M-g n/b next/previous error. gdb?
47 investigate org mode keys
48 learn version control
49 learn mail
50 check out imenu
51 bind capitalize-word to something obscure
52 sentance/paragraph movement/marking should be swapped with sexp/paren movement based on mode
53 bind fill-paragraph to something obscure
54 setup linewise paste
55 install magit (git control)
56 magpie expansion provides a completion key for acronym expansion based on buffer text
57 learn ediff
58 universal google
59 figure out auto-indent
60 learn eshell and prelude settings for it
61 combine register prefix and c-x prefix
62 note: remember to think of mouse & foot pedals
63 commands to change: select other window: C-x o.
64 ** prefix keybind changes
65 #+begin_src emacs-lisp
66
67
68 ; prefix key binds.
69 ; good info http://www.masteringemacs.org/articles/2011/02/08/mastering-key-bindings-emacs/
70 ; rebinding the prefix keys are tricky. apparently, some modes ignore any redefinition of a prefix key and use it explicitly,
71 ; so you have to dig into their key maps and redo things.
72 ; There are 2 simpler alternatives which have their own downsides.
73 ; One is cua mode, which I do not like because it smashes 2 keybinds onto 1 and limits what you can do.
74 ; The other is keyboard-translate, which translates the key presses before anything else.
75 ; The downside is that it translates them when you aren't using them as a prefix.
76 ; Since the swaps I'm using are all very accessible, the only downside is some mental jugling when reading docs etc about these keybinds.
77
78 ; I've seen this as an another suggestion, it was a total fail. The prefix command took over both keys.
79 ; (define-key key-translation-map [f12] "\C-c")
80 ; (define-key key-translation-map "\C-c" [left])
81
82
83 ;idea to remove the hook later since it is only needed at startup.
84 ; did not work however, and there is not a real need to fix it, so I did not investigate
85 ;(defun removeSwapHook ()
86 ; (remove-hook 'buffer-list-update-hook 'myKeySwap)
87 ; (remove-hook 'change-major-mode-hook 'removeSwapHook))
88 ;(add-hook 'change-major-mode-hook 'removeSwapHook)
89
90
91 ; went through almost all the relevant standard hooks,
92 ; this overcomes a known bug that (keyboard-translate) does not get applied when running emacs daemon
93 (add-hook 'buffer-list-update-hook (lambda () (interactive)
94 (keyboard-translate ?\C-x ?\C-s)
95 (keyboard-translate ?\C-s ?\C-x)
96 (keyboard-translate ?\C-c ?\C-d)
97 (keyboard-translate ?\C-d ?\C-c)))
98
99
100
101 ; these all don't work
102 ; don't know why this doesn't error but reversing the keys does
103 ;(keyboard-translate ?\t ?\M-\t)
104 ;(keyboard-translate [M-tab] [tab])
105 ; from what i can tell, it wants to use a keyboard-translate-table,
106 ; which is a char table, which is a vector indexed by chars,
107 ; and mod+tab is not a char (it has too many bits), it is an integer
108 ; it actually says it can hold vectors or strings, but that it is obsolete to do so
109 ;(characterp ?\M-a)
110 ;(characterp ?\C-a)
111
112
113
114 #+end_src
115
116 ** named commands
117 *** gdb
118 gdb-many-windows
119 *** tramp sudo
120 /ssh:host|sudo:host:
121 when in the same session, you can then do:
122 /sudo:root@host:
123
124 *** org insert table row
125 [org-shiftmetadown/up]
126 *** toggle line continuation / truncation / wrap
127 toggle-truncate-lines
128 *** auto-save on/off
129 my-as-on/my-as-off
130 *** toggle menu bar
131 menu-bar-mode
132 *** show abbreviations
133 list-abbrevs
134
135 *** rename-file-and-buffer
136 *** ediff-buffers
137 *** refill-mode
138 automatically balance a paragraph with newlines
139 *** executable-make-buffer-file-executable-if-script-p
140 make a script executable
141 *** (setq lazy-highlight-cleanup nil)
142 keep search highlight on after search is done
143 *** auto-revert-tail-mode
144 tail a file
145 *** trash-file-and-buffer
146 #+begin_src emacs-lisp
147 (defun trash-file-and-buffer ()
148 "Removes file connected to current buffer and kills buffer."
149 (interactive)
150 (let ((filename (buffer-file-name))
151 (buffer (current-buffer))
152 (name (buffer-name)))
153 (if (not (and filename (file-exists-p filename)))
154 (error "Buffer '%s' is not visiting a file!" name)
155 (delete-file filename)
156 (kill-buffer buffer)
157 (message "File '%s' successfully removed" filename))))
158
159 #+end_src
160 *** what-line
161 *** linum-mode
162 line numbers
163
164 *** sgml-pretty-print
165 format xml in nxml-mode
166 *** visual-line-mode
167 toggle word wrap.
168 ** compound commands
169 *** C-xc
170 exit0
171 *** C-x s
172 save file
173 *** C-x e
174 eval last sexp
175 *** C-x u
176 [undo-tree-visualize]
177 *** C-j u/U
178 [undo-tree save/restore state via register]
179 *** C-c -
180 [org insert table horizontal line or create list]
181 *** C-x tab
182 indent/dedent region
183
184 [shift-left and shift-right are default for indenting by tab stop,
185 and they are only defined as lambdas so I copy them here
186 to use with up and down.
187 #+begin_src emacs-lisp
188 ;; condition cuz emacs24 release doesn't have this yet
189 (when (boundp 'indent-rigidly-map)
190 (define-key indent-rigidly-map (kbd "<C-left>")
191 (lambda (beg end) (interactive "r")
192 (let* ((current (indent-rigidly--current-indentation beg end))
193 (next (indent--next-tab-stop current)))
194 (indent-rigidly beg end (- next current)))))
195
196 (define-key indent-rigidly-map (kbd "<C-right>")
197 (lambda (beg end) (interactive "r")
198 (let* ((current (indent-rigidly--current-indentation beg end))
199 (next (indent--next-tab-stop current 'prev)))
200 (indent-rigidly beg end (- next current))))))
201 #+end_src
202 *** C-x *
203 [calc-dispatch]
204 *** C-x =
205 [point information]
206 *** C-x d
207 [dired]
208 *** C-xb
209 [ibuffer]
210 #+begin_src emacs-lisp
211 (global-set-key (kbd "C-x C-b") 'ibuffer)
212 #+end_src
213
214 *** C-x r c
215 rectangular clear, replace area with whitespace
216 ** gnus
217 searching overview.
218 3 types:
219 ingroup searching
220 nnir searching with notmuch, specific group (not sure if it can do multiple)
221 search all groups with mairix
222 *** a]
223 compose new message
224 *** C-c C-c]
225 send message
226 *** s]
227 save newsrc file, alterations to groups.
228 *** g]
229 gnus refresh / get new
230 *** m]
231 gnus new message
232 *** F]
233 gnus quoted reply all
234 *** e]
235 gnus draft edit message
236 *** delete]
237 gnus delete draft
238 #+begin_src emacs-lisp
239 (add-hook 'gnus-startup-hook
240 (lambda ()
241 (define-key gnus-summary-mode-map (kbd "<delete>") 'gnus-summary-delete-article)))
242 #+end_src
243
244 *** b]
245 mairix search
246 #+begin_src emacs-lisp
247 (add-hook 'gnus-startup-hook
248 (lambda ()
249 (define-key gnus-group-mode-map "b" 'nnmairix-search)
250 (define-key gnus-summary-mode-map "b" 'nnmairix-search)))
251 #+end_src
252 *** B m]
253 move message, or messages in region
254 *** #]
255 mark article, move with B m
256 *** B delete]
257 gnus delete draft
258 *** / plus x a / b]
259 search current group (or see info manual for more groups),
260 using the gnus native search (its slow, do a notmuch or mairix search instead)
261 x= extra (ie. to)
262 todo; send in patch to make author search to in sent folder
263 a = author
264 / = subject
265 b = body
266 see C-h m for a full list
267 *** G G ]
268 do a nnir notmuch search, for the group on the current line
269 *** A T ]
270 jump to thread from nnir group
271
272 *** marks]
273 ! = saved for later
274 E = expired
275 M-& apply process mark to a non-process mark command
276 *** S D e]
277 edit as new
278 *** T k / C-M-k
279 maybe rebind this to a shorter keybind, like del
280 gnus-summary-kill-thread
281 ** message mode
282 *** C-ck]
283 discard message
284 ** notmuch
285 *** space]
286 notmuch advance to next message/thread
287
288 ** readline / bash / .inputrc
289 *** C-m
290 [--------]
291 #+begin_src emacs-lisp
292 (add-hook 'comint-mode-hook
293 (lambda ()
294 (define-key comint-mode-map "\C-m" nil)))
295 #+end_src
296 terminal crap, duplicate of enter
297
298 ** isearch
299 *** C-w
300 paste word/char under cursor into isearch
301 *** M-n/p
302 next/previous isearch history
303 *** C-o
304 isearch-occur
305 Activate occur easily inside isearch
306 from starter-kit
307 #+begin_src emacs-lisp
308 (define-key isearch-mode-map (kbd "C-o")
309 (lambda () (interactive)
310 (let ((case-fold-search isearch-case-fold-search))
311 (occur (if isearch-regexp
312 isearch-string
313 (regexp-quote isearch-string))))))
314 #+end_src
315 *** m-r
316 #+begin_src emacs-lisp
317 (defun my-isearch-toggle-regexp ()
318 (interactive)
319 (isearch-toggle-regexp)
320 (cond (isearch-regexp
321 (global-set-key (kbd "C-r") 'isearch-backward-regexp)
322 (define-key global-map (kbd "<f12>") 'isearch-forward-regexp)
323 (define-key global-map (kbd "<kp-add>") 'isearch-forward-regexp))
324 (t
325 (global-set-key (kbd "C-r") 'isearch-backward)
326 (define-key global-map (kbd "<f12>") 'isearch-forward)
327 (define-key global-map (kbd "<kp-add>") 'isearch-forward))))
328 (define-key isearch-mode-map (kbd "M-r") 'my-isearch-toggle-regexp)
329 #+end_src
330
331 ** icomplete
332 *** C-. C-,
333 icomplete-forward/backward-completions
334
335 ** info
336 *** [, ]
337 forward / previous node, descend/ascend tree as needed
338 *** x
339 Info-follow-nearest-node
340 #+begin_src emacs-lisp
341 (define-key Info-mode-map "x" 'Info-follow-nearest-node)
342 #+end_src
343 m, f, n, p or ^ command, depending on where you click.
344 ** auto-complete
345 *** S-return
346 select next completion candidate
347 ac-expand
348 ** agenda
349 *** t]
350 agenda cycle todo state
351 ** org
352 *** C-c / t]
353 make just todo items visible
354 *** S-<tab>
355 org-shifttab global visibility cycle / move table cell
356 *** C-cs]
357 schedule todo item
358 *** C-cx p]
359 org set property
360 *** C-c -]
361 org insert horizontal line
362 *** C-cq]
363 org tag
364 ** calc
365 i'd like to drill these sometime when I have space in my head, or I
366 plan to use calc.
367 *** space
368 [enter input to the stack, or duplicate top stack item]
369 *** C-M-i
370 [cycle 3 elements on stack]
371 *** tab
372 [cycle 2 elements on stack]
373 *** n
374 [negate]
375 *** _
376 [begin negative number]
377 *** /
378 [reciprocal]
379 *** x
380 [calc named command]
381 *** M-delete
382 [delete 2nd from top of stack]
383 *** C-u [-]0-9
384 [0=whole stack, 1-9=that many, -1-9=that element]
385 *** delete
386 [remove from the top of the stack]
387 *** '
388 [algebraic mode. infix expressions are calculated when input to the stack]
389 *** m a
390 [auto algebraic mode]
391 *** $,$$,$$$
392 [top x of stack reference]
393 *** s s/t/r/u
394 [store to variable: store, top, retrieve, unstore. the quick variables 0-9 don't need s prefix]
395 *** U/D
396 [undo/redo]
397 *** t p/n/]/y
398 [trail prev/next/end/yankh]
399 *** `
400 [calc edit mode, to edit the top of stack]
401
402 ** single/special keys
403 *** tab
404 isearch
405 #+begin_src emacs-lisp
406 (define-key isearch-mode-map (kbd "<tab>") 'isearch-query-replace)
407 #+end_src
408 *** f12
409 isearch-forward
410 #+begin_src emacs-lisp
411 ;; explained in http://stackoverflow.com/questions/7411920/how-to-bind-search-and-search-repeat-to-c-f-in-emacs
412 (global-set-key (kbd "<kp-add>") 'isearch-forward)
413 (global-set-key (kbd "<f12>") 'isearch-forward)
414 (define-key isearch-mode-map "\t" nil)
415 (define-key isearch-mode-map (kbd "<kp-add>") 'isearch-repeat-forward)
416 (define-key isearch-mode-map (kbd "<f12>") 'isearch-repeat-forward)
417 ;; get rid of the standard completion binding, always use auto-complete
418 ;; this didn't work very well
419 ;;(global-set-key (kbd "TAB") 'auto-complete)
420 (define-key global-map [remap completion-at-point] 'auto-complete)
421
422 #+end_src
423
424 *** end
425 move-end-of-line
426 #+begin_src emacs-lisp
427 ;; taken from emacs wiki, along with home function
428 ;; http://www.emacswiki.org/emacs/BackToIndentationOrBeginning
429 (defun point-in-comment ()
430 "Determine if the point is inside a comment"
431 (interactive)
432 (let ((syn (syntax-ppss)))
433 (and (nth 8 syn)
434 (not (nth 3 syn)))))
435 (defun end-of-code-or-line (arg)
436 "Move to end of line, or before start of comments depending on situation.
437 Toggle back and forth positions if we are already at one.
438 Comments are recognized in any mode that sets syntax-ppss
439 properly."
440 (interactive "P")
441 (when (catch 'bol
442 (let ((start (point))
443 (bol (save-excursion
444 (beginning-of-line)
445 (point)))
446 (eol (progn (move-end-of-line arg) (point))))
447 (while (point-in-comment)
448 (backward-char)
449 (when (= (point) bol)
450 (throw 'bol t)))
451 (throw 'bol (and (not (= eol start)) (>= start (point))))))
452 (move-end-of-line arg)))
453
454 (global-set-key (kbd "<end>") 'end-of-code-or-line)(add-hook 'org-mode-hook (lambda () (define-key org-mode-map (kbd "<end>") 'org-end-of-line)))
455 #+end_src
456
457 *** home
458 back-to-indentation
459 #+begin_src emacs-lisp
460 (defun back-to-indentation-or-beginning ()
461 (interactive)
462 (if (= (point) (progn (back-to-indentation) (point)))
463 (if (derived-mode-p 'org-mode)
464 (org-beginning-of-line)
465 (beginning-of-line))))
466 (global-set-key (kbd "<home>") 'back-to-indentation-or-beginning)
467
468 #+end_src
469
470 *** s-tab
471 indent-buffer
472 #+begin_src emacs-lisp
473 (global-set-key (kbd "<S-iso-lefttab>") 'indent-buffer)
474 #+end_src
475 *** s-delete
476 send-shell
477 #+begin_src emacs-lisp
478
479 (global-set-key (kbd "<S-delete>") 'send-shell)
480
481 ;; optional variables used by send-shell
482 (setq shell-send-yank-key nil)
483
484 (defun repeat-shell ()
485 (interactive)
486 "Repeat the last command in shell-mode, displaying the window if needed."
487 (let ((shell-buffer (get-buffer "*shell*")))
488 (if shell-buffer
489 (buffer-window-show shell-buffer)
490 (let ((original-buffer (current-buffer)))
491 (funcall 'shell)
492 (setq shell-buffer (current-buffer))
493 (switch-to-buffer original-buffer)))
494 (with-current-buffer shell-buffer
495 (goto-char (point-max))
496 (call-interactively 'comint-previous-input)
497 ;; the t flag makes the buffer advance
498 (comint-send-input nil t))))
499
500 (setq compilation-filenames '("Makefile" "makefile"))
501
502 (defun get-nearest-compilation-file ()
503 "Search for the compilation file traversing up the directory tree."
504 (interactive)
505 (let ((dir default-directory)
506 (parent-dir (file-name-directory (directory-file-name default-directory)))
507 (nearest-compilation-file 'nil))
508 (while (and (not (string= dir parent-dir))
509 (not nearest-compilation-file))
510 (dolist (filename compilation-filenames)
511 (setq file-path (concat dir filename))
512 (when (file-readable-p file-path)
513 (setq nearest-compilation-file file-path)))
514 (setq dir parent-dir
515 parent-dir (file-name-directory (directory-file-name parent-dir))))
516 nearest-compilation-file))
517 (defun run ()
518 (interactive)
519 "call run-fun if it is set, else run make if there is a makefile,
520 else save and repeat last shell command.
521 run-fun is meant to store file local variables, which show how to
522 do the main thing we want on this file, generally compile and
523 run.
524
525 example of setting it in a file:
526 ;; Local Variables:
527 ;; run-fun: merge-test
528 ;; End: "
529 (basic-save-buffer)
530 (if (and (boundp 'run-fun) run-fun)
531 (funcall run-fun)
532 (let ((makefile (get-nearest-compilation-file)))
533 (if (and makefile (stringp mode-name) (string= mode-name "C/l"))
534 (compile (format
535 "make -f %s" (get-nearest-compilation-file)))
536 (repeat-shell)))))
537
538
539 (defun send-shell ()
540 (interactive)
541 (send-shell-buffer "*shell*" 'shell (kbd "C-v")))
542
543 (defun send-python ()
544 (interactive)
545 (send-shell-buffer "*Python*" 'py-shell (kbd "C-v")))
546
547
548 (defun send-shell-buffer (buffer-name &optional init shell-send-yank-key)
549 "Send current line or region to shell-mode buffer.
550 When in shell-mode, copy the current line to the
551 most recently visited visible window.
552
553 SHELL-SEND-YANK-KEY: key to use instead
554 of yank to paste into recent window. This allows compatibility with
555 modes like org-mode which have their own yank function."
556 (if (string= (buffer-name) buffer-name)
557 ;; this section is copied out of comint-send-input
558 (progn
559 (let ((proc (get-buffer-process (current-buffer))))
560 (if (not proc) (user-error "Current buffer has no process")
561 (widen)
562
563 (let* ((pmark (process-mark proc))
564 (intxt (if (>= (point) (marker-position pmark))
565 (progn (if comint-eol-on-send (end-of-line))
566 (buffer-substring pmark (point)))
567 (let ((copy (funcall comint-get-old-input)))
568 (goto-char pmark)
569 (insert copy)
570 copy))))
571
572 (if (= (length intxt) 0)
573 (kill-new (comint-previous-matching-input-string "." 1))
574 (kill-new intxt)))))
575 (kill-append "\n" nil)
576 (select-window (previous-window nil nil 'visible))
577 (if (and (boundp 'shell-send-yank-key) shell-send-yank-key)
578 (call-interactively (global-key-binding shell-send-yank-key))
579 (yank))
580 (select-window (next-window nil nil 'visible)))
581 (let (start end)
582 (if mark-active
583 (setq start (mark)
584 end (point))
585 (setq start (save-excursion (beginning-of-line) (point))
586 end (save-excursion (end-of-line) (point)))
587 (let (line-move-visual)
588 (call-interactively 'next-line)))
589 (send-comint-input buffer-name start end init))))
590
591 ;; supporting functions
592 (defun send-comint-input (buffer-name start end &optional init)
593 "Input the region to BUFFER-NAME, assuming it is a comint-derived buffer.
594 Show BUFFER-NAME if it is not show.
595 Call INIT if BUFFER-NAME does not exist."
596 (let ((input (filter-buffer-substring start end)))
597 (send-comint-string buffer-name input init)))
598
599 (defun send-comint-string (buffer-name string &optional init)
600 "Input the string to BUFFER-NAME, assuming it is a comint-derived buffer.
601 Show BUFFER-NAME if it is not show.
602 Call INIT if BUFFER-NAME does not exist."
603 (let ((buffer (get-buffer buffer-name)))
604 (unless buffer
605 (message "nobuffer")
606 ;; save-excursion etc. don't work for (shell), so I do this instead
607 (if init (let ((original-buffer (current-buffer)))
608 (funcall init (and (boundp 'send-shell-buffer-name) send-shell-buffer-name))
609 (switch-to-buffer original-buffer)
610 (setq buffer (get-buffer buffer-name)))
611 (error "No existing buffer found and no init function argument. ")))
612 (buffer-window-show buffer)
613 (with-current-buffer buffer
614 (let ((proc (get-buffer-process buffer)))
615 (goto-char (process-mark proc))
616 (insert string)
617 (comint-send-input nil t)))))
618
619 (defun buffer-window-show (&optional buffer action)
620 "Like temp-buffer-window-show, but removed stuff
621 relevant to it being temp or help."
622 (let (window frame)
623 (with-current-buffer buffer
624 (when (let ((window-combination-limit
625 ;; When `window-combination-limit' equals
626 ;; `temp-buffer' or `temp-buffer-resize' and
627 ;; `temp-buffer-resize-mode' is enabled in this
628 ;; buffer bind it to t so resizing steals space
629 ;; preferably from the window that was split.
630 (if (or (eq window-combination-limit 'temp-buffer)
631 (and (eq window-combination-limit
632 'temp-buffer-resize)
633 temp-buffer-resize-mode))
634 t
635 window-combination-limit)))
636 ;; debug
637 ;;(message "window-combination-limit")
638 ;;(print window-combination-limit)
639 (setq window (display-buffer buffer action)))
640 (setq frame (window-frame window))
641 (unless (eq frame (selected-frame))
642 (raise-frame frame))
643 (setq minibuffer-scroll-window window)
644 (set-window-hscroll window 0)
645 ;; Return the window.
646 window))))
647
648
649 ;; when poping help, etc, allow reusing a window in a different frame if it is visible
650 ;; figured this out after spending quite a while reading doc string for display-buffer
651 ;; which is the main function which uses this.
652 ;; it will use other vars or its arg to override this,
653 ;; but those things are often nil.
654 ;; aha moments in reading it: ACTION = (FUNCTION-or-FUNCTIONLIST ALIST)
655 ;; FRAME adds an association to ACTION's alist, but it's not used if ACTION arg is nil.
656 (setq display-buffer-fallback-action `(,(car display-buffer-fallback-action) . '(reusable-frames . visible)))
657 ;; stop splitting windows verticallly when I open a buffer or shell
658 (setq split-height-threshold nil)
659 #+end_src
660
661 *** s-left arrow
662 shell
663 #+begin_src emacs-lisp
664 (global-set-key (kbd "<S-kp-equal>") 'shell-wrap)
665 (global-set-key (kbd "<S-left>") 'shell-wrap)
666 #+end_src
667 *** s-right arrow
668 previous-buffer
669 #+begin_src emacs-lisp
670 (global-set-key (kbd "<S-kp-divide>") 'previous-buffer)
671 #+end_src
672 *** esc
673 *** return
674 new line
675
676 #+begin_src emacs-lisp
677 ;; todo, this doesn't set the keybind for the help minibuffer
678
679
680 (global-set-key (kbd "\r") 'indent-new-comment-line)
681
682 ;; don't use enter for autocomplete, we use tab or something
683 (define-key ac-completing-map (kbd "<return>") nil)
684 (define-key ac-completing-map "\r" nil)
685
686 (add-hook 'org-mode-hook
687 (lambda ()
688 ;; copied from org-mode, replace org-enter with org-enter-indent
689 (org-defkey org-mode-map "\C-m" 'org-return-indent)))
690
691
692 (add-hook 'comint-mode-hook
693 (lambda ()
694 (define-key comint-mode-map "\r" nil)
695 (define-key comint-mode-map (kbd "<return>") 'comint-send-input)))
696
697 (add-hook 'comint-mode-hook
698 (lambda ()
699 (define-key comint-mode-map "\C-m" nil)
700 (define-key comint-mode-map "\C-d" nil)))
701
702 #+end_src
703
704 *** s-return
705 auto-correct-prev-word
706 #+begin_src emacs-lisp
707 (global-set-key (kbd "<S-return>") 'flyspell-auto-correct-previous-word)
708 #+end_src
709
710 *** down arrow
711 mark
712 #+begin_src emacs-lisp
713 (global-set-key (kbd "<kp-enter>") 'set-mark-command)
714 #+end_src
715 *** s-down arrow
716 extended command
717 #+begin_src emacs-lisp
718 (global-set-key (kbd "<S-kp-enter>") 'smex)
719 #+end_src
720 *** s-up arrow
721
722 ** mouse
723 *** mouse-2 mode line
724 mouse-delete-other-windows
725 *** C-mouse-2 mode line
726 mouse-split-window-horizontally
727 *** M-mouse-2 mode line
728 *** S-mouse-2 mode line
729 *** C-M-mouse-2 mode line
730 *** C-S-mouse2 mode line
731 *** mouse-3 mode line
732 mouse-delete-window
733 *** C-mouse-3 mode line
734 *** M-mouse-3 mode line
735 *** S-mouse-3 mode line
736 *** C-M-mouse-3 mode line
737 *** C-S-mouse-3 mode line
738 *** mouse-1
739 set cursor/mark
740 *** C-mouse-1
741 buffer list context menu
742 *** M-mouse-1
743 *** S-mouse-1
744 *** C-M-mouse-1
745 *** C-S-mouse-1
746 *** mouse-2
747 paste
748 *** C-mouse-2
749 *** M-mouse-2
750 *** S-mouse-2
751 *** C-M-mouse-2
752 *** C-S-mouse-2
753 *** mouse-3
754 set-mark
755 #+begin_src emacs-lisp
756 (define-key global-map [down-mouse-3] 'mouse3-func)
757 (global-set-key [mouse-3] 'mouse3-set-mark)
758 (global-set-key [drag-mouse-3] 'mouse3-set-mark)
759 #+end_src
760 *** C-mouse-3
761 global menu
762 *** M-mouse-3
763 *** S-mouse-3
764 *** C-M-mouse-3
765 *** C-S-mouse-3
766 *** mouse-9
767 move-mouse-to-point
768 #+begin_src emacs-lisp
769 (global-set-key (kbd "<mouse-6>") 'move-mouse-to-point)
770 #+end_src
771 *** C-mouse-9
772 *** M-mouse-9
773 *** S-mouse-9
774 *** C-M-mouse-9
775 *** C-S-mouse-9
776 *** mouse-8
777 *** C-mouse-8
778 *** M-mouse-8
779 *** S-mouse-8
780 *** C-M-mouse-8
781 *** C-S-mouse-8
782 *** 1/kp-end
783 *** C-1/kp-end
784 *** M-1/kp-end
785 *** S-1/kp-end
786 *** C-M-1/kp-end
787 *** C-S-1/kp-end
788 *** 2/kp-down
789 *** C-2/kp-down
790 *** M-2/kp-down
791 smex
792 #+begin_src emacs-lisp
793 ;; for when we have a standard keyboard which is not remapped
794 (global-set-key (kbd "M-2") 'smex)
795
796 #+end_src
797
798 *** S-2/kp-down
799 *** C-M-2/kp-down
800 *** C-S-2/kp-down
801 *** 3/kp-next
802 *** C-3/kp-next
803 *** M-3/kp-next
804 *** S-3/kp-next
805 *** C-M-3/kp-next
806 *** C-S-3/kp-next
807 *** 4/kp-left
808 indent-region
809 #+begin_src emacs-lisp
810 (global-set-key (kbd "<kp-left>") 'indent-region)
811 #+end_src
812 *** C-4/kp-left
813 *** M-4/kp-left
814 *** S-4/kp-left
815 *** C-M-4/kp-left
816 *** C-S-4/kp-left
817 *** 5/kp-begin
818 mark-defun
819 #+begin_src emacs-lisp
820 (global-set-key (kbd "<kp-begin>") 'mark-defun)
821 #+end_src
822 *** C-5/kp-begin
823 *** M-5/kp-begin
824 *** S-5/kp-begin
825 *** C-M-5/kp-begin
826 *** C-S-5/kp-begin
827 *** 6/kp-right
828 ibuffer
829 #+begin_src emacs-lisp
830 (global-set-key (kbd "<kp-right>") 'ibuffer)
831 #+end_src
832 *** C-6/kp-right
833 *** M-6/kp-right
834 *** S-6/kp-right
835 *** C-M-6/kp-right
836 *** C-S-6/kp-right
837 *** 7/kp-home
838 *** C-7/kp-home
839 *** M-7/kp-home
840 *** S-7/kp-home
841 *** C-M-7/kp-home
842 *** C-S-7/kp-home
843 *** 8/kp-up
844 *** C-8/kp-up
845 *** M-8/kp-up
846 *** S-8/kp-up
847 *** C-M-8/kp-up
848 *** C-S-8/kp-up
849 *** 9/kp-prior
850 delete-horizontal-space
851 #+begin_src emacs-lisp
852 (global-set-key (kbd "<kp-prior>") 'delete-horizontal-space)
853 #+end_src
854 *** C-9/kp-prior
855 *** M-9/kp-prior
856 *** S-9/kp-prior
857 *** C-M-9/kp-prior
858 *** C-S-9/kp-prior
859 *** 10/kp-insert
860 *** C-10/kp-insert
861 *** M-10/kp-insert
862 *** S-10/kp-insert
863 *** C-M-10/kp-insert
864 *** C-S-10/kp-insert
865 *** 11/kp-subtract
866 *** C-11/kp-subtract
867 *** M-11/kp-subtract
868 *** S-11/kp-subtract
869 *** C-M-11/kp-subtract
870 *** C-S-11/kp-subtract
871 *** 12/kp-add
872 *** C-12/kp-add
873 *** M-12/kp-add
874 *** S-12/kp-add
875 *** C-M-12/kp-add
876 *** C-S-12/kp-add
877 *** scroll
878 up/dn / scroll
879 on standard mouse, this scrolls,
880 because we have the accuracy to pick things up and
881 down easier, and because it is familiar.
882 *** C-scroll
883 cursor up/down fast
884 #+begin_src emacs-lisp
885 ;; compiling warns that next-line should be called interactively,
886 ;; but we would have to do something dumb, like give it a
887 ;; vector of keys in order to supply the 8 argument
888 (defun down-fast ()
889 (interactive)
890 (next-line 8))
891 (defun up-fast ()
892 (interactive)
893 (next-line -8))
894
895 (global-set-key (kbd "<C-up>") 'up-fast)
896 (global-set-key (kbd "<C-down>") 'down-fast)
897
898 (add-hook 'comint-mode-hook
899 (lambda ()
900 (define-key comint-mode-map (kbd "<C-mouse-4>") 'comint-previous-prompt)
901 (define-key comint-mode-map (kbd "<C-mouse-5>") 'comint-next-prompt)))
902 #+end_src
903
904 *** M-scroll
905 forward/back s-exp
906 #+begin_src emacs-lisp
907 (global-set-key (kbd "<M-mouse-4>") 'backward-sexp)
908 (global-set-key (kbd "<M-mouse-5>") 'forward-sexp)
909 #+end_src
910 *** S-scroll
911 expand/contract region
912 #+begin_src emacs-lisp
913 (global-set-key (kbd "<S-mouse-13>") 'my-contract-region)
914 (global-set-key (kbd "<S-mouse-14>") 'er/expand-region)
915 (global-set-key (kbd "<S-mouse-4>") 'my-contract-region)
916 (global-set-key (kbd "<S-mouse-5>") 'er/expand-region)
917 (global-set-key (kbd "<S-up>") 'my-contract-region)
918 (global-set-key (kbd "<S-down>") 'er/expand-region)
919
920 (defun my-contract-region (arg)
921 (interactive "p")
922 (let ((current-prefix-arg '-))
923 (call-interactively 'er/expand-region)))
924 #+end_src
925 *** C-M-scroll
926 scroll
927 background: I originally tried to make c-scroll be scroll
928 , but this made
929 for better compatibility with the standard mouse
930 #+begin_src emacs-lisp
931 (global-set-key (kbd "<C-M-mouse-4>") 'mwheel-scroll)
932 (global-set-key (kbd "<C-M-mouse-5>") 'mwheel-scroll)
933 ; (require 'smooth-scroll)
934 ; (smooth-scroll-mode nil)
935 ; (global-set-key (kbd "<C-M-mouse-4>") 'scroll-up-1)
936 ;(global-set-key (kbd "<C-M-mouse-5>") 'scroll-down-1)
937 #+end_src
938 *** C-S-scroll
939 increase / decrease text size
940 #+begin_src emacs-lisp
941 (global-set-key (kbd "<C-S-mouse-4>") 'text-scale-increase)
942 (global-set-key (kbd "<C-S-mouse-5>") 'text-scale-decrease)
943 (global-set-key (kbd "<C-S-mouse-13>") 'text-scale-increase)
944 (global-set-key (kbd "<C-S-mouse-14>") 'text-scale-decrease)
945 (global-set-key (kbd "<C-S-down>") 'text-scale-increase)
946 (global-set-key (kbd "<C-S-up>") 'text-scale-decrease)
947 #+end_src
948 *** left-scroll
949 left/right
950 *** C-left-scroll
951 back / forward word
952 #+begin_src emacs-lisp
953 (global-set-key (kbd "<C-left>") 'backward-symbol)
954 (global-set-key (kbd "<C-right>") 'forward-symbol)
955 #+end_src
956 *** M-left-scroll
957 ---
958 unreachable
959 *** S-left-scroll
960 ---
961 unreachable
962 *** C-M-left-scroll
963 ---
964 unreachable
965 *** C-S-left-scroll
966 ---
967 unreachable
968 ** left primary
969
970 *** C-2
971 copy-symbol
972 #+begin_src emacs-lisp
973 (global-unset-key (kbd "C-2"))
974 (defun copy-symbol (&optional arg)
975 "Copy symbol at point into kill-ring"
976 (interactive "P")
977 (kill-new (thing-at-point 'symbol)))
978
979 (global-set-key (kbd "C-2") 'copy-symbol)
980 #+end_src
981 *** M-2
982 shell-cd-to-file
983 #+begin_src emacs-lisp
984
985 (defun shell-cd-to-file ()
986 (interactive)
987 (let ((file (buffer-file-name)))
988 (if file
989 (send-comint-string "*shell*"
990 (concat "c " (file-name-directory file))
991 'shell)
992 (message "%s" "shell-cd-to-file: buffer has no file name"))))
993 (global-set-key (kbd "M-2") 'shell-cd-to-file)
994 #+end_src
995 *** C-M-2
996 ---
997 #+begin_src emacs-lisp
998 (global-unset-key (kbd "C-M-2"))
999 #+end_src
1000 *** C-S-2
1001 *** C-3
1002 dot-mode-execute
1003 #+begin_src emacs-lisp
1004 (global-set-key (kbd "C-3") 'dot-mode-execute)
1005 #+end_src
1006 *** M-3
1007 *** C-M-3
1008 recenter-top-bottom
1009 #+begin_src emacs-lisp
1010 (global-set-key (kbd "C-M-3") 'recenter-top-bottom)
1011 #+end_src
1012 *** C-S-3
1013 *** C-q
1014 org-cycle, comint previous arg
1015 #+begin_src emacs-lisp
1016 (global-set-key (kbd "C-q") 'outline-cycle)
1017 (add-hook 'org-mode-hook
1018 (lambda () (define-key org-mode-map (kbd "C-q") 'org-cycle)))
1019 (define-key widget-keymap (kbd "C-q") 'widget-forward)
1020 (add-hook 'comint-mode-hook
1021 (lambda () (define-key comint-mode-map (kbd "C-q") 'comint-insert-previous-argument)))
1022 #+end_src
1023 *** M-q
1024 org-archive-to-archive-sibling
1025 #+begin_src emacs-lisp
1026 (global-set-key (kbd "M-q") 'org-archive-to-archive-sibling)
1027 #+end_src
1028 *** C-M-q
1029 quoted-insert
1030 #+begin_src emacs-lisp
1031 (global-set-key (kbd "C-M-q") 'quoted-insert)
1032 #+end_src
1033 *** C-S-q
1034 *** C-w
1035 ---
1036 in terminal, it's ctrl-backspace, duplicate keybind.
1037 *** M-w
1038 org-clock-in
1039 #+begin_src emacs-lisp
1040 (global-set-key (kbd "M-w") 'org-clock-in)
1041 #+end_src
1042 *** C-M-w
1043 *** C-S-w
1044 *** C-e
1045 copy-line
1046 #+begin_src emacs-lisp
1047 ;; todo, make repeated calls to this append the kills
1048 (defun copy-line (&optional arg)
1049 "Copy lines (as many as prefix argument) in the kill ring.
1050 Ease of use features:
1051 - Move to start of next line.
1052 - Appends the copy on sequential calls.
1053 - Use newline as last char even on the last line of the buffer.
1054 - If region is active, copy its lines."
1055 (interactive "p")
1056 (let ((beg (line-beginning-position))
1057 (end (line-end-position (or arg 1))))
1058 (when mark-active
1059 (if (> (point) (mark))
1060 (setq beg (save-excursion (goto-char (mark)) (line-beginning-position)))
1061 (setq end (save-excursion (goto-char (mark)) (line-end-position)))))
1062 (if (eq last-command 'copy-line)
1063 (kill-append (buffer-substring beg end) (< end beg))
1064 (kill-ring-save beg end)))
1065 (kill-append "\n" nil)
1066 ;; dun need cuz I have yank-better
1067 ;;(beginning-of-line (or (and arg (1+ arg)) 2))
1068 (if (and arg (not (= 1 arg))) (message "%d lines copied" arg)))
1069
1070 (global-set-key (kbd "C-e") 'copy-line)
1071 #+end_src
1072 *** M-e
1073 org-clock-in-last
1074 #+begin_src emacs-lisp
1075 (global-set-key (kbd "M-e") 'org-clock-in-last)
1076 #+end_src
1077 *** C-M-e
1078 *** C-S-e
1079 *** C-r
1080 isearch-backward
1081 #+begin_src emacs-lisp
1082 (global-set-key (kbd "C-r") 'isearch-backward)
1083 (add-hook 'comint-mode-hook
1084 (lambda ()
1085 (define-key comint-mode-map (kbd "C-r") 'comint-history-isearch-backward-regexp)))
1086 #+end_src
1087 *** M-r
1088 org-clock-out
1089 #+begin_src emacs-lisp
1090 (global-set-key (kbd "M-r") 'org-clock-out)
1091 #+end_src
1092 *** C-M-r
1093 *** C-S-r
1094 *** C-a
1095 copy buffer
1096 #+begin_src emacs-lisp
1097 (defun copy-all ()
1098 "Copy entire buffer to clipboard"
1099 (interactive)
1100 (clipboard-kill-ring-save (point-min) (point-max)))
1101 (global-set-key (kbd "C-a") 'copy-all)
1102 #+end_src
1103 *** M-a
1104 macro record
1105 #+begin_src emacs-lisp
1106 (global-set-key (kbd "M-a") 'kmacro-start-macro-or-insert-counter)
1107 #+end_src
1108 *** C-M-a
1109 macro end / call
1110 #+begin_src emacs-lisp
1111 (global-set-key (kbd "C-M-a") 'kmacro-end-or-call-macro)
1112 (add-hook 'perl-mode-hook (lambda () (define-key perl-mode-map (kbd "C-M-a") nil)))
1113 (add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-M-a") nil)))
1114 (add-hook 'c++-mode-hook
1115 (lambda () (define-key c++-mode-map (kbd "C-M-a") nil)))
1116 (add-hook 'c-mode-hook
1117 (lambda () (define-key c-mode-map (kbd "C-M-a") nil)))
1118
1119
1120 #+end_src
1121 *** C-S-a
1122 *** C-s
1123 c-x prefix
1124
1125 *** M-s
1126 *** C-M-s
1127 split-window-vertically
1128 #+begin_src emacs-lisp
1129 (global-set-key (kbd "C-M-s") 'split-window-vertically)
1130 #+end_src
1131 *** C-S-s
1132 *** C-d
1133 C-c prefix
1134 *** M-d
1135 *** C-M-d
1136 swap buffer across windows
1137 from http://www.emacswiki.org/emacs/TransposeWindows
1138 #+begin_src emacs-lisp
1139 (setq swapping-buffer nil)
1140 (setq swapping-window nil)
1141 (defun swap-buffers-in-windows ()
1142 "Swap buffers between two windows"
1143 (interactive)
1144 (if (and swapping-window
1145 swapping-buffer)
1146 (let ((this-buffer (current-buffer))
1147 (this-window (selected-window)))
1148 (if (and (window-live-p swapping-window)
1149 (buffer-live-p swapping-buffer))
1150 (progn (switch-to-buffer swapping-buffer)
1151 (select-window swapping-window)
1152 (switch-to-buffer this-buffer)
1153 (select-window this-window)
1154 (message "Swapped buffers."))
1155 (message "Old buffer/window killed. Aborting."))
1156 (setq swapping-buffer nil)
1157 (setq swapping-window nil))
1158 (progn
1159 (setq swapping-buffer (current-buffer))
1160 (setq swapping-window (selected-window))
1161 (message "Buffer and window marked for swapping."))))
1162
1163 (global-set-key (kbd "C-M-d") 'swap-buffers-in-windows)
1164 #+end_src
1165 *** C-S-d
1166 *** C-f]
1167 kill-whole-line
1168 #+begin_src emacs-lisp
1169 (global-set-key (kbd "C-f") 'kill-whole-line-wrapper)
1170 (defun kill-whole-line-wrapper (&optional arg)
1171 "If we are at the end of the file, kill backwards instead of doing nothing."
1172 (interactive "P")
1173 (if (= (point) (point-max))
1174 (kill-whole-line -1)
1175 (kill-whole-line arg)))
1176 #+end_src
1177 *** M-f]
1178 print-var-at-point
1179 #+begin_src emacs-lisp
1180 (defun print-var-at-point ()
1181 (interactive)
1182 (let ((v (variable-at-point)))
1183 (if (symbolp v)
1184 (message "%s: %s" v (symbol-value v))
1185 (message "no symbol found at point"))))
1186 (global-set-key (kbd "M-f") 'print-var-at-point)
1187 #+end_src
1188
1189 *** C-M-f]
1190 kill rest of line
1191 #+begin_src emacs-lisp
1192
1193 (add-hook 'org-mode-hook
1194 (lambda ()
1195 (define-key org-mode-map (kbd "C-M-f") 'org-kill-line)))
1196
1197 (global-set-key (kbd "C-M-f") 'kill-line)
1198 #+end_src
1199 *** C-S-f
1200 *** C-g]
1201 cancel / other window
1202 #+begin_src emacs-lisp
1203 (global-set-key (kbd "C-g") 'other-window)
1204 #+end_src
1205 *** M-g]
1206 abort-recursive-edit
1207 #+begin_src emacs-lisp
1208 (global-set-key (kbd "M-g") 'abort-recursive-edit)
1209 #+end_src
1210 *** C-M-g]
1211 gnus
1212 #+begin_src emacs-lisp
1213 (global-set-key (kbd "C-M-g") 'mu4e)
1214 #+end_src
1215 *** C-S-g
1216 *** C-z
1217 #+begin_src emacs-lisp
1218 (global-set-key (kbd "C-z") 'undo-tree-undo)
1219 #+end_src
1220 *** M-z
1221 *** C-M-z]
1222 *** C-S-z
1223 *** C-x
1224 kill-region
1225 #+begin_src emacs-lisp
1226 (global-set-key (kbd "C-s") 'kill-region)
1227 #+end_src
1228 *** M-x]
1229 smex
1230 #+begin_src emacs-lisp
1231 (global-set-key (kbd "M-x") 'smex)
1232 #+end_src
1233 *** C-M-x]
1234 cut-to-register
1235 #+begin_src emacs-lisp
1236 ;; same args as copy-to-register
1237 (defun cut-to-register (register start end &optional delete-flag region)
1238 (interactive (list (register-read-with-preview "Cut to register: ")
1239 (region-beginning)
1240 (region-end)
1241 current-prefix-arg
1242 t))
1243 (copy-to-register register start end t region))
1244
1245 (global-set-key (kbd "C-M-x") 'cut-to-register)
1246 #+end_src
1247 *** C-S-x
1248 *** C-c
1249 copy
1250 #+begin_src emacs-lisp
1251 (global-set-key (kbd "C-d") 'kill-ring-save)
1252 (add-hook 'c-mode-hook
1253 (lambda () (define-key c-mode-map (kbd "C-d") nil)))
1254 (add-hook 'comint-mode-hook
1255 (lambda ()
1256 (define-key comint-mode-map (kbd "C-d") nil)))
1257 ;; the base map is shared by many c-modes, like java
1258 (add-hook 'c-mode-hook
1259 (lambda ()
1260 (define-key c-mode-base-map "\C-d" nil)
1261 (define-key c-mode-base-map (kbd "<deletechar>") 'c-electric-delete-forward)))
1262
1263 #+end_src
1264 *** M-c]
1265 org-capture
1266 #+begin_src emacs-lisp
1267 (define-key global-map "\M-c" 'org-capture)
1268 #+end_src
1269 *** C-M-c]
1270 copy-to-register
1271 #+begin_src emacs-lisp
1272 (global-set-key (kbd "C-M-c") 'copy-to-register)
1273 #+end_src
1274 *** C-S-c
1275 *** C-v
1276 yank
1277 #+begin_src emacs-lisp
1278 (global-set-key (kbd "C-v") 'yank-better)
1279
1280
1281
1282 (defun yank-better (arg)
1283 "Paste, linewise if our kill ends with a newline.
1284 I change the behavior of plain prefix. It makes it not do linewise paste,
1285 because sometimes you want to yank pop and a linewise paste screws that up.
1286 c-u with no number normally makes the point go before the yank.
1287 That is pointless for me, as it would be just as easier and less
1288 thought to pop the mark after yanking cuz it is set to before the mark."
1289 (interactive "*P")
1290 (if (and (not (equal arg '(4))) (string-suffix-p "\n" (current-kill 0 t)))
1291 (beginning-of-line))
1292 (if (and (stringp mode-name) (string= mode-name "Org"))
1293 (call-interactively 'org-yank)
1294 (setq this-command 'yank)
1295 (call-interactively 'yank (and (not (equal arg '(4)))))))
1296
1297 (put 'yank-better 'delete-selection 'yank)
1298 #+end_src
1299 *** M-v]
1300 insert-register
1301 #+begin_src emacs-lisp
1302 (global-set-key (kbd "M-v") 'insert-register)
1303 #+end_src
1304 *** C-M-v]
1305 yank-pop
1306 #+begin_src emacs-lisp
1307 (global-set-key (kbd "C-M-v") 'yank-pop)
1308 #+end_src
1309 *** C-S-v
1310 *** C-b]
1311 delete-other-windows
1312 #+begin_src emacs-lisp
1313 (global-set-key (kbd "C-b") 'delete-other-windows)
1314 #+end_src
1315 *** M-b]
1316 isearch-backward-current-symbol
1317 #+begin_src emacs-lisp
1318 (global-set-key (kbd "M-b") 'isearch-backward-current-symbol)
1319 #+end_src
1320 *** C-M-b]
1321 isearch-current-symbol
1322 #+begin_src emacs-lisp
1323 (global-set-key (kbd "C-M-b") 'isearch-current-symbol)
1324 #+end_src
1325 *** C-S-b
1326 *** C-tab]
1327 ---
1328 in terminal, it's just TAB, duplicate keybind.
1329 *** M-tab]
1330 ---
1331 in terminal it's duplicated of C-M-i
1332 *** C-M-tab
1333 *** C-S-tab
1334 *** C-delete]
1335 kill-symbol
1336 #+begin_src emacs-lisp
1337 (global-set-key (kbd "<C-delete>") 'kill-symbol)
1338 (defun kill-symbol (arg)
1339 (interactive "p")
1340 (kill-region (point) (save-excursion (forward-symbol arg) (point))))
1341
1342 #+end_src
1343 *** M-delete
1344 *** C-M-delete]
1345 kill-sexp
1346 #+begin_src emacs-lisp
1347 (global-set-key (kbd "<C-M-delete>") 'kill-sexp)
1348 #+end_src
1349 *** C-S-delete
1350
1351 *** C-left-arrow]
1352 compile / comint search
1353 #+begin_src emacs-lisp
1354 (defun set-p (var)
1355 (and (bound-and-true-p var)
1356 (not (eq var 'unset))))
1357 (global-set-key (kbd "C-(") 'run)
1358
1359 ;; make compile work from the gtags root dir
1360 (defadvice compile (before pre-compile-advice activate)
1361 (basic-save-buffer)
1362 (when (set-p ggtags-project-root)
1363 (setq-local compile-saved-dir default-directory)
1364 (setq default-directory ggtags-project-root)))
1365 (defadvice compile (after post-compile-advice activate)
1366 (when (bound-and-true-p compile-saved-dir)
1367 (setq default-directory compile-saved-dir)))
1368
1369
1370 (add-hook 'c-mode-hook (lambda () (define-key c-mode-map (kbd "C-(") 'compile)))
1371 (add-hook 'comint-mode-hook
1372 (lambda ()
1373 (define-key isearch-mode-map (kbd "C-(") 'isearch-repeat-backward)
1374 (define-key comint-mode-map (kbd "C-(") 'isearch-backward)))
1375
1376 #+end_src
1377 *** M-left-arrow
1378 *** C-M-left-arrow]
1379 org-shiftup
1380 #+begin_src emacs-lisp
1381 (add-hook 'org-mode-hook
1382 (lambda () (define-key org-mode-map (kbd "C-M-(") 'org-shiftup)))
1383 #+end_src
1384 *** C-S-left-arrow
1385 *** C-right-arrow]
1386 keyboard-yank-primary
1387 #+begin_src emacs-lisp
1388 (defun keyboard-yank-primary ()
1389 (interactive)
1390 (let ((mouse-yank-at-point t))
1391 (mouse-yank-primary nil)))
1392 ;; paste selection
1393 (global-set-key (kbd "C-)") 'keyboard-yank-primary) ;; kinesis binding
1394 (global-set-key (kbd "<S-right>") 'keyboard-yank-primary)
1395 #+end_src
1396 *** M-right-arrow
1397 *** C-M-right-arrow
1398 #+begin_src emacs-lisp
1399 (add-hook 'org-mode-hook
1400 (lambda () (define-key org-mode-map (kbd "C-M-)") 'org-shiftdown)))
1401 #+end_src
1402 *** C-S-right-arrow
1403 *** C-backspace]
1404 backward-kill-symbol
1405 #+begin_src emacs-lisp
1406 (global-set-key (kbd "<C-backspace>") 'backward-kill-symbol)
1407 (add-hook 'comint-mode-hook
1408 (lambda ()
1409 (define-key comint-mode-map (kbd "<C-backspace>") 'backward-kill-word)))
1410 (defun backward-kill-symbol (arg)
1411 (interactive "p")
1412 (kill-region (point) (save-excursion (backward-symbol arg) (point))))
1413 #+end_src
1414 *** M-backspace
1415 *** C-M-backspace]
1416 backward-kill-sexp
1417 #+begin_src emacs-lisp
1418 (global-set-key (kbd "<C-M-backspace>") 'backward-kill-sexp)
1419 #+end_src
1420 *** C-S-backspace
1421 *** C-f7
1422 *** M-f7
1423 *** C-M-f7
1424 *** C-S-f7
1425
1426 ** right primary
1427 *** C-*]
1428 split-window-horizontally
1429 #+begin_src emacs-lisp
1430 (global-set-key (kbd "C-*") 'split-window-horizontally)
1431 #+end_src
1432 *** M-*
1433 *** C-M-*]
1434 calc-dispatch
1435 #+begin_src emacs-lisp
1436 (global-set-key (kbd "C-M-*") 'calc-dispatch)
1437 #+end_src
1438 *** C-S-*
1439 *** C-9]
1440 delete-window-or-exit
1441 #+begin_src emacs-lisp
1442 (global-set-key (kbd "C-9") 'delete-window-or-exit)
1443
1444 (defun delete-window-or-exit ()
1445 "Delete window or exit emacs."
1446 (interactive)
1447 (if (condition-case nil (delete-window) (error t))
1448 (if (or (boundp 'server-process) (> (length (frame-list)) 1))
1449 (progn (basic-save-buffer) (delete-frame))
1450 (save-buffers-kill-terminal t))))
1451 #+end_src
1452 *** M-9]
1453 kill-buffer
1454 #+begin_src emacs-lisp
1455 (defun kill-buffer-no-ido ()
1456 "kill-buffer, avoid the ido remapping"
1457 (interactive)
1458 (kill-buffer))
1459 (global-set-key (kbd "M-9") 'kill-buffer-no-ido)
1460 #+end_src
1461 strangely, in simple mode, this is overridden.
1462 I found this map to override, but it didn't work, so it seems its being bound some other way.
1463 I did a grep of the emacs sources, but couldn't find anything.
1464 (define-key universal-argument-map [?9] nil)
1465
1466 *** C-M-9]
1467 end server edit
1468 ,save & kill buffer if it was opened externally via emacsclient
1469
1470 #+begin_src emacs-lisp
1471 (defun server-edit-save ()
1472 (interactive)
1473 (save-buffer)
1474 (server-edit))
1475 (global-set-key (kbd "C-M-9") 'server-edit-save)
1476 #+end_src
1477 *** C-S-9
1478 *** C-u]
1479 universal-argument
1480 *** M-u
1481 *** C-M-u]
1482 search-keybind
1483 #+begin_src emacs-lisp
1484 (global-set-key (kbd "C-M-u") 'search-keybind)
1485
1486 (defun search-keybind (regexp &optional nlines)
1487 (interactive (occur-read-primary-args))
1488 (save-excursion
1489 (describe-bindings)
1490 (set-buffer "*Help*")
1491 (occur regexp)
1492 (delete-windows-on "*Help*")
1493 ))
1494 #+end_src
1495 *** C-S-u
1496 *** C-i
1497 -----
1498 *** M-i
1499 *** C-M-i]
1500 query-replace-regexp
1501 #+begin_src emacs-lisp
1502 (global-set-key (kbd "C-M-i") 'query-replace-regexp)
1503 (add-hook 'flyspell-mode-hook
1504 (lambda () (define-key flyspell-mode-map (kbd "C-M-i") nil)))
1505 (add-hook 'text-mode-hook
1506 (lambda () (define-key text-mode-map (kbd "C-M-i") nil)))
1507
1508 #+end_src
1509 *** C-S-i
1510 *** C-o]
1511 occur
1512 #+begin_src emacs-lisp
1513 (global-set-key (kbd "C-o") 'occur)
1514 #+end_src
1515 *** M-o
1516 *** C-M-o]
1517 counsel-imenu
1518 #+begin_src emacs-lisp
1519 (global-set-key (kbd "C-M-o") 'counsel-imenu)
1520 #+end_src
1521 *** C-S-o
1522 *** C-p]
1523 move-mouse-to-point
1524 #+begin_src emacs-lisp
1525 (global-set-key (kbd "C-p") 'move-mouse-to-point)
1526 #+end_src
1527 *** M-p
1528 *** C-M-p]
1529 delete-horizontal-space
1530 #+begin_src emacs-lisp
1531 (global-set-key (kbd "C-M-p") 'delete-horizontal-space)
1532 #+end_src
1533 *** C-S-p
1534 *** C-j]
1535 pop-to-mark
1536 #+begin_src emacs-lisp
1537 (defun my-pop-to-mark-command ()
1538 "Jump to mark, and pop a new position for mark off the ring.
1539 \(Does not affect global mark ring\)."
1540 (interactive)
1541 (pop-to-mark-command)
1542 (if (and (derived-mode-p 'org-mode) (outline-invisible-p))
1543 (org-show-context 'mark-goto)))
1544
1545 (global-set-key (kbd "C-j") 'my-pop-to-mark-command)
1546 (define-key ido-common-completion-map (kbd "C-j") 'ido-select-text)
1547 (add-hook 'ido-setup-hook
1548 (lambda () (define-key ido-common-completion-map (kbd "C-j") 'ido-select-text)))
1549 (add-hook 'lisp-interaction-mode-hook
1550 (lambda ()
1551 (define-key lisp-interaction-mode-map (kbd "C-j") nil)))
1552
1553 #+end_src
1554 *** M-j]
1555 previous-error
1556 #+begin_src emacs-lisp
1557 (global-set-key (kbd "M-j") 'previous-error)
1558 #+end_src
1559 *** C-M-j]
1560
1561 register prefix
1562 #+begin_src emacs-lisp
1563 (define-key global-map (kbd "C-M-j") ctl-x-r-map)
1564 (define-key ctl-x-r-map "m" 'kmacro-to-register)
1565 #+end_src
1566
1567 *** C-S-j
1568 *** C-k]
1569 jump-to-register
1570 #+begin_src emacs-lisp
1571
1572 (global-set-key (kbd "C-k") 'jump-to-register)
1573 #+end_src
1574 *** M-k]
1575 next-error
1576 #+begin_src emacs-lisp
1577 (global-set-key (kbd "M-k") 'next-error)
1578 #+end_src
1579 *** C-M-k]
1580 man
1581 #+begin_src emacs-lisp
1582 (global-set-key (kbd "C-M-k") 'man)
1583 #+end_src
1584 *** C-S-k
1585 *** C-l]
1586 ivy-switch-buffer
1587 #+begin_src emacs-lisp
1588 (global-set-key (kbd "C-l") 'ivy-switch-buffer)
1589 #+end_src
1590 *** M-l
1591
1592 *** C-M-l]
1593 move cursor top bottom mid, comint clear screen
1594 #+begin_src emacs-lisp
1595 (global-set-key (kbd "C-M-l") 'move-to-window-line-top-bottom)
1596 #+end_src
1597 *** C-S-l
1598 *** C-;]
1599 used in flyspell, not sure what for, otherwise unbound
1600 *** M-;
1601 comment-dwim
1602 *** C-M-;]
1603 comment-current-line-dwim
1604 #+begin_src emacs-lisp
1605 (defun comment-current-line-dwim ()
1606 "Comment or uncomment the current line."
1607 (interactive)
1608 (save-excursion
1609 (push-mark (beginning-of-line) t t)
1610 (end-of-line)
1611 (comment-dwim nil))
1612 (move-beginning-of-line 2))
1613 (global-set-key (kbd "C-M-;") 'comment-current-line-dwim)
1614 #+end_src
1615 *** C-S-;
1616 *** C-m]
1617 *** M-m
1618 *** C-M-m]
1619 recursive grep
1620 #+begin_src emacs-lisp
1621 (define-key global-map (kbd "C-M-m") 'rgrep)
1622 #+end_src
1623 *** C-S-m
1624 *** C-,]
1625 counsel-find-file
1626 #+begin_src emacs-lisp
1627 (global-set-key (kbd "C-,") 'counsel-find-file)
1628 (add-hook 'flyspell-mode-hook
1629 (lambda () (define-key flyspell-mode-map (kbd "C-,") nil)))
1630 #+end_src
1631 *** M-,
1632 *** C-M-,]
1633 find-file-in-project
1634 #+begin_src emacs-lisp
1635 (global-set-key (kbd "C-M-,") 'find-file-in-project)
1636 #+end_src
1637 *** C-S-,
1638 *** C-.]
1639 find recent file
1640 Taken from starter kit.
1641 #+begin_src emacs-lisp
1642 (defun recentf-ido-find-file ()
1643 "Find a recent file using Ido."
1644 (interactive)
1645 (let* ((file-assoc-list
1646 (mapcar (lambda (x)
1647 (cons (file-name-nondirectory x)
1648 x))
1649 recentf-list))
1650 (filename-list
1651 (remove-duplicates (mapcar #'car file-assoc-list)
1652 :test #'string=))
1653 (filename (ido-completing-read "Choose recent file: "
1654 filename-list
1655 nil
1656 t)))
1657 (when filename
1658 (find-file (cdr (assoc filename
1659 file-assoc-list))))))
1660
1661 (add-hook 'flyspell-mode-hook
1662 (lambda () (define-key flyspell-mode-map (kbd "C-.") nil)))
1663 (define-key dot-mode-map (kbd "C-.") nil)
1664 (global-set-key (kbd "C-.") 'recentf-ido-find-file)
1665 (add-hook 'php-mode-hook
1666 (lambda () (define-key php-mode-map (kbd "C-.") nil)))
1667 #+end_src
1668 *** M-.
1669 *** C-M-.
1670 -
1671 #+begin_src emacs-lisp
1672 (define-key dot-mode-map (kbd "C-M-.") nil)
1673 ;; (global-set-key (kbd "C-M-.") 'execute-extended-command)
1674 #+end_src
1675 *** C-S-.
1676 *** C-/]
1677 join lines
1678 #+begin_src emacs-lisp
1679 (defun vim-style-join-line ()
1680 (interactive)
1681 (join-line '(4)))
1682 (global-set-key (kbd "C-/") 'vim-style-join-line)
1683 (define-key undo-tree-map (kbd "C-/") nil)
1684 #+end_src
1685 *** M-/
1686 *** C-M-/]
1687 copy-buffer-file-name
1688 #+begin_src emacs-lisp
1689 ;; haven't bound this atm, todo, maybe someday?
1690 (defun copy-variable (variable)
1691 (interactive
1692 (let ((v (variable-at-point))
1693 (enable-recursive-minibuffers t)
1694 val)
1695 (setq val (completing-read (if (symbolp v)
1696 (format
1697 "Describe variable (default %s): " v)
1698 "Describe variable: ")
1699 obarray
1700 (lambda (vv)
1701 (or (get vv 'variable-documentation)
1702 (and (boundp vv) (not (keywordp vv)))))
1703 t nil nil
1704 (if (symbolp v) (symbol-name v))))
1705 (list (if (equal val "")
1706 v (intern val)))))
1707 (kill-new (symbol-value variable)))
1708
1709 (defun copy-buffer-file-name ()
1710 (interactive)
1711 (let ((name (cond
1712 ((derived-mode-p 'mu4e-view-mode) (mu4e-message-field-at-point :path))
1713 (t buffer-file-name))
1714 ))
1715 (kill-new name)
1716 (message name)))
1717
1718
1719 (global-set-key (kbd "C-M-/") 'copy-buffer-file-name)
1720
1721
1722 #+end_src
1723 *** C-S-/
1724 *** C-8]
1725 calc-embedded-word
1726 #+begin_src emacs-lisp
1727 (global-set-key (kbd "C-8") 'calc-embedded-word)
1728 #+end_src
1729 *** M-8
1730 *** C-M-8
1731 *** C-S-8
1732 *** C-up-arrow]
1733 org prev headline
1734 #+begin_src emacs-lisp
1735 (define-key undo-tree-map "\C-_" nil)
1736 ;; disabled just because i don't want to accidentally hit it
1737 (define-key global-map "\C-_" nil)
1738 (global-set-key (kbd "<C-_>") 'beginning-of-defun)
1739
1740 (add-hook 'org-mode-hook
1741 (lambda ()
1742 (define-key org-mode-map (kbd "\C-_") 'outline-previous-visible-heading)))
1743
1744 #+end_src
1745
1746
1747 *** M-up-arrow
1748 *** C-M-up-arrow
1749 *** C-S-up-arrow
1750 winner undo
1751 #+begin_src emacs-lisp
1752 (global-set-key (kbd "<C-S-_>") 'winner-undo)
1753 #+end_src
1754 *** C-down-arrow]
1755 org next headline
1756 #+begin_src emacs-lisp
1757 (global-set-key (kbd "<C-kp-enter>") 'end-of-defun)
1758
1759 (add-hook 'org-mode-hook
1760 (lambda ()
1761 (define-key org-mode-map (kbd "<C-kp-enter>") 'outline-next-visible-heading)))
1762
1763 #+end_src
1764
1765
1766 *** M-down-arrow
1767 *** C-M-down-arrow]
1768 toggle-mark-activation
1769 #+begin_src emacs-lisp
1770 (defun toggle-mark-activation ()
1771 (interactive)
1772 (if mark-active
1773 (deactivate-mark t)
1774 (activate-mark)))
1775
1776 (global-set-key (kbd "<C-M-kp-enter>") 'toggle-mark-activation)
1777 #+end_src
1778 winner redo
1779 #+begin_src emacs-lisp
1780 (global-set-key (kbd "<C-S-kp-enter>") 'winner-redo)
1781 #+end_src
1782
1783 *** C-S-down-arrow]
1784 m-x for major mode
1785 #+begin_src emacs-lisp
1786 (global-set-key (kbd "<C-S-kp-enter>") 'smex-major-mode-commands)
1787 #+end_src
1788 *** C-lbracket
1789 ----
1790 *** M-lbracket
1791 *** C-M-lbracket]
1792 scroll-right
1793 #+begin_src emacs-lisp
1794 (global-set-key (kbd "C-M-[") 'scroll-right)
1795 #+end_src
1796 *** C-S-lbracket
1797 *** C-rbracket]
1798 fill-paragraph
1799 #+begin_src emacs-lisp
1800 (global-set-key (kbd "C-]") 'fill-paragraph)
1801 #+end_src
1802 *** M-rbracket
1803 *** C-M-rbracket]
1804 scroll-left
1805 #+begin_src emacs-lisp
1806 (global-set-key (kbd "C-M-]") 'scroll-left)
1807 #+end_src
1808 *** C-S-rbracket
1809 *** C-return]
1810 newline-anywhere
1811 #+begin_src emacs-lisp
1812 (defun newline-anywhere ()
1813 "Add a newline from anywhere in the line."
1814 (interactive)
1815 (end-of-line)
1816 (newline-and-indent))
1817 (global-set-key (kbd "<C-return>") 'newline-anywhere)
1818
1819 #+end_src
1820 *** M-return]
1821 plain newline
1822 #+begin_src emacs-lisp
1823 (defun plain-newline ()
1824 (interactive)
1825 (insert "\n"))
1826 (global-set-key (kbd "<M-return>") 'plain-newline)
1827 #+end_src
1828
1829 *** C-M-return
1830 #+begin_src emacs-lisp
1831 (defun newline-anywhere-previous ()
1832 "Add a newline from anywhere in the line."
1833 (interactive)
1834 (forward-line -1)
1835 (end-of-line)
1836 (newline-and-indent))
1837 (global-set-key (kbd "<C-M-return>") 'newline-anywhere-previous)
1838 #+end_src
1839 *** C-S-return
1840 *** C-space]
1841 org-edit-special
1842 #+begin_src emacs-lisp
1843 ;; commented due to new keyboard needing ctrl-space for mark
1844 ;; (kbd "<C-space>") does not work, (kbd "C-SPC") should work
1845 ;; (add-hook 'org-mode-hook
1846 ;; (lambda ()
1847 ;; (define-key org-mode-map (kbd "C-SPC") 'org-edit-special)
1848 ;; ;; org-src-mode-map is broken in git version of emacs.
1849 ;; ;; temporarily use this for exiting edit-special mode.
1850 ;; (global-set-key (kbd "C-M--") 'org-edit-src-exit)
1851 ;; (define-key org-src-mode-map (kbd "C-SPC") 'org-edit-src-exit)))
1852 #+end_src
1853 *** M-space
1854 *** C-M-space
1855 before or under cursor
1856 #+begin_src emacs-lisp
1857 (global-set-key (kbd "C-M-SPC") 'ispell-word)
1858 #+end_src
1859 *** C-S-space
1860 ** left secondary
1861 *** C-=
1862 *** M-=
1863 *** C-M-=
1864 *** C-S-=
1865 *** C-1
1866 *** M-1
1867 *** C-M-1
1868 *** C-S-1
1869 *** C-4
1870 *** M-4
1871 *** C-M-4
1872 widen
1873 #+begin_src emacs-lisp
1874 (global-set-key (kbd "C-M-4") 'widen)
1875 #+end_src
1876 *** C-S-4
1877 *** C-5
1878 *** M-5
1879 *** C-M-5
1880 *** C-S-5
1881 *** C-tab-key]
1882 query-replace
1883 #+begin_src emacs-lisp
1884
1885 (global-set-key (kbd "<C-kp-add>") 'query-replace)
1886 #+end_src
1887 *** M-tab-key
1888 *** C-M-tab-key
1889 *** C-S-tab-key
1890 *** C-t]
1891 org cycle todo / toggle comint motion
1892 #+begin_src emacs-lisp
1893 (add-hook 'org-mode-hook
1894 (lambda ()
1895 (define-key org-mode-map (kbd "C-t") 'org-todo)))
1896
1897 (defun my-comint-previous-input (arg)
1898 (interactive "*p")
1899 (if (comint-after-pmark-p)
1900 (comint-previous-input arg)
1901 (forward-line -1)))
1902
1903 (defun my-comint-next-input (arg)
1904 (interactive "*p")
1905 (if (comint-after-pmark-p)
1906 (comint-next-input arg)
1907 (forward-line)))
1908
1909 (add-hook 'comint-mode-hook
1910 (lambda ()
1911 (define-key comint-mode-map (kbd "C-t") 'comint-toggle-arrow-keys)
1912 (define-key comint-mode-map (kbd "<up>") 'my-comint-previous-input)
1913 (define-key comint-mode-map (kbd "<down>") 'my-comint-next-input)))
1914
1915
1916 (defun comint-toggle-arrow-keys ()
1917 (interactive)
1918 (toggle-arrow-keys comint-mode-map))
1919
1920 (setq-default comint-arrow-movement nil)
1921 (defun toggle-arrow-keys (map)
1922 (cond ((lookup-key map (kbd "<up>"))
1923 (setq-local comint-arrow-movement t)
1924 (define-key map (kbd "<up>") nil)
1925 (define-key map (kbd "<down>") nil))
1926 (t
1927 (setq-local comint-arrow-movement nil)
1928 (define-key map (kbd "<up>") 'my-comint-previous-input)
1929 (define-key map (kbd "<down>") 'my-comint-next-input)
1930 (goto-char (point-max)))))
1931
1932 (eval-after-load "message"
1933 '(define-key message-mode-map (kbd "C-t") 'mail-signature))
1934 #+end_src
1935 Thanks for the update. I will be enjoying it.
1936
1937 #+RESULTS:
1938 : comint-toggle-arrow-keys
1939 *** M-t
1940 *** C-M-t]
1941 org timestamp
1942 #+begin_src emacs-lisp
1943 (global-set-key (kbd "C-M-t") 'org-time-stamp-with-time)
1944 #+end_src
1945 *** C-S-t
1946 *** C-home
1947 start of buffer
1948 *** M-home
1949 *** C-M-home
1950 *** C-S-home
1951 *** C-end
1952 end of buffer
1953 *** M-end
1954 *** C-M-end
1955 *** C-S-end
1956 *** C-f9
1957 *** M-f9
1958 *** C-M-f9
1959 *** C-S-f9
1960 ** right secondary
1961 *** C-6
1962 save-buffers-kill-emacs
1963 #+begin_src emacs-lisp
1964 (global-set-key (kbd "C-6") 'save-buffers-kill-emacs)
1965 #+end_src
1966 *** M-6
1967 *** C-M-6]
1968 insert-small-copyright
1969 #+begin_src emacs-lisp
1970 (defun insert-small-copyright ()
1971 (interactive)
1972 (beginning-of-line)
1973 (let ((beg (point)))
1974 (insert "Copyright (C) 2017 Ian Kelling\nThis program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>")
1975 (comment-region beg (point))))
1976
1977 (global-set-key (kbd "C-M-6") 'insert-small-copyright)
1978 #+end_src
1979 *** C-S-6
1980 *** C-7
1981 *** M-7
1982 *** C-M-7]
1983 insert-full-copyright
1984 #+begin_src emacs-lisp
1985 (defun insert-full-copyright ()
1986 (interactive)
1987 (beginning-of-line)
1988 (let ((beg (point)))
1989 (insert "Copyright (C) 2017 Ian Kelling\n")
1990 (insert "\n")
1991 (insert "This program is free software: you can redistribute it and/or modify\n")
1992 (insert "it under the terms of the GNU General Public License as published by\n")
1993 (insert "the Free Software Foundation, either version 3 of the License, or\n")
1994 (insert "(at your option) any later version.\n")
1995 (insert "\n")
1996 (insert "This program is distributed in the hope that it will be useful,\n")
1997 (insert "but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
1998 (insert "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
1999 (insert "GNU General Public License for more details.\n")
2000 (insert "\n")
2001 (insert "You should have received a copy of the GNU General Public License\n")
2002 (insert "along with this program. If not, see <http://www.gnu.org/licenses/>.\n")
2003 (comment-region beg (point))))
2004
2005 (global-set-key (kbd "C-M-7") 'insert-full-copyright)
2006
2007 #+end_src
2008 *** C-S-7
2009 *** C-0
2010 text-scale-reset
2011 #+begin_src emacs-lisp
2012 (defun text-scale-reset ()
2013 (interactive)
2014 (text-scale-set 0))
2015 (global-set-key (kbd "C-0") 'text-scale-reset)
2016 #+end_src
2017 *** M-0
2018 *** C-M-0
2019 insert-apache
2020 #+begin_src emacs-lisp
2021 (defun insert-apache ()
2022 (interactive)
2023 (beginning-of-line)
2024 (let ((beg (point)))
2025 (insert "Copyright (C) 2017 Ian Kelling\n")
2026 (insert "\n")
2027 (insert "Licensed under the Apache License, Version 2.0 (the \"License\");\n")
2028 (insert "you may not use this file except in compliance with the License.\n")
2029 (insert "You may obtain a copy of the License at\n")
2030 (insert "\n")
2031 (insert " http://www.apache.org/licenses/LICENSE-2.0\n")
2032 (insert "\n")
2033 (insert "Unless required by applicable law or agreed to in writing, software\n")
2034 (insert "distributed under the License is distributed on an \"AS IS\" BASIS,\n")
2035 (insert "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n")
2036 (insert "See the License for the specific language governing permissions and\n")
2037 (insert "limitations under the License.\n")
2038 (comment-region beg (point))))
2039 (global-set-key (kbd "C-M-0") 'insert-apache)
2040 #+end_src
2041
2042 *** C-S-0
2043 *** C--
2044 *** M--
2045 *** C-M--
2046 org-edit-src-exit
2047 *** C-S--
2048 *** C-y]
2049 undo-tree-redo
2050 #+begin_src emacs-lisp
2051 (global-set-key (kbd "C-y") 'undo-tree-redo)
2052 (add-hook 'org-mode-hook
2053 (lambda () (define-key org-mode-map (kbd "C-y") nil)))
2054 #+end_src
2055
2056 *** M-y
2057 *** C-M-y
2058 *** C-S-y
2059 *** C-\
2060 #+begin_src emacs-lisp
2061 (global-set-key (kbd "C-\\") 'sr-speedbar-toggle)
2062 #+end_src
2063 *** M-\
2064 *** C-M-\]
2065 mark-defun
2066 #+begin_src emacs-lisp
2067 (global-set-key (kbd "C-M-\\") 'mark-defun)
2068 #+end_src
2069 *** C-S-\
2070 *** C-h
2071 help-prefix
2072
2073 *** M-h
2074 *** C-M-h
2075 *** C-S-h
2076 *** C-'
2077 eval-expression
2078 #+begin_src emacs-lisp
2079 (global-set-key (kbd "C-'") 'eval-expression)
2080 #+end_src
2081 *** M-'
2082 *** C-M-'
2083 *** C-S-'
2084 *** C-n]
2085 unpop to mark
2086 #+begin_src emacs-lisp
2087 (defun unpop-to-mark-command ()
2088 "Unpop off mark ring. Does nothing if mark ring is empty."
2089 (interactive)
2090 (when mark-ring
2091 (let ((pos (marker-position (car (last mark-ring)))))
2092 (if (not (= (point) pos))
2093 (goto-char pos)
2094 (setq mark-ring (cons (copy-marker (mark-marker)) mark-ring))
2095 (set-marker (mark-marker) pos)
2096 (setq mark-ring (nbutlast mark-ring))
2097 (goto-char (marker-position (car (last mark-ring))))))))
2098
2099 (global-set-key (kbd "C-n") 'unpop-to-mark-command)
2100 #+end_src
2101 *** M-n
2102 *** C-M-n]
2103 narrow-to-region
2104 #+begin_src emacs-lisp
2105 (global-set-key (kbd "C-M-n") 'narrow-to-region)
2106 #+end_src
2107 *** C-S-n
2108 *** C-rshift
2109 *** M-rshift
2110 *** C-M-rshift
2111 *** C-S-rshift
2112 *** C-escape]
2113 find-tag
2114 :ID: a6dd7e4c-1831-4493-bbfd-557dc2f9c856
2115 :CUSTOM_ID: 6901fa1b-c827-4525-b24b-bdb8fe5f638b
2116
2117
2118
2119
2120
2121
2122
2123
2124 :END:
2125 find-tag
2126 #+begin_src emacs-lisp
2127 (global-set-key (kbd "<C-escape>") 'find-tag)
2128 #+end_src
2129 *** M-escape
2130 *** C-M-escape
2131 *** C-S-escape
2132 * keybind table src
2133 not necessary to have at the end, but its convenient to have it next
2134 to its output.
2135 #+NAME: keybind-table-generator
2136 #+BEGIN_SRC emacs-lisp :results silent
2137 (defun org-custom-id-get (&optional pom create prefix)
2138 "Get the CUSTOM_ID property of the entry at point-or-marker POM.
2139 If POM is nil, refer to the entry at point.
2140 If the entry does not have a CUSTOM_ID, the function returns nil.
2141 However, when CREATE is non nil, create an ID if none is present already.
2142 PREFIX will be passed through to `org-id-new'.
2143 In any case, the CUSTOM_ID of the entry is returned."
2144 (org-with-point-at pom
2145 (let ((id (org-entry-get nil "CUSTOM_ID")))
2146 (cond
2147 ((and id (stringp id) (string-match "\\S-" id))
2148 id)
2149 (create
2150 (setq id (org-id-new prefix))
2151 (org-entry-put pom "CUSTOM_ID" id)
2152 (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
2153 id)))))
2154
2155 (defun get-title()
2156 (interactive)
2157 (let ((title (plist-get (cadr (org-element-at-point)) ':title)))
2158 ;; remove brackets from [title]
2159 ;; I was at one point using org-drill for spaces repitition,
2160 ;; and enclosed question and answer by 2 sets of brackets.
2161 (string-match "[^[ ][^]]*" title)
2162 (setq title (match-string 0 title))
2163 (print title)
2164 title))
2165
2166
2167 (defun org-dblock-write:keybind-dblock (arg)
2168 (let (output)
2169 (save-excursion
2170 (goto-char (org-find-entry-with-id "beginning-of-keybind-table-data"))
2171 (let* ((table-level (org-current-level))
2172 (keybind-level (1+ table-level))
2173 (prefixes (list "C-M-S-" "C-M-" "C-S-" "M-S-" "M-" "C-" "S-"))
2174 table-title
2175 previous-prefixes
2176 )
2177 (while (>= (org-current-level) table-level)
2178 (setq table-title (get-title))
2179 (outline-next-heading)
2180 (let (found-prefixes
2181 found-all-prefixes)
2182 ;; go through the first few elements of the table to find out what column headings aka prefixes it should have
2183 (save-excursion
2184 (while (not found-all-prefixes)
2185 (let ((prefixes-copy prefixes)
2186 current-prefix
2187 found-prefix)
2188 (while (and prefixes-copy (not found-prefix))
2189 (setq current-prefix (car prefixes-copy))
2190 (when (and (> (length (get-title)) (length current-prefix))
2191 (string= (substring (get-title) 0 (length current-prefix)) current-prefix))
2192 (setq found-prefix t))
2193 (setq prefixes-copy (cdr prefixes-copy)))
2194 (unless found-prefix
2195 (setq current-prefix ""))
2196 (if (and found-prefixes (string= (car (last found-prefixes)) current-prefix))
2197 (setq found-all-prefixes t)
2198 (push current-prefix found-prefixes)))
2199 (outline-next-heading)))
2200 (setq found-prefixes (reverse found-prefixes))
2201
2202 ;; start a new table or repeat the prefixes in the current table
2203
2204 (if (or (not previous-prefixes) (equal previous-prefixes found-prefixes))
2205 (setq output (concat output "|-|\n| "))
2206 (setq output (concat output "|-|\n\n|-|\n| ")))
2207 (setq output (concat output table-title " | "))
2208 (setq previous-prefixes found-prefixes)
2209
2210 ;; add the prefixes
2211 (dolist (prefix found-prefixes)
2212 (setq output (concat output prefix "|")))
2213 (setq output (concat output "\n|-|\n"))
2214
2215
2216 (let (subtree-end)
2217 (while (>= (org-current-level) keybind-level)
2218 (dotimes (i (length found-prefixes))
2219 ;; add keybind name
2220 (when (= i 0)
2221 (setq output (concat output "| " (substring (get-title) (length (car found-prefixes))) " | ")))
2222 ;; add keybinds by searching for regex [keybind] to the start of the next heading
2223 (save-excursion
2224 (outline-next-heading)
2225 (setq subtree-end (point)))
2226 ;; skip over scheduled line
2227
2228 ;; see comment after source block to understand this regex
2229 (re-search-forward "^\\s-*\\([^*: ].*?$\\)" subtree-end t)
2230 (let ((m (match-string 1)))
2231 (when m
2232 (setq output (concat output "[[#" (org-custom-id-get (point) 'create) "][" m "]]")))
2233 (setq output (concat output " | ")))
2234 ;; advance to next keybind
2235 (outline-next-heading))
2236 (setq output (concat output "\n"))
2237 ))))))
2238 (setq output (concat output "|-|"))
2239 (insert output))
2240 (org-table-map-tables 'org-table-align 'quietly))
2241
2242
2243 #+END_SRC
2244 after source block due to bad parsing of comments in non emacs lisp mode
2245 some easily forgotten regex elements. whitespace: \\s-
2246 non-greedy star: *?
2247 subexpression for close bracket char or nothing: \\(\\]\\|\\)
2248
2249 * keybind tables
2250 :LOGBOOK:
2251 CLOCK: [2016-11-28 Mon 10:59]--[2016-11-28 Mon 10:59] => 0:00
2252 :END:
2253 dunno why but it takes doing ctrl-c twice to update this
2254 #+BEGIN: keybind-dblock
2255 |---------------------+------------------------|
2256 | single/special keys | |
2257 |---------------------+------------------------|
2258 | tab key | [[#6c10a716-1d8e-4ce4-8e26-64468f19c17a][isearch]] |
2259 | tab | [[#51ece189-1840-41a1-8ca0-19f9a0481895][isearch-forward]] |
2260 | end | [[#00d589b7-2b8e-494c-b761-3afefebe6ec6][move-end-of-line]] |
2261 | home | [[#7800e455-c3f6-4a8f-8907-b2292449ab67][back-to-indentation]] |
2262 | s-tab | [[#3072901e-5cf3-4d6e-9ac8-3ef64a5f6ad2][indent-buffer]] |
2263 | s-delete | [[#e53728b6-054d-4443-a03e-6cf02d13724d][send-shell]] |
2264 | s-left arrow | [[#d8c473ac-5507-4a6b-9e5a-46558c17b09f][shell]] |
2265 | s-right arrow | [[#cbae2b27-ff95-4b12-88e0-e1a0f7705db6][previous-buffer]] |
2266 | esc | |
2267 | return | [[#fab6adea-ed20-45ab-a0a3-776c68d5c3a5][new line]] |
2268 | s-return | [[#c433c837-24fa-45e1-8991-a4d380550ea0][auto-correct-prev-word]] |
2269 | down arrow | [[#7a868484-9c63-4a73-abda-7751cb2c02be][mark]] |
2270 | s-down arrow | [[#097b97e0-8ad8-40f7-8388-c4ace1706b38][extended command]] |
2271 | s-up arrow | |
2272 |---------------------+------------------------|
2273
2274 |-------------------+----------------------------+---------------------------------+--------------------+---------------+-------------+-------------|
2275 | mouse | | C- | M- | S- | C-M- | C-S- |
2276 |-------------------+----------------------------+---------------------------------+--------------------+---------------+-------------+-------------|
2277 | mouse-2 mode line | [[#69aaa631-6fb5-4beb-b2d8-c0f3d92c0a98][mouse-delete-other-windows]] | [[#501479ab-e1e2-497e-bd86-071f8afa3378][mouse-split-window-horizontally]] | | | | |
2278 | mouse-3 mode line | [[#917a1844-8c38-4f31-8616-50fc81334f2c][mouse-delete-window]] | | | | | |
2279 | mouse-1 | [[#4e60e2e4-8c2f-4450-8060-2d793ede530c][set cursor/mark]] | [[#b661f84f-57df-4095-9dc1-d1a876a53ee5][buffer list context menu]] | | | | |
2280 | mouse-2 | [[#086b0b50-054f-462d-92fa-b27852f887b0][paste]] | | | | | |
2281 | mouse-3 | [[#0481632e-9c50-4328-9365-c4b5bf967b66][set-mark]] | [[#9623c78f-7705-4cbe-a990-c24eb1067377][global menu]] | | | | |
2282 | mouse-9 | [[#efaec161-b279-4129-86fd-b410430926e4][move-mouse-to-point]] | | | | | |
2283 | mouse-8 | | | | | | |
2284 | 1/kp-end | | | | | | |
2285 | 2/kp-down | | | [[#50db5a06-452e-491f-875b-3de936a4d04a][smex]] | | | |
2286 | 3/kp-next | | | | | | |
2287 | 4/kp-left | [[#c44d0f65-9502-4cc6-9642-96d907f6b093][indent-region]] | | | | | |
2288 | 5/kp-begin | [[#2458c6bc-7113-4d4b-bbdf-206e1cb842a7][mark-defun]] | | | | | |
2289 | 6/kp-right | [[#3b79bc58-6067-43bd-9471-9d592744a25a][ibuffer]] | | | | | |
2290 | 7/kp-home | | | | | | |
2291 | 8/kp-up | | | | | | |
2292 | 9/kp-prior | [[#a3b51adb-4405-4d9f-9b88-a8faa479fbe7][delete-horizontal-space]] | | | | | |
2293 | 10/kp-insert | | | | | | |
2294 | 11/kp-subtract | | | | | | |
2295 | 12/kp-add | | | | | | |
2296 | scroll | [[#33433f0f-5b0e-46ba-8452-d2a51e54769b][up/dn / scroll]] | [[#38c594ca-1d13-441b-833c-ad47b27e7073][cycle recent buffers]] | [[#e1e2e253-450d-4620-af9e-78d378f49ad5][forward/back s-exp]] | [[#945cbcda-9a5a-4a9f-ad5c-4ede9a43656e][expand region]] | [[#10bc56d0-a6fe-4e2e-a287-1d280358ad1c][scroll]] | [[#fc79fff3-259e-416a-a62a-c237b30ade28][zoom]] |
2297 | left-scroll | [[#d2d5c5c7-f0de-4e08-953b-d41d3e282ba7][left/right]] | [[#7bb95aa5-381e-454a-a6c6-aaeec728db08][back / forward word]] | [[#3aeb5be7-6026-42f6-a65b-b00799e44642][winner undo redo]] | [[#ca5cdcd4-b3da-4d7b-86ab-4c7c0ac2caf7][---]] | [[#7f7103f5-2488-46a6-8530-6d8a558e6eff][unreachable]] | [[#7b4f1f49-6d93-4210-a30c-8278d6e63655][unreachable]] |
2298 |-------------------+----------------------------+---------------------------------+--------------------+---------------+-------------+-------------|
2299
2300 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2301 | left primary | C- | M- | C-M- | C-S- |
2302 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2303 | 2 | [[#b7db9f5c-f31d-45fb-ac70-eb3ef9369d3d][copy-symbol]] | [[#53ecfda2-d9f6-4882-b7a2-9b3c859e3bcb][shell-cd-to-file]] | [[#33c4996d-92bc-4df0-b005-11553677be13][---]] | |
2304 | 3 | [[#401f56ff-6aba-4156-b128-f449b18c27af][dot-mode-execute]] | | [[#eb0cc3a8-b62e-4a24-9f84-cc8e854f91dd][recenter-top-bottom]] | |
2305 | q | [[#679fd3cd-c43b-409c-be36-4175a5f27cd3][org-cycle, comint previous arg]] | [[#9a186632-7b04-4af7-b7de-eaec87daf315][org-archive-to-archive-sibling]] | [[#1f5e9b63-7ce0-445c-a426-b41839585d38][quoted-insert]] | |
2306 | w | [[#20005b6d-9a9d-4b58-882c-7ce860c7a395][goto-t.org]] | [[#9531a0da-269f-4359-9124-e83fbf61a92f][org-clock-in]] | | |
2307 | e | [[#11e8f541-f0a0-4058-883a-98bd1e7b8c4d][copy-line]] | [[#74d0ed51-ddb5-488e-bf55-0f033916e319][org-clock-in-last]] | | |
2308 | r | [[#5088a8b2-a772-4660-a3b6-b8cca7099da6][isearch-backward]] | [[#8fe64424-1f11-4086-84b3-07c2af210c1c][org-clock-out]] | | |
2309 | a | [[#d57dd0ac-2251-44af-b232-30f8a2b0b198][copy-all]] | [[#77987ef8-6a18-4123-8ede-77bc766aa2aa][kmacro-start-macro-or-in...]] | [[#dd2c225e-2d18-4b95-bc30-765163a5e368][kmacro-end-or-call-macro]] | |
2310 | s | [[#f26dd0f5-0655-485f-8c76-e6dfc6abd947][C-x prefix]] | | [[#290ea04a-be99-416a-a95f-458045a91c93][split-window-vertically]] | |
2311 | d | [[#b699614a-9994-4fe7-b2c6-f0fe81b7ad2b][C-c prefix]] | | [[#d9f48fbe-0a32-4133-93fb-f43ff6ab0037][swap buffer]] | |
2312 | f | [[#2695ed8a-e0d3-4e84-8688-98e3c50723b0][kill-whole-line]] | [[#869f0aec-c739-4fb7-8e3a-8b55ab637765][print-var-at-point]] | [[#e7e4dd0b-418f-48ee-b366-9e733e3bec61][kill rest of line]] | |
2313 | g | [[#a58a1eda-43ed-437e-b483-5c312e0754a7][other-window / cancel]] | [[#a287d720-4419-4546-8262-1f377bb158d2][abort-recursive-edit]] | [[#327e18af-30b7-47e5-aa53-5f678788b4c1][gnus]] | |
2314 | z | [[#5c30ce7e-8bc6-45bf-b9b1-5c75334a3e27][undo-tree-undo]] | | | |
2315 | x | [[#ec1403d3-528e-41b1-a195-5563bc93e124][kill-region]] | [[#bb7c95d5-dd97-439d-bf1f-cdac98d11543][append-next-kill]] | [[#47cc90e3-335f-4c44-9f39-b732e5440664][append-next-kill]] | |
2316 | c | [[#400f06e1-8e45-443c-8d7b-3d1bb1176aab][copy]] | [[#7a265014-1e9c-4639-ad1d-26b3416379a8][org-capture]] | [[#503e0beb-6fda-4e94-9678-d58bd3cbbc8e][copy-to-register]] | |
2317 | v | [[#16411f68-7fe0-49e8-9a73-212471594f9e][yank]] | [[#fe04fffa-6f85-483a-b329-938531109c35][insert-register]] | [[#c559e9ea-1218-4ccb-9c3a-74cbac4be220][yank pop]] | |
2318 | b | [[#3090fb11-9a11-47e5-bc98-080ebd250d37][delete-other-windows]] | [[#c18b9197-3d52-45a6-9d20-50d18fe1e7a7][isearch-backward-current-symbol]] | [[#e9dd549f-d031-418a-a0d5-30cf85e91c37][isearch-current-symbol]] | |
2319 | tab | [[#928505cb-707c-47ba-af54-5ae1df2ee07d][yas-insert-snippet]] | [[#64f91d86-afa9-4500-8d7d-ce8b2668726b][indent line]] | | |
2320 | delete | [[#e3d8653e-2282-4e3a-a4f5-29211ba2e647][kill-symbol]] | | [[#d9664937-d61c-4cc8-89c6-7f2182655c20][kill-sexp]] | |
2321 | left-arrow | [[#601c8172-f9b7-4e36-88ab-c66c2911b4d7][compile]] | | [[#91ddc121-db27-4f1c-a9ec-a4d29b96a7d2][org-shiftup]] | |
2322 | right-arrow | [[#5f66f60b-adcd-45dc-86b2-5d1225e2455c][paste selection]] | | [[#fc2147b4-a19a-4fde-bb53-e7ac28f0bfa1][org-shiftdown]] | |
2323 | backspace | [[#96f90a00-2260-4340-ae03-f4a86bd65502][backward-kill-symbol]] | | [[#606b0991-7431-4a8a-a909-b872e104cc88][backward-kill-sexp]] | |
2324 | f7 | | | | |
2325 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2326 | right primary | C- | M- | C-M- | C-S- |
2327 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2328 | * | [[#045c374c-b03e-42cb-b274-0f30c81fe3f3][split-window-horizontally]] | | [[#05cf6230-9263-4fd4-9812-4f32009eed46][calc-dispatch]] | |
2329 | 9 | [[#43d14154-2722-4ba5-b547-1b78c6274ebf][delete-window-or-exit]] | [[#ed93f5b8-2c7f-46f8-8d84-2e10d9bc8f87][kill-buffer-and-window]] | [[#37ef629b-fdbc-4d0b-bfa0-335eb1d408ee][kill client buffer]] | |
2330 | u | [[#327992c0-6eba-4935-aec1-49871c2a8619][universal-argument]] | | [[#7af825b1-92d8-4d5d-aaa1-8b4b466ea2e0][search-keybind]] | |
2331 | i | [[#3124e200-1d6e-4ad2-9a36-0d03e1e7dc38][-----]] | | [[#b2cc7cdd-c177-4ef2-af43-28ca7a338fda][query-replace-regexp]] | |
2332 | o | [[#b87a2c8a-7eb3-4661-9b28-589d14206c41][occur]] | | [[#d30ac3cd-1963-4bd0-8052-98e12b6524b0][counsel-imenu]] | |
2333 | p | [[#d84de055-e92e-478d-bb39-bc39acfa1586][move-mouse-to-point]] | | [[#08e65732-2fb1-4a78-9d18-cee87eb867a7][delete-horizontal-space]] | |
2334 | j | [[#ca1ce86b-dcea-45c1-9a8e-dd4f306776e8][pop-to-mark]] | [[#b92414e2-0d5b-4576-8fa5-5e7f1e32819a][previous-error]] | [[#8fe7cac2-ab1a-4b39-aced-10c5e0157e68][register prefix]] | |
2335 | k | [[#eb1c2360-bfd4-4d5c-b789-11b5ca5ba475][jump to register]] | [[#9061b192-735a-4273-ae36-993e6fad9205][next-error]] | [[#e1d768be-6b9b-4322-931f-3e570376ae15][man]] | |
2336 | l | [[#137995db-ee30-4738-90e2-54dcd5cadcf2][ivy-switch-buffer]] | | [[#56fcff3b-ffd9-4280-a226-4b58558906b8][move cursor top bottom mid]] | |
2337 | ; | [[#150bef9a-3faa-4c72-a176-88c3be56f612][comment-dwim]] | [[#211e76d9-d89a-4cc6-abce-69397d456fda][comment-dwim]] | [[#17035e1e-bbe6-44a6-ad54-6a39b04feac3][comment-current-line-dwim]] | |
2338 | m | | | [[#9a6a1998-4ed6-485e-9b2d-c36a42d7ec1a][recursive grep]] | |
2339 | , | [[#e4f617b2-d3f1-47e4-ae7f-2d64c4fd47b9][counsel-find-file]] | | [[#e0691924-11e1-48d2-abee-27945a409676][find-file-in-project]] | |
2340 | . | [[#6e97b7f1-c5cf-48bb-9c09-db1950dc1eae][recentf-ido-find-file]] | | [[#824d422c-67b6-4d68-af11-6a2135e528f5][-]] | |
2341 | / | [[#941a7fa8-84b9-434d-89a0-1487385ec479][join lines]] | | [[#37f67593-4f60-4d3b-9aad-6c9bc4882443][copy-variable]] | |
2342 | 8 | [[#45644cfa-d408-4a69-a97a-545ef46ba656][calc-embedded-word]] | | | |
2343 | up-arrow | [[#2dade04a-8ac7-483c-8675-5268af6eca2b][back defun/headline]] | | | [[#572d6618-471a-43c7-8a50-3f5e56f45cd7][winner undo]] |
2344 | down-arrow | [[#a1f25c12-3523-45bd-9bf5-62bf3cd5ca43][forward dfun/headline]] | | [[#57a09286-94c6-4b9f-953a-7368743f95ec][toggle-mark-activation]] | [[#9c87093b-7e30-44fb-83c9-c1b176074a5d][smex-major-mode-commands]] |
2345 | lbracket | [[#9d9916dd-3280-47dd-aab1-cd28d5ebfe15][----]] | | [[#c10b53e9-657c-48f4-8afb-cad0e709bcd6][scroll-right]] | |
2346 | rbracket | [[#21b38c6b-3a46-4a08-8eca-d44abb148287][fill-paragraph]] | | [[#095c3d97-bc49-419a-a8c0-c7a21d46d980][scroll-left]] | |
2347 | return | [[#db6e4c41-c048-4bef-b0c9-e129464c056d][newline next line]] | [[#10b2591a-5628-46ee-b395-682e91efcb83][non-indented newline]] | [[#1fc4f025-719f-4866-a9ab-23b30e4581b1][open newline on previous line]] | |
2348 | space | [[#b7d5a893-3045-4968-a150-cb813fddfe9e][org-edit-special]] | | [[#47b5912e-edc7-42ec-841b-f0e202b7f593][spell check word]] | |
2349 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2350 | left secondary | C- | M- | C-M- | C-S- |
2351 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2352 | = | | | | |
2353 | 1 | | | | |
2354 | 4 | | | [[#2d4de3c9-9e0c-4ab4-89e3-e41bfed3c9a7][widen]] | |
2355 | 5 | | | | |
2356 | tab-key | [[#2f527321-7f78-421b-b0c4-6fc810da0246][query-replace]] | | | |
2357 | t | [[#3bcdf4a3-f33c-4dad-ba94-e4fd3775eca6][org change todo state]] | | [[#47c64b9c-346d-45ad-8c38-865fe22d31a6][org insert timestamp]] | |
2358 | home | [[#1919659a-b466-4519-9276-8bf06a916066][start of buffer]] | | | |
2359 | end | [[#0a7bd629-cbcc-4761-8fe2-cc9370b985a4][end of buffer]] | | | |
2360 | f9 | | | | |
2361 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2362 | right secondary | C- | M- | C-M- | C-S- |
2363 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2364 | 6 | [[#e44e584b-d925-4036-9ad5-a90d02e74bef][save-buffers-kill-emacs]] | | [[#da73de75-0914-4f48-81d5-9b408433b14b][insert-small-copyright]] | |
2365 | 7 | | | [[#a68c6b8e-9911-475e-ab35-e239771fe881][insert-full-copyright]] | |
2366 | 0 | [[#96ae2fcc-3a0c-40c4-aef8-06aff3fd42be][text-scale-reset]] | | [[#0e7f83a5-600e-4016-af98-95904300c016][insert-apache]] | |
2367 | - | | | [[#6febc7ea-9cc7-488c-af34-538b8e69633b][org-edit-src-exit]] | |
2368 | y | [[#97aee7f1-3647-4602-a65a-45e8a3aa3a7c][undo-tree-redo]] | | | |
2369 | \ | [[#69005926-08ab-4adc-a163-44fed609cc95][sr-speedbar-toggle]] | | [[#27045e96-59a3-45b4-b0ff-6247aa5ed47e][mark-defun]] | |
2370 | h | [[#3c5f241f-fc62-459d-ab85-6b7c1fb04801][help-prefix]] | | | |
2371 | ' | [[#9f252721-a2d5-46c6-b268-8ed597256229][eval-expression]] | | | |
2372 | n | [[#65ac9206-1a67-48dc-8b72-26d763d7bf2b][unpop-to-mark-command]] | | [[#34fb8fbd-42dc-46b0-8c3c-c7e51edc9687][narrow-to-region]] | |
2373 | rshift | | | | |
2374 | escape | [[#da8bae21-a7be-45de-8027-1b26e6285e40][find-tag]] | | | |
2375 |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
2376 #+END:
2377
2378
2379 * keybind notes
2380 common keys, which would be better off doing swaps than rebinds:
2381 c-x prefix -> c-s
2382 c-c prefix -> c-d
2383 yank c-y -> c-c
2384 search c-s -> kp-add
2385 kill line c-k -> c-f
2386 undo c-_ -> c-z
2387 set-mark-command c-@ -> kp-enter
2388 quoted-insert c-q -> c-m-q
2389 recenter-top-bottom c-l -> c-m-3
2390 kill-region c-w -> c-x
2391
2392 commands to make less accessible
2393 narrow-to-defun/subtree -> M-2 maybe
2394 occur
2395
2396 command to make more accessible, ...
2397
2398
2399 * TESTING / DEVELOPMENT AREA
2400
2401 (defun comint-send-string (process string)
2402 "Like `process-send-string', but also does extra bookkeeping for Comint mode."
2403 (if process
2404 (with-current-buffer (if (processp process)
2405 (process-buffer process)
2406 (get-buffer process))
2407 (comint-snapshot-last-prompt))
2408 (comint-snapshot-last-prompt))
2409 (process-send-string process string))
2410
2411