X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=emacs.d%2Fconfig.org;h=4bae6f018662665e13ac9d337f6134495ea91ebc;hb=acffaa7fabd3f9f497206e4207dfb6629bf2a502;hp=1928499707fcd6af11774add66d149e427a4a40e;hpb=99bbdf423fb3e58f2a1fcc4260609bbb0e7d222c;p=dotfiles.git diff --git a/emacs.d/config.org b/emacs.d/config.org index 1928499..4bae6f0 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -340,9 +340,7 @@ Enable rainbow mode in emacs lisp mode * Mode-line ** clean mode line - clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][Marstering Emacs]] - #+BEGIN_SRC emacs-lisp :tangle yes :results silent (defvar mode-line-cleaner-alist `((auto-complete-mode . " α") @@ -365,6 +363,7 @@ clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replac (org-indent-mode . "") ;; default is Fly (flyspell-mode . "") + (irony-mode . "I") ;; Major modes (lisp-interaction-mode . "λ") (hi-lock-mode . "") @@ -396,9 +395,7 @@ clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replac #+END_SRC ** Powerline mode - Install powerline mode [[https://github.com/milkypostman/powerline][powerline]] - #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package powerline :ensure t @@ -524,7 +521,7 @@ set height in mode line #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package ido :ensure t - :init (setq ido-enable-flex-matching t + :init (setq ido-enable-flex-matching nil ido-ignore-extensions t ido-use-virtual-buffers t ido-everywhere t) @@ -541,9 +538,9 @@ set height in mode line #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package flx-ido :ensure t - :init (setq ido-enable-flex-matching t + :init (setq ido-enable-flex-matching nil ido-use-faces nil) - :config (flx-ido-mode 1)) + :config (flx-ido-mode nil)) #+END_SRC ** IDO-vertically @@ -1100,6 +1097,8 @@ Toggle an eshell in split window below, refer [[http://www.howardism.org/Technic #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package exec-path-from-shell :ensure t + :init + (setq exec-path-from-shell-check-startup-files nil) :config (exec-path-from-shell-initialize)) #+END_SRC @@ -1419,8 +1418,7 @@ Color for Man-mode #+END_SRC * Dired -** Dired config -*** Dired bindings +** Dired bindings =C-o= is defined as a global key for window operation, here unset it in dired mode #+BEGIN_SRC emacs-lisp :tangle yes :results silent (defun sd/dired-key-map () @@ -1479,7 +1477,7 @@ Color for Man-mode (interactive) (dired-why) (message - "Δ: d-delete, u-ndelete, x-punge, f-ind, o-ther window, R-ename, C-opy, c-create, +new dir, r-evert, h-summary, ?-help,")) + "Δ: d-delete, u-ndelete, x-punge, f-ind, o-ther window, R-ename, C-opy, c-create, +new dir, r-evert, /-filter, h-summary, ?-help")) (defun sd/dired-high-level-dir () "Go to higher level directory" @@ -1506,7 +1504,7 @@ Color for Man-mode (match-string 1)))))) #+END_SRC -*** disable ido when dired new file +** disable ido when dired new file When create a new directory, I want to disalbe =ido= completion. see [[http://stackoverflow.com/questions/7479565/emacs-ido-mode-and-creating-new-files-in-directories-it-keeps-changing-the-dire][here]]. Thhis code snippets copied from [[https://emacs.stackexchange.com/questions/13713/how-to-disable-ido-in-dired-create-directory/13795#13795?newreg%3Ddb17c20f7af3490fb11cf15f1d888e9e][How to disable IDO in ‘dired-create-directory’]] #+BEGIN_SRC emacs-lisp :tangle yes :results silent @@ -1530,7 +1528,7 @@ Disalble =ido= when new a directory or file in =dired= mode (mk-disable-ido 'sd/dired-new-file) #+END_SRC -*** Dired open with +** Dired open with =!= =dired-do-shell-command= =&= =dired-do-async-shell-command= here on Mac, just use "open" commands to pen =.pdf=, =.html= and image files @@ -1545,22 +1543,25 @@ here on Mac, just use "open" commands to pen =.pdf=, =.html= and image files ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "mplayer") ("\\.\\(?:mp3\\|flac\\)\\'" "rhythmbox") ("\\.html?\\'" "open") + ("\\.dmg\\'" "open") ("\\.cue?\\'" "audacious"))) #+END_SRC ** dired-hacks #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package dired-hacks-utils - :ensure t) - - - (defconst my-dired-media-files-extensions '("mp3" "mp4" "MP3" "MP4" "avi" "mpg" "flv" "ogg" "wmv" "mkv" "mov" "wma") - "Media file extensions that should launch in VLC.") + :ensure t + :defer t) +#+END_SRC - (add-to-list 'dired-guess-shell-alist-user - (list (concat "\\." - (regexp-opt my-dired-media-files-extensions) - "\\'") "mplayer")) +** dired-narrow +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + ;;narrow dired to match filter + (use-package dired-narrow + :ensure t + :commands (dired-narrow) + :bind (:map dired-mode-map + ("/" . dired-narrow))) #+END_SRC * Ibuffer @@ -1572,7 +1573,14 @@ here on Mac, just use "open" commands to pen =.pdf=, =.html= and image files (define-key ibuffer-mode-map (kbd "j") 'ibuffer-forward-line) (define-key ibuffer-mode-map (kbd "k") 'ibuffer-backward-line) (define-key ibuffer-mode-map (kbd "r") 'ibuffer-update) - (define-key ibuffer-mode-map (kbd "g") 'ibuffer-jump-to-buffer)) + (define-key ibuffer-mode-map (kbd "g") 'ibuffer-jump-to-buffer) + (define-key ibuffer-mode-map (kbd "h") 'sd/ibuffer-summary)) + + (defun sd/ibuffer-summary () + "Show summary of keybindings in ibuffer mode" + (interactive) + (message + "Β: m|u - (un)mark, /-filter, //-remove filter, t, RET, g, k, S, D, Q; q to quit; h for help")) #+END_SRC * Completion @@ -1691,11 +1699,79 @@ to call =compilation= interactively. #+END_SRC ** C & C++ +*** c/c++ style #+BEGIN_SRC emacs-lisp :tangle yes :results silent (setq c-default-style "stroustrup" c-basic-offset 4) #+END_SRC +*** flycheck +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (use-package flycheck + :ensure t) +#+END_SRC + +*** irony +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (use-package irony + :ensure t + :config + (add-hook 'c++-mode-hook 'irony-mode) + (add-hook 'c-mode-hook 'irony-mode) + (add-hook 'objc-mode-hook 'irony-mode)) +#+END_SRC + +Install clang, on mac, it has =libclang.dylib=, but no develop headers. Install by =brew= +#+BEGIN_SRC sh + brew install llvm --with-clang +#+END_SRC + +then install irony searver, and =LIBCLANG_LIBRARY= and =LIBCLANG_INCLUDE_DIR= accordingly +#+BEGIN_SRC emacs-lisp :tangle no :results silent + (irony-install-server) +#+END_SRC + +#+BEGIN_SRC sh + cmake -DLIBCLANG_LIBRARY\=/usr/local/Cellar/llvm/3.6.2/lib/libclang.dylib \ + -DLIBCLANG_INCLUDE_DIR=/usr/local/Cellar/llvm/3.6.2/include \ + -DCMAKE_INSTALL_PREFIX\=/Users/peli3/.emacs.d/irony/ \ + /Users/peli3/.emacs.d/elpa/irony-20160713.1245/server && cmake --build . --use-stderr --config Release --target install +#+END_SRC + +irony-mode-hook, copied from [[https://github.com/Sarcasm/irony-mode][irony-mode]] github +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + ;; replace the `completion-at-point' and `complete-symbol' bindings in + ;; irony-mode's buffers by irony-mode's function + (defun my-irony-mode-hook () + (define-key irony-mode-map [remap completion-at-point] + 'irony-completion-at-point-async) + (define-key irony-mode-map [remap complete-symbol] + 'irony-completion-at-point-async)) + (add-hook 'irony-mode-hook 'my-irony-mode-hook) + (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options) +#+END_SRC + +irony-company +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (use-package company-irony + :ensure t) + + (eval-after-load 'company + '(add-to-list 'company-backends 'company-irony)) + + (use-package flycheck-irony + :ensure t) + + (eval-after-load 'flycheck + '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup)) +#+END_SRC + +*** yasnippet +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (use-package yasnippet + :ensure t) +#+END_SRC + * Compile Set the environments vairables in compilation mode #+BEGIN_SRC emacs-lisp :tangle yes :results silent @@ -2144,6 +2220,7 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g= (global-set-key (kbd "s-n") 'persp-next) (global-set-key (kbd "s-p") 'persp-prev) + (global-set-key (kbd "s-;") 'persp-switch-last) (global-set-key (kbd "s-=") 'text-scale-increase) (global-set-key (kbd "s--") 'text-scale-decrease) @@ -2268,7 +2345,7 @@ Most use =C-o C-o= to switch buffers; =C-o x, v= to split window; =C-o o= to del ;; ("d" ace-delete-window "ace-one" :exit t) ("C-o" ido-switch-buffer nil :exit t) ("d" sd/project-or-dired-jump nil :exit t) - ("b" ibuffer nil n:exit t) + ("b" ibuffer nil :exit t) ("e" eshell nil :exit t) ("m" bookmark-jump-other-window nil :exit t) ("M" bookmark-set nil :exit t)