emacs - add latex pdf beamer support
[dotfiles.git] / emacs.d_2 / config.org
index 2a722e0..e1c9f8c 100644 (file)
@@ -14,8 +14,11 @@ Set system PATH and emacs exec path
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
+  (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
 
@@ -29,16 +32,17 @@ 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       
 
 ** General Setting
 
@@ -344,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.
@@ -432,7 +522,28 @@ Use [[https://github.com/DarwinAwardWinner/ido-ubiquitous][ido-ubiquitous]] for
 
 #+END_SRC
 
-* File and Buffer Operation
+** 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
 
@@ -455,6 +566,7 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
 
 #+END_SRC
 
+
 ** =Super= bindings for file, buffer and windows
 
 Some global bindings on =Super=, on Mac, it is =Command=
@@ -464,6 +576,11 @@ Some global bindings on =Super=, on Mac, it is =Command=
   (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
@@ -546,12 +663,17 @@ I use the prefix =M-s= for searching in buffers
     (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-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)
 
-  (define-key isearch-mode-map (kbd "M-s") 'isearch-forward-regexp)
+  ;; (global-set-key (kbd "M-s M-r") 'isearch-backward-regexp)
 
 #+END_SRC
 
+
+
 * Misc Settings
 
 
@@ -830,18 +952,40 @@ We can use [[https://www.gnu.org/software/emms/quickstart.html][Emms]] for multi
   (use-package emms
     :ensure t
     :init
-    (setq emms-source-file-default-directory "~/Music/")
+    (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")
-    :config
-    (emms-standard)
-    (emms-default-players))
+    (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