X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d_2%2Fconfig.org;h=e1c9f8c5ee82ab5a7e17838d59d40761559222c5;hb=7a61db417646acfebe92d8fe62bce3b0a8733ac9;hp=5255e6f6c7ced3edab18db885cc2eb86cf7daa01;hpb=05a9ab437c0346197e180c2a4e7312f9ac528053;p=dotfiles.git diff --git a/emacs.d_2/config.org b/emacs.d_2/config.org index 5255e6f..e1c9f8c 100644 --- a/emacs.d_2/config.org +++ b/emacs.d_2/config.org @@ -10,6 +10,18 @@ Most config are just copied from [[https://github.com/howardabrams/dot-files][ho ** Setting loading Path +Set system PATH and emacs exec path + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (setenv "PATH" (concat (getenv "PATH") + ":" "/usr/local/bin" + ":" "/Library/TeX/texbin")) + (setq exec-path (append exec-path '("/usr/local/bin"))) + (setq exec-path (append exec-path '("/Library/TeX/texbin/"))) + +#+END_SRC + Set the emacs load path #+BEGIN_SRC emacs-lisp :tangle yes :results silent @@ -20,18 +32,19 @@ Set the emacs load path ** Package Initialization -#+BEGIN_SRC emacs-lisp :tangle yes +#+BEGIN_SRC emacs-lisp :tangle yes :results silent (require 'package) (setq package-archives '(("mepla" . "http://melpa.milkbox.net/packages/") + ("gnu" . "http://elpa.gnu.org/packages/") ("org" . "http://orgmode.org/elpa/"))) (package-initialize) -#+END_SRC +#+END_SRC -** Windows Setting +** General Setting Disable scroll bar, tool-bar and menu-bar @@ -47,7 +60,15 @@ Disable scroll bar, tool-bar and menu-bar (defalias 'yes-or-no-p 'y-or-n-p) (show-paren-mode 1) - (global-set-key (kbd "") 'toggle-frame-fullscreen) + + +#+END_SRC + +Switch the focus to help window when it appears + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (setq help-window-select t) #+END_SRC @@ -281,6 +302,9 @@ Always indents header, and hide header leading starts so that no need type =#+ST (sqlite . t) (js . t))) + ;; use current window for org source buffer editting + (setq org-src-window-setup 'current-window ) + #+END_SRC ** Org-bullets @@ -311,11 +335,12 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined :ensure t :commands worf-mode :init (add-hook 'org-mode-hook 'worf-mode) - :config - (define-key worf-mode-map "[" nil) - (define-key worf-mode-map "]" nil) - (define-key worf-mode-map (kbd "M-[") 'worf-backward) - (define-key worf-mode-map (kbd "M-]") 'worf-forward)) + ;; :config + ;; (define-key worf-mode-map "[" nil) + ;; (define-key worf-mode-map "]" nil) + ;; (define-key worf-mode-map (kbd "M-[") 'worf-backward) + ;; (define-key worf-mode-map (kbd "M-]") 'worf-forward) + ) #+END_SRC @@ -323,6 +348,92 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined ** Capture +** Export PDF + +Install MacTex-basic and some tex packages + +#+BEGIN_SRC bash + + sudo tlmgr update --self + + 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 + +#+END_SRC + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + ;; ;; allow for export=>beamer by placing + + ;; http://emacs-fu.blogspot.com/2011/04/nice-looking-pdfs-with-org-mode-and.html + ;; #+LaTeX_CLASS: beamer in org files + (unless (boundp 'org-export-latex-classes) + (setq org-export-latex-classes nil)) + (add-to-list 'org-export-latex-classes + ;; beamer class, for presentations + '("beamer" + "\\documentclass[11pt]{beamer}\n + \\mode<{{{beamermode}}}>\n + \\usetheme{{{{beamertheme}}}}\n + \\usecolortheme{{{{beamercolortheme}}}}\n + \\beamertemplateballitem\n + \\setbeameroption{show notes} + \\usepackage[utf8]{inputenc}\n + \\usepackage[T1]{fontenc}\n + \\usepackage{hyperref}\n + \\usepackage{color} + \\usepackage{listings} + \\lstset{numbers=none,language=[ISO]C++,tabsize=4, + frame=single, + basicstyle=\\small, + showspaces=false,showstringspaces=false, + showtabs=false, + keywordstyle=\\color{blue}\\bfseries, + commentstyle=\\color{red}, + }\n + \\usepackage{verbatim}\n + \\institute{{{{beamerinstitute}}}}\n + \\subject{{{{beamersubject}}}}\n" + + ("\\section{%s}" . "\\section*{%s}") + + ("\\begin{frame}[fragile]\\frametitle{%s}" + "\\end{frame}" + "\\begin{frame}[fragile]\\frametitle{%s}" + "\\end{frame}"))) + + ;; letter class, for formal letters + + (add-to-list 'org-export-latex-classes + + '("letter" + "\\documentclass[11pt]{letter}\n + \\usepackage[utf8]{inputenc}\n + \\usepackage[T1]{fontenc}\n + \\usepackage{color}" + + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + + + (require 'ox-md) + (require 'ox-beamer) + + (setq org-latex-pdf-process + '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" + "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" + "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) + + (setq TeX-parse-self t) + + (setq TeX-PDF-mode t) + (add-hook 'LaTeX-mode-hook + (lambda () + (LaTeX-math-mode) + (setq TeX-master t))) + +#+END_SRC * Magit [[https://github.com/magit/magit][Magit]] is a very cool git interface on Emacs. @@ -353,6 +464,8 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined (ido-everywhere 1) (add-to-list 'completion-ignored-extensions ".pyc")) + (icomplete-mode t) + #+END_SRC ** FLX @@ -369,7 +482,7 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined ** IDO-vertically -#+BEGIN_SRC emacs-lisp :tangle yes :result silent +#+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package ido-vertical-mode :ensure t @@ -382,7 +495,7 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined ** SMEX -#+BEGIN_SRC emacs-lisp :tangle yes :result silent +#+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package smex :ensure t @@ -393,6 +506,174 @@ cause we cannot input =[= and =]=, so here I unset this mappings. And redifined #+END_SRC +** Ido-ubiquitous + +Use [[https://github.com/DarwinAwardWinner/ido-ubiquitous][ido-ubiquitous]] for ido everywhere. It makes =describe-function= can also use ido + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package ido-ubiquitous + :ensure t + :init + (setq magit-completing-read-function 'magit-ido-completing-read) + (setq gnus-completing-read-function 'gnus-ido-completing-read) + :config + (ido-ubiquitous-mode 1)) + +#+END_SRC + +** Ido-exit-target + +[[https://github.com/waymondo/ido-exit-target][ido-exit-target]] let you open file/buffer on =other-windows= when call =ido-switch-buffer= + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package ido-exit-target + :ensure t + :init + (define-key ido-common-completion-map (kbd "C-j") #'ido-exit-target-other-window)) + +#+END_SRC + +* Key bindings + +** Remove prefix =ESC=, refer [[http://emacs.stackexchange.com/questions/14755/how-to-remove-bindings-to-the-esc-prefix-key][here]] + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + ;; (define-key key-translation-map (kbd "ESC") (kbd "C-g")) + +#+END_SRC + +** Esc on Minibuffer + +Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g= + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (define-key minibuffer-local-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-ns-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-isearch-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-completion-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-must-match-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-must-match-filename-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-filename-completion-map [escape] 'keyboard-escape-quit) + (define-key minibuffer-local-filename-must-match-map [escape] 'keyboard-escape-quit) + + ;; Also map s-h same as C-g + (define-key minibuffer-local-map (kbd "s-h") 'keyboard-escape-quit) + +#+END_SRC + + +** =Super= bindings for file, buffer and windows + +Some global bindings on =Super=, on Mac, it is =Command= + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (global-set-key (kbd "s-h") 'keyboard-quit) + (global-set-key (kbd "s-j") 'ido-switch-buffer) + ;; s-k --> kill-this-buffer + (global-set-key (kbd "s-k") (lambda () + (interactive) + (if (> (length (window-list)) 1) + (delete-window) + (message "Only one Windows now!")))) + ;; s-l --> goto-line + ;; s-; --> + ;; s-' --> 'next-multiframe-window + (global-set-key (kbd "") 'toggle-frame-fullscreen) + + ;; (global-set-key (kbd "s-y") 'projectile-find-file) + (global-set-key (kbd "s-f") 'projectile-find-file) + (global-set-key (kbd "s-[") 'next-buffer) + (global-set-key (kbd "s-]") 'previous-buffer) + + (global-set-key (kbd "s-`") 'mode-line-other-buffer) + + + + ;; someothers default mapping on super (command) key + ;; s-s save-buffer + ;; s-k kill-this-buffer + + + ;; s-h --> ns-do-hide-emacs + ;; s-j --> ido-switch-buffer + + ;; s-k --> kill-this-buffer + ;; s-l --> goto-line + ;; s-; --> undefined + ;; s-' --> next-multiframe-window + ;; s-ret --> toggle-frame-fullscreen + + + ;; s-y --> ns-paste-secondary + ;; s-u --> revert-buffer + ;; s-i --> undefined - but used for iterm globally + ;; s-o --> used for emacs globally + ;; s-p --> projectile-persp-switch-project + + ;; s-[ --> next-buffer + + ;; s-] --> previous-buffer + + + ;; s-0 --> undefined + ;; s-9 --> undefined + ;; s-8 --> undefined + ;; s-7 --> undefined + ;; s-6 --> undefined + ;; s-- --> center-line + ;; s-= --> undefined + + ;; s-n --> make-frame + ;; s-m --> iconify-frame + ;; s-b --> undefined + ;; s-, --> customize + ;; s-. --> undefined + ;; s-/ --> undefined + + ;; s-g --> isearch-repeat-forward + ;; s-f --> projectile-find-file + + ;; s-d --> isearch-repeat-background + ;; s-s --> save-buffer + ;; s-a --> make-whole-buffer + + ;; s-b --> undefined + ;; s-v --> yank + ;; s-c --> ns-copy-including-secondary + + ;; s-t --> ns-popup-font-panel + ;; s-r --> undefined + ;; s-e --> isearch-yanqk-kill + ;; s-w --> delete-frame + ;; s-q --> same-buffers-kill-emacs + + ;; s-` --> other-frame +#+END_SRC + +** =M-s= bindings for searching + +I use the prefix =M-s= for searching in buffers + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (defun pl-make-keymap (key bindings) + (setq keymap (make-sparse-keymap)) + (dolist (binding bindings) + (define-key keymap (car binding) (cdr binding))) + (global-set-key key keymap)) + + (global-set-key (kbd "M-s M-s") 'isearch-forward-regexp) + (global-set-key (kbd "M-s M-r") 'isearch-backward-regexp) + + (define-key isearch-mode-map "\M-s" 'isearch-repeat-forward) + (define-key isearch-mode-map "\M-r" 'isearch-repeat-backward) + + ;; (global-set-key (kbd "M-s M-r") 'isearch-backward-regexp) + +#+END_SRC + + + * Misc Settings @@ -482,7 +763,9 @@ Refer [[https://github.com/abo-abo/hydra/blob/master/hydra-examples.el][hydra-ex (split-window-below) (windmove-down)) "horz") - ("o" delete-other-windows "one" :exit t) + ;; ("o" delete-other-windows "one" :exit t) + ;; Todo define o to triggle delete others windows and restore windows layout + ("o" triggle-windows-max-size "maximize" :exit t) ("a" ace-window "ace") ("s" ace-swap-window "swap") ("d" ace-delete-window "ace-one" :exit t) @@ -497,6 +780,12 @@ Refer [[https://github.com/abo-abo/hydra/blob/master/hydra-examples.el][hydra-ex (global-unset-key (kbd "M-o")) (global-set-key (kbd "M-o") 'sd/hydra-window/body) + (defun triggle-windows-max-size () + (interactive) + (if (> (length (window-list)) 1) + (delete-other-windows) + (winner-undo))) + #+END_SRC ** Line Number @@ -593,7 +882,11 @@ Type =o= to go to the link #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package smartparens - :ensure t) + :ensure t + :config + (progn + (require 'smartparens-config) + (add-hook 'prog-mode-hook 'smartparens-mode))) #+END_SRC @@ -613,6 +906,86 @@ Type =o= to go to the link #+END_SRC +** Projectile + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package projectile + :ensure t + :init + (setq projectile-enable-caching t) + :config + (projectile-global-mode t)) + + (use-package persp-projectile + :ensure t + :config + (persp-mode) + :bind + (:map projectile-mode-map + ("s-p" . projectile-persp-switch-project))) + + ;; projectile-find-file + ;; projectile-switch-buffer + ;; projectile-find-file-other-window +#+END_SRC + +** Which key + +[[https://github.com/justbur/emacs-which-key][which-key]] show the key bindings + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package which-key + :ensure t + :config + (which-key-mode)) + +#+END_SRC + +** Emms + +We can use [[https://www.gnu.org/software/emms/quickstart.html][Emms]] for multimedia in Emacs + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package emms + :ensure t + :init + (setq emms-source-file-default-directory "~/Music/emms/") + :config + (emms-standard) + (emms-default-players) + (define-emms-simple-player mplayer '(file url) + (regexp-opt '(".ogg" ".mp3" ".mgp" ".wav" ".wmv" ".wma" ".ape" + ".mov" ".avi" ".ogm" ".asf" ".mkv" ".divx" ".mpeg" + "http://" "mms://" ".rm" ".rmvb" ".mp4" ".flac" ".vob" + ".m4a" ".flv" ".ogv" ".pls")) + "mplayer" "-slave" "-quiet" "-really-quiet" "-fullscreen") + (emms-history-load)) + +#+END_SRC + +** GnoGo + +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 + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package gnugo + :ensure t + :defer t + :init + (require 'gnugo-imgen) + (setq gnugo-xpms 'gnugo-imgen-create-xpms) + (add-hook 'gnugo-start-game-hook '(lambda () + (gnugo-image-display-mode) + (gnugo-grid-mode))) + :config + (add-to-list 'gnugo-option-history (format "--boardsize 19 --color black --level 1"))) + +#+END_SRC + * Programming ** Languages @@ -632,12 +1005,19 @@ Type =o= to go to the link **** Lispy Mode +In Lisp Mode, =M-o= is defined, but I use this for global hydra window. So here disable this key +bindings in =lispy-mode-map= after loaded. see [[http://stackoverflow.com/questions/298048/how-to-handle-conflicting-keybindings][here]] + #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package lispy - :ensure t) - - ;(add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1))) + :ensure t + :init + (eval-after-load 'lispy + '(progn + (define-key lispy-mode-map (kbd "M-o") nil))) + :config + (add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1)))) #+END_SRC @@ -722,7 +1102,7 @@ Set the environments vairables in compilation mode Enable auto-insert mode -#+BEGIN_SRC emacs-lisp :tangle yes :results silenc +#+BEGIN_SRC emacs-lisp :tangle yes :results silent (auto-insert-mode t) (setq auto-insert-query nil) @@ -791,4 +1171,22 @@ Refer [[https://www.emacswiki.org/emacs/AutoInsertMode][AutoInsertMode]] Wiki #+END_SRC +** Completion + +company mode + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + + (use-package company + :ensure t + :diminish company-mode + :init (setq company-idle-delay 0.1) + :config + (global-company-mode)) + +#+END_SRC + +* Todo +- change M-o to trigger to delete other windows and restore previous config +-