1 #+TITLE: Emacs Configuration file
3 #+EMAIL: seudut@gmail.com
7 Most config are just copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s and [[https://github.com/abo-abo/oremacs][abo-abo's]] dotfiles
11 ** Setting loading Path
13 Set system PATH and emacs exec path
15 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
17 (setenv "PATH" (concat (getenv "PATH")
19 ":" "/Library/TeX/texbin"))
20 (setq exec-path (append exec-path '("/usr/local/bin")))
21 (setq exec-path (append exec-path '("/Library/TeX/texbin/")))
25 Set the emacs load path
27 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
28 ;; (add-to-list 'load-path "~/.emacs.d/elisp")
31 ** Package Initialization
33 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
37 (setq package-archives '(("mepla" . "http://melpa.milkbox.net/packages/")
38 ("gnu" . "http://elpa.gnu.org/packages/")
39 ("org" . "http://orgmode.org/elpa/")))
47 Disable scroll bar, tool-bar and menu-bar
49 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
54 ;; (setq debug-on-error t)
55 (setq inhibit-startup-message t)
57 (defalias 'yes-or-no-p 'y-or-n-p)
60 (setq make-backup-files nil)
65 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
67 (setq custom-file "~/.emacs.d/custom.el")
68 (if (file-exists-p custom-file)
73 Switch the focus to help window when it appears
75 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
77 (setq help-window-select t)
81 Setting scroll right/left
82 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
83 ; (global-set-key (kbd "C-,") 'scoll-left)
84 ; (global-set-key (kbd "C-.") 'scoll-right)
87 Set default window size
88 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
89 (setq initial-frame-alist
95 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
96 (setq auto-save-default nil)
98 ;; restore last session
99 ;; (desktop-save-mode t)
102 * Package Management Tools
106 Using [[https://github.com/jwiegley/use-package][use-package]] to manage emacs packages
108 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
110 (unless (package-installed-p 'use-package)
111 (package-refresh-contents)
112 (package-install 'use-package))
114 (require 'use-package)
120 [[https://github.com/dimitri/el-get][El-get]] is package management tool, whicl allows to install external elisp package from any git repository not in mepla.
121 Check out [[http://tapoueh.org/emacs/el-get.html][el-get]].
123 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
128 (add-to-list 'load-path "~/.emacs.d/el-get"))
132 * Color and Fonts Settings
134 ** highlight current line
136 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
138 (global-hl-line-mode)
144 [[https://github.com/paldepind/smart-comment][smart-comments]]
146 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
148 (use-package smart-comment
150 :bind ("M-;" . smart-conmment))
158 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
160 (global-font-lock-mode 1)
164 [[https://github.com/i-tu/Hasklig][Hasklig]] and Source Code Pro, defined fonts family
166 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
169 (defvar sd/fixed-font-family
170 (cond ((x-list-fonts "Hasklig") "Hasklig")
171 ((x-list-fonts "Source Code Pro") "Source Code Pro:weight:light")
172 ((x-list-fonts "Anonymous Pro") "Anonymous Pro")
173 ((x-list-fonts "M+ 1mn") "M+ 1mn"))
174 "The fixed width font based on what is installed, `nil' if not defined."))
180 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
183 (when sd/fixed-font-family
184 (set-frame-font sd/fixed-font-family)
185 (set-face-attribute 'default nil :font sd/fixed-font-family :height 130)
186 (set-face-font 'default sd/fixed-font-family)))
192 Loading theme should be after all required loaded, refere [[https://github.com/jwiegley/use-package][:defer]] in =use-package=
194 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
196 (setq vc-follow-symlinks t)
198 (use-package color-theme
200 :init (require 'color-theme)
201 :config (use-package color-theme-sanityinc-tomorrow
205 (load-theme 'sanityinc-tomorrow-bright t)))
207 ;(eval-after-load 'color-theme
208 ; (load-theme 'sanityinc-tomorrow-bright t))
212 Change the Org-mode colors
214 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
216 (defun org-src-color-blocks-light ()
217 "Colors the block headers and footers to make them stand out more for lighter themes"
220 '(org-block-begin-line
221 ((t (:underline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
222 '(org-block-background
223 ((t (:background "#FFFFEA"))))
225 ((t (:background "#FFFFEA"))))
227 ((t (:overline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
229 '(mode-line-buffer-id ((t (:foreground "#005000" :bold t))))
230 '(which-func ((t (:foreground "#008000"))))))
232 (defun org-src-color-blocks-dark ()
233 "Colors the block headers and footers to make them stand out more for dark themes"
236 '(org-block-begin-line
237 ((t (:foreground "#008ED1" :background "#002E41"))))
238 '(org-block-background
239 ((t (:background "#000000"))))
241 ((t (:background "#000000"))))
243 ((t (:foreground "#008ED1" :background "#002E41"))))
245 '(mode-line-buffer-id ((t (:foreground "black" :bold t))))
246 '(which-func ((t (:foreground "green"))))))
248 (org-src-color-blocks-dark)
252 improve color for org-mode
253 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
254 (deftheme ha/org-theme "Sub-theme to beautify org mode")
257 (defvar sd/variable-font-tuple
258 (cond ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
259 ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
260 ((x-list-fonts "Verdana") '(:font "Verdana"))
261 ((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
262 (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro.")))
263 "My variable width font available to org-mode files and whatnot."))
265 (defun sd/org-color ()
266 (let* ((sd/fixed-font-tuple (list :font sd/fixed-font-family))
267 (base-font-color (face-foreground 'default nil 'default))
268 (background-color (face-background 'default nil 'default))
269 (primary-color (face-foreground 'mode-line nil))
270 (secondary-color (face-background 'secondary-selection nil 'region))
271 (base-height (face-attribute 'default :height))
272 (headline `(:inherit default :weight bold :foreground ,base-font-color)))
273 (custom-theme-set-faces 'ha/org-theme
274 `(org-agenda-structure ((t (:inherit default :height 2.0 :underline nil))))
275 `(org-verbatim ((t (:inherit 'fixed-pitched :foreground "#aef"))))
276 `(org-table ((t (:inherit 'fixed-pitched))))
277 `(org-block ((t (:inherit 'fixed-pitched))))
278 `(org-block-background ((t (:inherit 'fixed-pitched))))
279 `(org-block-begin-line ((t (:inherit 'fixed-pitched))))
280 `(org-block-end-line ((t (:inherit 'fixed-pitched))))
281 `(org-level-8 ((t (,@headline ,@sd/variable-font-tuple))))
282 `(org-level-7 ((t (,@headline ,@sd/variable-font-tuple))))
283 `(org-level-6 ((t (,@headline ,@sd/variable-font-tuple))))
284 `(org-level-5 ((t (,@headline ,@sd/variable-font-tuple))))
285 `(org-level-4 ((t (,@headline ,@sd/variable-font-tuple
286 :height ,(round (* 1.1 base-height))))))
287 `(org-level-3 ((t (,@headline ,@sd/variable-font-tuple
288 :height ,(round (* 1.25 base-height))))))
289 `(org-level-2 ((t (,@headline ,@sd/variable-font-tuple
290 :height ,(round (* 1.5 base-height))))))
291 `(org-level-1 ((t (,@headline ,@sd/variable-font-tuple
292 :height ,(round (* 1.75 base-height))))))
293 `(org-document-title ((t (,@headline ,@sd/variable-font-tuple :height 1.5 :underline nil)))))))
300 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
302 (use-package rainbow-delimiters
305 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
311 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
313 (use-package page-break-lines
316 (turn-on-page-break-lines-mode))
322 Enable rainbow mode in emacs lisp mode
324 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
325 (use-package rainbow-mode
328 ; (add-hook emacs-lisp-mode-hook 'rainbow-mode)
337 clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][Marstering Emacs]]
339 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
340 (defvar mode-line-cleaner-alist
341 `((auto-complete-mode . " α")
342 (yas/minor-mode . " Ï…")
343 (paredit-mode . " π")
346 (projectile-mode . "")
348 (undo-tree-mode . "")
350 (which-key-mode . "")
352 (smartparens-mode . "")
354 (linum-relative-mode . "")
356 (auto-revert-mode . "")
358 (org-indent-mode . "")
362 (lisp-interaction-mode . "λ")
365 (emacs-lisp-mode . "EL")
367 (nxhtml-mode . "nx"))
368 "Alist for `clean-mode-line'.
370 When you add a new element to the alist, keep in mind that you
371 must pass the correct minor/major mode symbol and a string you
372 want to use in the modeline *in lieu of* the original.")
375 (defun clean-mode-line ()
377 (loop for cleaner in mode-line-cleaner-alist
378 do (let* ((mode (car cleaner))
379 (mode-str (cdr cleaner))
380 (old-mode-str (cdr (assq mode minor-mode-alist))))
382 (setcar old-mode-str mode-str))
384 (when (eq mode major-mode)
385 (setq mode-name mode-str)))))
388 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
393 Install powerline mode [[https://github.com/milkypostman/powerline][powerline]]
395 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
396 (use-package powerline
399 ;; (powerline-center-theme)
402 ;; (use-package smart-mode-line
404 ;; (use-package smart-mode-line-powerline-theme
408 Revised powerline-center-theme
409 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
410 (defun sd/powerline-simpler-vc (s)
412 (replace-regexp-in-string "Git[:-]" "" s)
415 (defface sd/powerline-active1 '((t (:background "yellow" :foreground "black" :inherit mode-line)))
416 "My Powerline face 1 based on powerline-active1."
419 (defface sd/buffer-modified-active1 '((t (:background "red" :foreground "black" :inherit mode-line)))
420 "My Powerline face 1 based on powerline-active1."
423 (defface sd/buffer-view-active1 '((t (:background "green" :foreground "black" :inherit mode-line)))
424 "My Powerline face 1 based on powerline-active1."
427 (defface sd/mode-line-buffer-id
428 '((t (:background "yellow" :foreground "black" :inherit mode-line-buffer-id)))
429 "My powerline mode-line face, based on mode-line-buffer-id"
432 ;; Don't show buffer modified for scratch and eshell mode
433 (defun sd/buffer-show-modified ()
434 "Dot not show modified indicator for buffers"
436 (unless (or (string-match "*scratch*" (buffer-name))
437 (equal major-mode 'eshell-mode))
440 (defun sd/powerline-center-theme_revised ()
441 "Setup a mode-line with major and minor modes centered."
443 (setq-default mode-line-format
446 (let* ((active (powerline-selected-window-active))
447 (mode-line-buffer-id (if active 'sd/mode-line-buffer-id 'mode-line-buffer-id-inactive))
448 (mode-line (if active 'mode-line 'mode-line-inactive))
449 (my-face1 (if active 'sd/powerline-active1 'powerline-inactive1))
450 (my-face-buffer-modified (if (and (sd/buffer-show-modified) (buffer-modified-p))
451 'sd/buffer-modified-active1
452 (if buffer-read-only 'sd/buffer-view-active1
454 (face1 (if active 'powerline-active1 'powerline-inactive1))
455 (face2 (if active 'powerline-active2 'powerline-inactive2))
456 (separator-left (intern (format "powerline-%s-%s"
457 (powerline-current-separator)
458 (car powerline-default-separator-dir))))
459 (separator-right (intern (format "powerline-%s-%s"
460 (powerline-current-separator)
461 (cdr powerline-default-separator-dir))))
462 (lhs (list (powerline-raw "%* " my-face-buffer-modified 'l)
463 ;; (powerline-buffer-size mode-line 'l)
464 (powerline-buffer-id mode-line-buffer-id 'l)
465 (powerline-raw " " my-face1)
466 (funcall separator-left my-face1 face1)
467 (powerline-narrow face1 'l)
468 ;; (powerline-vc face1)
469 (sd/powerline-simpler-vc (powerline-vc face1))))
470 (rhs (list (powerline-raw global-mode-string face1 'r)
471 (powerline-raw "%4l" face1 'r)
472 (powerline-raw ":" face1)
473 (powerline-raw "%3c" face1 'r)
474 (funcall separator-right face1 my-face1)
475 ;; (powerline-raw " " my-face1)
476 (powerline-raw (format-time-string " %I:%M %p ") my-face1 'r)
477 ;; (powerline-raw "%6p" my-face1 'r)
478 ;; (powerline-hud my-face1 face1 )
480 (center (list (powerline-raw " " face1)
481 (funcall separator-left face1 face2)
482 (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
483 (powerline-raw erc-modified-channels-object face2 'l))
484 (powerline-major-mode face2 'l)
485 (powerline-process face2)
486 (powerline-raw " :" face2)
487 (powerline-minor-modes face2 'l)
488 (powerline-raw " " face2)
489 (funcall separator-right face2 face1))))
490 (concat (powerline-render lhs)
491 (powerline-fill-center face1 (/ (powerline-width center) 2.0))
492 (powerline-render center)
493 (powerline-fill face1 (powerline-width rhs))
494 (powerline-render rhs)))))))
496 (sd/powerline-center-theme_revised)
499 Fix the issue in mode line when showing triangle
500 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
501 (setq ns-use-srgb-colorspace nil)
504 set height in mode line
505 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
506 (set-variable 'powerline-height 14)
507 (set-variable 'powerline-text-scale-factor (/ (float 100) 140))
508 ;; (custom-set-variables
509 ;; '(powerline-height 14)
510 ;; '(powerline-text-scale-factor (/ (float 100) 140)))
512 (set-face-attribute 'mode-line nil :height 100)
519 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
523 :init (setq ido-enable-flex-matching t
524 ido-ignore-extensions t
525 ido-use-virtual-buffers t
530 (add-to-list 'completion-ignored-extensions ".pyc"))
538 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
542 :init (setq ido-enable-flex-matching t
544 :config (flx-ido-mode 1))
549 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
550 (use-package ido-vertical-mode
553 (setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
555 (ido-vertical-mode 1))
560 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
564 :init (smex-initialize)
567 ("M-X" . smex-major-mode-commands))
573 Use [[https://github.com/DarwinAwardWinner/ido-ubiquitous][ido-ubiquitous]] for ido everywhere. It makes =describe-function= can also use ido
575 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
577 (use-package ido-ubiquitous
580 (setq magit-completing-read-function 'magit-ido-completing-read)
581 (setq gnus-completing-read-function 'gnus-ido-completing-read)
583 (ido-ubiquitous-mode 1))
588 [[https://github.com/waymondo/ido-exit-target][ido-exit-target]] let you open file/buffer on =other-windows= when call =ido-switch-buffer=
589 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
590 (use-package ido-exit-target
593 (mapcar (lambda (map)
594 (define-key map (kbd "C-j") #'ido-exit-target-split-window-right)
595 (define-key map (kbd "C-k") #'ido-exit-target-split-window-below))
596 (list ido-buffer-completion-map
597 ;; ido-common-completion-map
598 ido-file-completion-map
599 ido-file-dir-completion-map)))
602 * Normal Text Operation
605 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
606 (use-package undo-tree
609 (define-key undo-tree-visualizer-mode-map "j" 'undo-tree-visualize-redo)
610 (define-key undo-tree-visualizer-mode-map "k" 'undo-tree-visualize-undo)
611 (define-key undo-tree-visualizer-mode-map "h" 'undo-tree-visualize-switch-branch-left)
612 (define-key undo-tree-visualizer-mode-map "l" 'undo-tree-visualize-switch-branch-right)
613 (global-undo-tree-mode 1))
615 (global-set-key (kbd "s-u") 'undo-tree-visualize)
619 Stolen from [[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-spelling.el][here]], hunspell will search dictionary in =DICPATH=
620 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
621 (setenv "DICPATH" "/usr/local/share/hunspell")
623 (when (executable-find "hunspell")
624 (setq-default ispell-program-name "hunspell")
625 (setq ispell-really-hunspell t))
627 ;; (defun text-mode-hook-setup ()
628 ;; ;; Turn off RUN-TOGETHER option when spell check text-mode
629 ;; (setq-local ispell-extra-args (flyspell-detect-ispell-args)))
630 ;; (add-hook 'text-mode-hook 'text-mode-hook-setup)
631 ;; (add-hook 'text-mode-hook 'flyspell-mode)
633 ;; enable flyspell check on comments and strings in progmamming modes
634 ;; (add-hook 'prog-mode-hook 'flyspell-prog-mode)
636 ;; I don't use the default mappings
637 (with-eval-after-load 'flyspell
638 (define-key flyspell-mode-map (kbd "C-;") nil)
639 (define-key flyspell-mode-map (kbd "C-,") nil)
640 (define-key flyspell-mode-map (kbd "C-.") nil))
643 Make flyspell enabled for org-mode, see [[http://emacs.stackexchange.com/questions/9333/how-does-one-use-flyspell-in-org-buffers-without-flyspell-triggering-on-tangled][here]]
644 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
645 ;; NO spell check for embedded snippets
646 (defadvice org-mode-flyspell-verify (after org-mode-flyspell-verify-hack activate)
647 (let ((rlt ad-return-value)
648 (begin-regexp "^[ \t]*#\\+begin_\\(src\\|html\\|latex\\)")
649 (end-regexp "^[ \t]*#\\+end_\\(src\\|html\\|latex\\)")
652 (when ad-return-value
654 (setq old-flag case-fold-search)
655 (setq case-fold-search t)
656 (setq b (re-search-backward begin-regexp nil t))
657 (if b (setq e (re-search-forward end-regexp nil t)))
658 (setq case-fold-search old-flag))
659 (if (and b e (< (point) e)) (setq rlt nil)))
660 (setq ad-return-value rlt)))
664 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
665 (use-package expand-region
668 (global-set-key (kbd "C-=") 'er/expand-region))
675 Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
677 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
679 (define-key minibuffer-local-map [escape] 'keyboard-escape-quit)
680 (define-key minibuffer-local-map [escape] 'keyboard-escape-quit)
681 (define-key minibuffer-local-ns-map [escape] 'keyboard-escape-quit)
682 (define-key minibuffer-local-isearch-map [escape] 'keyboard-escape-quit)
683 (define-key minibuffer-local-completion-map [escape] 'keyboard-escape-quit)
684 (define-key minibuffer-local-must-match-map [escape] 'keyboard-escape-quit)
685 (define-key minibuffer-local-must-match-filename-map [escape] 'keyboard-escape-quit)
686 (define-key minibuffer-local-filename-completion-map [escape] 'keyboard-escape-quit)
687 (define-key minibuffer-local-filename-must-match-map [escape] 'keyboard-escape-quit)
689 ;; Also map s-h same as C-g
690 (define-key minibuffer-local-map (kbd "s-h") 'keyboard-escape-quit)
694 ** =Super= bindings for file, buffer and windows
696 Some global bindings on =Super=, on Mac, it is =Command=
698 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
699 (defun sd/delete-current-window ()
701 (if (> (length (window-list)) 1)
703 (message "Only one Windows now!")))
705 (global-set-key (kbd "s-h") 'keyboard-quit)
706 (global-set-key (kbd "s-j") 'ido-switch-buffer)
707 (global-set-key (kbd "s-k") 'ido-find-file)
708 (global-set-key (kbd "s-l") 'sd/delete-current-window)
710 ;; (global-set-key (kbd "s-/") 'swiper)
712 ;; s-' --> 'next-multiframe-window
713 (global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
715 (global-set-key (kbd "s-f") 'projectile-find-file)
717 (global-set-key (kbd "s-`") 'mode-line-other-buffer)
719 (global-set-key (kbd "s-n") 'persp-next)
720 (global-set-key (kbd "s-p") 'persp-prev)
722 (global-set-key (kbd "s-=") 'text-scale-increase)
723 (global-set-key (kbd "s--") 'text-scale-decrease)
725 ;; (global-set-key (kbd "s-u") 'undo-tree-visualize)
728 ;; someothers default mapping on super (command) key
730 ;; s-k kill-this-buffer
733 ;; s-h --> ns-do-hide-emacs
734 ;; s-j --> ido-switch-buffer +
735 ;; s-k --> kill-this-buffer
738 ;; s-' --> next-multiframe-window
739 ;; s-ret --> toggle-frame-fullscreen +
741 ;; s-y --> ns-paste-secondary
742 ;; s-u --> revert-buffer
743 ;; s-i --> undefined - but used for iterm globally
744 ;; s-o --> used for emacs globally
745 ;; s-p --> projectile-persp-switch-project +
746 ;; s-[ --> next-buffer +
747 ;; s-] --> previous-buffer +
754 ;; s-- --> center-line
757 ;; s-n --> make-frame
758 ;; s-m --> iconify-frame
764 ;; s-g --> isearch-repeat-forward
765 ;; s-f --> projectile-find-file +
766 ;; s-d --> isearch-repeat-background
767 ;; s-s --> save-buffer
768 ;; s-a --> make-whole-buffer
772 ;; s-c --> ns-copy-including-secondary
774 ;; s-t --> ns-popup-font-panel
776 ;; s-e --> isearch-yanqk-kill
777 ;; s-w --> delete-frame
778 ;; s-q --> same-buffers-kill-emacs
780 ;; s-` --> other-frame
783 ** Search Replace and highlight
785 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
790 (setq ivy-use-virtual-buffers t)
791 (global-set-key (kbd "s-/") 'swiper)
797 ;; (global-set-key "\C-s" 'swiper)
798 ;; (global-set-key (kbd "C-c C-r") 'ivy-resume)
799 ;; (global-set-key (kbd "<f6>") 'ivy-resume)
800 (global-set-key (kbd "M-x") 'counsel-M-x)
801 ;; ;; (global-set-key (kbd "C-x C-f") 'counsel-find-file)
802 (global-set-key (kbd "C-h f") 'counsel-describe-function)
803 (global-set-key (kbd "C-h v") 'counsel-describe-variable)
804 ;; (global-set-key (kbd "<f1> l") 'counsel-load-library)
805 ;; (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
806 ;; (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
807 ;; (global-set-key (kbd "C-c g") 'counsel-git)
808 ;; (global-set-key (kbd "C-c j") 'counsel-git-grep)
809 ;; (global-set-key (kbd "C-c k") 'counsel-ag)
810 ;; (global-set-key (kbd "C-x l") 'counsel-locate)
811 ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
812 ;; ;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
815 'ivy-current-match nil
821 use the prefix =M-s= for searching in buffers
822 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
823 (defun sd/make-keymap (key bindings)
824 (setq keymap (make-sparse-keymap))
825 (dolist (binding bindings)
826 (define-key keymap (car binding) (cdr binding)))
827 (global-set-key key keymap))
829 (use-package highlight-symbol
832 (sd/make-keymap "\M-s"
833 '(("w" . save-buffer)
834 ;; ("\M-w" . save-buffer)
835 ("e" . revert-buffer)
836 ("s" . isearch-forward-regexp)
837 ("\M-s" . isearch-forward-regexp)
838 ("r" . isearch-backward-regexp)
839 ("." . isearch-forward-symbol-at-point)
841 ;; ("h" . highlight-symbol-at-point)
842 ("h" . highlight-symbol)
843 ("m" . highlight-regexp)
844 ("l" . highlight-lines-matching-regexp)
845 ("M" . unhighlight-regexp)
846 ("f" . keyboard-quit)
847 ("q" . keyboard-quit)))
849 ;; search and replace and highlight
850 (define-key isearch-mode-map (kbd "M-s") 'isearch-repeat-forward)
851 (define-key isearch-mode-map (kbd "M-r") 'isearch-repeat-backward)
852 (global-set-key (kbd "s-[") 'highlight-symbol-next)
853 (global-set-key (kbd "s-]") 'highlight-symbol-prev)
854 (global-set-key (kbd "s-\\") 'highlight-symbol-query-replace)
857 (define-key minibuffer-local-map "\M-s" nil)
859 (set-face-background 'ido-first-match "yellow")
861 ;; M-s M-w eww-search-words
871 ** Org-mode Basic setting
873 Always indents header, and hide header leading starts so that no need type =#+STATUP: indent=
875 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
879 (setq org-startup-indented t)
880 (setq org-hide-leading-starts t)
881 (setq org-src-fontify-natively t)
882 (setq org-src-tab-acts-natively t)
883 (setq org-confirm-babel-evaluate nil)
884 (setq org-use-speed-commands t)
885 (setq org-completion-use-ido t))
887 (org-babel-do-load-languages
888 'org-babel-load-languages
904 ;; use current window for org source buffer editting
905 (setq org-src-window-setup 'current-window )
907 (define-key org-mode-map (kbd "C-'") nil)
908 ;; C-M-i is mapped to imenu globally
909 (define-key org-mode-map (kbd "C-M-i") nil)
911 ;; set the ditta.jar path
912 (setq org-ditaa-jar-path "/usr/local/Cellar/ditaa/0.9/libexec/ditaa0_9.jar")
914 (file-exists-p org-ditaa-jar-path)
915 (error "seudut: ditaa.jar not found at %s " org-ditaa-jar-path))
920 use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 charactes
922 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
923 (use-package org-bullets
926 (add-hook 'org-mode-hook
928 (org-bullets-mode t))))
930 (setq org-bullets-bullet-list '("⦿" "✪" "◉" "○" "►" "◆"))
932 ;; increase font size when enter org-src-mode
933 (add-hook 'org-src-mode-hook (lambda () (text-scale-increase 2)))
938 [[https://github.com/abo-abo/worf][worf]] mode is an extension of vi-like binding for org-mode.
939 In =worf-mode=, it is mapping =[=, =]= as =worf-backward= and =worf-forward= in global, wich
940 cause we cannot input =[= and =]=, so here I unset this mappings. And redifined this two to
941 =M-[= and =M-]=. see this [[https://github.com/abo-abo/worf/issues/19#issuecomment-223756599][issue]]
943 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
948 :init (add-hook 'org-mode-hook 'worf-mode)
950 ;; (define-key worf-mode-map "[" nil)
951 ;; (define-key worf-mode-map "]" nil)
952 ;; (define-key worf-mode-map (kbd "M-[") 'worf-backward)
953 ;; (define-key worf-mode-map (kbd "M-]") 'worf-forward)
960 Refer to [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
965 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
966 (global-set-key "\C-cl" 'org-store-link)
967 (global-set-key "\C-ca" 'org-agenda)
968 (global-set-key "\C-cb" 'org-iswitchb)
973 Replace the list bullet =-=, =+=, with =•=, a litter change based [[https://github.com/howardabrams/dot-files/blob/master/emacs-org.org][here]]
975 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
976 ;; (use-package org-mode
978 ;; (font-lock-add-keywords 'org-mode
979 ;; '(("^ *\\([-+]\\) "
980 ;; (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))))
985 refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][fancy todo states]],
987 To track TODO state changes, the =!= is to insert a timetamp, =@= is to insert a note with
988 timestamp for the state change.
990 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
991 ;; (setq org-todo-keywords
992 ;; '((sequence "☛ TODO(t)" "|" "✔ DONE(d)")
993 ;; (sequence "âš‘ WAITING(w)" "|")
994 ;; (sequence "|" "✘ CANCELLED(c)")))
995 ; (setq org-todo-keyword-faces
996 ; (quote ("TODO" . (:foreground "red" :weight bold))
997 ; ("NEXT" . (:foreground "blue" :weight bold))
998 ; ("WAITING" . (:foreground "forest green" :weight bold))
999 ; ("DONE" . (:foreground "magenta" :weight bold))
1000 ; ("CANCELLED" . (:foreground "forest green" :weight bold))))
1003 (setq org-todo-keywords
1004 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
1005 ;; (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")
1006 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" ))))
1008 (setq org-todo-keyword-faces
1009 (quote (("TODO" :foreground "red" :weight bold)
1010 ("NEXT" :foreground "blue" :weight bold)
1011 ("DONE" :foreground "forest green" :weight bold)
1012 ("WAITING" :foreground "orange" :weight bold)
1013 ("HOLD" :foreground "magenta" :weight bold)
1014 ("CANCELLED" :foreground "forest green" :weight bold)
1015 ;; ("MEETING" :foreground "forest green" :weight bold)
1016 ;; ("PHONE" :foreground "forest green" :weight bold)
1020 Fast todo selections
1022 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1023 (setq org-use-fast-todo-selection t)
1024 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1027 TODO state triggers and tags, [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
1029 - Moving a task to =CANCELLED=, adds a =CANCELLED= tag
1030 - Moving a task to =WAITING=, adds a =WAITING= tag
1031 - Moving a task to =HOLD=, add =HOLD= tags
1032 - Moving a task to =DONE=, remove =WAITING=, =HOLD= tag
1033 - Moving a task to =NEXT=, remove all waiting/hold/cancelled tags
1035 This tags are used to filter tasks in agenda views
1036 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1037 (setq org-todo-state-tags-triggers
1038 (quote (("CANCELLED" ("CANCELLED" . t))
1039 ("WAITING" ("WAITING" . t))
1040 ("HOLD" ("WAITING") ("HOLD" . t))
1041 (done ("WAITING") ("HOLD"))
1042 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1043 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1044 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1048 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1049 ;; log time when task done
1050 ;; (setq org-log-done (quote time))
1051 ;; save clocking into to LOGBOOK
1052 (setq org-clock-into-drawer t)
1053 ;; save state change notes and time stamp into LOGBOOK drawer
1054 (setq org-log-into-drawer t)
1055 (setq org-clock-into-drawer "CLOCK")
1059 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1060 (setq org-tag-alist (quote ((:startgroup)
1066 ("CANCELLED" . ?c))))
1068 ;; Allow setting single tags without the menu
1069 (setq org-fast-tag-selection-single-key (quote expert))
1072 *** Capture - Refile - Archive
1074 Capture lets you quickly store notes with little interruption of your work flow.
1076 **** Capture Templates
1078 When a new taks needs to be added, categorize it as
1080 All captured file which need next actions are stored in =refile.org=,
1081 - A new task / note (t) =refile.org=
1082 - A work task in office =office.org=
1083 - A jourenl =diary.org=
1084 - A new habit (h) =refile.org=
1086 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1087 (setq org-directory "~/org")
1088 (setq org-default-notes-file "~/org/refile.org")
1089 (setq sd/org-diary-file "~/org/diary.org")
1091 (global-set-key (kbd "C-c c") 'org-capture)
1093 (setq org-capture-templates
1094 (quote (("t" "Todo" entry (file org-default-notes-file)
1095 "* TODO %?\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
1096 ("n" "Note" entry (file org-default-notes-file)
1097 "* %? :NOTE:\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
1098 ("j" "Journal" entry (file+datetree sd/org-diary-file)
1099 "* %?\n:LOGBOOK:\n:END:" :clock-in t :clock-resume t)
1100 ("h" "Habit" entry (file org-default-notes-file)
1101 "* NEXT %?\n:LOGBOOK:\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:END:\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n "))))
1106 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1107 (setq org-refile-targets (quote (;; (nil :maxlevel . 9)
1108 (org-agenda-files :maxlevel . 9))))
1110 (setq org-refile-use-outline-path t)
1112 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1116 Setting agenda files and the agenda view
1117 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1118 (setq org-agenda-files (quote ("~/org/gtd.org"
1121 ;; only show today's tasks in agenda view
1122 (setq org-agenda-span 'day)
1123 ;; Use current windows for agenda view
1124 (setq org-agenda-window-setup 'current-window)
1126 ;; show all feature entries for repeating tasks,
1127 ;; this is already setting by default
1128 (setq org-agenda-repeating-timestamp-show-all t)
1130 ;; Show all agenda dates - even if they are empty
1131 (setq org-agenda-show-all-dates t)
1136 Install MacTex-basic and some tex packages
1140 sudo tlmgr update --self
1142 sudo tlmgr install titlesec framed threeparttable wrapfig multirow enumitem bbding titling tabu mdframed tcolorbox textpos import varwidth needspace tocloft ntheorem environ trimspaces collection-fontsrecommended capt-of
1146 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1147 ;; ;; allow for export=>beamer by placing
1149 ;; http://emacs-fu.blogspot.com/2011/04/nice-looking-pdfs-with-org-mode-and.html
1150 ;; #+LaTeX_CLASS: beamer in org files
1151 (unless (boundp 'org-export-latex-classes)
1152 (setq org-export-latex-classes nil))
1153 (add-to-list 'org-export-latex-classes
1154 ;; beamer class, for presentations
1156 "\\documentclass[11pt]{beamer}\n
1157 \\mode<{{{beamermode}}}>\n
1158 \\usetheme{{{{beamertheme}}}}\n
1159 \\usecolortheme{{{{beamercolortheme}}}}\n
1160 \\beamertemplateballitem\n
1161 \\setbeameroption{show notes}
1162 \\usepackage[utf8]{inputenc}\n
1163 \\usepackage[T1]{fontenc}\n
1164 \\usepackage{hyperref}\n
1166 \\usepackage{listings}
1167 \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
1170 showspaces=false,showstringspaces=false,
1172 keywordstyle=\\color{blue}\\bfseries,
1173 commentstyle=\\color{red},
1175 \\usepackage{verbatim}\n
1176 \\institute{{{{beamerinstitute}}}}\n
1177 \\subject{{{{beamersubject}}}}\n"
1179 ("\\section{%s}" . "\\section*{%s}")
1181 ("\\begin{frame}[fragile]\\frametitle{%s}"
1183 "\\begin{frame}[fragile]\\frametitle{%s}"
1186 ;; letter class, for formal letters
1188 (add-to-list 'org-export-latex-classes
1191 "\\documentclass[11pt]{letter}\n
1192 \\usepackage[utf8]{inputenc}\n
1193 \\usepackage[T1]{fontenc}\n
1194 \\usepackage{color}"
1196 ("\\section{%s}" . "\\section*{%s}")
1197 ("\\subsection{%s}" . "\\subsection*{%s}")
1198 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1199 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1200 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1204 (require 'ox-beamer)
1206 (setq org-latex-pdf-process
1207 '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
1208 "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
1209 "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
1211 (setq TeX-parse-self t)
1213 (setq TeX-PDF-mode t)
1214 (add-hook 'LaTeX-mode-hook
1217 (setq TeX-master t)))
1223 extend org-mode's easy templates, refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][Extend org-modes' esay templates]]
1225 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1227 (add-to-list 'org-structure-template-alist
1228 '("E" "#+BEGIN_SRC emacs-lisp :tangle yes :results silent\n?\n#+END_SRC"))
1229 (add-to-list 'org-structure-template-alist
1230 '("S" "#+BEGIN_SRC sh\n?\n#+END_SRC"))
1231 (add-to-list 'org-structure-template-alist
1232 '("p" "#+BEGIN_SRC plantuml :file uml.png \n?\n#+END_SRC"))
1237 [[https://github.com/magit/magit][Magit]] is a very cool git interface on Emacs.
1238 and Defined keys, using vi keybindings, Refer abo-abo's setting [[https://github.com/abo-abo/oremacs/blob/c5cafdcebc88afe9e73cc8bd40c49b70675509c7/modes/ora-nextmagit.el][here]]
1239 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1243 ;; don't ask me to confirm the unsaved change
1244 (setq magit-save-repository-buffers nil)
1245 :commands magit-status magit-blame
1247 (dolist (map (list magit-status-mode-map
1250 magit-staged-section-map))
1251 (define-key map "j" 'magit-section-forward)
1252 (define-key map "k" 'magit-section-backward)
1253 (define-key map "D" 'magit-discard)
1254 (define-key map "O" 'magit-discard-file)
1255 (define-key map "n" nil)
1256 (define-key map "p" nil)
1257 (define-key map "v" 'recenter-top-bottom)
1258 (define-key map "i" 'magit-section-toggle)))
1263 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1264 (defalias 'e 'find-file)
1265 (defalias 'ff 'find-file)
1266 (defalias 'ee 'find-files)
1269 *** Eshell erase buffer
1270 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1271 (defun sd/eshell-clear-buffer ()
1272 "Clear eshell buffer"
1274 (let ((inhibit-read-only t))
1276 (eshell-send-input)))
1278 (add-hook 'eshell-mode-hook (lambda ()
1279 (local-set-key (kbd "C-l") 'sd/eshell-clear-buffer)))
1283 Toggle an eshell in split window below, refer [[http://www.howardism.org/Technical/Emacs/eshell-fun.html][eshell-here]]
1284 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1285 (defun sd/window-has-eshell ()
1286 "Check if current windows list has a eshell buffer, and return the window"
1289 (walk-windows (lambda (window)
1290 (if (equal (with-current-buffer (window-buffer window) major-mode)
1296 (defun sd/toggle-eshell-here ()
1297 "Toggle a eshell buffer vertically"
1299 (if (sd/window-has-eshell)
1300 (if (equal major-mode 'eshell-mode)
1302 (if (equal (length (window-list)) 1)
1303 (mode-line-other-buffer)
1305 (select-window (sd/window-has-eshell)))
1307 (let ((dir default-directory))
1309 (split-window-vertically (- (/ (window-total-height) 3)))
1311 (unless (and (boundp 'eshell-buffer-name) (get-buffer eshell-buffer-name))
1313 (switch-to-buffer eshell-buffer-name)
1314 (goto-char (point-max))
1316 (insert (format "cd %s" dir))
1317 (eshell-send-input)))))
1319 (global-unset-key (kbd "M-`"))
1320 (global-set-key (kbd "M-`") 'sd/toggle-eshell-here)
1323 *** TODO smart display
1326 ** [[https://github.com/abo-abo/hydra][Hydra]]
1328 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1331 ;; disable new line in minibuffer when hint hydra
1336 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1337 (defhydra sd/font-zoom (global-map "<f2>")
1339 ("g" text-scale-increase "in")
1340 ("l" text-scale-decrease "out"))
1343 *** Windmove Splitter
1345 Refer [[https://github.com/abo-abo/hydra/blob/master/hydra-examples.el][hydra-example]], to enlarge or shrink the windows splitter
1347 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1349 (defun hydra-move-splitter-left (arg)
1350 "Move window splitter left."
1352 (if (let ((windmove-wrap-around))
1353 (windmove-find-other-window 'right))
1354 (shrink-window-horizontally arg)
1355 (enlarge-window-horizontally arg)))
1357 (defun hydra-move-splitter-right (arg)
1358 "Move window splitter right."
1360 (if (let ((windmove-wrap-around))
1361 (windmove-find-other-window 'right))
1362 (enlarge-window-horizontally arg)
1363 (shrink-window-horizontally arg)))
1365 (defun hydra-move-splitter-up (arg)
1366 "Move window splitter up."
1368 (if (let ((windmove-wrap-around))
1369 (windmove-find-other-window 'up))
1370 (enlarge-window arg)
1371 (shrink-window arg)))
1373 (defun hydra-move-splitter-down (arg)
1374 "Move window splitter down."
1376 (if (let ((windmove-wrap-around))
1377 (windmove-find-other-window 'up))
1379 (enlarge-window arg)))
1384 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1385 (defhydra sd/hydra-misc (:color red :columns nil)
1386 "Miscellaneous Commands"
1387 ("e" eshell "eshell" :exit t)
1390 (if (not (eq nil (get-buffer "*Packages*")))
1391 (switch-to-buffer "*Packages*")
1392 (package-list-packages)))
1393 "list-package" :exit t)
1394 ("g" magit-status "git-status" :exit t)
1395 ("'" mode-line-other-buffer "last buffer" :exit t)
1396 ("C-'" mode-line-other-buffer "last buffer" :exit t)
1397 ("m" man "man" :exit t)
1398 ("d" dired-jump "dired" :exit t)
1399 ("b" ibuffer "ibuffer" :exit t)
1403 (global-set-key (kbd "C-'") 'sd/hydra-misc/body)
1407 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1408 (defhydra sd/hydra-launcher (:color blue :columns 2)
1410 ("e" emms "emms" :exit t)
1416 Enable linum mode on programming modes
1418 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1419 (add-hook 'prog-mode-hook 'linum-mode)
1420 ;; (add-hook 'prog-mode-hook (lambda ()
1421 ;; (setq-default indicate-empty-lines t)))
1424 Fix the font size of line number
1426 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1428 (defun fix-linum-size ()
1430 (set-face-attribute 'linum nil :height 110))
1432 (add-hook 'linum-mode-hook 'fix-linum-size)
1436 I like [[https://github.com/coldnew/linum-relative][linum-relative]], just like the =set relativenumber= on =vim=
1438 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1440 (use-package linum-relative
1443 (defun linum-new-mode ()
1444 "If line numbers aren't displayed, then display them.
1445 Otherwise, toggle between absolute and relative numbers."
1448 (linum-relative-toggle)
1452 ("A-k" . linum-new-mode))
1454 ;; auto enable linum-new-mode in programming modes
1455 (add-hook 'prog-mode-hook 'linum-relative-mode)
1459 ** Save File Position
1461 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1463 (require 'saveplace)
1464 (setq-default save-place t)
1465 (setq save-place-forget-unreadable-files t)
1466 (setq save-place-skip-check-regexp "\\`/\\(?:cdrom\\|floppy\\|mnt\\|/[0-9]\\|\\(?:[^@/:]*@\\)?[^@/:]*[^@/:.]:\\)")
1472 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1474 (use-package multi-term
1481 [[https://github.com/abo-abo/ace-link][ace-link]] is a package written by [[https://github.com/abo-abo][Oleh Krehel]]. It is convenient to jump to link in help mode, info-mode, etc
1482 Type =o= to go to the link
1484 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1486 (use-package ace-link
1489 (ace-link-setup-default))
1495 [[https://github.com/re5et/emux][emux]] is
1497 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1499 (el-get-bundle re5et/emux)
1505 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1507 (use-package smartparens
1511 (require 'smartparens-config)
1512 (add-hook 'prog-mode-hook 'smartparens-mode)))
1518 [[https://github.com/abo-abo/ace-window][ace-window]]
1520 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1522 (use-package ace-window
1526 ; (global-set-key (kbd "M-o") 'ace-window)
1528 (setq aw-keys '(?a ?s ?d ?f ?j ?k ?l)))
1534 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1536 (use-package projectile
1539 (setq projectile-enable-caching t)
1541 (projectile-global-mode t))
1543 (use-package persp-projectile
1548 (:map projectile-mode-map
1549 ("s-t" . projectile-persp-switch-project)))
1551 ;; projectile-find-file
1552 ;; projectile-switch-buffer
1553 ;; projectile-find-file-other-window
1558 [[https://github.com/justbur/emacs-which-key][which-key]] show the key bindings
1560 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1562 (use-package which-key
1571 We can use [[https://www.gnu.org/software/emms/quickstart.html][Emms]] for multimedia in Emacs
1573 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1577 (setq emms-source-file-default-directory "~/Music/")
1580 (emms-default-players)
1581 (define-emms-simple-player mplayer '(file url)
1582 (regexp-opt '(".ogg" ".mp3" ".mgp" ".wav" ".wmv" ".wma" ".ape"
1583 ".mov" ".avi" ".ogm" ".asf" ".mkv" ".divx" ".mpeg"
1584 "http://" "mms://" ".rm" ".rmvb" ".mp4" ".flac" ".vob"
1585 ".m4a" ".flv" ".ogv" ".pls"))
1586 "mplayer" "-slave" "-quiet" "-really-quiet" "-fullscreen")
1587 (emms-history-load))
1593 Play Go in Emacs, gnugo xpm refert [[https://github.com/okanotor/dotemacs/blob/f95b774cb292d1169748bc0a62ba647bbd8c0652/etc/my-inits/my-inits-gnugo.el][to here]]. start at image display mode and grid mode
1595 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1601 (require 'gnugo-imgen)
1602 (setq gnugo-xpms 'gnugo-imgen-create-xpms)
1603 (add-hook 'gnugo-start-game-hook '(lambda ()
1604 (gnugo-image-display-mode)
1607 (add-to-list 'gnugo-option-history (format "--boardsize 19 --color black --level 1")))
1613 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1615 ;; (use-package tabbar-ruler
1618 ;; (setq tabbar-ruler-global-tabbar t)
1619 ;; (setq tabbar-ruler-global-ruler t)
1620 ;; (setq tabbar-ruler-popu-menu t)
1621 ;; (setq tabbar-ruler-popu-toolbar t)
1622 ;; (setq tabbar-use-images t)
1624 ;; (tabbar-ruler-group-by-projectile-project)
1625 ;; (global-set-key (kbd "s-1") 'tabbar-forward-group)
1626 ;; (global-set-key (kbd "s-2") 'tabbar-ruler-forward))
1630 ** View only for some directory
1631 When see function by =C-h f=, and visit the source code, I would like the buffer is read only. See [[http://emacs.stackexchange.com/questions/3676/how-to-enter-view-only-mode-when-browsing-emacs-source-code-from-help/3681#3681][here]]
1632 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1633 (dir-locals-set-class-variables
1635 '((nil . ((buffer-read-only . t)
1636 (show-trailing-whitespace . nil)
1638 (eval . (whitespace-mode -1))))))
1640 ;; (dir-locals-set-directory-class (expand-file-name "/usr/local/share/emacs") 'emacs)
1641 (dir-locals-set-directory-class "/usr/local/Cellar/emacs" 'emacs)
1642 ;; (dir-locals-set-directory-class "~/.emacs.d/elpa" 'emacs)
1643 (dir-locals-set-directory-class "~/dotfiles/emacs.d/elpa" 'emacs)
1644 (dir-locals-set-directory-class "~/dotfiles/emacs.d/el-get" 'emacs)
1648 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1649 (el-get-bundle info+
1650 :url "https://raw.githubusercontent.com/emacsmirror/emacswiki.org/master/info+.el"
1658 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1659 (defun sd/info-mode ()
1661 (unless (equal major-mode 'Info-mode)
1662 (unless (> (length (window-list)) 1)
1663 (split-window-right))
1668 ;; (global-set-key (kbd "C-h i") 'sd/info-mode)
1670 ;; open Info buffer in other window instead of current window
1671 (defadvice info (before my-info (&optional file buf) activate)
1674 (defadvice Info-exit (after my-info-exit activate)
1675 (sd/delete-current-window))
1681 ** TODO swiper to occur
1684 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1685 ;; (set-language-environment "UTF-8")
1686 ;; (set-default-coding-systems 'utf-8)
1690 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1691 ;; (el-get-bundle howardabrams/demo-it)
1693 (use-package org-tree-slide
1696 ;; (use-package yasnippet
1701 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1702 (use-package org-tree-slide
1705 ;; (define-key org-mode-map "\C-ccp" 'org-tree-slide-mode)
1706 (define-key org-tree-slide-mode-map (kbd "<ESC>") 'org-tree-slide-content)
1707 (define-key org-tree-slide-mode-map (kbd "<SPACE>") 'org-tree-slide-move-next-tree)
1708 (define-key org-tree-slide-mode-map [escape] 'org-tree-slide-move-previous-tree))
1712 =C-o= is defined as a global key for window operation, here unset it in dired mode
1713 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1717 (setq dired-omit-mode t)
1718 (setq dired-omit-files (concat dired-omit-files "\\|^\\..+$"))
1719 (add-hook 'dired-mode-hook (lambda ()
1720 (define-key dired-mode-map (kbd "C-o") nil)
1721 (define-key dired-mode-map (kbd "H") 'dired-omit-mode)
1722 (define-key dired-mode-map (kbd "DEL") (lambda () (interactive) (find-alternate-file "..")))
1723 (dired-omit-mode))))
1727 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1731 (setq diredp-hide-details-initially-flag nil)
1733 (define-key dired-mode-map (kbd "j") 'diredp-next-line)
1734 (define-key dired-mode-map (kbd "k") 'diredp-previous-line)
1735 (define-key dired-mode-map (kbd "g") 'dired-goto-file))
1739 company mode and company-statistics
1740 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1741 (use-package company
1743 :diminish company-mode
1744 :init (setq company-idle-delay 0.1)
1746 (global-company-mode))
1748 (use-package company-statistics
1751 (company-statistics-mode))
1754 * Programming Language
1756 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1757 (use-package color-identifiers-mode
1760 (add-hook 'emacs-lisp-mode-hook 'color-identifiers-mode)
1762 :diminish color-identifiers-mode)
1764 (global-prettify-symbols-mode t)
1767 In Lisp Mode, =M-o= is defined, but I use this for global hydra window. So here disable this key
1768 bindings in =lispy-mode-map= after loaded. see [[http://stackoverflow.com/questions/298048/how-to-handle-conflicting-keybindings][here]]
1769 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1773 (eval-after-load "lispy"
1775 (define-key lispy-mode-map (kbd "M-o") nil)))
1777 (add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1))))
1782 [[https://www.emacswiki.org/emacs/CPerlMode][CPerl mode]] has more features than =PerlMode= for perl programming. Alias this to =CPerlMode=
1783 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1784 (defalias 'perl-mode 'cperl-mode)
1786 ;; (setq cperl-hairy t)
1787 ;; Turns on most of the CPerlMode options
1788 (setq cperl-auto-newline t)
1789 (setq cperl-highlight-variables-indiscriminately t)
1790 ;(setq cperl-indent-level 4)
1791 ;(setq cperl-continued-statement-offset 4)
1792 (setq cperl-close-paren-offset -4)
1793 (setq cperl-indent-parents-as-block t)
1794 (setq cperl-tab-always-indent t)
1795 ;(setq cperl-brace-offset 0)
1797 (add-hook 'cperl-mode-hook
1799 (cperl-set-style "C++")))
1801 (defalias 'perldoc 'cperl-perldoc)
1805 Refer [[https://www.emacswiki.org/emacs/AutoInsertMode][AutoInsertMode]] Wiki
1806 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1807 (eval-after-load 'autoinsert
1808 '(define-auto-insert '("\\.pl\\'" . "Perl skeleton")
1811 "#!/usr/bin/perl -w" \n
1813 "use strict;" > \n \n
1819 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1820 (font-lock-add-keywords 'cperl-mode
1821 '(("\\(say\\)" . cperl-nonoverridable-face)
1822 ("\\([0-9.]\\)*" . font-lock-constant-face)
1823 ("\".*\\(\\\n\\).*\"" . font-lock-constant-face)
1824 ("\n" . font-lock-constant-face)
1825 ("\\(^#!.*\\)$" . cperl-nonoverridable-face)))
1827 ;; (font-lock-add-keywords 'Man-mode
1828 ;; '(("\\(NAME\\)" . font-lock-function-name-face)))
1833 Change the compile-command to set the default command run when call =compile=
1834 Mapping =s-r= (on Mac, it's =Command + R= to run the script. Here =current-prefix-arg= is set
1835 to call =compilation= interactively.
1836 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1837 (defun my-perl-hook ()
1839 (setq-local compilation-read-command nil)
1840 (set (make-local-variable 'compile-command)
1841 (concat "/usr/bin/perl "
1842 (if buffer-file-name
1843 (shell-quote-argument buffer-file-name))))
1844 (local-set-key (kbd "s-r")
1847 ; (setq current-prefix-arg '(4)) ; C-u
1848 (call-interactively 'compile)))))
1850 (add-hook 'cperl-mode-hook 'my-perl-hook)
1854 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1855 (setq c-default-style "stroustrup"
1860 Set the environments vairables in compilation mode
1861 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1862 (use-package compile
1865 (setq compilation-environment (cons "LC_ALL=C" compilation-environment))
1866 (setq compilation-auto-jump-to-first-error t)
1867 (setq compilation-auto-jump-to-next t)
1868 (setq compilation-scroll-output 'first-error))
1870 ;; super-r to compile
1871 (with-eval-after-load "compile"
1872 (define-key compilation-mode-map (kbd "C-o") nil)
1873 (define-key compilation-mode-map (kbd "n") 'compilation-next-error)
1874 (define-key compilation-mode-map (kbd "p") 'compilation-previous-error)
1875 (define-key compilation-mode-map (kbd "r") #'recompile))
1879 ** Enable auto-insert mode
1880 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1881 (auto-insert-mode t)
1882 (setq auto-insert-query nil)
1886 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1887 (eval-after-load 'autoinsert
1888 '(define-auto-insert '("\\.cpp\\'" . "C++ skeleton")
1890 "Short description:"
1892 "\n * " (file-name-nondirectory (buffer-file-name))
1894 "#include <iostream>" \n
1896 (file-name-sans-extension
1897 (file-name-nondirectory (buffer-file-name)))
1899 "using namespace std;" \n \n
1907 (eval-after-load 'autoinsert
1908 '(define-auto-insert '("\\.c\\'" . "C skeleton")
1910 "Short description:"
1912 " * " (file-name-nondirectory (buffer-file-name)) "\n"
1914 "#include <stdio.h>" \n
1916 (file-name-sans-extension
1917 (file-name-nondirectory (buffer-file-name)))
1928 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1929 (eval-after-load 'autoinsert
1930 '(define-auto-insert '("\\.\\(py\\)\\'" . "Python skeleton")
1939 Emacs lisp auto-insert, based on the default module in =autoinsert.el=, but replace =completing-read= as
1940 =completing-read-ido-ubiquitous= to fix the edge case of that =ido= cannot handle.
1941 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1942 (eval-after-load 'autoinsert
1943 '(define-auto-insert '("\\.el\\'" . "my Emacs Lisp header")
1945 "Short description: "
1946 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str
1947 (make-string (max 2 (- 80 (current-column) 27)) ?\s)
1948 "-*- lexical-binding: t; -*-" '(setq lexical-binding t)
1950 ;; Copyright (C) " (format-time-string "%Y") " "
1951 (getenv "ORGANIZATION") | (progn user-full-name) "
1953 ;; Author: " (user-full-name)
1954 '(if (search-backward "&" (line-beginning-position) t)
1955 (replace-match (capitalize (user-login-name)) t t))
1956 '(end-of-line 1) " <" (progn user-mail-address) ">
1959 ;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords)))
1960 '(setq v1 (mapcar (lambda (x) (list (symbol-name (car x))))
1961 finder-known-keywords)
1962 v2 (mapconcat (lambda (x) (format "%12s: %s" (car x) (cdr x)))
1963 finder-known-keywords
1965 ((let ((minibuffer-help-form v2))
1966 (completing-read-ido-ubiquitous "Keyword, C-h: " v1 nil t))
1969 \;; This program is free software; you can redistribute it and/or modify
1970 \;; it under the terms of the GNU General Public License as published by
1971 \;; the Free Software Foundation, either version 3 of the License, or
1972 \;; (at your option) any later version.
1974 \;; This program is distributed in the hope that it will be useful,
1975 \;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1976 \;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1977 \;; GNU General Public License for more details.
1979 \;; You should have received a copy of the GNU General Public License
1980 \;; along with this program. If not, see <http://www.gnu.org/licenses/>.
1992 \;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")))
1995 ** Org file template
1996 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
1997 (eval-after-load 'autoinsert
1998 '(define-auto-insert '("\\.\\(org\\)\\'" . "Org-mode skeleton")
2001 "#+TITLE: " str (make-string 30 ?\s) > \n
2002 "#+AUTHOR: Peng Li\n"
2003 "#+EMAIL: seudut@gmail.com\n"
2004 "#+DATE: " (shell-command-to-string "echo -n $(date +%Y-%m-%d)") > \n
2010 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2011 (use-package markdown-mode
2013 :commands (markdown-mode gfm-mode)
2014 :mode (("README\\.md\\'" . gfm-mode)
2015 ("\\.md\\'" . markdown-mode)
2016 ("\\.markdown\\'" . markdown-mode))
2017 :init (setq markdown-command "multimarkdown"))
2020 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2021 (use-package markdown-preview-eww
2027 Refer [[https://www.emacswiki.org/emacs/GnusGmail][GnusGmail]]
2028 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2029 (setq user-mail-address "seudut@gmail.com"
2030 user-full-name "Peng Li")
2032 (setq gnus-select-method
2034 (nnimap-address "imap.gmail.com")
2035 (nnimap-server-port "imaps")
2036 (nnimap-stream ssl)))
2038 (setq smtpmail-smtp-service 587
2039 gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
2041 ;; Use gmail sending mail
2042 (setq message-send-mail-function 'smtpmail-send-it
2043 smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
2044 smtpmail-auth-credentials '(("smtp.gmail.com" 587 "seudut@gmail.com" nil))
2045 smtpmail-default-smtp-server "smtp.gmail.com"
2046 smtpmail-smtp-server "smtp.gmail.com"
2047 smtpmail-smtp-service 587
2048 starttls-use-gnutls t)
2051 And put the following in =~/.authinfo= file, replacing =<USE>= with your email address
2052 and =<PASSWORD>= with the password
2054 machine imap.gmail.com login <USER> password <PASSWORD> port imaps
2055 machine smtp.gmail.com login <USER> password <PASSWORD> port 587
2061 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2064 (setq gnus-permanently-visible-groups "\.*")
2066 (cond (window-system
2067 (setq custom-background-mode 'light)
2068 (defface my-group-face-1
2069 '((t (:foreground "Red" :bold t))) "First group face")
2070 (defface my-group-face-2
2071 '((t (:foreground "DarkSeaGreen4" :bold t)))
2072 "Second group face")
2073 (defface my-group-face-3
2074 '((t (:foreground "Green4" :bold t))) "Third group face")
2075 (defface my-group-face-4
2076 '((t (:foreground "SteelBlue" :bold t))) "Fourth group face")
2077 (defface my-group-face-5
2078 '((t (:foreground "Blue" :bold t))) "Fifth group face")))
2079 (setq gnus-group-highlight
2080 '(((> unread 200) . my-group-face-1)
2081 ((and (< level 3) (zerop unread)) . my-group-face-2)
2082 ((< level 3) . my-group-face-3)
2083 ((zerop unread) . my-group-face-4)
2084 (t . my-group-face-5))))
2088 (add-hook 'gnus-group-mode-hook (lambda ()
2089 (define-key gnus-group-mode-map "k" 'gnus-group-prev-group)
2090 (define-key gnus-group-mode-map "j" 'gnus-group-next-group)
2091 (define-key gnus-group-mode-map "g" 'gnus-group-jump-to-group)
2092 (define-key gnus-group-mode-map "v" (lambda () (interactive) (gnus-group-select-group t)))))
2095 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2096 (setq gnus-fetch-old-headers 't)
2100 (setq gnus-extract-address-components
2101 'mail-extract-address-components)
2103 (setq gnus-summary-line-format "%U%R%z%I%(%[%-20,20f%]%) %s%-80= %11&user-date;\n")
2104 (setq gnus-user-date-format-alist '(((gnus-seconds-today) . "%H:%M")
2105 ((+ 86400 (gnus-seconds-today)) . "%a %H:%M")
2106 (604800 . "%a, %b %-d")
2107 (15778476 . "%b %-d")
2110 (setq gnus-thread-sort-functions '((not gnus-thread-sort-by-number)))
2111 (setq gnus-unread-mark ?\.)
2112 (setq gnus-use-correct-string-widths t)
2115 (setq gnus-thread-hide-subtree t)
2117 ;; (with-eval-after-load 'gnus-summary-mode
2118 ;; (define-key gnus-summary-mode-map (kbd "C-o") 'sd/hydra-window/body))
2120 (add-hook 'gnus-summary-mode-hook (lambda ()
2121 (define-key gnus-summary-mode-map (kbd "C-o") nil)))
2127 See [[https://www.emacswiki.org/emacs/GnusWindowLayout][GnusWindowLayout]]
2128 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2129 (gnus-add-configuration
2135 (summary 1.0 poine)))))
2137 (gnus-add-configuration
2143 (summary 0.50 point)
2146 (with-eval-after-load 'gnus-group-mode
2147 (gnus-group-select-group "INBOX"))
2148 ;; (add-hook 'gnus-group-mode-map (lambda ()
2149 ;; (gnus-group-select-group "INBOX")))
2153 To fix some issue that =toolbar-make-button-list= is void, see the [[https://github.com/bruceravel/gnuplot-mode/issues/31][issue]], here I set some variable as =nil=
2154 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2155 (use-package gnuplot
2158 (setq gnuplot-help-xpm nil)
2159 (setq gnuplot-line-xpm nil)
2160 (setq gnuplot-region-xpm nil)
2161 (setq gnuplot-buffer-xpm nil)
2162 (setq gnuplot-doc-xpm nil))
2165 Use =gnuplot= on =Org-mode= file, see [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html][ob-doc-gnuplot]]
2166 #+BEGIN_SRC gnuplot :exports code :file ./temp/file.png
2169 set title "Putting it All Together"
2182 h(x) = 10*sqrt(abs(x))
2184 plot f(x) w lp lw 1, g(x) w p lw 2, h(x) w l lw 3
2188 [[file:./temp/file.png]]
2191 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2200 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2201 (with-eval-after-load 'ediff
2202 (setq ediff-split-window-function 'split-window-horizontally)
2203 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2204 (add-hook 'ediff-startup-hook 'ediff-toggle-wide-display)
2205 (add-hook 'ediff-cleanup-hook 'ediff-toggle-wide-display)
2206 (add-hook 'ediff-suspend-hook 'ediff-toggle-wide-display))
2209 * TODO Convert ASCII to key
2210 ** map =function-key-map= [[http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ctrl.htm][ascii_ctrl]]
2211 new file =C-x C-f C-f=
2213 ** write color syntax for =Man-mode=
2215 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2216 (font-lock-add-keywords 'perl-mode '(("\\(|\\w+?\\(,\\w+?\\)?|\\)" 1 'py-builtins-face)))
2219 * TODO set fly-spell binding
2221 * TODO imenu bindings
2223 * DONE modified indicator
2225 - State "DONE" from "TODO" [2016-07-18 Mon 23:35]
2227 * DONE highlight selected ido candicate
2229 - State "DONE" from "TODO" [2016-07-19 Tue 01:49]
2231 * DONE show time in right of mode-line
2233 - State "DONE" from "TODO" [2016-07-19 Tue 01:11]
2237 - State "DONE" from "TODO" [2016-07-19 Tue 01:11]
2239 * TODO jump last change point
2240 * TODO emms mode-line
2243 Here are some global key bindings for basic editting
2244 ** Project operations - =super=
2245 =projectile= settins
2246 ** Windown & Buffer - =C-o=
2247 Defind a =hydra= function for windows, buffer & bookmark operations. And map it to =C-o= globally.
2248 Most use =C-o C-o= to switch buffers; =C-o x, v= to split window; =C-o o= to delete other windows
2249 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2252 (defhydra sd/hydra-window (:color red :columns nil)
2254 ("h" windmove-left nil :exit t)
2255 ("j" windmove-down nil :exit t)
2256 ("k" windmove-up nil :exit t)
2257 ("l" windmove-right nil :exit t)
2258 ("H" hydra-move-splitter-left nil)
2259 ("J" hydra-move-splitter-down nil)
2260 ("K" hydra-move-splitter-up nil)
2261 ("L" hydra-move-splitter-right nil)
2264 (split-window-right)
2269 (split-window-below)
2272 ("o" delete-other-windows "one" :exit t)
2273 ("C-o" ido-switch-buffer "buf" :exit t)
2274 ("C-k" sd/delete-current-window "del" :exit t)
2275 ("'" other-window "other" :exit t)
2276 ("a" ace-window "ace")
2277 ("s" ace-swap-window "swap")
2278 ("d" ace-delete-window "ace-one" :exit t)
2279 ("i" ace-maximize-window "ace-one" :exit t)
2280 ("b" ido-switch-buffer "buf" :exit t)
2281 ("C-b" ido-switch-buffer "buf" :exit t)
2282 ("m" bookmark-jump-other-window "open bmk" :exit t)
2283 ("M" bookmark-set "set bmk" :exit t)
2285 ("u" (progn (winner-undo) (setq this-command 'winner-undo)) "undo")
2286 ("r" (progn (winner-redo) (setq this-command 'winner-redo)) "redo")
2287 ("C-h" nil nil :exit t)
2288 ("C-j" nil nil :exit t)
2289 ;; ("C-k" nil :exit t)
2290 ("C-l" nil nil :exit t)
2291 ("C-;" nil nil :exit t)
2292 ("p" nil nil :exit t)
2293 ("n" nil nil :exit t)
2294 ("[" nil nil :exit t)
2295 ("]" nil nil :exit t)
2298 (global-unset-key (kbd "C-o"))
2299 (global-set-key (kbd "C-o") 'sd/hydra-window/body)
2303 - cut, yank, =C-w=, =C-y=
2305 - undo, redo - undo-tree
2306 - select, expand-region
2307 - spell check, flyspell
2310 Use =Avy= for motion
2311 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2315 (avy-setup-default))
2317 (global-set-key (kbd "C-M-j") 'avy-goto-line-below)
2318 (global-set-key (kbd "C-M-n") 'avy-goto-line-below)
2319 (global-set-key (kbd "C-M-k") 'avy-goto-line-above)
2320 (global-set-key (kbd "C-M-p") 'avy-goto-line-above)
2322 (global-set-key (kbd "C-M-f") 'avy-goto-word-1-below)
2323 (global-set-key (kbd "C-M-b") 'avy-goto-word-1-above)
2325 ;; (global-set-key (kbd "M-g e") 'avy-goto-word-0)
2326 (global-set-key (kbd "C-M-w") 'avy-goto-char-timer)
2327 (global-set-key (kbd "C-M-l") 'avy-goto-char-in-line)
2329 ;; will delete above
2330 (global-set-key (kbd "M-g j") 'avy-goto-line-below)
2331 (global-set-key (kbd "M-g k") 'avy-goto-line-above)
2332 (global-set-key (kbd "M-g w") 'avy-goto-word-1-below)
2333 (global-set-key (kbd "M-g b") 'avy-goto-word-1-above)
2334 (global-set-key (kbd "M-g e") 'avy-goto-word-0)
2335 (global-set-key (kbd "M-g f") 'avy-goto-char-timer)
2336 (global-set-key (kbd "M-g c") 'avy-goto-char-in-line)
2338 ;; M-g TAB move-to-column
2339 ;; M-g ESC Prefix Command
2343 ;; M-g p previous-error
2345 ;; M-g M-g goto-line
2346 ;; M-g M-n next-error
2347 ;; M-g M-p previous-error
2350 =imenu=, mapping =C-M-i= to =counsel-imenu=
2351 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2352 (global-unset-key (kbd "C-M-i"))
2353 (global-set-key (kbd "C-M-i") #'counsel-imenu)
2356 ** Search & Replace / hightlight =M-s=
2360 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2362 ;; (defhydra sd/search-highlight (:color red :columns nil)
2364 ;; ("M-s" . isearch-forward-regexp "search-forward" :exit t)
2365 ;; ("s" . isearch-forward-regexp "search-forward" :exit t)
2366 ;; ("r" . isearch-backward-regexp "search-backward" :exit t)
2369 ;; (setq-default indicate-empty-lines t)
2373 Occur search key bindings
2374 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
2375 (defun sd/occur-keys ()
2376 "My key bindings in occur-mode"
2378 (switch-to-buffer-other-window "*Occur*")
2379 (define-key occur-mode-map (kbd "C-o") nil)
2380 (define-key occur-mode-map (kbd "C-n") (lambda ()
2383 (occur-mode-goto-occurrence-other-window)
2386 (define-key occur-mode-map (kbd "C-p") (lambda ()
2389 (occur-mode-goto-occurrence-other-window)
2393 (add-hook 'occur-hook #'sd/occur-keys)
2395 (use-package color-moccur
2397 :commands (isearch-moccur isearch-all)
2399 (setq isearch-lazy-highlight t)
2401 (use-package moccur-edit))
2405 #+BEGIN_SRC ditaa :file temp/hello-world.png :cmdline -r
2414 [[file:temp/hello-world.png]]
2417 * =C-u C-h a= search funtions