├── .gitignore ├── CHANGELOG.org ├── CONTRIBUTING.org ├── LICENSE ├── Makefile ├── README.org ├── core ├── ome-advanced.org ├── ome-auto-mode.org ├── ome-basic.org ├── ome-completion.org ├── ome-gui.org ├── ome-keybindings.org ├── ome-miscs.org ├── ome-org.org └── ome-writing.org ├── custom.el ├── init.el ├── modules ├── ome-cc.org ├── ome-clojure.org ├── ome-common-lisp.org ├── ome-emacs-lisp.org ├── ome-experimental.org ├── ome-golang.org ├── ome-haskell.org ├── ome-java.org ├── ome-javascript.org ├── ome-ocaml.org ├── ome-php.org ├── ome-python.org ├── ome-ruby.org ├── ome-scheme.org ├── ome-sml.org ├── ome-tex.org └── ome-web.org ├── ome-publish.org ├── ome.org └── screenshots ├── auctex-completion.jpg ├── auctex-outline-minor-mode.jpg ├── auto-complete-clojure.jpg ├── auto-complete-common-lisp.jpg ├── auto-complete-cpp-qt.jpg ├── auto-complete-cpp.jpg ├── auto-complete-elisp.jpg ├── auto-complete-javascript.jpg ├── auto-complete-python.jpg ├── auto-complete-scheme.jpg ├── compile-and-view-tex.jpg ├── helm-grep.jpg ├── helm-m-x.jpg ├── helm-man-page.jpg ├── helm-recentf.jpg ├── helm-select-multiple-files.jpg ├── org-babel-emacs-lisp.jpg ├── sr-speedbar.jpg ├── startup-screen.jpg └── w3m-lisp-hyperspec-docs.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#*\# 3 | /.emacs.desktop 4 | /.emacs.desktop.lock 5 | .elc 6 | auto-save-list 7 | tramp 8 | .\#* 9 | 10 | # Org-mode 11 | .org-id-locations 12 | *_archive 13 | 14 | # elpa 15 | elpa 16 | 17 | # el-get 18 | el-get 19 | 20 | # the generated el files by org-babel 21 | ome*el 22 | *ome*part*el 23 | *ome*part*org 24 | 25 | # auto-complete data file 26 | ac*dat 27 | 28 | # saved-places 29 | *saved-places* 30 | 31 | # recentf 32 | .recentf 33 | 34 | # projectile 35 | projectile* 36 | 37 | # url 38 | url 39 | 40 | # oh-my-emacs doc 41 | doc 42 | 43 | # abbrev 44 | abbrev_defs 45 | 46 | # eshell 47 | eshell 48 | 49 | # tex and pdf 50 | *tex 51 | *pdf 52 | 53 | # ido.last 54 | ido.last 55 | -------------------------------------------------------------------------------- /CHANGELOG.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs ChangeLog 2 | 3 | * v0.3 4 | 5 | ** Refactoring 6 | - split ome files to core and modules 7 | 8 | ** core 9 | - By default, use git shallow clone for el-get to save time and bandwidth. 10 | - Upgrade the builtin =org-mode= to latest 8.x branch. 11 | - Enhance =ome-load= and =ome-install= function. 12 | - =ome-package-list-to-org-table= function to get a list of installed 13 | el-get packages in org-mode format. 14 | - Improve compatibility for Mac OS X. 15 | 16 | ** ome-completion module 17 | - Enable filename completion in =text-mode=, =org-mode= and =prog-mode=. 18 | 19 | ** ome-cc module 20 | - Auto-complete support for C/C++ macros 21 | 22 | ** ome-experimental module 23 | - Put some unstable useful package in ome-experimental module, such as 24 | - smooth-scrolling 25 | - hungry-delete 26 | - fill-column-indicator 27 | - doxymacs(moved out from ome-cc module) 28 | 29 | ** ome-java module 30 | - Integrate =emacs-eclim= for Java development. 31 | 32 | ** ome-lisp module 33 | - split the all-in-one ome-lisp module to 34 | - ome-emacs-lisp module 35 | - ome-common-lisp module 36 | - ome-clojure module 37 | - ome-scheme module 38 | 39 | ** ome-javascript module 40 | - Experimental support for JavaScript development 41 | - Enable the following package by default: 42 | - js3-mode 43 | - tern 44 | - nodejs-repl 45 | - Also contains some sample config code for: 46 | - js-comint 47 | - js2-mode 48 | - swank-js 49 | - skewer-mode 50 | 51 | ** ome-ocaml module 52 | - Minimal ocaml development support 53 | 54 | ** Miscs 55 | - Add =diminish=, cleanup mode line 56 | - Add =po-mode= for i18n/l10n work 57 | - Refine smartparens auto newline in cc-mode 58 | - =linum-mode= 59 | - Generally, only enable =linum-mode= in =text-mode= and =prog-mode= 60 | - Enable =linum-mode= in some minor mode. 61 | - Various doc updates 62 | - add CONTRIBUTING guide 63 | - lots of typo fix 64 | 65 | * v0.2 66 | ** Documentation 67 | - Add prerequisites matrix and el-get packages matrix. 68 | 69 | ** Evil 70 | - add =evil-leader= 71 | - add =evil-surround= 72 | - fix evil cursor color for better compatibility with Emacs color-theme 73 | 74 | ** Completion 75 | - Add completion matrix to show the current status of auto-complete support 76 | to various programming languages. 77 | - add =ac-geiser=, new auto-complete backend for geiser. 78 | 79 | ** Ruby 80 | - Basic ruby support 81 | - =inf-ruby= 82 | - =smartparens-ruby= 83 | - auto-mode-alist for ruby 84 | 85 | ** ome-advanced module 86 | - add =expand-region.el= 87 | - add =ace-jump-mode= 88 | - add =ack-and-a-half= 89 | 90 | ** Compatibility 91 | - Fix a $PATH problem in Mac OS, thanks @judevc. 92 | 93 | ** Miscs 94 | - add =lacarte=, the interactive menubar 95 | - Basic flycheck support. 96 | - lots of typo fix. 97 | 98 | * V0.1 99 | ** Basic settings 100 | *** Basic stuff 101 | - set =tab-width= to 4 102 | - =uniquify= buffers with same name 103 | - =saveplace= and =recentf= 104 | - =turn-on-auto-fill= for =text-mode= and =prog-mode= 105 | - =global-auto-revert-mode= for monitoring file changes 106 | - =global-subword-mode= for better code navigation 107 | - =delete-trailing-whitespace= before save. 108 | - other convenient settings such as =yes-or-no-p= prompt, bell rings, etc. 109 | *** GUI 110 | - =powerline= 111 | - =yascroll= for a tiny scrollbar 112 | - use "Monaco" font if available 113 | - disable menu-bar by default 114 | - adopt solarized color-theme 115 | 116 | ** cc-mode 117 | - Adopt =c-context-line-break= for =(kbd "RET")= 118 | - Toggle on hungry-delete and auto-newline 119 | - Open ".h" file in =c++-mode= by default 120 | - CMake file editing support 121 | - Doxymacs support 122 | - Cscope for code indexing 123 | - Completion with =auto-complete-clang= 124 | 125 | ** Completion everywhere 126 | - =M-/= for =hippie-expand= 127 | - Enable =auto-complete= by default, together with an ac support for =pcomplete= 128 | - Use the ubiquitous helm for minibuffer, files/buffer switch completion 129 | support 130 | - Yasnippet for template insertion 131 | 132 | ** Lisp 133 | *** Emacs Lisp 134 | - =turn-on-eldoc-mode= by default 135 | - auto-complete in ielm and eshell 136 | 137 | *** Common Lisp 138 | - Adopt SLIME with a fancy default settings 139 | - ac-slime provide auto-complete backend 140 | - Out-of-box support for sbcl/ccl/clisp 141 | 142 | *** Clojure 143 | - Adopt nrepl, which is similar with SLIME 144 | - ac-nrepl provide auto-complete backend 145 | 146 | *** Scheme 147 | - Adopt geiser, which is similar with SLIME 148 | - Also provide a pseudo code snippet for swank-chicken if you like 149 | 150 | ** Miscs 151 | - Enable some dangerous commands such as =narrow-to-page=, =narrow-to-region= 152 | - Toggle on emacs server mode by default 153 | - Adopt =rainbow-delimiters-mode= for colorful parens 154 | - Open image and compressed files transparently 155 | - Enable =outline-minor-mode= for =prog-mode= 156 | - Adopt =magit= for git integration 157 | - =global-visual-line-mode t= 158 | - Projectile for simple project management 159 | - Smartparens as the ultimate solution for pair management in Emacs 160 | - Emacs-w3m for browsing html docs when you don't want to leave Emacs 161 | - Quickrun to run code snippets instantly 162 | 163 | ** Org-mode settings 164 | - Enable org-mode speed keys by default 165 | - Enable =org-src-fontify-natively= 166 | - Integrate with =htmlize= for html export, solves a conflict between htmlize 167 | and rainbow-delimiters-mode 168 | - Enable cdlatex for org-mode 169 | 170 | ** Python 171 | - Adopt elpy, the one for all solution for Python in Emacs, together with a 172 | comprehensive documentation 173 | 174 | ** \TeX and \LaTeX 175 | - Use =xetex= as the default =TeX-engine= for better support for \TeX{} font 176 | selection and PDF export. 177 | - Enable =outline-minor-mode= and =flyspell-mode=. 178 | - Enable =TeX-interactive-mode=, =TeX-PDF-mode=, =TeX-fold-mode= and 179 | =reftex-mode=. 180 | - Favors [[http://okular.kde.org/][Okular]] and [[https://projects.gnome.org/evince/][Evince]] as the default viewer in Linux, and fallbacks to 181 | =xdg-open= if both Okular and Evince is unavailable. 182 | - =turn-on-cdlatex= with AUCTeX 183 | 184 | ** Writing 185 | - =markdown-mode= support 186 | -------------------------------------------------------------------------------- /CONTRIBUTING.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Contributing 2 | 3 | * Why 4 | 5 | Oh-my-emacs starts as a single guy's endeavor to reorganize his messy 6 | =.emacs.d=. Till now the original goal has been met. So why it is still 7 | continuing? 8 | 9 | Actually, the current goal of oh-my-emacs is to provide an awesome, out-of-box, 10 | literate =.emacs.d= for both newbies and nerds. However, the man who start this 11 | project is just a single guy who want but still didn't own a beautiful Mac 12 | yet. Though he is familiar with Ubuntu and ArchLinux, he knows little about 13 | other Linux distributions(such as Fedora, openSUSE, etc), and Mac. He knows 14 | something about C/C++/Java/Lisp/Python/Ruby/Scheme/Clojure/JavaScript, and 15 | nothing about Haskell/OCaml/Golang/Erlang, etc. So he need help to 16 | - make oh-my-emacs run on more platforms (though no plan for windows port) 17 | - make oh-my-emacs support as many programming languages, workflows as 18 | possible. 19 | 20 | * How 21 | 22 | First, please do contribute! There are several ways to contribute: 23 | 24 | - introduce oh-my-emacs to your friends 25 | - submit bugs via github issues 26 | - send patches via github pull request 27 | - Fix doc typo, grammer and syntax error, that should not be so hard 28 | - Develop new packages for oh-my-emacs 29 | - Develop new modules for oh-my-emacs, which may contans serveral emacs 30 | packages (I'll be really appreciate for package and module contributor.) 31 | 32 | Possible ideas to improve oh-my-emacs: 33 | - Semantic completion, based on [[https://github.com/auto-complete/auto-complete][auto-complete]], which is one of the main 34 | selling points of oh-my-emacs. 35 | - Support new languages, such as Haskell/OCaml/Golang/Erlang, etc. 36 | - Add [[https://travis-ci.org/][travis-ci]] support to this project. Currently, the stupid guy still 37 | didn't figure out a good way to integrate travis-ci, he need your help. 38 | 39 | * Rules 40 | 41 | - Documentation is important, please do provide some documentation for 42 | packages or modules. 43 | 44 | * Workflow 45 | ** Codebase 46 | 47 | The basic code structure for a new el-get package is: 48 | 49 | #+BEGIN_SRC emacs-lisp 50 | (defun ome-package-name-setup () 51 | ;; put elisp code here for package customization 52 | ;; (setq package-name-variable t) 53 | ) 54 | 55 | (ome-install 'package-name) 56 | #+END_SRC 57 | 58 | The function =ome-package-name-setup= provide some user customizations for 59 | package. =(ome-install 'package-name)= will tell oh-my-emacs that "I want this 60 | package installed with customization code in =ome-package-name-setup= 61 | function." 62 | 63 | ** Git hints 64 | 65 | - You'd better not to work on =master= branch, please check out a new 66 | topic/feature/bugfix branch of your own: 67 | 68 | #+BEGIN_SRC sh 69 | git checkout -b feature/add-ome-package 70 | #+END_SRC 71 | 72 | - Please rebase your code if github reminds you some code conflict, which 73 | means the base branch you checked out from is a little outdated and need to 74 | be updated first. 75 | 76 | #+BEGIN_SRC sh 77 | # checkout to your base branch 78 | git checkout master 79 | # pull from remote 80 | git pull origin master 81 | # checkout to your feature branch 82 | git checkout feature/add-ome-package 83 | # rebase 84 | git rebase -i 85 | # solve code conflicts 86 | # git add; git commit 87 | #+END_SRC 88 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) [2016], [Xiao Hanyu] 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Name of your emacs binary 2 | EMACS=emacs 3 | 4 | BATCH=$(EMACS) --batch -Q --eval '(require (quote org))' --eval '(setq ome-dir default-directory)' 5 | 6 | FILES = ome.org 7 | 8 | FILESO = $(FILES:.org=.el) 9 | 10 | all: el 11 | $(BATCH) --eval '(mapc (lambda (x) (byte-compile-file (symbol-name x))) (quote ($(FILESO))))' 12 | 13 | el: $(FILES) 14 | $(BATCH) --eval '(mapc (lambda (x) (org-babel-load-file (symbol-name x))) (quote ($(FILES))))' 15 | 16 | %.el: %.org 17 | $(BATCH) --eval '(org-babel-load-file "$<")' 18 | 19 | doc: doc/index.html 20 | 21 | doc/index.html: 22 | mkdir -p doc 23 | $(BATCH) --batch -Q --eval '(org-babel-load-file "ome-publish.org")' 24 | rm ome-publish.el 25 | cp doc/README.html doc/index.html 26 | echo "Documentation published to doc/" 27 | 28 | tarball: 29 | tar czf oh-my-emacs.tar.gz \ 30 | --exclude-backups \ 31 | core el-get modules ome-el-get-recipes \ 32 | CHANGELOG.org CONTRIBUTING.org custom.el init.el \ 33 | LICENSE.txt Makefile ome.org ome-publish.org README.org 34 | 35 | clean: 36 | rm -f *.elc *.aux *.tex *.pdf ome*.el ome*.html doc/*html *~ .ome*.part.org 37 | -------------------------------------------------------------------------------- /core/ome-advanced.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Advanced 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some advanced features or packages which could make emacs 7 | look unlike emacs. So ensure you have some basic knowledge and experience 8 | before loading this file. 9 | 10 | * Prerequisites 11 | :PROPERTIES: 12 | :CUSTOM_ID: advanced-prerequisites 13 | :END: 14 | 15 | #+NAME: advanced-prerequisites 16 | #+CAPTION: Prerequisites for ome-advanced module 17 | | | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 18 | |----------+---------+---------------------------+------------------------------+---------------------+---------------------+------------| 19 | | [[http://www.tug.org/texlive/][texlive]] | | texlive-full latex-beamer | texlive-most texlive-langcjk | texlive-all | | Yes | 20 | | [[http://beyondgrep.com/][ack-grep]] | ack | ack-grep | ack | ack | ack | No | 21 | | [[https://github.com/ggreer/the_silver_searcher][ag]] | | the_silver_searcher | the_silver_searcher | the_silver_searcher | the_silver_searcher | No | 22 | 23 | Notes: 24 | - [[http://www.tug.org/texlive/][texlive]] is required by evil, since evil need =texi2pdf= to =make 25 | info=. However, I don't think it is a good idea to install the huge texlive 26 | just to build evil, so I've made a [[http://gitorious.org/evil/evil/merge_requests/50][patch]] for it. 27 | 28 | * El-get packages 29 | :PROPERTIES: 30 | :CUSTOM_ID: advanced-el-get-packages 31 | :END: 32 | 33 | #+NAME: advanced-el-get-packages 34 | #+CAPTION: El-get packages matrix for ome-advanced module 35 | | Package | Status | Description | 36 | |------------------+-------------+-----------------------------------------------| 37 | | [[http://gitorious.org/evil][evil]] | Required | Finally, the Emacs OS get a good editor. | 38 | | [[https://github.com/cofi/evil-leader][evil-leader]] | Required | key for evil. | 39 | | [[https://github.com/timcharper/evil-surround][evil-surround]] | Recommended | Surround.vim for evil. | 40 | | [[https://github.com/magnars/expand-region.el][expand-region.el]] | Recommended | Expand and select. | 41 | | [[git://gitorious.org/vimpulse/vimpulse.git][vimpulse]] | Deprecated | Use evil instead. | 42 | | [[http://www.gnu.org/software/emacs/manual/html_node/viper/][viper]] | Deprecated | Use evil instead. | 43 | | [[https://github.com/Wilfred/ag.el][ag.el]] | Recommended | Better than ack. | 44 | | [[https://github.com/syohex/emacs-helm-ag][helm-ag.el]] | Recommended | Helm interface to ag. | 45 | | [[https://github.com/jhelwig/ack-and-a-half][ack-and-a-half]] | Deprecated | Yet another emacs front-end to ack. | 46 | | [[https://github.com/winterTTr/ace-jump-mode][ace-jump-mode]] | Recommended | A quick cursor location minor mode for emacs. | 47 | 48 | * Evil 49 | :PROPERTIES: 50 | :CUSTOM_ID: evil 51 | :END: 52 | 53 | #+BEGIN_QUOTE 54 | As a poke at Emacs' creeping featurism, vi advocates have been known to 55 | describe Emacs as "a great operating system, lacking only a decent editor". 56 | 57 | -- [[http://en.wikipedia.org/wiki/Editor_war][Editor war]] 58 | #+END_QUOTE 59 | 60 | I must say that emacs is a great platform, but lacks a quick and effective 61 | editor like vi, fortunately, there comes [[http://gitorious.org/evil][evil]]. 62 | 63 | "Evil is an extensible vi layer for Emacs. It emulates the main features of 64 | Vim, and provides facilities for writing custom extensions." IMHO, evil is a 65 | great successor to [[http://www.emacswiki.org/emacs/Vimpulse][Vimpulse]], [[http://www.emacswiki.org/emacs/VimMode][vim-mode]] and [[http://www.emacswiki.org/emacs/ViperMode][ViperMode]]. 66 | 67 | By default, oh-my-emacs =turn-on-evil-mode= on =text-mode= and =prog-mode=, 68 | since emacs has only three [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Major-Modes.html][basic major modes]], you'll get evil enabled in almost 69 | all modes which focus on editing, by editing I mean, modes such as =c-mode=, 70 | =js-mode= would =turn-on-evil-mode=, however, modes such as =dired=, =info= 71 | would not =turn-on-evil-mode= by default. And since =Info-mode= didn't has a 72 | parent mode, so we need to =turn-off-evil-mode= manually. 73 | 74 | If you need to turn off evil temporarily for a single buffer, use 75 | =M-x evil-local-mode= instead of =M-x evil-mode=, since the latter will turn 76 | off evil-mode globally, which means, evil-mode will be turned off for the whole 77 | Emacs session. 78 | 79 | #+NAME: evil 80 | #+BEGIN_SRC emacs-lisp 81 | (defun ome-evil-setup () 82 | ;; (define-key evil-insert-state-map (kbd "C-[") 'evil-force-normal-state) 83 | (setq evil-auto-indent t) 84 | (setq evil-regexp-search t) 85 | (setq evil-want-C-i-jump t) 86 | (mapc 87 | (lambda (mode-hook) 88 | (add-hook mode-hook 'turn-on-evil-mode)) 89 | '(text-mode-hook 90 | prog-mode-hook 91 | comint-mode-hook 92 | conf-mode-hook)) 93 | (mapc 94 | (lambda (mode-hook) 95 | (add-hook mode-hook 'turn-off-evil-mode)) 96 | '(Info-mode-hook))) 97 | 98 | (ome-install 'evil) 99 | #+END_SRC 100 | 101 | * Evil-leader 102 | :PROPERTIES: 103 | :CUSTOM_ID: evil-leader 104 | :END: 105 | 106 | The keyboard is a real and heavily occupied estate in both Emacs and 107 | Vim. Specially, just about every key is already bound to a command in normal 108 | state Vim. Fortunately, Vim provides an easy way to define additional mappings 109 | on these keys. It's called a [[http://usevim.com/2012/07/20/vim101-leader/][mapleader]]. 110 | 111 | Evil leader just provides the == feature from Vim to evil, which 112 | provides an easy way to bind keys under a variable prefix key. The default 113 | binding of == is =\=, which is not easy to reach, so oh-my-emacs bind 114 | it to ==, you don't use == to move right, ha? Some other people 115 | prefer to bind the == key to comma =,=, but =,= already has a 116 | binding(=evil-repeat-find-char-revers= in evil normal state). 117 | 118 | BTW, oh-my-emacs will use [[https://github.com/emacs-helm/helm][helm]] in evil-leader if available. Since I'm a heavy 119 | user of [[https://github.com/emacs-helm/helm][helm]], I personally bind lots of keys with evil-leader just for [[https://github.com/emacs-helm/helm][helm]]. So 120 | now you can do =helm-find-files= simply by = e=, for example. Enjoy it. 121 | 122 | I also bind some keys to [[https://github.com/syohex/emacs-git-gutter][git-gutter.el]], so you can just stage your commits when 123 | editing your document at your fingertips. 124 | 125 | #+NAME: evil-leader 126 | #+BEGIN_SRC emacs-lisp 127 | (defun ome-evil-leader-setup () 128 | (evil-leader/set-leader "") 129 | (unless (featurep 'helm) 130 | (evil-leader/set-key 131 | "e" 'find-file 132 | "b" 'switch-to-buffer)) 133 | (eval-after-load "helm" 134 | (progn 135 | (require 'helm-projectile) 136 | (evil-leader/set-key 137 | "f" 'helm-for-files 138 | "l" 'helm-locate 139 | "y" 'helm-show-kill-ring 140 | "t" 'helm-top 141 | "m" 'helm-man-woman 142 | "o" 'helm-occur 143 | "j" 'helm-M-x 144 | "e" 'helm-find-files 145 | "b" 'helm-buffers-list 146 | "h" 'helm-projectile-find-file 147 | "r" 'helm-recentf 148 | "H" 'helm-projectile))) 149 | (eval-after-load "helm-ag" 150 | (evil-leader/set-key 151 | "a" 'helm-projectile-ag)) 152 | (eval-after-load "expand-region" 153 | (progn 154 | (setq expand-region-contract-fast-key "z") 155 | (evil-leader/set-key "xx" 'er/expand-region))) 156 | (eval-after-load "magit" 157 | (evil-leader/set-key "g" 'magit-status)) 158 | (eval-after-load "quickrun" 159 | (evil-leader/set-key "q" 'quickrun)) 160 | (eval-after-load "git-gutter-mode" 161 | (evil-leader/set-key 162 | "s" 'git-gutter:stage-hunk 163 | "n" 'git-gutter:next-hunk 164 | "p" 'git-gutter:previous-hunk)) 165 | (evil-leader/set-key 166 | "k" 'kill-buffer 167 | "d" 'dired 168 | "z" 'repeat 169 | "0" 'delete-window 170 | "1" 'delete-other-windows 171 | "2" 'split-window-below 172 | "3" 'split-window-right) 173 | (global-evil-leader-mode)) 174 | 175 | (ome-install 'evil-leader) 176 | #+END_SRC 177 | 178 | * Evil-surround 179 | :PROPERTIES: 180 | :CUSTOM_ID: evil-surround 181 | :END: 182 | 183 | As I said, =smartparens= is the ultimate pair management solution for 184 | Emacs. So why [[https://github.com/timcharper/evil-surround][evil-surround]]? 185 | 186 | [[https://github.com/timcharper/evil-surround][evil-surround]] is a port of [[https://github.com/tpope/vim-surround][vim-surround]] to evil. I think you can treat 187 | =evil-surround= as a complement of =smartparens= in pair changing, deleting 188 | and adding, while =smartparens= is good at pair inserting and operating. 189 | 190 | IMHO, no editors can compete with Vim in pure text editing speed[1]. So I 191 | think =evil-surround= is still worth a try. [[http://www.catonmat.net/blog/vim-plugins-surround-vim/][Here]] is an excellent and concise 192 | tutorial for =vim-surround=. Note that there may be some minor differences 193 | between =evil-surround= and =vim-surround=. However, for daily use, they're 194 | almost the same. 195 | 196 | #+NAME: evil-surround 197 | #+BEGIN_SRC emacs-lisp 198 | (ome-install 'evil-surround) 199 | #+END_SRC 200 | 201 | * Expand-region 202 | :PROPERTIES: 203 | :CUSTOM_ID: expand-region 204 | :END: 205 | 206 | Often we need to select text. We select since we want to limit our operation to 207 | a small region. For a long time, people select text by =C-@= and then manually 208 | moving the point with =C-f=, =M-f= or something similar. 209 | 210 | However, most of the time, we want to select text by semantic unit, such as 211 | sentences, paragraphs, s-exps, code blocks, instead of just select character by 212 | character, or word by word. So there comes [[https://github.com/magnars/expand-region.el][expand-region.el]], created by 213 | [[https://github.com/magnars/expand-region.el][magnars]], the author of [[http://emacsrocks.com/][emacsrocks]]. 214 | 215 | As its name, =expand-region= can expand/contract the selected region by 216 | semantic units. Just keep pressing the key until it selects what you 217 | want. Here's a live [[http://emacsrocks.com/e09.html][demo]] of expand-region from emacsrocks. 218 | 219 | Again, oh-my-emacs defines two extra lazy keys with the help of =evil-leader=, 220 | thus, in normal-state evil, you can trigger =(er/expand-region)= by = 221 | xx=, and then expand/contract the region by hitting =x= or =z=. 222 | 223 | If you are in =evil-insert-state=, you can trigger =(er/expand-region)= by 224 | =C-==. Ah, in this case, =smartparens= is your good friend. You can select the 225 | region, then QUOTE the region with =smartparens= pairs. Sounds amazing, ha? 226 | Just try it and you will love it. 227 | 228 | #+NAME: expand-region 229 | #+BEGIN_SRC emacs-lisp 230 | (defun ome-expand-region-setup () 231 | (global-set-key (kbd "C-=") 'er/expand-region)) 232 | 233 | (ome-install 'expand-region) 234 | #+END_SRC 235 | 236 | * Ace-jump-mode 237 | :PROPERTIES: 238 | :CUSTOM_ID: ace-jump-mode 239 | :END: 240 | 241 | [[https://github.com/winterTTr/ace-jump-mode][ace-jump-mode]] is a minor mode for Emacs, enabling fast/direct cursor movement 242 | in current view. "You can move your cursor to ANY position (across window and 243 | frame) in emacs by using only 3 times key press." 244 | 245 | To tell the truth, I still don't why it it called "ace-jump". Seems [[https://github.com/johnlindquist/AceJump][AceJump]] 246 | first appears as an [[http://www.jetbrains.com/idea/][Intellij]] [[http://plugins.jetbrains.com/plugin/7086?pr%3DphpStorm][plugin]]. [[http://www.vim.org/scripts/script.php?script_id%3D3526][EasyMotion]] provides a similar feature to 247 | Vim. 248 | 249 | Oh-my-emacs adopt [[https://github.com/cofi/evil-leader][evil-leader]] and bind serveral keys to ace-jump-mode commands: 250 | - = c=: =ace-jump-char-mode= 251 | - = w=: =ace-jump-word-mode= 252 | - = l=: =ace-jump-line-mode= 253 | 254 | By default, == is ==, so you can use = c= to activate 255 | =ace-jump-char-mode=, and move you cursor quickly and directly. Enjoy it. 256 | 257 | #+NAME: ace-jump-mode 258 | #+BEGIN_SRC emacs-lisp 259 | (defun ome-ace-jump-mode-setup () 260 | (when (and (featurep 'evil) (featurep 'evil-leader)) 261 | (evil-leader/set-key 262 | "c" 'ace-jump-char-mode 263 | "w" 'ace-jump-word-mode 264 | "l" 'ace-jump-line-mode))) 265 | 266 | (ome-install 'ace-jump-mode) 267 | #+END_SRC 268 | 269 | * ag 270 | :PROPERTIES: 271 | :CUSTOM_ID: ag 272 | :END: 273 | 274 | ag, [[https://github.com/ggreer/the_silver_searcher][the silver searcher]], a code searching tool similar to [[http://beyondgrep.com/][ack]] but much more 275 | faster. It searches code abot 3-5x faster than ack, and "The command name is 276 | 33% shorter than ack, and all keys are on the home row!". I've used it for 277 | serveral months and it's amazing. 278 | 279 | [[https://github.com/bbatsov/projectile][Projectile]] has builtin support for ag(=projectile-ag=) via =C-c p A=. 280 | 281 | #+NAME: ag 282 | #+BEGIN_SRC emacs-lisp 283 | (when (executable-find "ag") 284 | (ome-install 'ag)) 285 | #+END_SRC 286 | 287 | * helm-ag 288 | :PROPERTIES: 289 | :CUSTOM_ID: helm-ag 290 | :END: 291 | 292 | [[https://github.com/syohex/emacs-helm-ag][helm-ag.el]] provides interfaces of [[https://github.com/ggreer/the_silver_searcher][The Silver Searcher]] with helm. 293 | 294 | #+NAME: helm-ag 295 | #+BEGIN_SRC emacs-lisp 296 | (when (executable-find "ag") 297 | (ome-install 'helm-ag)) 298 | #+END_SRC 299 | 300 | * Todo 301 | *** Evil mode 302 | - Evil has some conflicts with smartparens due to cursor position. I should 303 | temporarily disable =evil-local-mode= when I do operations like 304 | =sp-up-sexp=. Maybe I can get this by =post-command-hook= or smartparens's 305 | =post-command-handler=? Or just use =defadvice=? 306 | 307 | 308 | [1] See [[http://vimgolf.com/][vimgolf]] for funny things. 309 | -------------------------------------------------------------------------------- /core/ome-auto-mode.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Auto-mode 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains various settings for minor file types, such as SCons build 7 | file, archlinux's PKGBUILD file, etc. 8 | 9 | * El-get packages 10 | :PROPERTIES: 11 | :CUSTOM_ID: auto-mode-el-get-packages 12 | :END: 13 | 14 | #+NAME: auto-mode-el-get-packages 15 | #+CAPTION: el-get packages for ome-auto-mode module 16 | | Package | Status | Description | 17 | |-----------+----------+-------------------------------------| 18 | | [[https://github.com/yoshiki/yaml-mode.git][yaml-mode]] | Required | Major mode for editting YAML files. | 19 | 20 | * SCons 21 | :PROPERTIES: 22 | :CUSTOM_ID: scons 23 | :END: 24 | 25 | [[http://www.scons.org/][SCons]] is a next generation build system that is much easier to configure and 26 | use than the traditional make utility. SCons uses the Python general purpose 27 | programming language as a foundation, and all SCons build files are Python 28 | scripts, so we just set SCons build file work with python-mode. 29 | 30 | #+NAME: scons 31 | #+BEGIN_SRC emacs-lisp 32 | (add-to-list 'auto-mode-alist '("SConstruct" . python-mode)) 33 | #+END_SRC 34 | 35 | * Puppet 36 | :PROPERTIES: 37 | :CUSTOM_ID: puppet 38 | :END: 39 | 40 | [[https://puppetlabs.com/][Puppet]] is configuration management tool from [[http://en.wikipedia.org/wiki/Puppet_Labs][Puppet Labs]], it is the de facto 41 | industry standard for IT automation. Puppet is written by ruby but has its own 42 | DSL, so the emacs builtin =ruby-mode= is not proper for editing puppet files. 43 | 44 | #+NAME: puppet 45 | #+BEGIN_SRC emacs-lisp 46 | (defun ome-puppet-mode-setup () 47 | (when (featurep 'evil) 48 | (add-hook 'puppet-mode-hook 'turn-on-evil-mode))) 49 | 50 | (ome-install 'puppet-mode) 51 | #+END_SRC 52 | 53 | * ArchLinux PKGBUILD 54 | :PROPERTIES: 55 | :CUSTOM_ID: pkgbuild 56 | :END: 57 | 58 | A PKGBUILD is an Arch Linux package build description file, which is actually 59 | a shell script. Thus you can edit PKGBUILD file with emacs 60 | =shell-script-mode=, however, =pkgbuild-mode= provides a better workflow based 61 | on =shell-script-mode= for PKGBUILD files, including: 62 | - A default PKGBUILD template as a starting point 63 | - Some shortcuts to update md5sum, browse package's website, build tarball, 64 | etc. 65 | 66 | Just install =pkgbuild-mode= from =el-get= will bring all this goodies to your 67 | fingertips. 68 | 69 | #+NAME: pkgbuild 70 | #+BEGIN_SRC emacs-lisp 71 | (when (executable-find "pacman") 72 | (ome-install 'pkgbuild-mode)) 73 | #+END_SRC 74 | 75 | * Dockerfile 76 | :PROPERTIES: 77 | :CUSTOM_ID: dockerfile 78 | :END: 79 | 80 | [[https://www.docker.com/][docker]] is a new awesome platform to building and shipping development and 81 | production environment. 82 | 83 | #+NAME: dockerfile-mode 84 | #+BEGIN_SRC emacs-lisp 85 | (defun dockerfile-mode-setup ()) 86 | 87 | (ome-install 'dockerfile-mode) 88 | #+END_SRC 89 | 90 | * Wikipedia 91 | :PROPERTIES: 92 | :CUSTOM_ID: wikipedia 93 | :END: 94 | 95 | Wikitext language, or [[http://en.wikipedia.org/wiki/Wiki_markup][wiki markup]], is a lightweight markup language used to 96 | write pages in wiki websites, such as Wikipedia, and is a simplified 97 | alternative/intermediate to HTML. Its ultimate purpose is to be converted by 98 | wiki software into HTML, which in turn is served to web browsers. 99 | 100 | Unfortunately, there is no commonly accepted standard wikitext language. So I 101 | just pick =wikipedia-mode=, which is one of the many possible packages from 102 | el-get, as the mode for editing wiki documents. If you have better choice, 103 | please tell me. 104 | 105 | #+NAME: wikipedia 106 | #+BEGIN_SRC emacs-lisp 107 | (defun ome-wikipedia-mode-setup () 108 | (add-to-list 'auto-mode-alist 109 | '("\\.wiki\\'" . wikipedia-mode))) 110 | 111 | (ome-install 'wikipedia-mode) 112 | #+END_SRC 113 | * YAML 114 | :PROPERTIES: 115 | :CUSTOM_ID: yaml 116 | :END: 117 | 118 | [[http://www.yaml.org/][YAML]] is a human friendly data serialization standard for all programming 119 | languages. I really like it for its simplicity and readability. However, Emacs 120 | didn't have a builtin mode for editing YAML files, so you know how easy to 121 | solve this by adopting =el-get=. Thanks =el-get= again! 122 | 123 | [[http://raml.org/][RAML]] is a spec for building RESTful APIs, it is built on top of 124 | YAML. Currently, as I know, there's no =raml-mode=. 125 | 126 | #+NAME: yaml 127 | #+BEGIN_SRC emacs-lisp 128 | (defun ome-yaml-mode-setup () 129 | (add-hook 'yaml-mode-hook 130 | (lambda () 131 | (linum-mode 1) 132 | (evil-local-mode 1) 133 | (indent-guide-mode 1))) 134 | (add-to-list 'auto-mode-alist '("\\.raml\\'" . yaml-mode)) 135 | (add-to-list 'ac-modes 'yaml-mode)) 136 | 137 | (ome-install 'yaml-mode) 138 | #+END_SRC 139 | -------------------------------------------------------------------------------- /core/ome-basic.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Basic 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: basic-prerequisites 9 | :END: 10 | 11 | #+NAME: basic-prerequisites 12 | #+CAPTION: Prerequisites for ome-basic module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |------------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://aspell.net/][GNU Aspell]] | | aspell, aspell-en | | | | | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: basic-el-get-packages 20 | :END: 21 | 22 | #+NAME: basic-el-get-packages 23 | #+CAPTION: el-get packages for ome-basic module 24 | | Package | Status | Description | 25 | |----------------------+-------------+---------------------------------------------------------------------------| 26 | | saveplace | Builtin | Save cursor place in opened files. | 27 | | recentf | Builtin | Maintains a recent opened file list. | 28 | | uniquify | Builtin | Better differentiate buffers with same file name. | 29 | | auto-fill-mode | Builtin | We should still obey the 80-characters rule. | 30 | | [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] | Required | ensure environment variables inside Emacs the same as in the user's shell | 31 | | [[https://github.com/flycheck/flycheck][flycheck]] | Recommended | aka "Flymake done right" | 32 | | [[https://github.com/editorconfig/editorconfig-emacs][editorconfig]] | Recommended | [[http://editorconfig.org][EditorConfig]] plugin for emacs | 33 | | [[https://github.com/zk-phi/indent-guide][indent-guide]] | Recommended | Show vertical lines to guide indentation | 34 | 35 | * Some Basic Settings 36 | :PROPERTIES: 37 | :CUSTOM_ID: basic 38 | :END: 39 | 40 | Sometimes you find weird thing in OS X's Emacs that a command works in your 41 | shell but not in Emacs. Thus you cannot install some el-get packages such as 42 | [[http://www.gnu.org/software/auctex/][auctex]]. 43 | 44 | Thanks [[https://github.com/purcell/exec-path-from-shell][purcell/exec-path-from-shell]], it solves this problem perfectly. 45 | 46 | #+NAME: exec-path-from-shell 47 | #+BEGIN_SRC emacs-lisp 48 | (defun ome-exec-path-from-shell-setup () 49 | (when (memq window-system '(mac ns)) 50 | (exec-path-from-shell-initialize))) 51 | 52 | (ome-install 'exec-path-from-shell) 53 | #+END_SRC 54 | 55 | #+NAME: basic 56 | #+BEGIN_SRC emacs-lisp 57 | ;; set environment coding system 58 | (set-language-environment "UTF-8") 59 | ;; auto revert buffer globally 60 | (global-auto-revert-mode t) 61 | ;; set TAB and indention 62 | (setq-default tab-width 4) 63 | (setq-default indent-tabs-mode nil) 64 | ;; y or n is suffice for a yes or no question 65 | (fset 'yes-or-no-p 'y-or-n-p) 66 | ;; always add new line to the end of a file 67 | (setq require-final-newline t) 68 | ;; add no new lines when "arrow-down key" at the end of a buffer 69 | (setq next-line-add-newlines nil) 70 | ;; prevent the annoying beep on errors 71 | (setq ring-bell-function 'ignore) 72 | ;; remove trailing whitespaces before save 73 | (add-hook 'before-save-hook 'delete-trailing-whitespace) 74 | ;; enable to support navigate in camelCase words 75 | (global-subword-mode t) 76 | ;; hide startup splash screen 77 | (setq inhibit-startup-screen t) 78 | 79 | ;; shell-mode settings 80 | (unless (eq system-type 'windows-nt) 81 | (setq explicit-shell-file-name "/bin/bash") 82 | (setq shell-file-name "/bin/bash")) 83 | ;; always insert at the bottom 84 | (setq comint-scroll-to-bottom-on-input t) 85 | ;; no duplicates in command history 86 | (setq comint-input-ignoredups t) 87 | ;; what to run when i press enter on a line above the current prompt 88 | (setq comint-get-old-input (lambda () "")) 89 | ;; max shell history size 90 | (setq comint-input-ring-size 1000) 91 | ;; show all in emacs interactive output 92 | (setenv "PAGER" "cat") 93 | ;; set lang to enable Chinese display in shell-mode 94 | (setenv "LANG" "en_US.UTF-8") 95 | 96 | ;; set text-mode as the default major mode, instead of fundamental-mode 97 | ;; The first of the two lines in parentheses tells Emacs to turn on Text mode 98 | ;; when you find a file, unless that file should go into some other mode, such 99 | ;; as C mode. 100 | (setq-default major-mode 'text-mode) 101 | 102 | ;;; ido-mode 103 | (setq ido-enable-prefix nil) 104 | (setq ido-enable-case nil) 105 | (setq ido-enable-flex-matching t) 106 | (setq ido-everywhere t) 107 | (ido-mode t) 108 | 109 | ;; use icomplete in minibuffer 110 | (icomplete-mode t) 111 | 112 | ;; delete the selection with a keypress 113 | (delete-selection-mode t) 114 | #+END_SRC 115 | 116 | * Mac OS X compatibilities 117 | :PROPERTIES: 118 | :CUSTOM_ID: mac 119 | :END: 120 | 121 | ** Installation 122 | 123 | There're multiple [[http://wikemacs.org/index.php/Installing_Emacs_on_OS_X][choices]] to install Emacs on Mac OS X. I prefer [[http://brew.sh/][Homebrew]], and 124 | got my Emacs with =brew install emacs --cocoa=. This version of emacs even has 125 | native [[http://batsov.com/articles/2012/12/09/emacs-24-dot-3-introduces-native-osx-full-screen-support/][full screen support]]. 126 | 127 | You'd better remove the outdated OS X's emacs to avoid conflicts with the new 128 | one. 129 | 130 | #+BEGIN_SRC sh 131 | sudo rm /usr/bin/emacs 132 | sudo rm -rf /usr/share/emacs 133 | #+END_SRC 134 | 135 | ** Keybindings 136 | 137 | Another problem with emacs on Mac OX X is the keybindings to =Meta= and 138 | =Control=. Since most of the macbooks lack the right =Control= key, I prefer to 139 | bind Mac's =Command= and =Option= key to Emacs's =Meta= and =Control= key, 140 | respectively. 141 | 142 | However, sometimes, people would like to use an exteranl keyboard as the main 143 | input, so we need a switch between the "Mac" keys and "PC" keys via =M-x 144 | ome-switch-mac-keys=. 145 | 146 | #+BEGIN_SRC emacs-lisp 147 | (defvar mac-keys-p nil) 148 | 149 | (defun ome-switch-mac-keys () 150 | (interactive) 151 | (if mac-keys-p 152 | (progn 153 | (setq mac-command-modifier 'super) 154 | (setq mac-option-modifier 'meta) 155 | (setq mac-keys-p nil) 156 | (message "turn off Mac OS X's control/meta.")) 157 | (progn 158 | (setq mac-command-modifier 'meta) 159 | (setq mac-option-modifier 'control) 160 | (setq mac-keys-p t) 161 | (message "turn on Mac OS X's control/meta.")))) 162 | 163 | (when (eq system-type 'darwin) 164 | (ome-switch-mac-keys)) 165 | #+END_SRC 166 | 167 | ** Homebrew 168 | 169 | Lots of oh-my-emacs packages depends on external tools/libs/packages, which can 170 | be installed by apt(Ubuntu/Debian/Mint), yum(Fedora), homebrew(ala, Mac OS 171 | X). However, unlike other linux distributions, Mac OS X often has two different 172 | package collections, one is the system builtin, the other is something like 173 | homebrew. Sometimes, there're conflicts that makes you think that you have got 174 | the latest packages while actually emacs still use the system's builtin, 175 | outdated packages. So we need some special settings for this. 176 | 177 | Many el-get packages(such as [[http://common-lisp.net/project/slime/][slime]] in ome-common-lisp module) need [[http://www.gnu.org/software/texinfo/][texinfo]]. You 178 | can get latest texinfo by: 179 | 180 | #+BEGIN_SRC sh 181 | brew install texinfo 182 | #+END_SRC 183 | 184 | then you must do something to make texinfo become emacs's good friend. 185 | #+BEGIN_SRC sh 186 | brew link texinfo --force 187 | #+END_SRC 188 | 189 | * File encoding 190 | 191 | By default, emacs will detect file encoding according to an encoding priority 192 | list when opening a file, you can get your file encoding information by =C-h 193 | C=, aka =(describe-coding-system)=. However, sometimes this encoding priority 194 | list may not be proper for you, in this case, you can change this encoding 195 | priority list by =(set-coding-system-priority &rest coding-systems)=. 196 | 197 | For example, if you are Chinese and often have to work with Windows text 198 | document, then =(set-coding-system-priority 'utf-8 'chinese-gb18030)= may be 199 | the right solution for you to avoid garbled text. This statement tells emacs 200 | first try to open a chinese text file with utf-8 encoding, if failed, then try 201 | to open again with [[http://en.wikipedia.org/wiki/GB_18030][gb18030]] encoding. This will works for most Chinese users. 202 | 203 | If you want to change the file encoding temporarily when opening a file, 204 | =M-x revert-buffer-with-coding-system=. 205 | 206 | Text encoding is a complex topic, check emacs [[https://www.gnu.org/software/emacs/manual/html_node/emacs/International.html][manual]] for internal details. 207 | 208 | Check https://github.com/xiaohanyu/oh-my-emacs/issues/132 for detailed 209 | discussion. 210 | 211 | * Auto-fill Mode 212 | :PROPERTIES: 213 | :CUSTOM_ID: auto-fill 214 | :END: 215 | 216 | [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html][Auto Fill mode]] is a buffer-local minor mode in which lines are broken 217 | automatically when they become too wide. Breaking happens only when you type a 218 | or . 219 | 220 | You may wonder why we still live with 80 columns rule in modern life, in which 221 | we have large monitors, intelligent editors(or IDEs). I don't explain the 222 | reasons here, you can refer stackoverflow [[http://stackoverflow.com/questions/110928/is-there-a-valid-reason-for-enforcing-a-maximum-width-of-80-characters-in-a-code][1]] and [[http://stackoverflow.com/questions/373561/do-people-still-live-by-the-80-column-rule][2]] to get some feeling. 223 | 224 | I zealously wrap my code at 80 columns if possible, and encourage my colleagues 225 | to follow the same rule. In fact, there're some projects in which 80 columns 226 | rule is mandatory. 227 | 228 | I enable auto fill minor mode for text-mode and prog-mode and all [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Derived-Modes.html][derived modes]] 229 | from them[1]. For how to quickly fill a paragraph or region, see [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Fill-Commands.html][Explicit Fill 230 | Commands]]. 231 | 232 | #+NAME: auto-fill 233 | #+BEGIN_SRC emacs-lisp 234 | (setq-default fill-column 79) 235 | (add-hook 'text-mode-hook 'turn-on-auto-fill) 236 | (add-hook 'prog-mode-hook 'turn-on-auto-fill) 237 | #+END_SRC 238 | 239 | * Save Place in Opened Files 240 | :PROPERTIES: 241 | :CUSTOM_ID: saveplace 242 | :END: 243 | 244 | When you visit a file, point goes to the last place where it was when you 245 | previously visited the same file. The following code comes from [[http://emacs-fu.blogspot.com/2009/05/remembering-your-position-in-file.html][emacs-fu]]. 246 | 247 | #+NAME: saveplace 248 | #+BEGIN_SRC emacs-lisp 249 | (setq-default save-place t) 250 | (setq save-place-file (concat user-emacs-directory ".saved-places")) 251 | (require 'saveplace) 252 | #+END_SRC 253 | 254 | * Recentf 255 | :PROPERTIES: 256 | :CUSTOM_ID: recentf 257 | :END: 258 | 259 | All modern editors(or IDEs) provide features like open recent files/projects, 260 | so does emacs -- =recentf=, a builtin emacs package which maintains a menu for 261 | visiting files that were operated on recently. Together with =savespace=, 262 | emacs provides a quick way to restore your workspace. 263 | 264 | The following code comes from [[http://www.masteringemacs.org/articles/2011/01/27/find-files-faster-recent-files-package/][masteringemacs]], which combined =ido= and 265 | =recentf=. 266 | 267 | #+NAME: recentf 268 | #+BEGIN_SRC emacs-lisp 269 | (require 'recentf) 270 | 271 | ;; get rid of `find-file-read-only' and replace it with something 272 | ;; more useful. 273 | (global-set-key (kbd "C-x C-r") 'ido-recentf-open) 274 | 275 | ;; save the .recentf file to .emacs.d/ 276 | (setq recentf-save-file (concat user-emacs-directory ".recentf")) 277 | 278 | ;; enable recent files mode. 279 | (recentf-mode t) 280 | 281 | ;; 50 files ought to be enough. 282 | (setq recentf-max-saved-items 50) 283 | 284 | (defun ido-recentf-open () 285 | "Use `ido-completing-read' to \\[find-file] a recent file" 286 | (interactive) 287 | (if (find-file (ido-completing-read "Find recent file: " recentf-list)) 288 | (message "Opening file...") 289 | (message "Aborting"))) 290 | #+END_SRC 291 | 292 | * Uniquify 293 | :PROPERTIES: 294 | :CUSTOM_ID: uniquify 295 | :END: 296 | 297 | Sometimes when you view different files with same filenames, emacs will 298 | append "<1>", "<2>" to the filename as the buffer name to differentiate 299 | them. Maybe you do not like the default naming patterns to "uniquify" these 300 | buffers, so emacs provides a uniquify package which can change the default 301 | naming of buffers to include parts of the file name (directory names) until the 302 | buffer names are unique. 303 | 304 | You can type =C-h i m emacs RET s uniquify RET= to get the manual about 305 | uniquify package. Or you can refer to [[http://trey-jackson.blogspot.com/2008/01/emacs-tip-11-uniquify.html][1]] and [[http://emacs-fu.blogspot.com/2009/11/making-buffer-names-unique.html][2]]. 306 | 307 | #+NAME: uniquify 308 | #+BEGIN_SRC emacs-lisp 309 | (setq uniquify-buffer-name-style 'post-forward-angle-brackets) 310 | (require 'uniquify) 311 | #+END_SRC 312 | 313 | * Flyspell 314 | :PROPERTIES: 315 | :CUSTOM_ID: flyspell 316 | :END: 317 | 318 | Emacs has builtin support for [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Spelling.html][spelling checking and correcting]] -- =flyspell=, 319 | but it is nonsense to enable it by default since most programming mode has 320 | special keyword which is not always spelled correctly by the judgement of the 321 | spelling checker. 322 | 323 | In order to use =flyspell=, you must install an external spell checker, such as 324 | [[http://aspell.net/][Aspell]] or [[http://www.gnu.org/software/ispell/][Ispell]], but GNU recommends [[http://aspell.net/man-html/Using-Aspell-as-a-Replacement-for-Ispell.html][Using Aspell as a Replacement for 325 | Ispell]]. The following code snippets comes from [[https://github.com/bbatsov/prelude/blob/master/core/prelude-editor.el][emacs prelude]]. 326 | 327 | #+NAME: flyspell 328 | #+BEGIN_SRC emacs-lisp 329 | ;; use aspell instead of ispell 330 | (setq ispell-program-name "aspell" 331 | ispell-extra-args '("--sug-mode=ultra")) 332 | #+END_SRC 333 | 334 | * Flycheck 335 | :PROPERTIES: 336 | :CUSTOM_ID: flycheck 337 | :END: 338 | 339 | [[https://github.com/flycheck/flycheck][Flycheck]] (aka "Flymake done right") is a modern on-the-fly syntax checking 340 | extension for GNU Emacs 24. 341 | 342 | #+NAME: flycheck 343 | #+BEGIN_SRC emacs-lisp 344 | (defun ome-flycheck-setup () 345 | (eval-after-load 'flycheck 346 | '(setq flycheck-checkers (delq 'emacs-lisp-checkdoc flycheck-checkers))) 347 | (add-hook 'prog-mode-hook 'flycheck-mode)) 348 | 349 | (ome-install 'flycheck) 350 | #+END_SRC 351 | 352 | * EditorConfig 353 | :PROPERTIES: 354 | :CUSTOM_ID: editorconfig 355 | :END: 356 | 357 | We live in a world with multiple editors or IDEs, and often we need 358 | collaboration with others. We can tune our emacs as best as we could. However, 359 | we still need a consistent, cross-editor, cross IDEs way to set some basic 360 | editor style. 361 | 362 | Fortunately, there comes [[http://editorconfig.org/][EditorConfig]]. EditorConfig helps developers define and 363 | maintain consistent coding styles between different editors and IDEs. The 364 | EditorConfig project consists of a file format for defining coding styles and a 365 | collection of text editor plugins that enable editors to read the file format 366 | and adhere to defined styles. EditorConfig files are easily readable and they 367 | work nicely with version control systems. 368 | 369 | You need to install =editorconfig= before you use the emacs package, check 370 | [[https://github.com/editorconfig/editorconfig-core-c/blob/master/INSTALL.md#installing-from-a-binary-package][Installation]]. 371 | 372 | #+NAME: editorconfig 373 | #+BEGIN_SRC emacs-lisp 374 | (defun ome-editorconfig-setup () 375 | (require 'editorconfig)) 376 | 377 | (ome-install 'editorconfig) 378 | #+END_SRC 379 | 380 | * Indent-guide 381 | :PROPERTIES: 382 | :CUSTOM_ID: indent-guide 383 | :END: 384 | 385 | Often we work with indented code, and it's better for our friend, the Emacs 386 | editor, to provide some indentation guide for us. Most of the builtin 387 | indentation features or third-party packages provide static indentation guide, 388 | which may be not good in some cases. Fortunately, a smart guy write a dynamic 389 | [[https://github.com/zk-phi/indent-guide][indent-guide]] package for us. It's amazing. 390 | 391 | #+NAME: indent-guide 392 | #+BEGIN_SRC emacs-lisp 393 | (defun ome-indent-guide-setup () 394 | (require 'indent-guide)) 395 | 396 | (ome-install 'indent-guide) 397 | #+END_SRC 398 | 399 | [[https://github.com/zk-phi/indent-guide][indent-guide]] 400 | 401 | * Todo 402 | ** Flycheck 403 | - Customizable prefix key, see https://github.com/flycheck/flycheck/issues/223. 404 | - Checkers for Common Lisp. 405 | - Test with big files for performance. 406 | - More documentation and tutorial. 407 | 408 | 409 | [1] Actually, emacs has only three [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Major-Modes.html][basic major modes]], so we actually enable 410 | auto-fill in almost every programming and writing modes. 411 | -------------------------------------------------------------------------------- /core/ome-gui.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs GUI 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * El-get packages 7 | :PROPERTIES: 8 | :CUSTOM_ID: gui-el-get-packages 9 | :END: 10 | 11 | #+NAME: gui-el-get-packages 12 | #+CAPTION: El-get packages for ome-gui module 13 | | Package | Status | Description | 14 | |-----------------+----------+----------------------------------------| 15 | | [[https://github.com/bbatsov/solarized-emacs][solarized-emacs]] | Required | Adopt this as the default color-theme. | 16 | | [[https://github.com/jonathanchu/emacs-powerline][emacs-powerline]] | Required | Eye candy for Emacs mode line. | 17 | | [[https://github.com/coldnew/linum-relative][linum-relative]] | Required | Eye candy for Emacs linum-mode. | 18 | 19 | * Basic GUI Settings 20 | #+NAME: gui-basics 21 | #+BEGIN_SRC emacs-lisp 22 | ;; show column number and line number 23 | (dolist (mode '(column-number-mode line-number-mode)) 24 | (when (fboundp mode) (funcall mode t))) 25 | 26 | (dolist (mode-hook '(text-mode-hook prog-mode-hook conf-mode-hook)) 27 | (add-hook mode-hook 28 | (lambda () 29 | (linum-mode 1)))) 30 | 31 | ;; make the fringe thinner (default is 8 in pixels) 32 | (fringe-mode 4) 33 | 34 | ;; show parenthesis match 35 | (show-paren-mode 1) 36 | (setq show-paren-style 'expression) 37 | 38 | ;; Toggle line highlighting in all buffers 39 | (global-hl-line-mode t) 40 | 41 | ;; http://stackoverflow.com/questions/27758800/why-does-emacs-leave-a-gap-when-trying-to-maximize-the-frame 42 | (setq frame-resize-pixelwise t) 43 | #+END_SRC 44 | 45 | * Choose Monaco as the Default English Font 46 | :PROPERTIES: 47 | :CUSTOM_ID: font 48 | :END: 49 | 50 | Choosing a good and comfortable font is quite important in your whole coding 51 | life. Although the default font of emacs is good enough, I believe there're 52 | better choices. And you can refer to [[http://hivelogic.com/articles/top-10-programming-fonts][TOP 10 PROGRAMMING FONTS]] and [[http://www.sitepoint.com/top-10-programming-fonts/][10 of the 53 | Best Programming Fonts]] to get some feel of various programming fonts. 54 | 55 | And I prefer [[http://en.wikipedia.org/wiki/Monaco_(typeface)][Monaco]]. However, I've googled a lot to prove that Monaco is free 56 | to use on non-Mac platforms, but found nothing about the official warrant. So 57 | I pretend that it is free. If you found any illegal issues, please tell me and 58 | I'll choose another free font. Thanks. 59 | 60 | Finally, about how to install Monaco fonts in Linux, see 61 | https://github.com/cstrap/monaco-font. If you didn't install Monaco, 62 | oh-my-emacs will fallback to the default font. Yeah, the so-called 63 | self-adapting. 64 | 65 | #+NAME: font 66 | #+BEGIN_SRC emacs-lisp 67 | ;; frame font 68 | ;; Setting English Font 69 | (if (member "Monaco" (font-family-list)) 70 | (set-face-attribute 71 | 'default nil :font "Monaco 12")) 72 | #+END_SRC 73 | 74 | * Full screen support 75 | :PROPERTIES: 76 | :CUSTOM_ID: fullscreen 77 | :END: 78 | 79 | By default, oh-my-emacs won't bind any shortcut to function keys. There're 80 | two reasons: 81 | - Some special keyboards(such as [[http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard][HHKB]]) lacks function keys. 82 | - Some function keys are occupied by system, either by the windows manager, the 83 | operating system, or something else which you have no idea to know it before. 84 | 85 | Of course you can overrides this convention as you like, oh-my-emacs is just a 86 | starting point. 87 | 88 | #+BEGIN_SRC emacs-lisp 89 | ;; http://www.emacswiki.org/emacs/FullScreen 90 | (defun ome-toggle-fullscreen () 91 | "Toggle full screen" 92 | (interactive) 93 | (set-frame-parameter 94 | nil 'fullscreen 95 | (when (not (frame-parameter nil 'fullscreen)) 'fullboth))) 96 | 97 | ;; (global-set-key (kbd "") 'ome-toggle-fullscreen) 98 | #+END_SRC 99 | 100 | * Solarized Color Theme 101 | :PROPERTIES: 102 | :CUSTOM_ID: color-theme 103 | :END: 104 | 105 | [[http://ethanschoonover.com/solarized][Solarized]] is my favourite color theme. it is available for multiple 106 | applications, not only for emacs. I'll set this as the default theme for 107 | oh-my-emacs. 108 | 109 | There're multiple el-get/elpa packages for solarized theme, and the original 110 | oh-my-emacs adopts [[https://github.com/sellout/emacs-color-theme-solarized.git][color-theme-solarized]] package, which requires [[http://www.nongnu.org/color-theme][color-theme]] 111 | package as a dependency, which failed to install sometimes. So oh-my-emacs now 112 | adopts [[https://github.com/bbatsov/solarized-emacs][solarized-emacs]] package. One thing you should be aware of is, you should 113 | use =M-x load-theme= instead of =color-theme-xxxx= to change current color 114 | theme. 115 | 116 | #+NAME: color-theme 117 | #+BEGIN_SRC emacs-lisp 118 | (defadvice load-theme (around ome-load-theme disable) 119 | ad-do-it 120 | 121 | ;; Remove boxes from Powerline arrows 122 | (set-face-attribute 'mode-line nil :box nil) 123 | (set-face-attribute 'mode-line-inactive nil :box nil)) 124 | 125 | (defun ome-solarized-emacs-setup () 126 | ;; make the fringe stand out from the background 127 | (setq solarized-distinct-fringe-background t) 128 | ;; make the modeline high contrast 129 | (setq solarized-high-contrast-mode-line t) 130 | ;; Use less bolding 131 | (setq solarized-use-less-bold t) 132 | ;; Use more italics 133 | (setq solarized-use-more-italic t) 134 | ;; Use less colors for indicators such as git:gutter, flycheck and similar. 135 | (setq solarized-emphasize-indicators nil) 136 | 137 | (setq x-underline-at-descent-line t) 138 | 139 | (ad-enable-advice 'load-theme 'around 'ome-load-theme) 140 | (ad-activate 'load-theme) 141 | 142 | (load-theme 'solarized-dark t)) 143 | 144 | (ome-install 'solarized-emacs) 145 | #+END_SRC 146 | 147 | ** Q&A 148 | 149 | Q: How to change the default solarized color theme for ome? 150 | 151 | A: Just [[http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming][untangle]] 152 | the related code block by convert =#+BEGIN_SRC emacs-lisp= to =#+BEGIN_SRC 153 | emacs-lisp :tangle no=, and choose any color-theme as you like. Check github 154 | [[https://github.com/xiaohanyu/oh-my-emacs/issues/58][issue]] for detailed discussion. 155 | 156 | * Powerline 157 | :PROPERTIES: 158 | :CUSTOM_ID: powerline 159 | :END: 160 | 161 | Powerline is an eye candy for emacs [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Mode-Line.html][mode line]]. Actually, the [[https://github.com/jonathanchu/emacs-powerline][emacs-powerline]] is 162 | inspired by [[https://github.com/Lokaltog/vim-powerline][vim-powerline]]. There're also powerline variants for [[https://github.com/erikw/tmux-powerline][tmux]], [[https://github.com/milkbikis/powerline-shell][shell]], etc. 163 | 164 | #+NAME: powerline 165 | #+BEGIN_SRC emacs-lisp 166 | (defun ome-emacs-powerline-setup ()) 167 | 168 | (ome-install 'emacs-powerline) 169 | #+END_SRC 170 | 171 | Actually, there're two packages as emacs's powerline: 172 | - https://github.com/jonathanchu/emacs-powerline 173 | - https://github.com/milkypostman/powerline 174 | 175 | I've used milkypostman's powerline for a long time, however, there're some tiny 176 | annoying problem with this package. Check this [[https://github.com/xiaohanyu/oh-my-emacs/issues/73][issue]] for example. So I've now 177 | decide to give janathanchu's powerline a try. Hope it works as expected. 178 | 179 | * Linum-relative 180 | :PROPERTIES: 181 | :CUSTOM_ID: linum-relative 182 | :END: 183 | 184 | I think the inspiration of [[https://github.com/coldnew/linum-relative][linum-relative]] comes from [[https://github.com/myusuf3/numbers.vim][numbers.vim]]. Thanks 185 | [[https://github.com/vimeitor][vimeitor]] for methoning this for me, I tried and I found it's really useful. So 186 | I made it a default for oh-my-emacs. 187 | 188 | #+NAME: linum-relative 189 | #+BEGIN_SRC emacs-lisp 190 | (defun ome-linum-relative-setup () 191 | (require 'linum-relative)) 192 | 193 | (ome-install 'linum-relative) 194 | #+END_SRC 195 | 196 | * Todo 197 | ** Speedbar 198 | - Combine projectile and speedbar to provide a project navigation 199 | feature. [[https://github.com/rdallasgray/graphene][graphene]] has a solution, which may be worth a try. 200 | 201 | ** Color-theme 202 | - More color-theme support 203 | - https://github.com/lvillani/el-monokai-theme 204 | - https://github.com/chriskempson/tomorrow-theme 205 | - https://github.com/chriskempson/base16 206 | - https://github.com/hbin/molokai-theme 207 | -------------------------------------------------------------------------------- /core/ome-keybindings.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Keybindings 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | Key bindings for oh-my-emacs, mainly imported from [[https://github.com/eschulte/emacs24-starter-kit][emacs24-starter-kit]]. 7 | 8 | * You know, like Readline. 9 | 10 | #+BEGIN_SRC emacs-lisp 11 | (global-set-key (kbd "C-M-h") 'backward-kill-word) 12 | #+END_SRC 13 | 14 | * Align your code in a pretty way. 15 | 16 | #+BEGIN_SRC emacs-lisp 17 | (global-set-key (kbd "C-x \\") 'align-regexp) 18 | #+END_SRC 19 | 20 | * Completion that uses many different methods to find options. 21 | 22 | #+BEGIN_SRC emacs-lisp 23 | (global-set-key (kbd "M-/") 'hippie-expand) 24 | #+END_SRC 25 | 26 | * Font size 27 | 28 | #+BEGIN_SRC emacs-lisp 29 | (define-key global-map (kbd "C-+") 'text-scale-increase) 30 | (define-key global-map (kbd "C--") 'text-scale-decrease) 31 | #+END_SRC 32 | 33 | * Use regex searches by default. 34 | 35 | #+BEGIN_SRC emacs-lisp 36 | (global-set-key (kbd "C-s") 'isearch-forward-regexp) 37 | (global-set-key (kbd "C-r") 'isearch-backward-regexp) 38 | (global-set-key (kbd "C-M-s") 'isearch-forward) 39 | (global-set-key (kbd "C-M-r") 'isearch-backward) 40 | #+END_SRC 41 | 42 | * File finding 43 | #+BEGIN_SRC emacs-lisp 44 | (global-set-key (kbd "C-x M-f") 'ido-find-file-other-window) 45 | (global-set-key (kbd "C-x C-p") 'find-file-at-point) 46 | (global-set-key (kbd "C-c y") 'bury-buffer) 47 | (global-set-key (kbd "C-c r") 'revert-buffer) 48 | (global-set-key (kbd "M-`") 'file-cache-minibuffer-complete) 49 | (global-set-key (kbd "C-x C-b") 'ibuffer) 50 | #+END_SRC 51 | 52 | * Window switching. 53 | #+BEGIN_SRC emacs-lisp 54 | (windmove-default-keybindings) ;; Shift+direction 55 | (global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one 56 | (global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two 57 | #+END_SRC 58 | 59 | * Indentation help 60 | #+BEGIN_SRC emacs-lisp 61 | (global-set-key (kbd "C-x ^") 'join-line) 62 | #+END_SRC 63 | 64 | * If you want to be able to M-x without meta 65 | #+BEGIN_SRC emacs-lisp 66 | (global-set-key (kbd "C-x C-m") 'execute-extended-command) 67 | #+END_SRC 68 | 69 | * Help should search more than just commands 70 | #+BEGIN_SRC emacs-lisp 71 | (global-set-key (kbd "C-h a") 'apropos) 72 | #+END_SRC 73 | 74 | * Occur 75 | Occur can show all lines in the current buffer containing a match for REGEXP. 76 | #+BEGIN_SRC emacs-lisp 77 | (global-set-key (kbd "C-c o") 'occur) 78 | #+END_SRC 79 | 80 | * RET 81 | 82 | #+BEGIN_SRC emacs-lisp 83 | (global-set-key (kbd "RET") 'reindent-then-newline-and-indent) 84 | #+END_SRC 85 | -------------------------------------------------------------------------------- /core/ome-org.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Org 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains configuration for the eminently useful [[http://orgmode.org/][Org Mode]]. 7 | 8 | Org-mode is for keeping notes, maintaining ToDo lists, doing project 9 | planning, and authoring with a fast and effective plain-text system. 10 | Org Mode can be used as a very simple folding outliner or as a complex 11 | GTD system or tool for reproducible research and literate programming. 12 | 13 | For more information on org-mode check out [[http://orgmode.org/worg/][worg]], a large Org-mode wiki 14 | which is also *implemented using* Org-mode and [[http://git-scm.com/][git]]. 15 | 16 | * El-get packages 17 | :PROPERTIES: 18 | :CUSTOM_ID: org-el-get-packages 19 | :END: 20 | 21 | #+NAME: org-el-get-packages 22 | #+CAPTION: El-get packages for ome-org module 23 | | Package | Status | Description | 24 | |------------+-------------+-------------------------------------------| 25 | | [[http://orgmode.org/][org-mode]] | Required | One of the killer Apps on Emacs platform. | 26 | | [[http://www.emacswiki.org/emacs/Htmlize][htmlize]].el | Recommended | Export an buffer to html format. | 27 | | [[http://staff.science.uva.nl/~dominik/Tools/cdlatex/][CDLaTeX]] | Recommended | Speedy \LaTeX{} input. | 28 | 29 | * Org-mode upgrade 30 | :PROPERTIES: 31 | :CUSTOM_ID: org-mode-upgrade 32 | :END: 33 | 34 | #+BEGIN_QUOTE 35 | Org 8.0 is the most disruptive major version of Org. 36 | 37 | -- http://orgmode.org/Changes_old.html 38 | #+END_QUOTE 39 | 40 | So why upgrade? Because it is there, it is the future of org-mode. Second, I 41 | want to export my org files to markdown format, sometimes, and org-mode 8.x 42 | provide a new great export engine, which is one of the most exciting features 43 | of org-mode 8.x, check [[http://article.gmane.org/gmane.emacs.orgmode/65574][the mailing list]] for original announcing post. For other 44 | features, check [[http://orgmode.org/worg/org-8.0.html][org 8.0 upgrading doc]]. 45 | 46 | You can get the latest org-mode by =M-x el-get-install RET org-mode= 47 | directly. However, with oh-my-emacs, we need some tricks to make it work. 48 | 49 | Oh-my-emacs use =org-babel= from =org-mode= to provide a literate emacs 50 | configuration, so we need to =(require 'org)= just after oh-my-emacs 51 | starts. However, by default, oh-my-emacs will load the builtin =org-mode= 52 | instead of the latest =org-mode= package from =el-get=. To replace the builtin 53 | =org-mode= with the latest =org-mode= from =el-get= when we boot oh-my-emacs 54 | even for the initial oh-my-emacs setup, we need to install =org-mode= just 55 | after =el-get= setup, that means, =org-mode= should be the first package to be 56 | installed via =el-get=, this can be done by putting the following code snippet 57 | to =$HOME/.emacs.d/init.el=: 58 | 59 | #+NAME: org-mode-upgrade 60 | #+BEGIN_SRC emacs-lisp :tangle no 61 | (defun ome-org-mode-setup () 62 | ;; markdown export support 63 | (require 'ox-md)) 64 | 65 | (add-to-list 'el-get-sources 66 | '(:name org-mode 67 | :after (progn 68 | (ome-org-mode-setup)))) 69 | 70 | (el-get 'sync (mapcar 'el-get-source-name el-get-sources)) 71 | #+END_SRC 72 | 73 | * Keybindings 74 | :PROPERTIES: 75 | :CUSTOM_ID: keybindings 76 | :END: 77 | 78 | #+NAME: keybindings 79 | #+BEGIN_SRC emacs-lisp 80 | (add-hook 'org-mode-hook 81 | (lambda () 82 | (local-set-key (kbd "M-C-n") 'outline-next-visible-heading) 83 | (local-set-key (kbd "M-C-p") 'outline-previous-visible-heading) 84 | (local-set-key (kbd "M-C-u") 'outline-up-heading) 85 | ;; table 86 | (local-set-key (kbd "M-C-w") 'org-table-copy-region) 87 | (local-set-key (kbd "M-C-y") 'org-table-paste-rectangle) 88 | (local-set-key (kbd "M-C-l") 'org-table-sort-lines) 89 | ;; display images 90 | (local-set-key (kbd "M-I") 'org-toggle-iimage-in-org))) 91 | #+END_SRC 92 | 93 | * Speed keys 94 | :PROPERTIES: 95 | :CUSTOM_ID: speed-keys 96 | :END: 97 | Speed commands enable single-letter commands in Org-mode files when 98 | the point is at the beginning of a headline, or at the beginning of a 99 | code block. 100 | 101 | See the `=org-speed-commands-default=' variable for a list of the keys 102 | and commands enabled at the beginning of headlines. All code blocks 103 | are available at the beginning of a code block, the following key 104 | sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will 105 | display a list of the code blocks commands and their related keys. 106 | 107 | #+NAME: speed-keys 108 | #+BEGIN_SRC emacs-lisp 109 | (setq org-use-speed-commands t) 110 | #+END_SRC 111 | 112 | * Code blocks 113 | :PROPERTIES: 114 | :CUSTOM_ID: babel 115 | :END: 116 | This activates a number of widely used languages, you are encouraged 117 | to activate more languages using the customize interface for the 118 | `=org-babel-load-languages=' variable, or with an elisp form like the 119 | one below. The customize interface of `=org-babel-load-languages=' 120 | contains an up to date list of the currently supported languages. 121 | 122 | #+NAME: babel 123 | #+BEGIN_SRC emacs-lisp :tangle no 124 | (org-babel-do-load-languages 125 | 'org-babel-load-languages 126 | '((emacs-lisp . t) 127 | (sh . t))) 128 | #+END_SRC 129 | 130 | You are encouraged to add the following to your personal configuration 131 | although it is not added by default as a security precaution. 132 | 133 | #+BEGIN_SRC emacs-lisp :tangle no 134 | (setq org-confirm-babel-evaluate nil) 135 | #+END_SRC 136 | 137 | Use =C-c '= to edit the current code block. This brings up a language 138 | major-mode edit buffer containing the body of the code block. Manually saving 139 | this buffer with == will write the contents back to the Org 140 | buffer. You can also set =org-edit-src-auto-save-idle-delay= to save the base 141 | buffer after some idle delay, or org-edit-src-turn-on-auto-save to auto-save 142 | this buffer into a separate file using auto-save-mode. Use =C-c '= again to 143 | exit. 144 | 145 | Since ome adopts [[https://gitorious.org/evil/pages/Home][evil]], there's a small annoyance with =org-src-mode=. Just like 146 | other modes, you can type =C-x C-s= (which binds to =org-edit-src-save= in 147 | =org-src-mode= to save your commits), however, typing =:w= (which binds to 148 | =evil-write=) will cause an error since there's no real file that associates 149 | with the current =org-src-mode=. So we have to do some hack to bind =:w= to 150 | =org-edit-src-save=. Check this [[https://bitbucket.org/lyro/evil/issue/399/issues-with-org-src-mode][bitbucket issue ]]for detailed discussion. 151 | 152 | #+BEGIN_SRC emacs-lisp 153 | (setq org-edit-src-auto-save-idle-delay 5) 154 | (setq org-edit-src-content-indentation 0) 155 | 156 | (add-hook 'org-src-mode-hook 157 | (lambda () 158 | (make-local-variable 'evil-ex-commands) 159 | (setq evil-ex-commands (copy-list evil-ex-commands)) 160 | (evil-ex-define-cmd "w[rite]" 'org-edit-src-save))) 161 | #+END_SRC 162 | 163 | * Code block fontification 164 | :PROPERTIES: 165 | :CUSTOM_ID: code-block-fontification 166 | :END: 167 | 168 | The following displays the contents of code blocks in org-mode files using the 169 | major-mode of the code. It also changes the behavior of =TAB= to as if it were 170 | used in the appropriate major mode. This means that reading and editing code 171 | form inside of your Org-mode files is much more like reading and editing of 172 | code using its major mode. 173 | 174 | #+NAME: code-block-fontification 175 | #+BEGIN_SRC emacs-lisp 176 | (setq org-src-fontify-natively t) 177 | (setq org-src-tab-acts-natively t) 178 | #+END_SRC 179 | 180 | When you use org-mode's inline [[http://orgmode.org/manual/Emphasis-and-monospace.html][markup formatting]], there're some characters 181 | which will make the markup failed, such as the "'"(single quote) and 182 | "`"(backtick) char in Lisp/Scheme/Clojure code. We need to do some hack to 183 | org-mode's parser, check [[http://stackoverflow.com/questions/16443386/how-to-escape-double-quote][stackoverflow: how to escape double quote?]] and 184 | [[http://stackoverflow.com/questions/24169333/how-can-i-emphasize-or-verbatim-quote-a-comma-in-org-mode][stackoverflow: how can I emphasize or verbatim quote a comma in org mode?]] for 185 | two examples. 186 | 187 | Besides, I've found that modify ~org-emphasis-regexp-components~ only affect 188 | fontification in org-mode, we need some extra work to make it work with 189 | ~org-export~. I've spent almost 1.5 hours to figure out this, even read some 190 | code snippet of org-mode's parser. We need to ~(org-element--set-regexps)~ 191 | manually after we modify ~org-emphasis-regexp-components~. Actually, 192 | ~(org-element--set-regexps)~ will set some a new value for the hidden variable 193 | ~org-element--object-regexp~, which is used to recognize org-mode's "element". 194 | 195 | #+NAME: inline-code-block-regexp 196 | #+BEGIN_SRC emacs-lisp 197 | (setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n\r") 198 | (custom-set-variables `(org-emphasis-alist ',org-emphasis-alist)) 199 | (org-element--set-regexps) 200 | #+END_SRC 201 | 202 | * The Library of Babel 203 | :PROPERTIES: 204 | :CUSTOM_ID: library-of-babel 205 | :END: 206 | The library of babel contains makes many useful functions available 207 | for use by code blocks in *any* emacs file. See the actual 208 | =library-of-babel.org= (located in the Org-mode =contrib/babel= 209 | directory) file for information on the functions, and see 210 | [[http://orgmode.org/worg/org-contrib/babel/intro.php#library-of-babel][worg:library-of-babel]] for more usage information. 211 | 212 | Code blocks can be loaded into the library of babel from any Org-mode 213 | file using the `org-babel-lob-ingest' function. 214 | 215 | * Htmlize 216 | :PROPERTIES: 217 | :CUSTOM_ID: htmlize 218 | :END: 219 | 220 | [[http://www.emacswiki.org/emacs/Htmlize][htmlize.el]] is a package for exporting the contents of an Emacs buffer to HTML 221 | while respecting display properties such as colors, fonts, underlining, 222 | invisibility, etc. 223 | 224 | Org-mode can utilize =htmlize= when =org-html-export-as-html= for source code syntax 225 | highlighting if =htmlize= is available. 226 | 227 | However, there's a minor problem with oh-my-emacs's default settings of 228 | =rainbow-delimiters-mode=. Functions such as =htmlize-buffer= will report an 229 | error: =htmlize-make-face-map: Wrong type argument: listp, 230 | "rainbow-delimiters-depth-1-face"=, so I do a small hack to overcome this by 231 | using the elisp's =defadvice= utility. 232 | 233 | Actually, =rainbow-delimiters-mode= still has some problems within org-mode's 234 | code block, which may be a bug of =rainbow-delimiters-mode=. 235 | 236 | #+NAME: htmlize 237 | #+BEGIN_SRC emacs-lisp 238 | (defadvice htmlize-buffer-1 (around ome-htmlize-buffer-1 disable) 239 | (rainbow-delimiters-mode -1) 240 | ad-do-it 241 | (rainbow-delimiters-mode t)) 242 | 243 | (ome-install 'htmlize) 244 | #+END_SRC 245 | 246 | * Org-LaTeX 247 | :PROPERTIES: 248 | :CUSTOM_ID: org-latex 249 | :END: 250 | 251 | Syntax highlighting is really cool when export org-mode files to other 252 | formats. We get syntax highlighting for html by [[http://www.emacswiki.org/emacs/Htmlize][htmlize.el]], so what about 253 | \LaTeX{}? 254 | 255 | Actually, org-mode has builtin support for syntax highlighting in \LaTeX{}, 256 | check the builtin documentation via =C-h v org-latex-listings RET=. Check post 257 | [[http://joat-programmer.blogspot.com/2013/07/org-mode-version-8-and-pdf-export-with.html][1]] and [[http://praveen.kumar.in/2012/03/10/org-mode-latex-and-minted-syntax-highlighting/][2]] for technical details. 258 | 259 | Note that the following code snippet works with org-mode 8.x branch. So if you 260 | still use org-mode 7.x, you may need to [[http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-12-3][setup manually]]. 261 | 262 | #+NAME: org-latex 263 | #+BEGIN_SRC emacs-lisp 264 | ;; code snippet comes from 265 | ;; http://joat-programmer.blogspot.com/2013/07/org-mode-version-8-and-pdf-export-with.html 266 | ;; Include the latex-exporter 267 | ;; check whether org-mode 8.x is available 268 | (when (require 'ox-latex nil 'noerror) 269 | ;; You need to install pygments to use minted 270 | (when (executable-find "pygmentize") 271 | ;; Add minted to the defaults packages to include when exporting. 272 | (add-to-list 'org-latex-packages-alist '("" "minted")) 273 | ;; Tell the latex export to use the minted package for source 274 | ;; code coloration. 275 | (setq org-latex-listings 'minted) 276 | ;; Let the exporter use the -shell-escape option to let latex 277 | ;; execute external programs. 278 | ;; This obviously and can be dangerous to activate! 279 | (setq org-latex-minted-options 280 | '(("mathescape" "true") 281 | ("linenos" "true") 282 | ("numbersep" "5pt") 283 | ("frame" "lines") 284 | ("framesep" "2mm"))) 285 | (setq org-latex-pdf-process 286 | '("xelatex -shell-escape -interaction nonstopmode -output-directory %o %f")))) 287 | #+END_SRC 288 | 289 | * Org-CDLaTeX 290 | :PROPERTIES: 291 | :CUSTOM_ID: org-cdlatex 292 | :END: 293 | 294 | If [[http://staff.science.uva.nl/~dominik/Tools/cdlatex/][CDLaTeX]] is available, turn on it in org-mode. See "[[http://www.gnu.org/software/emacs/manual/html_node/org/CDLaTeX-mode.html][Using CDLaTeX to enter 295 | math]]" for details. 296 | 297 | #+NAME: org-cdlatex 298 | #+BEGIN_SRC emacs-lisp 299 | (when (el-get-package-is-installed 'cdlatex-mode) 300 | (add-hook 'org-mode-hook 'turn-on-org-cdlatex)) 301 | #+END_SRC 302 | 303 | * Org-export 304 | :PROPERTIES: 305 | :CUSTOM_ID: org-export 306 | :END: 307 | 308 | Org-mode has [[http://orgmode.org/manual/Exporting.html][export facilities]] to export Org documents or parts of Org 309 | documents to a variety of other formats. 310 | 311 | However, there're some conventions in different formats, so we need some 312 | [[http://orgmode.org/manual/Exporting.html]["smart" tricks]] to follow these conventions with exporting Org documents to 313 | other formats. 314 | 315 | ** smart quotes 316 | 317 | The differentiation of single quote, double quote, back quote may comes from 318 | the world of \TeX of pre-Unicode eras trying to "improve" the typograph by 319 | using conventions that no longer hold any more[1]. 320 | 321 | Org mode has builtin support for this "smart quote" feature. You can put a 322 | snippet of ~#+OPTIONS: ':t~ at the start of your Org document, or just turn on 323 | it globally. 324 | 325 | #+BEGIN_SRC emacs-lisp 326 | (setq org-export-with-smart-quotes t) 327 | #+END_SRC 328 | 329 | * Todo 330 | - How to handle =org-mode= format like ===? 331 | 332 | [1] [[http://stackoverflow.com/questions/1432952/why-does-html-markup-often-enclose-text-with-backticks-and-single-quotes][Why does HTML markup often enclose text with backticks and single quotes?]] 333 | [2] [[http://stackoverflow.com/questions/15097114/how-to-get-smart-quotes-on-org-mode-export][how to get smart quotes on org-mode export?]] 334 | -------------------------------------------------------------------------------- /core/ome-writing.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Writing 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some packages for document writing. 7 | 8 | * Prerequisites 9 | :PROPERTIES: 10 | :CUSTOM_ID: ome-writing-prerequisites 11 | :END: 12 | 13 | #+NAME: ome-writing-prerequisites 14 | #+CAPTION: Prerequisites for ome-writing module 15 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 16 | |----------+---------+--------------------+-----------+--------+----------+------------| 17 | | [[http://daringfireball.net/projects/markdown/][markdown]] | | markdown | | | | No | 18 | 19 | * El-get packages 20 | :PROPERTIES: 21 | :CUSTOM_ID: writing-el-get-packages 22 | :END: 23 | 24 | #+NAME: writing-el-get-packages 25 | #+CAPTION: El-get packages for ome-writing module 26 | | Package | Status | Description | 27 | |---------------+----------+------------------------------------------------------| 28 | | [[http://jblevins.org/projects/markdown-mode/][markdown-mode]] | Required | Markdown is so popular that this package is required | 29 | 30 | * Markdown 31 | :PROPERTIES: 32 | :CUSTOM_ID: markdown 33 | :END: 34 | 35 | [[http://en.wikipedia.org/wiki/Markdown][Markdown]] is a lightweight markup language, which is very popular as a doc 36 | writing format in many popular open source projects. 37 | 38 | [[https://github.com/thierryvolpiatto/markdown-pp][markdown-pp]] is a preprocessor for Markdown files to generate a table of 39 | contents and other documentation needs, so I add "mdpp" file to 40 | markdown-mode's auto-mode-alist. 41 | 42 | [[http://jblevins.org/projects/markdown-mode/][markdown-mode]] also support html export. Under the hood, it adopts the original 43 | [[file://home/xiao/downloads/Markdown_1.0.1.zip][markdown]] perl script to do the heavy job. So you need to install it before 44 | =markdown-export=. 45 | 46 | The author of [[http://jblevins.org/projects/markdown-mode/][markdown-mode]], [[http://jblevins.org/][Jason Blevins]], is an assistant professor of 47 | economics at the ohio state university, who maintains a lot of open source 48 | [[http://jblevins.org/projects/][softwares]], which is amazing. 49 | 50 | #+NAME: markdown 51 | #+BEGIN_SRC emacs-lisp 52 | (defun ome-markdown-mode-setup () 53 | (add-to-list 'auto-mode-alist 54 | '("\\.mdpp" . markdown-mode))) 55 | 56 | (ome-install 'markdown-mode) 57 | #+END_SRC 58 | 59 | * Todo 60 | - Integrate [[https://github.com/ppareit/graphviz-dot-mode][graphviz-dot-mode]] 61 | -------------------------------------------------------------------------------- /custom.el: -------------------------------------------------------------------------------- 1 | ;;; This file contains some temporary code snippets, it will be loaded after 2 | ;;; various oh-my-emacs modules. When you just want to test some code snippets 3 | ;;; and don't want to bother with the huge ome.*org files, you can put things 4 | ;;; here. 5 | 6 | ;; For example, oh-my-emacs disables menu-bar-mode by default. If you want it 7 | ;; back, just put following code here. 8 | (menu-bar-mode t) 9 | 10 | ;;; You email address 11 | (setq user-mail-address "xiaohanyu1988@gmail.com") 12 | 13 | ;;; Calendar settings 14 | ;; you can use M-x sunrise-sunset to get the sun time 15 | (setq calendar-latitude 39.9) 16 | (setq calendar-longitude 116.3) 17 | (setq calendar-location-name "Beijing, China") 18 | 19 | ;;; Time related settings 20 | ;; show time in 24hours format 21 | (setq display-time-24hr-format t) 22 | ;; show time and date 23 | (setq display-time-and-date t) 24 | ;; time change interval 25 | (setq display-time-interval 10) 26 | ;; show time 27 | (display-time-mode t) 28 | 29 | ;;; Some tiny tool functions 30 | (defun replace-all-chinese-quote () 31 | (interactive) 32 | (save-excursion 33 | (mark-whole-buffer) 34 | (replace-regexp "”\\|“" "\"") 35 | (mark-whole-buffer) 36 | (replace-regexp "’\\|‘" "'"))) 37 | 38 | ;; Comment function for GAS assembly language 39 | (defun gas-comment-region (start end) 40 | "Comment region for AT&T syntax assembly language The default 41 | comment-char for gas is ';', we need '#' instead" 42 | (interactive "r") 43 | (setq end (copy-marker end t)) 44 | (save-excursion 45 | (goto-char start) 46 | (while (< (point) end) 47 | (beginning-of-line) 48 | (insert "# ") 49 | (next-line)) 50 | (goto-char end))) 51 | 52 | (defun gas-uncomment-region (start end) 53 | "Uncomment region for AT&T syntax assembly language the 54 | inversion of gas-comment-region" 55 | (interactive "r") 56 | (setq end (copy-marker end t)) 57 | (save-excursion 58 | (goto-char start) 59 | (while (< (point) end) 60 | (beginning-of-line) 61 | (if (equal (char-after) ?#) 62 | (delete-char 1)) 63 | (next-line)) 64 | (goto-char end))) 65 | 66 | (defun cl-struct-define (name docstring parent type named slots children-sym 67 | tag print-auto) 68 | (cl-assert (or type (equal '(cl-tag-slot) (car slots)))) 69 | (cl-assert (or type (not named))) 70 | (if (boundp children-sym) 71 | (add-to-list children-sym tag) 72 | (set children-sym (list tag))) 73 | (let* ((parent-class parent)) 74 | (while parent-class 75 | (add-to-list (intern (format "cl-struct-%s-tags" parent-class)) tag) 76 | (setq parent-class (get parent-class 'cl-struct-include)))) 77 | ;; If the cl-generic support, we need to be able to check 78 | ;; if a vector is a cl-struct object, without knowing its particular type. 79 | ;; So we use the (otherwise) unused function slots of the tag symbol 80 | ;; to put a special witness value, to make the check easy and reliable. 81 | (unless named (fset tag :quick-object-witness-check)) 82 | (put name 'cl-struct-slots slots) 83 | (put name 'cl-struct-type (list type named)) 84 | (if parent (put name 'cl-struct-include parent)) 85 | (if print-auto (put name 'cl-struct-print print-auto)) 86 | (if docstring (put name 'structure-documentation docstring))) 87 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;;; init.el --- Where all the magic begins 2 | ;; 3 | ;; Part of the oh-my-emacs 4 | ;; 5 | ;; This is the first thing to get loaded. 6 | ;; 7 | 8 | ;; Enter debugger if an error is signaled during Emacs startup. 9 | ;; 10 | ;; This works the same as you boot emacs with "--debug-init" every time, except 11 | ;; for errors in "init.el" itself, which means, if there's an error in 12 | ;; "init.el", "emacs --debug-init" will entering the debugger, while "emacs" 13 | ;; will not; however, if there's an error in other files loaded by init.el, 14 | ;; both "emacs" and "emacs --debug-init" will entering the debugger. I don't 15 | ;; know why. 16 | (setq debug-on-error t) 17 | 18 | (defvar ome-dir (file-name-directory (or load-file-name (buffer-file-name))) 19 | "oh-my-emacs home directory.") 20 | 21 | ;; believe me, you don't need menubar(execpt OSX), toolbar nor scrollbar 22 | (and (fboundp 'menu-bar-mode) 23 | (not (eq system-type 'darwin)) 24 | (menu-bar-mode -1)) 25 | (dolist (mode '(tool-bar-mode scroll-bar-mode)) 26 | (when (fboundp mode) (funcall mode -1))) 27 | 28 | ;; Now install el-get at the very first 29 | (add-to-list 'load-path "~/.emacs.d/el-get/el-get") 30 | 31 | (unless (require 'el-get nil 'noerror) 32 | (with-current-buffer 33 | (url-retrieve-synchronously 34 | "https://raw.github.com/dimitri/el-get/master/el-get-install.el") 35 | (let (el-get-master-branch 36 | ;; do not build recipes from emacswiki due to poor quality and 37 | ;; documentation 38 | el-get-install-skip-emacswiki-recipes) 39 | (goto-char (point-max)) 40 | (eval-print-last-sexp))) 41 | ;; build melpa packages for el-get 42 | (el-get-install 'package) 43 | (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") 44 | ("melpa" . "http://melpa.org/packages/"))) 45 | (el-get-elpa-build-local-recipes)) 46 | 47 | ;; enable git shallow clone to save time and bandwidth 48 | (setq el-get-git-shallow-clone t) 49 | 50 | ;; Sometimes, we need to experiment with our own recipe, or override the 51 | ;; default el-get recipe to get around bugs. 52 | (add-to-list 'el-get-recipe-path (expand-file-name "ome-el-get-recipes" ome-dir)) 53 | 54 | ;; tell el-get to look into local customizations for every package into 55 | ;; `~/.emacs.d/init-.el' 56 | (setq el-get-user-package-directory "~/.emacs.d") 57 | 58 | ;; Some workaround for emacs version < 24.0, thanks Silthanis@github. 59 | (if (< emacs-major-version 24) 60 | (defun file-name-base (&optional filename) 61 | "Return the base name of the FILENAME: no directory, no extension. 62 | FILENAME defaults to `buffer-file-name'." 63 | (file-name-sans-extension 64 | (file-name-nondirectory (or filename (buffer-file-name)))))) 65 | 66 | ;; Oh-my-emacs adopt org-mode 8.x from v0.3, so org-mode should be the first 67 | ;; package to be installed via el-get 68 | (defun ome-org-mode-setup () 69 | ;; markdown export support 70 | (require 'ox-md)) 71 | 72 | (add-to-list 'el-get-sources 73 | '(:name org-mode 74 | :after (progn 75 | (ome-org-mode-setup)))) 76 | 77 | (el-get 'sync (mapcar 'el-get-source-name el-get-sources)) 78 | 79 | ;; load up the ome 80 | (org-babel-load-file (expand-file-name "ome.org" ome-dir)) 81 | 82 | ;;; init.el ends here 83 | -------------------------------------------------------------------------------- /modules/ome-cc.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs CC 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some settings for =cc-mode=. 7 | 8 | * Prerequisites 9 | :PROPERTIES: 10 | :CUSTOM_ID: cc-prerequisites 11 | :END: 12 | 13 | #+NAME: cc-prerequisites 14 | #+CAPTION: Prerequisites for ome-cc module 15 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 16 | |------------+---------+---------------------+-----------+--------+-----------------+------------| 17 | | [[http://www.xmlsoft.org/][libxml2]] | | libxml2 libxml2-dev | | | libxml2 libxslt | Yes | 18 | | [[http://clang.llvm.org/][clang]] | | clang | | | | Yes | 19 | | [[http://www.freedesktop.org/wiki/Software/pkg-config/][pkg-config]] | | pkg-config | | | | Yes | 20 | | [[http://www.cmake.org/][CMake]] | | cmake | | | | No | 21 | | [[http://cscope.sourceforge.net/][Cscope]] | | cscope | | | | No | 22 | 23 | Note: 24 | - [[http://www.xmlsoft.org/][libxml2]], you need to =sudo apt-get install libxml2 libxml2-dev= in 25 | Ubuntu, and =brew install libxml2 libxslt= =brew link --force libxml2 26 | libxslt= in Mac with homebrew. There is required for el-get to build doxymacs. 27 | 28 | * El-get packages 29 | :PROPERTIES: 30 | :CUSTOM_ID: cc-el-get-packages 31 | :END: 32 | 33 | #+NAME: cc-el-get-packages 34 | #+CAPTION: El-get packages for ome-cc module 35 | | Package | Status | Description | 36 | |---------------------+-------------+---------------------------------| 37 | | cc-mode | Builtin | Where all the magic starts. | 38 | | [[http://www.itk.org/Wiki/CMake_Editors_Support][cmake-mode]] | Recommended | Editing support for CMake. | 39 | | [[https://github.com/vmfhrmfoaj/cscope-el.git][xcscope]] | Recommended | Code indexing and browsing. | 40 | | [[https://github.com/brianjcj/auto-complete-clang][auto-complete-clang]] | Required | Semantic completiong for C/C++. | 41 | 42 | * Basic CC-Mode Settings 43 | :PROPERTIES: 44 | :CUSTOM_ID: basic-cc 45 | :END: 46 | 47 | =cc-mode= is not a single mode, actually, =cc-mode= is a collection of emacs 48 | major mode for "editing files containing C, C++, Objective-C, Java, CORBA IDL 49 | (and the variants CORBA PSDL and CIDL), Pike and AWK code." 50 | 51 | Although =cc-mode= is a bit old, it is still powerful and flexible. It 52 | contains a powerful [[http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Indentation-Engine-Basics][indentation engine]], supports various builtin coding 53 | [[http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Styles][styles]], and provides various useful [[http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Minor-Modes][minor modes]]. 54 | 55 | You do need some basic elisp knowledge to master the power of =cc-mode=. For 56 | example, you need to know what the difference between =setq= and 57 | =setq-default=, some basic knowledge about elisp hooks, etc. 58 | 59 | #+NAME: basic 60 | #+BEGIN_SRC emacs-lisp 61 | (setq c-default-style '((java-mode . "java") 62 | (awk-mode . "awk") 63 | (c-mode . "k&r") 64 | (c++-mode . "stroustrup") 65 | (other . "linux"))) 66 | 67 | (setq-default c-basic-offset 4) 68 | (add-to-list 'auto-mode-alist '("\\.h$" . c++-mode)) 69 | 70 | (defun ome-c-initialization-hook () 71 | (define-key c-mode-base-map (kbd "RET") 'c-context-line-break)) 72 | 73 | (add-hook 'c-initialization-hook 'ome-c-initialization-hook) 74 | 75 | (defun ome-c-mode-common-hook () 76 | (add-to-list 'c-cleanup-list 'defun-close-semi) 77 | ;; (c-toggle-auto-newline) 78 | (c-toggle-hungry-state)) 79 | 80 | ;; this will affect all modes derived from cc-mode, like 81 | ;; java-mode, php-mode, etc 82 | (add-hook 'c-mode-common-hook 'ome-c-mode-common-hook) 83 | #+END_SRC 84 | 85 | * Makefile Settings 86 | :PROPERTIES: 87 | :CUSTOM_ID: makefile 88 | :END: 89 | 90 | The only thing you need to do in =makefile-mode= is to enable tab indentation 91 | instead of space indentation, since =makefile-mode= relies on tabs being tabs 92 | instead of a mixture of spaces and tabs, which I think, is a bug, but used as 93 | a feature of makefile. Ah, weird details and historical dirty quirks of 94 | makefile. 95 | 96 | #+NAME: makefile 97 | #+BEGIN_SRC emacs-lisp 98 | (add-hook 'makefile-mode-hook 99 | (lambda () 100 | (setq indent-tabs-mode t))) 101 | #+END_SRC 102 | 103 | * CMake 104 | :PROPERTIES: 105 | :CUSTOM_ID: cmake 106 | :END: 107 | 108 | [[http://www.cmake.org/][CMake]] is my favourite build tool for C/C++ software. To be precise, CMake is 109 | not a build tool, since it does not build the project, instead, it generates 110 | the files needed by your build tool(GNU make, Visual Studio, etc). The only 111 | thing that I dislike about CMake is its syntax, which is weird and hard to 112 | type. Anyway, it is much better than conventional [[http://en.wikipedia.org/wiki/GNU_build_system][Autotools]], IMHO, Autotools is 113 | quite complicated, brings more problems than it solves. Do not use it unless 114 | you have to. 115 | 116 | #+NAME: cmake 117 | #+BEGIN_SRC emacs-lisp 118 | (when (executable-find "cmake") 119 | (ome-install 'cmake-mode)) 120 | #+END_SRC 121 | 122 | * Indexing with Cscope 123 | :PROPERTIES: 124 | :CUSTOM_ID: cscope 125 | :END: 126 | 127 | There're multiple tools for source browsing in Emacs, such as the builtin 128 | [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Tags.html][etags]], and [[http://ctags.sourceforge.net/][ctags]], etc. While etags/ctags supports multiple programming 129 | languages, [[http://cscope.sourceforge.net/][cscope]] was designed for C code, however, you can do some [[http://cscope.sourceforge.net/cscope_vim_tutorial.html][hack]] to 130 | make it work with C++/Java. 131 | 132 | The limitation of tag-like source code indexing and browsing tools is, all 133 | these tools lacks deep understanding of the programming language, all they know 134 | is just symbols/tokens, they know little about semantics, so you may find 135 | unwanted or wrong results with tag tools. Cscope understands some semantics of 136 | C programming languages, such as symbol/function definitions, and it will lead 137 | you to the right place in C programming language. No more promise for other 138 | lanauges since cscope have no knowledge of OOP. 139 | 140 | Cscope has a bundled =xcscope.el=, which provide an Emacs interface to 141 | cscope. The default keybindings use the =C-c s= prefix: 142 | - Finding: 143 | - =C-c s s= Find symbol. 144 | - =C-c s d= Find global definition. 145 | - =C-c s g= Find global definition (alternate binding). 146 | - =C-c s G= Find global definition without prompting. 147 | - =C-c s c= Find functions calling a function. 148 | - =C-c s C= Find called functions (list functions called from a function). 149 | - =C-c s t= Find text string. 150 | - =C-c s e= Find egrep pattern. 151 | - =C-c s f= Find a file. 152 | - =C-c s i= Find files #including a file. 153 | - Navigation through the search results: 154 | - =C-c s b= Display *cscope* buffer. 155 | - =C-c s B= Auto display *cscope* buffer toggle. 156 | - =C-c s n= Next symbol. 157 | - =C-c s N= Next file. 158 | - =C-c s p= Previous symbol. 159 | - =C-c s P= Previous file. 160 | - =C-c s u= Pop mark. 161 | - Setting and unsetting the variable, =cscope-initial-directory=, (location 162 | searched for the cscope database directory): 163 | - =C-c s a= Set initial directory. 164 | - =C-c s A= Unset initial directory. 165 | - Database maintenance: 166 | - =C-c s L= Create list of files to index. 167 | - =C-c s I= Create list and index. 168 | - =C-c s E= Edit list of files to index. 169 | - =C-c s W= Locate this buffer's cscope directory ("W" --> "where"). 170 | - =C-c s S= Locate this buffer's cscope directory. (alternate binding: "S" 171 | --> "show"). 172 | - =C-c s T= Locate this buffer's cscope directory. (alternate binding: "T" 173 | --> "tell"). 174 | - =C-c s D= Dired this buffer's directory. 175 | 176 | #+NAME: cscope 177 | #+BEGIN_SRC emacs-lisp 178 | (if (executable-find "cscope") 179 | (ome-install 'xcscope)) 180 | 181 | #+END_SRC 182 | * Auto-complete-clang 183 | :PROPERTIES: 184 | :CUSTOM_ID: auto-complete-clang 185 | :END: 186 | 187 | Completion in Emacs is always a hot topic in Emacs community. Of course, 188 | there're always solutions, but none of them is perfect. The traditional 189 | approach relies on [[http://cedet.sourceforge.net/semantic.shtml][semantic]] from [[http://cedet.sourceforge.net/semantic.shtml][cedet]], which provides a parser for C/C++ and 190 | various other lanauges. But I don't think it's a good idea to written a parser 191 | in Elisp, especially a C++ parser. IMHO, semantic is bloated, slow, and often 192 | make your Emacs stuck. So I didn't use it in oh-my-emacs. 193 | 194 | The second choice is [[http://cx4a.org/software/gccsense/][GCCSense]], which is written by the same author of 195 | [[http://cx4a.org/software/auto-complete/][auto-complete]]. I've read the manual but I found it a little complex to 196 | install. So I won't adopt it. 197 | 198 | Instead, I use [[https://github.com/brianjcj/auto-complete-clang][auto-complete-clang]], which combines the power of auto-complete, 199 | clang, and yasnippet. I also write some wrapper functions for it, one of them 200 | is interactive [[http://www.freedesktop.org/wiki/Software/pkg-config/][pkg-config]] completion support. Thus, if you just write a "hello 201 | world" program with C/C++ standard library, then the semantic completion is 202 | already at your fingertips. Otherwise, if you want to write some huge 203 | programs with third-party libs, then just =M-x 204 | ome-pkg-config-enable-clang-flag name-of-lib=, and completion will be right 205 | here. Ensure that you have pkg-config installed and all the necessary libs 206 | installed if you want to write program with that library. 207 | 208 | The default auto-complete-clang package didn't provide completion for C/C++ 209 | macros, so I did a little hack by setting =ac-clang-flags=, see 210 | https://github.com/Rip-Rip/clang_complete/issues/42 for technical details. 211 | 212 | #+NAME: auto-complete-clang 213 | #+BEGIN_SRC emacs-lisp 214 | (defun ome-pkg-config-enable-clang-flag (pkg-config-lib) 215 | "This function will add necessary header file path of a 216 | specified by `pkg-config-lib' to `ac-clang-flags', which make it 217 | completionable by auto-complete-clang" 218 | (interactive "spkg-config lib: ") 219 | (if (executable-find "pkg-config") 220 | (if (= (shell-command 221 | (format "pkg-config %s" pkg-config-lib)) 222 | 0) 223 | (setq ac-clang-flags 224 | (append ac-clang-flags 225 | (split-string 226 | (shell-command-to-string 227 | (format "pkg-config --cflags-only-I %s" 228 | pkg-config-lib))))) 229 | (message "Error, pkg-config lib %s not found." pkg-config-lib)) 230 | (message "Error: pkg-config tool not found."))) 231 | 232 | ;; (ome-pkg-config-enable-clang-flag "QtGui") 233 | 234 | (defun ome-auto-complete-clang-setup () 235 | (require 'auto-complete-clang) 236 | (setq command "echo | g++ -v -x c++ -E - 2>&1 | 237 | grep -A 20 starts | grep include | grep -v search") 238 | (setq ac-clang-flags 239 | (mapcar (lambda (item) 240 | (concat "-I" item)) 241 | (split-string 242 | (shell-command-to-string command)))) 243 | ;; completion for C/C++ macros. 244 | (push "-code-completion-macros" ac-clang-flags) 245 | (push "-code-completion-patterns" ac-clang-flags) 246 | (dolist (mode-hook '(c-mode-hook c++-mode-hook)) 247 | (add-hook mode-hook 248 | (lambda () 249 | (add-to-list 'ac-sources 'ac-source-clang))))) 250 | 251 | (when (executable-find "clang") 252 | (ome-install 'auto-complete-clang)) 253 | #+END_SRC 254 | 255 | * Todo 256 | - Port cc-mode's =hungry-delete= to other mode. 257 | - Documentation for some useful cc-mode keybindings such as 258 | - =C-c C-c= 259 | - =M-;= 260 | - Integrate [[http://www.wonderworks.com/download/filladapt.el][filladapt]] package to enhance emacs's adaptive filling. 261 | - Add special font-lock support for some Qt's "keywords" such as "signal" and 262 | "slot". 263 | - Auto-complete-clang: 264 | - For huge C/C++ programs, auto-complete-clang maybe a little slow, maybe 265 | https://github.com/Golevka/emacs-clang-complete-async is a better 266 | solution. 267 | - Learn something about [[http://www.gnu.org/software/global/][GNU Global]], thanks [[http://www.reddit.com/user/stack_pivot][stack_pivot]]. 268 | -------------------------------------------------------------------------------- /modules/ome-clojure.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Clojure 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some settings for [[* Clojure][Clojure]] programming language. 7 | 8 | * Prerequisites 9 | :PROPERTIES: 10 | :CUSTOM_ID: clojure-prerequisites 11 | :END: 12 | 13 | #+NAME: clojure-prerequisites 14 | #+CAPTION: Prerequisites for ome-clojure module 15 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 16 | |------------+---------+--------------------+-----------+--------+----------+------------| 17 | | [[http://leiningen.org/][Leiningen]] | [web] | [web] | [web] | [web] | [web] | Yes | 18 | 19 | Note: 20 | - [[http://leiningen.org/][Leiningen]] for Clojure. I recommend you install leiningen from the official 21 | website to keep update with the lastest version. 22 | 23 | * El-get packages 24 | :PROPERTIES: 25 | :CUSTOM_ID: clojure-el-get-packages 26 | :END: 27 | 28 | #+NAME: clojure-el-get-packages 29 | #+CAPTION: El-get packages for ome-clojure module 30 | | Package | Status | Description | 31 | |--------------+----------+-------------------------------------------| 32 | | [[https://github.com/clojure-emacs/clojure-mode][clojure-mode]] | Required | Major mode for Clojure. | 33 | | [[https://github.com/clojure-emacs/cider][CIDER]] | Required | CIDER is a Clojure IDE and REPL for Emacs | 34 | | [[https://github.com/clojure-emacs/ac-cider][ac-cider]] | Required | Emacs auto-complete client for CIDER | 35 | 36 | * Clojure 37 | :PROPERTIES: 38 | :CUSTOM_ID: clojure 39 | :END: 40 | 41 | [[http://www.clojure.org][Clojure]] is a modern Lisp on top of JVM, it is a member of the Lisp family of 42 | languages. Clojure extends the code-as-data system beyond parenthesized lists 43 | (s-expressions) to vectors and maps. 44 | 45 | Since Clojure is a Lisp dialect, it should work the SLIME way. Yeah, first 46 | comes [[https://github.com/technomancy/swank-clojure][swank-clojure]], then [[https://github.com/clojure-emacs/cider][CIDER]][1]. The only thing you need to install is 47 | [[http://leiningen.org/][leiningen]] 2.x. I recommend you to install it manually, since not all [[https://github.com/technomancy/leiningen/wiki/Packaging][package 48 | manager]] provides the latest version. 49 | 50 | The general way to install lastest stable leiningen is: 51 | #+BEGIN_SRC sh 52 | wget -O /tmp/lein https://raw.github.com/technomancy/leiningen/stable/bin/lein 53 | sudo mv /tmp/lein /usr/bin/lein 54 | lein version 55 | #+END_SRC 56 | 57 | Or you can see leiningen's [[https://github.com/technomancy/leiningen/wiki/Upgrading][wiki]] for upgrading details. 58 | 59 | And to make leiningen works with emacs cider, you should make leiningen know 60 | something about cider, here's my =$HOME/.lein/profiles.clj=: 61 | 62 | #+BEGIN_SRC clojure 63 | {:user 64 | {:plugins 65 | [[cider/cider-nrepl "0.8.2"]]} 66 | :repl-options 67 | {:nrepl-middleware 68 | [cider.nrepl.middleware.apropos/wrap-apropos 69 | cider.nrepl.middleware.classpath/wrap-classpath 70 | cider.nrepl.middleware.complete/wrap-complete 71 | cider.nrepl.middleware.info/wrap-info 72 | cider.nrepl.middleware.inspect/wrap-inspect 73 | cider.nrepl.middleware.macroexpand/wrap-macroexpand 74 | cider.nrepl.middleware.ns/wrap-ns 75 | cider.nrepl.middleware.resource/wrap-resource 76 | cider.nrepl.middleware.stacktrace/wrap-stacktrace 77 | cider.nrepl.middleware.test/wrap-test 78 | cider.nrepl.middleware.trace/wrap-trace 79 | cider.nrepl.middleware.undef/wrap-undef]}} 80 | #+END_SRC 81 | 82 | Now, just open a clojure file, then =cider-jack-in=, and you can program 83 | Clojure the SLIME way. [[http://vimeo.com/22798433][Here]] is an awesome live demo to demonstrate the Clojure 84 | workflow. 85 | 86 | It's really really awesome, ah? 87 | 88 | #+NAME: clojure 89 | #+BEGIN_SRC emacs-lisp 90 | (ome-install 'clojure-mode) 91 | 92 | (defun ome-cider-setup () 93 | (add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode) 94 | (setq nrepl-hide-special-buffers t) 95 | (setq cider-repl-tab-command 'indent-for-tab-command) 96 | (setq cider-prefer-local-resources t) 97 | (setq cider-repl-pop-to-buffer-on-connect nil) 98 | (setq cider-repl-pop-to-buffer-on-connect nil) 99 | (setq cider-popup-stacktraces nil) 100 | (setq cider-repl-popup-stacktraces t) 101 | (setq cider-auto-select-error-buffer t) 102 | (setq nrepl-buffer-name-show-port t) 103 | (setq cider-repl-display-in-current-window t) 104 | (setq cider-repl-result-prefix ";; => ") 105 | (setq cider-interactive-eval-result-prefix ";; => ") 106 | (setq cider-repl-use-clojure-font-lock t) 107 | (setq cider-test-show-report-on-success t) 108 | (setq nrepl-hide-special-buffers t) 109 | (setq nrepl-buffer-name-separator "-") 110 | (setq nrepl-buffer-name-show-port t) 111 | ;; repl history 112 | (setq cider-repl-wrap-history t)) 113 | 114 | (defun ome-ac-cider-setup () 115 | (add-hook 'cider-mode-hook 'ac-flyspell-workaround) 116 | (add-hook 'cider-mode-hook 'ac-cider-setup) 117 | (add-hook 'cider-repl-mode-hook 'ac-cider-setup) 118 | (eval-after-load "auto-complete" 119 | '(add-to-list 'ac-modes 'cider-repl-mode))) 120 | 121 | (when (executable-find "lein") 122 | (ome-install 'cider) 123 | (ome-install 'ac-cider)) 124 | #+END_SRC 125 | 126 | * Todos 127 | - The boot up speed of JVM is too slow, so we may need to refer to 128 | http://icylisper.github.io/jark/. 129 | 130 | 131 | [1] CIDER was formerly known as and renamed from =nrepl.el=. 132 | -------------------------------------------------------------------------------- /modules/ome-common-lisp.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Common Lisp 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some settings for [[* Common Lisp][Common Lisp]]. 7 | 8 | * Prerequisites 9 | :PROPERTIES: 10 | :CUSTOM_ID: common-lisp-prerequisites 11 | :END: 12 | 13 | #+NAME: common-lisp-prerequisites 14 | #+CAPTION: Prerequisites for ome-common-lisp module 15 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 16 | |------------+---------+--------------------+-----------+--------+----------+------------| 17 | | [[http://www.sbcl.org/][SBCL]] | | sbcl | | | | Yes | 18 | | [[http://ccl.clozure.com/][Clozure CL]] | | [web] | | | | No | 19 | | [[http://www.clisp.org/][CLISP]] | | clisp | | | | No | 20 | 21 | Note: 22 | - [[http://www.sbcl.org/][SBCL]] or [[http://ccl.clozure.com/][Clozure CL]] or [[http://www.clisp.org/][CLISP]] as a Common Lisp implementation. I recommend 23 | SBCL since it has good performance, and is easy to install via package 24 | manager. 25 | 26 | * El-get packages 27 | :PROPERTIES: 28 | :CUSTOM_ID: common-lisp-el-get-packages 29 | :END: 30 | 31 | #+NAME: common-lisp-el-get-packages 32 | #+CAPTION: El-get packages for ome-common-lisp module 33 | | | Status | Description | 34 | |-----------------+----------+------------------------------------------------| 35 | | [[http://common-lisp.net/project/slime/][slime]] | Required | One of the most amazing packages for Emacs. | 36 | | [[https://github.com/purcell/ac-slime][ac-slime]] | Required | AC backend for slime. | 37 | 38 | * Common Lisp 39 | :PROPERTIES: 40 | :CUSTOM_ID: common-lisp 41 | :END: 42 | 43 | [[http://common-lisp.net/project/slime/][SLIME]] is the Superior Lisp Interaction Mode for Emacs, here're some [[http://www.cliki.net/SLIME%2520Features][features]] 44 | and [[http://www.cliki.net/SLIME%2520Tips][tips]]. Believe me, SLIME in Emacs is a subversive developing environment for 45 | Common Lisp, it is the ultimate solution for languages with a [[http://en.wikipedia.org/wiki/Read%25E2%2580%2593eval%25E2%2580%2593print_loop][REPL]]. SLIME is 46 | the bridge between an Editor(here, Emacs for example, vim users have a [[http://www.vim.org/scripts/script.php?script_id%3D2531][slimv]] 47 | which is a fork of SLIME to vim) and a running Common Lisp environment. It 48 | makes your workflow so smooth and enjoyable that you will miss it so much when 49 | working with other REPL languages such as Python/Ruby/JavaScript[1], etc. 50 | 51 | Some good resources about SLIME: 52 | - [[http://bc.tech.coop/blog/081209.html][Understanding SLIME (Using Emacs and Lisp Cooperatively)]], a really concise 53 | explanation of SLIME's architecture, together with lots of valuable links, 54 | from which you will understand why SLIME is so great and amazing. 55 | - [[http://lisp-book.org/contents/chslime.pdf][Chapter 18. SLIME]] from [[http://lisp-book.org/contents/chslime.pdf][Lisp Outside the Box]] provides a really detailed guide 56 | to SLIME. 57 | - [[http://common-lisp.net/project/slime/doc/html/][SLIME User Manual]] provides expert information and is your lifelong friend. 58 | - For Chinese, [[http://www.feime.net/2013/%25E6%2596%25B0%25E5%25B9%25B4%25E7%25AC%25AC%25E4%25B8%2580%25E7%25AF%2587-%25E7%25BB%2599lisp%25E6%2596%25B0%25E6%2589%258B%25E4%25BB%258B%25E7%25BB%258D%25E4%25B8%258Bslime%25E8%25BF%2599%25E4%25B8%25AA%25E7%25A5%259E%25E5%2599%25A8/][Albertlee's Blog]] provides a detailed overview of SLIME. 59 | - [[http://ghostopera.org/blog/2012/06/24/the-newbie-guide-to-common-lisp/][The Newbie Guide to Getting Started on Common Lisp]] provides a concise and 60 | helpful guide to start programming with Common Lisp. 61 | 62 | Besides, [[http://www.whoishostingthis.com/resources/common-lisp/][wiht]] do a really good job to list many valuable links for learning 63 | common lisp. 64 | 65 | To use SLIME, you must install an [[http://www.cliki.net/common%2520lisp%2520implementation][Lisp Implementation]], just like if you want to do 66 | C programming, you must install a C compiler such as GCC. Here I recommend [[http://www.sbcl.org/][SBCL]] 67 | for you. You can get it by =sudo apt-get install sbcl= in Ubuntu/Mint/Debian. 68 | 69 | [[http://www.lispworks.com/][LispWorks]] provides a comprehensive documentation for Common Lisp called 70 | [[http://www.lispworks.com/documentation/HyperSpec/Front/][hyperspec]], which integrates quite well with SLIME through 71 | =slime-documentation-lookup=. You can get by =sudo apt-get install hyperspec= 72 | in Ubuntu/Mint/Debian. To use hyperspec in ubuntu/mint, you can: =sudo apt-get 73 | install hyperspec=, which also set proper =common-lisp-hyperspec-root= for 74 | you. On other Linux distributions, maybe you need to set it manually to tell 75 | SLIME where to find the hyperspec document. 76 | 77 | You can also get [[http://en.wikipedia.org/wiki/Common_Lisp_the_Language][CLTL]] by =sudo apt-get install cltl=, which is the defacto 78 | standard for Common Lisp before the ANSI standard. 79 | 80 | Oh-my-emacs also configure [[http://emacs-w3m.namazu.org/][emacs-w3m]] as the default documentation browser for 81 | SLIME. 82 | 83 | Oh-my-emacs integrates [[https://github.com/purcell/ac-slime][ac-slime]] for instant in-buffer completion, and should be 84 | self-adapted to your system, by which I mean, it will use an available lisp 85 | implementation by finding it using =executable-find= instead of specifying a 86 | fixed file path like =/usr/bin/sbcl=. 87 | 88 | Enough stuff, enjoy your Common Lisp journey with Emacs and SLIME. 89 | 90 | #+NAME: slime 91 | #+BEGIN_SRC emacs-lisp 92 | (defun ome-slime-setup () 93 | ;; Define multiple lisp backends 94 | ;; see http://nklein.com/2010/05/getting-started-with-clojureemacsslime/ 95 | (defmacro defslime-start (name lisp-impl) 96 | `(when (executable-find (symbol-name ,lisp-impl)) 97 | (defun ,name () 98 | (interactive) 99 | (let ((slime-default-lisp ,lisp-impl)) 100 | (slime))))) 101 | 102 | (setq slime-lisp-implementations 103 | `((sbcl (,(executable-find "sbcl")) :coding-system utf-8-unix) 104 | (ccl (,(executable-find "ccl"))) 105 | (ccl64 (,(executable-find "ccl64"))) 106 | (clisp (,(executable-find "clisp"))))) 107 | 108 | (defslime-start slime-sbcl 'sbcl) 109 | (defslime-start slime-ccl 'ccl) 110 | (defslime-start slime-ccl64 'ccl64) 111 | (defslime-start slime-clisp 'clisp) 112 | 113 | ;; If you use ubuntu/mint, then "sudo apt-get install hyperspec" will set 114 | ;; this for you in a file like "/etc/emacs/site-start.d/60hyperspec.el" 115 | ;; (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/") 116 | 117 | ;; Open SBCL rc file in lisp-mode 118 | (add-to-list 'auto-mode-alist '("\\.sbclrc$" . lisp-mode)) 119 | 120 | (global-set-key (kbd "C-c s") 'slime-selector) 121 | (setq slime-net-coding-system 'utf-8-unix) 122 | (setq slime-complete-symbol*-fancy t) 123 | (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol) 124 | (setq inferior-lisp-program 125 | (or (executable-find "sbcl") 126 | (executable-find "ccl") 127 | (executable-find "ccl64") 128 | (executable-find "clisp"))) 129 | (slime-setup '(slime-fancy 130 | slime-indentation 131 | slime-banner 132 | slime-highlight-edits))) 133 | 134 | (defun ome-ac-slime-setup () 135 | (add-hook 'slime-mode-hook 136 | (lambda () 137 | (set-up-slime-ac t))) ; use slime-fuzzy-complete-symbol 138 | (add-hook 'slime-repl-mode-hook 139 | (lambda () 140 | (set-up-slime-ac t))) 141 | (eval-after-load "auto-complete" 142 | '(add-to-list 'ac-modes 'slime-repl-mode))) 143 | 144 | (when (or (executable-find "sbcl") 145 | (executable-find "ccl") 146 | (executable-find "ccl64") 147 | (executable-find "clisp")) 148 | (ome-install 'slime) 149 | (ome-install 'ac-slime)) 150 | #+END_SRC 151 | 152 | * Todos 153 | - Integrate [[http://www.foldr.org/~michaelw/emacs/redshank/][redshank]]? 154 | - Find a method to rebase the source tree of various CL implementations, which 155 | is useful for =slime-edit-definition=. 156 | 157 | 158 | [1] [[https://github.com/swank-js/swank-js][swank-js]], [[http://common-lisp.net/~crhodes/swankr/][swankr]] 159 | -------------------------------------------------------------------------------- /modules/ome-emacs-lisp.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Lisp 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some settings [[* Emacs Lisp][Emacs Lisp]] programming. 7 | 8 | * El-get packages 9 | :PROPERTIES: 10 | :CUSTOM_ID: emacs-lisp-el-get-packages 11 | :END: 12 | 13 | #+NAME: emacs-lisp-el-get-packages 14 | #+CAPTION: El-get packages for ome-emacs-lisp module 15 | | Package | Status | Description | 16 | |-----------------+----------+------------------------------------------------| 17 | | [[https://github.com/purcell/elisp-slime-nav][elisp-slime-nav]] | Required | Shortcuts for browsing elisp code. | 18 | 19 | * Basics 20 | :PROPERTIES: 21 | :CUSTOM_ID: basic-lisp 22 | :END: 23 | 24 | This section contains some basic settings which is common to all lisp modes. 25 | 26 | #+NAME: basic-lisp 27 | #+BEGIN_SRC emacs-lisp 28 | (defvar ome-lisp-modes '(emacs-lisp-mode 29 | inferior-emacs-lisp-mode 30 | lisp-interaction-mode 31 | scheme-mode 32 | lisp-mode 33 | eshell-mode 34 | slime-repl-mode 35 | nrepl-mode 36 | clojure-mode 37 | common-lisp-mode) 38 | "List of Lisp modes.") 39 | #+END_SRC 40 | 41 | * Emacs Lisp 42 | :PROPERTIES: 43 | :CUSTOM_ID: emacs-lisp 44 | :END: 45 | 46 | Emacs is really a great "IDE" for developing Elisp programs. This section 47 | contains some goodies for elisp development. 48 | 49 | [[https://github.com/purcell/elisp-slime-nav][elisp-slime-nav]] provide some slime-like shortcuts to find function/variable 50 | definitions, which is useful when you want to know the details, as you know, 51 | there's no secret with source code. But the default shortcuts for 52 | =elisp-slime-nav-find-elisp-thing-at-point= has conflicts with =evil-mode=, 53 | which is enabled by default by oh-my-emacs, I still didn't figure out a good 54 | way to solve this, so any help will be appreciated. 55 | 56 | #+NAME: emacs-lisp 57 | #+BEGIN_SRC emacs-lisp 58 | (defun ome-remove-elc-on-save () 59 | "If you're saving an elisp file, likely the .elc is no longer valid." 60 | (make-local-variable 'after-save-hook) 61 | (add-hook 'after-save-hook 62 | (lambda () 63 | (if (file-exists-p (concat buffer-file-name "c")) 64 | (delete-file (concat buffer-file-name "c")))))) 65 | 66 | (add-hook 'emacs-lisp-mode-hook 'ome-remove-elc-on-save) 67 | (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) 68 | (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) 69 | 70 | (defun ome-elisp-slime-nav-setup () 71 | ;; (defun ome-elisp-slime-nav-keybindings-in-evil () 72 | ;; (if (and (boundp 'evil-mode) evil-mode) 73 | ;; (progn (define-key elisp-slime-nav-mode-map (kbd "C-c C-d .") 74 | ;; 'elisp-slime-nav-find-elisp-thing-at-point) 75 | ;; (define-key elisp-slime-nav-mode-map (kbd "C-c C-d ,") 76 | ;; 'pop-tag-mark)))) 77 | (dolist (hook '(emacs-lisp-mode-hook 78 | lisp-interaction-mode-hook 79 | ielm-mode-hook 80 | eshell-mode-hook)) 81 | (add-hook hook 'turn-on-elisp-slime-nav-mode))) 82 | ;; (add-hook hook 'ome-elisp-slime-nav-keybindings-in-evil))) 83 | 84 | (ome-install 'elisp-slime-nav) 85 | #+END_SRC 86 | 87 | ** IELM 88 | :PROPERTIES: 89 | :CUSTOM_ID: ielm 90 | :END: 91 | 92 | [[http://www.emacswiki.org/emacs/InferiorEmacsLispMode][IELM]] is an alternative to Lisp Interactive mode, you can treat IELM as [[http://emacs-fu.blogspot.com/2011/03/ielm-repl-for-emacs.html][a REPL 93 | for emacs]]. Though convenient, IELM lacks some import features to be a real 94 | REPL, such as =python-shell-send-defun= in Emacs 24.3 builtin python mode. 95 | 96 | #+NAME: emacs-lisp 97 | #+BEGIN_SRC emacs-lisp 98 | (defun ome-visit-ielm () 99 | "Switch to default `ielm' buffer. 100 | Start `ielm' if it's not already running." 101 | (interactive) 102 | (ome-start-or-switch-to 'ielm "*ielm*")) 103 | 104 | (define-key emacs-lisp-mode-map (kbd "C-c C-z") 'ome-visit-ielm) 105 | (add-to-list 'ac-modes 'inferior-emacs-lisp-mode) 106 | (add-hook 'ielm-mode-hook 'ac-emacs-lisp-mode-setup) 107 | (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) 108 | #+END_SRC 109 | 110 | ** Eshell 111 | :PROPERTIES: 112 | :CUSTOM_ID: eshell 113 | :END: 114 | 115 | I think you can treat [[http://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Eshell]] as a combination of traditional Unix shell and 116 | IELM. Eshell is a command shell written in Emacs Lisp, which means it's as 117 | portable as Emacs itself. In fact, Eshell replicates most of the features and 118 | commands from GNU CoreUtils and the Bourne-like shells, thus Eshell will 119 | function identically on any environment Emacs itself runs on. 120 | 121 | To your surprise, Eshell does not inherit from =comint-mode=, which means that 122 | hooks and routines for =comint-mode= won't work for Eshell. For more details 123 | about how to mastering eshell, see [[http://www.masteringemacs.org/articles/2010/12/13/complete-guide-mastering-eshell/][MASTERING ESHELL]]. 124 | 125 | #+NAME: eshell 126 | #+BEGIN_SRC emacs-lisp 127 | (add-hook 'eshell-mode-hook 128 | (lambda () 129 | (add-to-list 'ac-sources 'ac-source-pcomplete))) 130 | 131 | (add-to-list 'ac-modes 'eshell-mode) 132 | (add-hook 'eshell-mode-hook 'turn-on-eldoc-mode) 133 | (add-hook 'eshell-mode-hook 'ac-emacs-lisp-mode-setup) 134 | #+END_SRC 135 | 136 | * Todos 137 | - What is overlay? 138 | - What is syntax? 139 | - Learn more knowledge about emacs key-maps, and what's the difference between 140 | =global-set-key= and =remap=. 141 | - Learn more knowledge about emacs syntax-table, functions like 142 | =modify-syntax-entry=, etc. 143 | - What =enable-recursive-minibuffers= means to us? 144 | - How to do asynchronous programming in emacs lisp? 145 | - Make =ielm= as a real elisp =REPL=? 146 | -------------------------------------------------------------------------------- /modules/ome-experimental.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs GUI 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some experimental packages, which may be: 7 | - not stable enough 8 | - usable, with some minor annoying problems, however 9 | - young packages without long time testing and validating. 10 | 11 | Load necessary packages as you like. 12 | 13 | * Prerequisites 14 | :PROPERTIES: 15 | :CUSTOM_ID: experimental-prerequisites 16 | :END: 17 | 18 | #+NAME: experimental-prerequisites 19 | #+CAPTION: Prerequisites for ome-experimental module 20 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 21 | |---------+---------+--------------------+-----------+--------+----------+------------| 22 | | [[http://www.stack.nl/~dimitri/doxygen/][Doxygen]] | | doxygen | | | | No | 23 | 24 | Note: 25 | - [[http://www.stack.nl/~dimitri/doxygen/][Doxygen]], even if you don't have doxygen installed, you can still use 26 | doxymacs to insert doxygen-style comments. So I make this dependency 27 | optional. However, so many Mac OS users have problems with this el-get 28 | package, so I move 29 | 30 | * El-get packages 31 | :PROPERTIES: 32 | :CUSTOM_ID: experimental-el-get-packages 33 | :END: 34 | 35 | #+NAME: experimental-el-get-packages 36 | #+CAPTION: El-get packages for ome-experimental module 37 | | Package | Status | Description | 38 | |------------------+--------------+-------------------------------------------------------| 39 | | [[http://www.emacswiki.org/emacs/LaCarte][lacarte]] | Recommended | Access menubar in minibuffer command loop. | 40 | | [[http://www.emacswiki.org/emacs/SrSpeedbar][SrSpeedbar]] | Experimental | Make [[http://www.gnu.org/software/emacs/manual/html_node/speedbar/index.html][Speedbar]] show in same frame. | 41 | | [[https://github.com/m2ym/yascroll-el][yascroll]] | Required | Eye candy for Emacs scroll bar. | 42 | | [[https://github.com/aspiers/smooth-scrolling][smooth-scrolling]] | Recommended | Emacs smooth scrolling package. | 43 | | [[https://github.com/nflath/hungry-delete][hungry-delete]] | Experimental | Enables hungry deletion in all modes. | 44 | | [[http://doxymacs.sourceforge.net/][doxymacs]] | Experimental | Literate comments for cc-mode. | 45 | | [[https://github.com/zk-phi/sublimity][sublimity]] | Experimental | Bring sublime's smooth-scrolling and minimap to emacs | 46 | | [[https://github.com/emacsmirror/pos-tip][pos-tip]] | Experimental | Show tooltip at point | 47 | | [[https://github.com/flycheck/flycheck-pos-tip][flycheck-pos-tip]] | Experimental | Flycheck errors display in tooltip | 48 | | [[http://www.gnu.org/software/gettext/manual/html_node/PO-Mode.html][po-mode]] | Experimental | Emacs's PO File Editor | 49 | | [[https://github.com/zk/emacs-dirtree][emacs-dirtree]] | Experimental | Directory tree views in Emacs | 50 | 51 | Note: 52 | - [[http://doxymacs.sourceforge.net/][doxymacs]]: There're many Mac OS users having problems building with this 53 | package, so I have to move this package from ome-cc module to 54 | ome-experimental module. See [[https://github.com/xiaohanyu/oh-my-emacs/issues/17][github issue]] for details. 55 | 56 | * Lacarte 57 | :PROPERTIES: 58 | :CUSTOM_ID: lacarte 59 | :END: 60 | 61 | By default, oh-my-emacs disables =menu-bar-mode=. Of course you can turn it on 62 | by =M-x menu-bar-mode=, however, most of the time menubar in Emacs is useless. 63 | Unfortunately, there may be some times that we want to access the menubar just 64 | to find or execute oblivious command. For example, the prefix key of 65 | =outline-mode= is =C-c @=, which is quite hard to type, and I often forgot the 66 | normal keybindings of outline-minor-mode. The normal workflow for this case is 67 | divided into three steps: 68 | 1. turn on the menubar by =M-x menu-bar-mode= 69 | 2. find/execute the command you want 70 | 3. turn off the menubar again by =M-x menu-bar-mode= 71 | 72 | Ah, a little tedious, isn't it? Fortunately, with [[http://www.emacswiki.org/emacs/LaCarte][lacarte]], I can just =M-x 73 | lacarte-execute-menu-command=, and it will lead me to the right place. Helm 74 | also provides a =helm-source-lacarte= for lacarte support. See [[https://github.com/emacs-helm/helm/blob/master/helm-misc.el][helm-misc.el]] for 75 | details. 76 | 77 | #+NAME: lacarte 78 | #+BEGIN_SRC emacs-lisp 79 | (defun ome-lacarte-setup () 80 | (global-set-key (kbd "C-c M-x") 'lacarte-execute-command) 81 | (global-set-key (kbd "C-c M-m") 'lacarte-execute-menu-command)) 82 | 83 | (ome-install 'lacarte) 84 | #+END_SRC 85 | 86 | * Sr-speedbar 87 | :PROPERTIES: 88 | :CUSTOM_ID: sr-speedbar 89 | :END: 90 | 91 | [[http://www.gnu.org/software/emacs/manual/html_node/speedbar/index.html][Speedbar]] is a program for Emacs which provides a special frame for conveniently 92 | navigating in or operating on another frame. The original inpiration comes from 93 | the "explorer" feature often used in modern development environments. 94 | 95 | By default, speedbar will fork a new frame, which, IMHO, is a bad 96 | idea. =sr-speedbar= solves this problem, however, it brings some new problems: 97 | - By default, the value of =sr-speedbar-right-side= is =t=. And this windows 98 | will be occupied by =helm= when you do things with =helm=, which is quite 99 | boring. So I have to =(setq sr-speedbar-right-side nil)=. 100 | - By default, the width of =sr-speedbar= window will change when you resize 101 | the Emacs frame, so I have to adopt a code snippet from [[http://www.emacswiki.org/emacs/SrSpeedbar][emacswiki]]. 102 | - Even we =(setq window-size-fixed 'width)=, the width of =sr-speedbar= window 103 | still changes in some rare cases. For example, when you delete "window-1" by 104 | =delete-window= in the following layout, =sr-speedbar= will expand, while 105 | "window-2" will keep its width unchanged. 106 | 107 | | sr-speedbar | window-1 | window-2 | 108 | 109 | #+NAME: sr-speedbar 110 | #+BEGIN_SRC emacs-lisp 111 | (defadvice sr-speedbar-open (around ome-sr-speedbar-open disable) 112 | ad-do-it 113 | (with-current-buffer sr-speedbar-buffer-name 114 | (setq window-size-fixed 'width))) 115 | 116 | (defun ome-sr-speedbar-setup () 117 | ;;keep speed bar window width after resizing 118 | (ad-enable-advice 'sr-speedbar-open 'around 'ome-sr-speedbar-open) 119 | (ad-activate 'sr-speedbar-open) 120 | (setq sr-speedbar-skip-other-window-p t) 121 | (setq sr-speedbar-right-side nil)) 122 | 123 | (ome-install 'sr-speedbar) 124 | #+END_SRC 125 | 126 | * Yascroll 127 | :PROPERTIES: 128 | :CUSTOM_ID: yascroll 129 | :END: 130 | 131 | [[https://github.com/m2ym/yascroll-el][yascroll.el]] is Yet Another Scroll Bar Mode for GNU Emacs. 132 | 133 | #+NAME: yascroll 134 | #+BEGIN_SRC emacs-lisp 135 | (defun ome-yascroll-setup () 136 | (global-yascroll-bar-mode 1)) 137 | 138 | (ome-install 'yascroll) 139 | #+END_SRC 140 | 141 | * Smooth-scrolling 142 | :PROPERTIES: 143 | :CUSTOM_ID: smooth-scrolling 144 | :END: 145 | 146 | Make emacs scroll smoothly. *WARNING*: This makes your emacs slow. 147 | 148 | #+NAME: smooth-scrolling 149 | #+BEGIN_SRC emacs-lisp 150 | (ome-install 'smooth-scrolling) 151 | #+END_SRC 152 | 153 | * Hungry-delete 154 | :PROPERTIES: 155 | :CUSTOM_ID: hungry-delete 156 | :END: 157 | 158 | CC-mode does have some good [[http://www.gnu.org/software/emacs/manual/html_node/ccmode/Minor-Modes.html][innovations]], among which hungry-delete is what I 159 | want most. Fortunately, a good guy ported [[https://github.com/nflath/hungry-delete][hungry-delete]] from cc-mode to a 160 | independent package. 161 | 162 | #+NAME: hungry-delete 163 | #+BEGIN_SRC emacs-lisp 164 | (defun ome-hungry-delete-setup () 165 | (dolist (hook '(text-mode-hook prog-mode-hook comint-mode-hook)) 166 | (add-hook hook 'turn-on-hungry-delete-mode))) 167 | 168 | (ome-install 'hungry-delete) 169 | #+END_SRC 170 | 171 | * Fill-Column-Indicator 172 | :PROPERTIES: 173 | :CUSTOM_ID: fill-column-indicator 174 | :END: 175 | 176 | "Many modern editors and IDEs can graphically indicate the location of the fill 177 | column by drawing a thin line (in design parlance, a "rule") down the length of 178 | the editing window. Fill-column-indicator implements this facility in Emacs 179 | [[https://github.com/alpaker/Fill-Column-Indicator][Fill-Column-Indicator]]." 180 | 181 | This package still has some conflicts with other oh-my-emacs packages, so I 182 | put it in ome-experimental module instead of core. 183 | 184 | #+NAME: fill-column-indicator 185 | #+BEGIN_SRC emacs-lisp :tangle no 186 | (defun ome-fill-column-indicator-setup () 187 | (add-hook 'text-mode-hook 'fci-mode) 188 | (add-hook 'prog-mode-hook 'fci-mode)) 189 | 190 | (ome-install 'fill-column-indicator) 191 | #+END_SRC 192 | 193 | * Documentation with Doxymacs in CC-mode 194 | :PROPERTIES: 195 | :CUSTOM_ID: doxymacs 196 | :END: 197 | 198 | #+BEGIN_QUOTE 199 | Doxygen is the de facto standard tool for generating documentation from 200 | annotated C++ sources, but it also supports other popular programming languages 201 | such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and 202 | UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D. 203 | 204 | -- http://www.doxygen.org/ 205 | #+END_QUOTE 206 | 207 | [[http://doxymacs.sourceforge.net/][Doxymacs]] brings the power of doxygen to Emacs, you can easily insert Doxygen 208 | style comments in emacs. The default keybindings are: 209 | - =C-c d ?= look up documentation for the symbol under the point. 210 | - =C-c d r= rescan your Doxygen tags file. 211 | - =C-c d f= insert a Doxygen comment for the next function. 212 | - =C-c d i= insert a Doxygen comment for the current file. 213 | - =C-c d ;= insert a Doxygen comment for a member variable on the current line 214 | (like M-;). 215 | - =C-c d m= insert a blank multi-line Doxygen comment. 216 | - =C-c d s= insert a blank single-line Doxygen comment. 217 | - =C-c d @= insert grouping comments around the current region. 218 | 219 | If you like, you can even integrate Doxygen to CMake workflow, see [[http://majewsky.wordpress.com/2010/08/14/tip-of-the-day-cmake-and-doxygen/][here]]. 220 | 221 | #+NAME: doxymacs 222 | #+BEGIN_SRC emacs-lisp 223 | (defun ome-doxymacs-setup () 224 | (add-hook 'c-mode-common-hook 'doxymacs-mode) 225 | (add-hook 'c-mode-common-hook 'doxymacs-font-lock)) 226 | 227 | (ome-install 'doxymacs) 228 | #+END_SRC 229 | 230 | * Sublimity 231 | :PROPERTIES: 232 | :CUSTOM_ID: sublimity 233 | :END: 234 | 235 | As a long-history editor, emacs lacks some "modern" features established by 236 | other "modern" editors, among which [[http://www.sublimetext.com/][sublime]] is one of the most famous and 237 | popular. To tell the truth, the minimap and smooth-scrolling looks really 238 | charming and attractive. There're various attempts trying to bring these 239 | features to emacs, such as [[http://www.emacswiki.org/emacs/MiniMap][minimap.el]], but none of them work perfectly. 240 | 241 | [[https://github.com/zk-phi/sublimity][sublimity]] is just another attemp, it's not perfect, however, IMHO, it's better 242 | than others. 243 | 244 | After installing sublimity, type =M-x sublimity-mode= to enable it. 245 | 246 | *WARNING*: This makes your emacs slow. 247 | 248 | #+NAME: sublimity 249 | #+BEGIN_SRC emacs-lisp 250 | (defun ome-sublimity-setup () 251 | (require 'sublimity-scroll) 252 | (require 'sublimity-map)) 253 | 254 | (ome-install 'sublimity) 255 | #+END_SRC 256 | 257 | * Pos-tip 258 | :PROPERTIES: 259 | :CUSTOM_ID: pos-tip 260 | :END: 261 | 262 | By default, =auto-complete= will use =popup.el= library to display completion 263 | list, while =popup.el= itself can show some tooltip to display annotations of 264 | the menu items when available. However, sometimes the layout of the tooltip 265 | looks bad when you use the builtin =popup.el= windows. Fortunately, =pos-tip= 266 | provide a better way to display tooltips in a specified location, and it can be 267 | used by other frontend program like =popup.el=. Auto-complete has a builtin 268 | variable =ac-quick-help-prefer-pos-tip=, which defaults to =t=, that means when 269 | we have =pos-tip= library installed, we will have a better tooltip window. I 270 | tried and it works like a charm. However, some users of ome reported that they 271 | have various problem installing =pos-tip=, see github issue [[https://github.com/xiaohanyu/oh-my-emacs/issues/70][70]] and [[https://github.com/xiaohanyu/oh-my-emacs/issues/71][71]], so I 272 | made it a experimental package in ome ome-experimental module, and I hope you 273 | have a good luck and able to enjoy it. To get this package, just =(ome-load 274 | "modules/ome-experimental.org" "pos-tip")= 275 | 276 | #+NAME: pos-tip 277 | #+BEGIN_SRC emacs-lisp 278 | (defun ome-pos-tip-setup () 279 | (require 'pos-tip)) 280 | 281 | (ome-install 'pos-tip) 282 | 283 | #+END_SRC 284 | 285 | By default, flycheck show errors in [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Echo-Area.html][echo area]], which is not intuitive. This 286 | [[https://github.com/flycheck/flycheck-pos-tip][flycheck-pos-tip]] extention will display errors under point using [[https://github.com/emacsmirror/pos-tip][pos-tip]]. 287 | 288 | #+NAME: flycheck-pos-tip 289 | #+BEGIN_SRC emacs-lisp 290 | (defun ome-flycheck-pos-tip-setup () 291 | (eval-after-load 'flycheck 292 | '(progn 293 | (require 'flycheck-pos-tip) 294 | (setq flycheck-display-errors-function 295 | #'flycheck-pos-tip-error-messages) 296 | (setq flycheck-pos-tip-timeout 10)))) 297 | 298 | (ome-install 'flycheck-pos-tip) 299 | #+END_SRC 300 | 301 | * Po-mode 302 | :PROPERTIES: 303 | :CUSTOM_ID: po-mode 304 | :END: 305 | 306 | Emacs always bring you some surprises for you daily job. Some day I wanted to 307 | do some i18n/l10n work for a python project, and I found [[http://www.gnu.org/software/gettext/manual/html_node/PO-Mode.html][PO-Mode]], which is 308 | really awesome. I even wanted to write a tiny tutorial for this great mode, but 309 | I just gave up. Since for any questions in =po-mode=, you can just type =?= or 310 | =h=, and you will get a brief and concise answer. 311 | 312 | #+NAME: po-mode 313 | #+BEGIN_SRC emacs-lisp 314 | (defun ome-po-mode-setup () 315 | (add-hook 'po-mode-hook 316 | (lambda () 317 | (linum-mode 1))) 318 | ;; disable evil-mode since some key binding conflicts 319 | (when (featurep 'evil) 320 | (add-hook 'po-mode-hook 'turn-off-evil-mode))) 321 | 322 | (ome-install 'po-mode) 323 | #+END_SRC 324 | 325 | * emacs-dirtree 326 | :PROPERTIES: 327 | :CUSTOM_ID: emacs-dirtree 328 | :END: 329 | 330 | [[https://github.com/zk/emacs-dirtree][emacs-dirtree]] provide a long lost directory browser for Emacs. However, this 331 | package didn't update for a long time, so I only put this in ome-experimental 332 | module, and you can load this package by put `(ome-load 333 | "modules/ome-experimental.org" "emacs-dirtree")` in oh-my-emacs startup file. 334 | 335 | #+NAME: emacs-dirtree 336 | #+BEGIN_SRC emacs-lisp 337 | (defun ome-emacs-dirtree-setup ()) 338 | 339 | (ome-install 'emacs-dirtree) 340 | #+END_SRC 341 | -------------------------------------------------------------------------------- /modules/ome-golang.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs golang 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: golang-prerequisites 9 | :END: 10 | 11 | #+NAME: golang-prerequisites 12 | #+CAPTION: Prerequisites for ome-golang module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[https://golang.org/cmd/go][go tool]] | | go | | | | Yes | 16 | | [[https://github.com/rogpeppe/godef][godef]] | | [go] | | | | No | 17 | | [[https://github.com/dougm/goflymake][goflymake]] | | [go] | | | | No | 18 | | [[https://github.com/nsf/gocode][gocode]] | | [go] | | | | No | 19 | 20 | * El-get packages 21 | :PROPERTIES: 22 | :CUSTOM_ID: golang-el-get-packages 23 | :END: 24 | 25 | #+NAME: golang-el-get-packages 26 | #+CAPTION: El-get packages for ome-golang module 27 | | Package | Status | Description | 28 | |--------------+----------+---------------------------------------------------| 29 | | [[https://github.com/dominikh/go-mode.el][go-mode]] | Required | This is the Emacs mode for editing Go code | 30 | 31 | * About Go 32 | You can find all the necessary information about golang in the official [[https://golang.org][site]]. 33 | 34 | * go-mode 35 | :PROPERTIES: 36 | :CUSTOM_ID: go-mode 37 | :END: 38 | 39 | Beginning with Go 1.4, editor integration will not be part of the Go distribution 40 | anymore, making the github repository the canonical place for go-mode. Please refer 41 | the repo for all the features and other information for the go-mode. 42 | 43 | #+NAME: go-mode 44 | #+BEGIN_SRC emacs-lisp 45 | (defun ome-go-mode-setup () 46 | 47 | ; set the GOPATH here if not already 48 | ; (setenv "GOPATH" "/home/chuchao/gowork") 49 | 50 | ;; enable the go-mode 51 | (require 'go-mode) 52 | (add-hook 'before-save-hook 'gofmt-before-save) 53 | 54 | ; key binding for go-remove-unused-imports 55 | (add-hook 'go-mode-hook '(lambda () 56 | (local-set-key (kbd "C-c C-r") 'go-remove-unused-imports))) 57 | 58 | ; key binding for go-goto-imports 59 | (add-hook 'go-mode-hook '(lambda () 60 | (local-set-key (kbd "C-c C-g") 'go-goto-imports))) 61 | 62 | ; bind C-c C-f for gofmt 63 | (add-hook 'go-mode-hook '(lambda () 64 | (local-set-key (kbd "C-c C-f") 'gofmt))) 65 | 66 | ; godoc 67 | (when (executable-find "godoc") 68 | (add-hook 'go-mode-hook '(lambda () 69 | (local-set-key (kbd "C-c C-k") 'godoc)))) 70 | 71 | ; goflymake 72 | (when (executable-find "goflymake") 73 | (add-to-list 'load-path (concat (getenv "GOPATH") "/src/github.com/dougm/goflymake")) 74 | (require 'go-flymake) 75 | (require 'go-flycheck)) 76 | 77 | ; go-code 78 | (when (executable-find "gocode") 79 | 80 | (add-to-list 'load-path (concat (getenv "GOPATH") "/src/github.com/nsf/gocode/emacs-company")) 81 | (require 'company-go) 82 | 83 | (add-hook 'go-mode-hook 'company-mode) 84 | (add-hook 'go-mode-hook (lambda () 85 | (set (make-local-variable 'company-backends) '(company-go)) 86 | (company-mode))))) 87 | 88 | (when (executable-find "go") 89 | (ome-install 'go-mode)) 90 | #+END_SRC 91 | 92 | * Note 93 | The settings listed above are mainly referred from the blog post 94 | [[http://yousefourabi.com/blog/2014/05/emacs-for-go/][Emacs for Go]], adapted to 95 | the oh-my-emacs framework with some other configurations. Credits also go to the 96 | original author of the blog post and also the authros of the awesome golang 97 | related emacs modes. 98 | -------------------------------------------------------------------------------- /modules/ome-haskell.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Haskell 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: haskell-prerequisites 9 | :END: 10 | 11 | #+NAME: haskell-prerequisites 12 | #+CAPTION: Prerequisites for ome-haskell module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://www.haskell.org/ghc/][GHC]] | | ghc | | | | Yes | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: haskell-el-get-packages 20 | :END: 21 | 22 | #+NAME: haskell-el-get-packages 23 | #+CAPTION: El-get packages for ome-haskell module 24 | | Package | Status | Description | 25 | |--------------+----------+---------------------------------------------------| 26 | | [[https://github.com/haskell/haskell-mode/wiki][haskell-mode]] | Required | This is a package for developing haskell in Emacs | 27 | 28 | * About Haskell 29 | You can find all the necessary information about haskell in the official [[http://www.haskell.org][site]]. 30 | 31 | * haskell-mode 32 | :PROPERTIES: 33 | :CUSTOM_ID: haskell-mode 34 | :END: 35 | 36 | haskell-mode features a wide a range of tooling, from basic editing to building 37 | packages and interactive evaluation. The package customization defined in the 38 | *ome-haskell-mode-setup* function mostly come from this [[https://github.com/haskell/haskell-mode/blob/master/examples/init.el][example file]] with some 39 | minor teaks according personal preferences. 40 | 41 | #+NAME: haskell-mode 42 | #+BEGIN_SRC emacs-lisp 43 | (defun ome-haskell-mode-setup () 44 | (add-to-list 'load-path ".") 45 | ;; Always load via this. If you contribute you should run `make all` 46 | ;; to regenerate this. 47 | (load "haskell-mode-autoloads") 48 | 49 | ;; Customization 50 | (custom-set-variables 51 | ;; Use cabal-dev for the GHCi session. Ensures our dependencies are in scope. 52 | ;;'(haskell-process-type 'cabal-dev) 53 | 54 | ;; Use notify.el (if you have it installed) at the end of running 55 | ;; Cabal commands or generally things worth notifying. 56 | '(haskell-notify-p t) 57 | 58 | ;; To enable tags generation on save. 59 | '(haskell-tags-on-save t) 60 | 61 | ;; To enable stylish on save. 62 | '(haskell-stylish-on-save t)) 63 | 64 | (add-hook 'haskell-mode-hook 'haskell-hook) 65 | (add-hook 'haskell-mode-hook 'interactive-haskell-mode) 66 | (add-hook 'haskell-mode-hook 'haskell-indent-mode) 67 | (add-hook 'haskell-cabal-mode-hook 'haskell-cabal-hook) 68 | 69 | ;; Haskell main editing mode key bindings. 70 | (defun haskell-hook () 71 | ;; Use simple indentation. 72 | (turn-on-haskell-simple-indent) 73 | (define-key haskell-mode-map (kbd "") 'haskell-simple-indent-newline-same-col) 74 | (define-key haskell-mode-map (kbd "C-") 'haskell-simple-indent-newline-indent) 75 | 76 | ;; Load the current file (and make a session if not already made). 77 | (define-key haskell-mode-map [?\C-c ?\C-l] 'haskell-process-load-file) 78 | (define-key haskell-mode-map [f5] 'haskell-process-load-file) 79 | 80 | ;; Switch to the REPL. 81 | (define-key haskell-mode-map [?\C-c ?\C-z] 'haskell-interactive-switch) 82 | ;; “Bring” the REPL, hiding all other windows apart from the source 83 | ;; and the REPL. 84 | (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring) 85 | 86 | ;; Build the Cabal project. 87 | (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build) 88 | ;; Interactively choose the Cabal command to run. 89 | (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal) 90 | 91 | ;; Get the type and info of the symbol at point, print it in the 92 | ;; message buffer. 93 | (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type) 94 | (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info) 95 | 96 | ;; Contextually do clever things on the space key, in particular: 97 | ;; 1. Complete imports, letting you choose the module name. 98 | ;; 2. Show the type of the symbol after the space. 99 | (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space) 100 | 101 | ;; Jump to the imports. Keep tapping to jump between import 102 | ;; groups. C-u f8 to jump back again. 103 | (define-key haskell-mode-map [f8] 'haskell-navigate-imports) 104 | 105 | ;; Jump to the definition of the current symbol. 106 | (define-key haskell-mode-map (kbd "M-.") 'haskell-mode-tag-find) 107 | 108 | ;; Indent the below lines on columns after the current column. 109 | (define-key haskell-mode-map (kbd "C-") 110 | (lambda () 111 | (interactive) 112 | (haskell-move-nested 1))) 113 | ;; Same as above but backwards. 114 | (define-key haskell-mode-map (kbd "C-") 115 | (lambda () 116 | (interactive) 117 | (haskell-move-nested -1)))) 118 | 119 | ;; Useful to have these keybindings for .cabal files, too. 120 | (defun haskell-cabal-hook () 121 | (define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build) 122 | (define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal) 123 | (define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring) 124 | (define-key haskell-cabal-mode-map [?\C-c ?\C-z] 'haskell-interactive-switch))) 125 | 126 | (when (executable-find "ghc") 127 | (ome-install 'haskell-mode)) 128 | #+END_SRC 129 | -------------------------------------------------------------------------------- /modules/ome-java.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Java 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: java-prerequisites 9 | :END: 10 | 11 | #+NAME: java-prerequisites 12 | #+CAPTION: Prerequisites for ome-java module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://www.eclipse.org/][eclipse]] | | | | | | Yes | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: java-el-get-packages 20 | :END: 21 | 22 | #+NAME: java-el-get-packages 23 | #+CAPTION: El-get packages for ome-java module 24 | 25 | | Package | Status | Description | 26 | |-------------+----------+---------------------------------------| 27 | | [[https://github.com/senny/emacs-eclim][emacs-eclim]] | Required | The bridge between emacs and eclipse. | 28 | 29 | * Eclim 30 | :PROPERTIES: 31 | :CUSTOM_ID: eclim 32 | :END: 33 | 34 | #+BEGIN_QUOTE 35 | Emacs was a really great idea in the seventies and one of the frightening 36 | things about Emacs today is if you skip the last 20 years it is much the same. 37 | 38 | -- [[http://www.computerworld.com.au/article/207799/don_t_use_emacs_says_java_father/][Don't use Emacs, says Java's father]] 39 | #+END_QUOTE 40 | 41 | I must say that it is really a pain to do Java programming with Emacs, 42 | however, when I turn to a modern IDE(eclipse/netbeans), just as Java's father 43 | said, I would miss Emacs again. You want to know why? Refer to [[http://gnuvince.wordpress.com/2012/02/19/why-i-still-use-emacs/][Why I Still Use 44 | Emacs]]. 45 | 46 | However, Eclipse, or some other java IDEs, do provide some fascinating features 47 | such as refactoring, 100% absolutely correct semantic completion, on-the-fly 48 | syntax checking, maven/ant integration, etc. 49 | 50 | Fortunately, there comes [[https://github.com/senny/emacs-eclim][emacs-eclim]], which brings the power of Eclipse to 51 | Emacs by utilizing [[http://eclim.org/][eclim]], ah, the best of both world. 52 | 53 | To install eclim, first you need to install Eclipse. You can install Eclipse 54 | through your OS package manager, or you can download a tarball directly from 55 | [[http://www.eclipse.org/downloads/][official eclipse website]]. I recommend the later method since it is much more 56 | portable, and dumps all eclipse files to a single folder, say, =/opt/eclipse/= 57 | for example. And one extra advice, I recommend you install Eclipse version 3.x 58 | instead of 4.x since 4.x is not stable enough IMHO. My working environments 59 | include Eclipse 3.7 and eclim_1.7.18. I didn't have too much time to test 60 | other combinations, so if you encounter problems, don't hesitate to open a new 61 | issue in oh-my-emacs's github. 62 | 63 | Then you should download and install eclim, see [[http://eclim.org/install.html][eclim install guide]] for 64 | details. I use the following command to do an automated install. 65 | 66 | #+BEGIN_SRC sh 67 | java -Dvim.files=$HOME/.vim -Declipse.home=/opt/eclipse -jar eclim_1.7.18.jar install 68 | #+END_SRC 69 | 70 | Oh-my-emacs assumes that you install Eclipse to =/opt/eclipse/= directory, and 71 | set your Eclipse workspace to =$HOME/workspace=. So if your settings are 72 | different, don't forget to set =eclim-executable= and =eclimd-executable= 73 | properly. Finally, ensure that you can find =eclipse= in your shell's =$PATH= 74 | since oh-my-emacs relies on this way to determine the availability of Eclipse. 75 | 76 | Ok, that's enough, you want to know what eclim can provide for you? [[http://www.skybert.net/emacs/java/][Enterprise 77 | Java Development in Emacs]] show you an illustrated guide. 78 | 79 | #+NAME: eclim 80 | #+BEGIN_SRC emacs-lisp 81 | (defun ome-eclim-setup () 82 | ;; (add-to-list 'eclim-eclipse-dirs "/opt/eclipse") 83 | (setq eclim-auto-save t 84 | eclim-executable (or (executable-find "eclim") "/opt/eclipse/eclim") 85 | eclimd-executable (or (executable-find "eclimd") "/opt/eclipse/eclimd") 86 | eclimd-wait-for-process nil 87 | eclimd-default-workspace "~/workspace/" 88 | help-at-pt-display-when-idle t 89 | help-at-pt-timer-delay 0.1) 90 | 91 | ;; Call the help framework with the settings above & activate 92 | ;; eclim-mode 93 | (help-at-pt-set-timer) 94 | 95 | ;; keep consistent which other auto-complete backend. 96 | (custom-set-faces 97 | '(ac-emacs-eclim-candidate-face ((t (:inherit ac-candidate-face)))) 98 | '(ac-emacs-eclim-selection-face ((t (:inherit ac-selection-face))))) 99 | 100 | ;; Hook eclim up with auto complete mode 101 | (require 'ac-emacs-eclim-source) 102 | ;; (ac-emacs-eclim-config) 103 | 104 | (require 'eclimd) 105 | 106 | (add-hook 'java-mode-hook 107 | (lambda () 108 | (add-to-list 'ac-sources 'ac-source-emacs-eclim) 109 | (eclim-mode t)))) 110 | 111 | (when (executable-find "eclipse") 112 | (ome-install 'eclim)) 113 | #+END_SRC 114 | 115 | * Todo 116 | - Complitation support, use =M-n= and =M-p= to navigate the eclim warnings and 117 | errors just like =c-mode= and =c++-mode=. 118 | - Provide a menubar to eclim thus users can get a quick overview of eclim 119 | features. 120 | - Eclim would report warnings like =describe-mode: Symbol's function definition 121 | is void: eclim-project-mode= when you hit =C-h m= in auxiliary eclim modes. 122 | -------------------------------------------------------------------------------- /modules/ome-javascript.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs JavaScript 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | As with python, there're many choices to do JavaScript programming in Emacs, 7 | however, IMHO, none of them are perfect, and easy to use. I've spent weeks of 8 | spare time to experience various emacs packages for JavaScript, and only 9 | figured out a not too bad solution based on [[https://github.com/thomblake/js3-mode][js3-mode]], [[https://github.com/abicky/nodejs-repl.el][nodejs-repl]], and [[https://github.com/marijnh/tern][tern]]. 10 | 11 | * Prerequisites 12 | :PROPERTIES: 13 | :CUSTOM_ID: javascript-prerequisites 14 | :END: 15 | 16 | #+NAME: javascript-prerequisites 17 | #+CAPTION: Prerequisites for ome-javascript module 18 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 19 | |---------+---------+--------------------+-----------+--------+----------+------------| 20 | | [[http://nodejs.org/][nodejs]] | | nodejs | | | | Yes | 21 | | [[http://ternjs.net/][tern]] | | [npm] | [npm] | [npm] | [npm] | Yes | 22 | 23 | * El-get packages 24 | :PROPERTIES: 25 | :CUSTOM_ID: javascript-el-get-packages 26 | :END: 27 | 28 | #+NAME: javascript-el-get-packages 29 | #+CAPTION: El-get packages for ome-javascript module 30 | | Package | Status | Description | 31 | |-------------+------------+-----------------------------------------------------| 32 | | [[https://github.com/thomblake/js3-mode][js3-mode]] | Required | A chimeric fork of js2-mode and js-mode | 33 | | [[https://github.com/marijnh/tern][tern]] | Required | A great JavaScript code analyzer | 34 | | [[https://github.com/abicky/nodejs-repl.el][nodejs-repl]] | Required | Run Node.js REPL and communicate the process | 35 | | [[http://js-comint-el.sourceforge.net/][js-comint]] | Deprecated | Run JavaScript in an inferior process window | 36 | | [[https://github.com/mooz/js2-mode][js2-mode]] | Deprecated | Parse JavaScript to AST using elisp | 37 | | [[https://github.com/swank-js/swank-js][swank-js]] | Deprecated | Swank backend for Node.JS and in-browser JavaScript | 38 | | [[https://github.com/skeeto/skewer-mode][skewer-mode]] | Deprecated | Browser JavaScript REPL in Emacs. | 39 | 40 | * js3-mode 41 | :PROPERTIES: 42 | :CUSTOM_ID: js3-mode 43 | :END: 44 | 45 | As the author said, [[https://github.com/thomblake/js3-mode][js3-mode]] is a "A chimeric fork of js2-mode and 46 | js-mode". The main advantage of js3-mode over js2-mode, IMHO, is its 47 | indentation work as I expected. However, some third party packages depend on 48 | js2-mode, so this is a trade-off. I'm familiar with the internals of js2-mode, 49 | any discussion is welcomed if you prefer js2-mode over js3-mode. 50 | 51 | And another small issue is, js3-mode bind the =RET= key to =js3-enter-key=, 52 | which break smartparens's newline and indentation. I didn't figure out a good 53 | way to solve this. 54 | 55 | #+NAME: js3-mode 56 | #+BEGIN_SRC emacs-lisp 57 | (defun ome-js3-mode-setup () 58 | (add-hook 'js3-mode-hook 59 | (lambda () 60 | (setq js3-auto-indent-p t 61 | js3-curly-indent-offset 0 62 | js3-enter-indents-newline t 63 | js3-expr-indent-offset 2 64 | js3-indent-on-enter-key t 65 | js3-lazy-commas t 66 | js3-lazy-dots t 67 | js3-lazy-operators t 68 | js3-paren-indent-offset 2 69 | js3-square-indent-offset 4) 70 | (linum-mode 1))) 71 | 72 | ;; https://github.com/Fuco1/smartparens/issues/239 73 | ;; (defadvice js3-enter-key (after fix-sp-state activate) 74 | ;; (setq sp-last-operation 'sp-self-insert)) 75 | 76 | ;; (sp-local-pair 'js3-mode 77 | ;; "{" 78 | ;; nil 79 | ;; :post-handlers 80 | ;; '((ome-create-newline-and-enter-sexp js3-enter-key)))) 81 | (add-to-list 'ac-modes 'js3-mode)) 82 | 83 | (ome-install 'js3-mode) 84 | #+END_SRC 85 | 86 | * Tern 87 | :PROPERTIES: 88 | :CUSTOM_ID: tern 89 | :END: 90 | 91 | Tern is a stand-alone code-analysis engine for JavaScript. It is written in 92 | JavaScript, and capable of running both on [[http://nodejs.org/][nodejs]] and in the browser. 93 | 94 | IMHO, tern is really an awesome project, various editors including Emacs 95 | provides tern support. The author of tern, [[http://marijnhaverbeke.nl/][Marijin Haverbeke]], is really a cool 96 | guy, an excellent JavaScript/Lisp hacker. He is also a tech writer, the author 97 | of "Eloquent JavaScript". 98 | 99 | Tern is really cool, besides the parser, it even has type inference for 100 | JavaScript. And it works both for browser and nodejs in an extensible way. For 101 | example, to get completion for both nodejs and jquery, just put a 102 | =.tern-project= file in your js project root directory, the content of this 103 | =.tern-project= file is self-explained, see tern's [[http://ternjs.net/doc/manual.html#configuration][manual]] for tech details. 104 | 105 | #+NAME: tern-project 106 | #+BEGIN_SRC javascript 107 | { 108 | "libs": [ 109 | "browser", 110 | "jquery" 111 | ], 112 | "plugins": { 113 | "node": {} 114 | } 115 | } 116 | #+END_SRC 117 | 118 | It is quite easy to setup and configure tern, the only thing you need to do is 119 | =sudo npm install -g tern=. Enjoy the auto-completion support from tern and 120 | auto-complete for JavaScript programming in Emacs. 121 | 122 | #+NAME: tern 123 | #+BEGIN_SRC emacs-lisp 124 | (defun ome-tern-setup () 125 | (when (el-get-package-installed-p 'js2-mode) 126 | (add-hook 'js2-mode-hook (lambda () (tern-mode t)))) 127 | (when (el-get-package-installed-p 'js3-mode) 128 | (add-hook 'js3-mode-hook (lambda () (tern-mode t)))) 129 | (setq tern-command (cons (executable-find "tern") '())) 130 | (eval-after-load 'tern 131 | '(progn 132 | (require 'tern-auto-complete) 133 | (tern-ac-setup)))) 134 | 135 | (ome-install 'tern) 136 | #+END_SRC 137 | 138 | * js2-mode 139 | :PROPERTIES: 140 | :CUSTOM_ID: js2-mode 141 | :END: 142 | 143 | [[https://github.com/mooz/js2-mode][js2-mode]] is really an awesome emacs package for JavaScript programming. It is 144 | originally written by [[http://steve-yegge.blogspot.com/][Steve Yegge]]. I said it is awesome since it build a 145 | JavaScript [[http://en.wikipedia.org/wiki/Abstract_syntax_tree][AST]] using emacs-lisp, thus there're even some third party "plugins" 146 | for js2-mode: 147 | - [[https://github.com/magnars/js2-refactor.el][js2-refactor]]: A JavaScript refactoring library for emacs. 148 | - [[https://github.com/ScottyB/ac-js2][ac-js2]]: Javascript auto-completion in Emacs using Js2-mode's parser and 149 | Skewer-mode. 150 | 151 | The only thing I dislike about js2-mode is indentation. That's why I adopt 152 | [[https://github.com/thomblake/js3-modej][js3-mode]] for oh-my-emacs since js3-mode provides more friendly indentation 153 | settings and works as expected. 154 | 155 | #+NAME: js2-mode 156 | #+BEGIN_SRC emacs-lisp :tangle no 157 | (defun ome-js2-mode-setup () 158 | (add-hook 'js2-mode-hook 159 | (lambda () 160 | (setq js2-basic-offset 2))) 161 | (setq js2-bounce-indent-p t)) 162 | ;; (add-to-list 'auto-mode-alist '("\\.json$" . js2-mode)) 163 | ;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))) 164 | 165 | (ome-install 'js2-mode) 166 | #+END_SRC 167 | 168 | * swank-js 169 | :PROPERTIES: 170 | :CUSTOM_ID: swank-js 171 | :END: 172 | 173 | I really love the [[http://www.common-lisp.net/project/slime/][SLIME]] way, I hope that one day every programming language can 174 | work the SLIME way. I was really exciting when I first saw [[https://github.com/swank-js/swank-js][swank-js]]. It is 175 | really great and awesome if I can do JavaScript programming in SLIME way. 176 | 177 | Unfortunately, things do not always work as expected. There're some serious 178 | show-stop bugs, and it is under little development due to [[https://github.com/swank-js/swank-js/issues/52][lack of 179 | developers]]. Another problem of swank-js is installation since it depends on 180 | SLIME, which is not quite easy to setup and configure, either. 181 | 182 | However, I still keep my code here for reference, which records some of my 183 | initial setup of swank-js and maybe useful for you, or in future. 184 | 185 | To use swank-js, you must have [[http://nodejs.org/][nodejs]] installed, and then =sudo npm install -g 186 | swank-js=. If you have any problems, I recommend you to upgrade your nodejs to 187 | latest version and try again. And to make the following code work, you must 188 | setup and configure SLIME and js3-mode correctly. 189 | 190 | #+NAME: swank-js 191 | #+BEGIN_SRC emacs-lisp :tangle no 192 | (defun ome-swank-js-setup () 193 | (require 'slime-js) 194 | (add-hook 'js3-mode-hook 195 | (lambda () 196 | (slime-js-minor-mode 1))) 197 | (add-hook 'css-mode-hook 198 | (lambda () 199 | (define-key css-mode-map (kbd "M-C-x") 'slime-js-refresh-css) 200 | (define-key css-mode-map (kbd "C-c C-r") 'slime-js-embed-css)))) 201 | 202 | ;; Wow, swank-js has lots of dependencies. 203 | (when (and (require 'slime nil 'noerror) 204 | (require 'js3-mode nil 'noerror) 205 | (executable-find "npm") 206 | (executable-find "swank-js")) 207 | (ome-install 'swank-js)) 208 | 209 | (eval-after-load 'auto-complete 210 | '(progn 211 | (add-to-list 'ac-modes 'js-mode) 212 | (add-to-list 'ac-modes 'js2-mode) 213 | (add-to-list 'ac-modes 'js3-mode) 214 | (add-hook 'slime-mode-hook 'set-up-slime-ac) 215 | (add-hook 'slime-repl-mode-hook 'set-up-slime-ac))) 216 | 217 | (eval-after-load 'slime 218 | '(progn 219 | (slime-setup '(slime-repl slime-js)))) 220 | #+END_SRC 221 | 222 | * nodejs-repl 223 | :PROPERTIES: 224 | :CUSTOM_ID: nodejs-repl 225 | :END: 226 | 227 | There're multiple choices to get a JavaScript repl in Emacs. Unfortunately, 228 | none of them are perfect and work as expected. I myself prefers [[https://github.com/abicky/nodejs-repl.el][nodejs-repl]] 229 | over [[http://js-comint-el.sourceforge.net/][js-comint]] since it provides good support for TAB completion. However, it 230 | lacks some interactive commands, which need to be improved. 231 | 232 | #+NAME: nodejs-repl 233 | #+BEGIN_SRC emacs-lisp 234 | (defun ome-nodejs-repl-setup ()) 235 | 236 | (ome-install 'nodejs-repl) 237 | #+END_SRC 238 | 239 | * js-comint 240 | :PROPERTIES: 241 | :CUSTOM_ID: js-comint 242 | :END: 243 | 244 | [[http://js-comint-el.sourceforge.net/][js-comint.el]] is a comint mode for emacs which allows you to run a compatible 245 | javascript repl in Emacs, it is an alternative to [[https://github.com/abicky/nodejs-repl.el][nodejs-repl]]. Actually, Nodejs 246 | is not born when js-comint was first released. 247 | 248 | #+NAME: js-comint 249 | #+BEGIN_SRC emacs-lisp :tangle no 250 | (defun ome-js-comint-setup () 251 | (setq inferior-js-program-command "node") 252 | (add-hook 'js3-mode-hook 253 | '(lambda () 254 | (local-set-key (kbd "C-x C-e") 255 | 'js-send-last-sexp) 256 | (local-set-key (kbd "C-M-x") 257 | 'js-send-last-sexp-and-go) 258 | (local-set-key (kbd "C-c b") 259 | 'js-send-buffer) 260 | (local-set-key (kbd "C-c C-b") 261 | 'js-send-buffer-and-go) 262 | (local-set-key (kbd "C-c l") 263 | 'js-load-file-and-go))) 264 | (setenv "NODE_NO_READLINE" "1") 265 | (setq inferior-js-mode-hook 266 | (lambda () 267 | ;; We like nice colors 268 | (ansi-color-for-comint-mode-on)))) 269 | 270 | (ome-install 'js-comint) 271 | #+END_SRC 272 | 273 | * Skewer-mode 274 | :PROPERTIES: 275 | :CUSTOM_ID: skewer-mode 276 | :END: 277 | 278 | What's wrong with swank-js? 279 | 280 | #+BEGIN_QUOTE 281 | Skewer provides nearly the same functionality as swank-js, a JavaScript 282 | back-end to SLIME. At a glance my extension seems redundant. 283 | 284 | The problem with swank-js is the complicated setup. It requires a cooperating 285 | Node.js server, a particular version of SLIME, and a lot of patience. I could 286 | never get it working, and if I did I wouldn’t want to have to do all that setup 287 | again on another computer. In contrast, Skewer is just another Emacs package, 288 | no special setup needed. Thanks to package.el installing and using it should be 289 | no more difficult than installing any other package. 290 | 291 | Most importantly, with Skewer I can capture the setup in my .emacs.d repository 292 | where it will automatically work across any operating system, so long as it has 293 | Emacs installed. 294 | 295 | -- The [[http://nullprogram.com/blog/2012/10/31/][author]] of skewer-mode 296 | #+END_QUOTE 297 | 298 | To tell the truth, I have installed skewer-mode but didn't dive into it since I 299 | want to work with nodejs, while skewer-mode [[https://github.com/skeeto/skewer-mode/issues/37][didn't support nodejs]] yet. The 300 | code is kept here just for reference. 301 | 302 | #+NAME: skewer-mode 303 | #+BEGIN_SRC emacs-lisp :tangle no 304 | (defun ome-skewer-mode-setup () 305 | (add-hook 'js2-mode-hook 'skewer-mode) 306 | (add-hook 'css-mode-hook 'skewer-css-mode) 307 | (add-hook 'html-mode-hook 'skewer-html-mode)) 308 | 309 | (ome-install 'skewer-mode) 310 | #+END_SRC 311 | -------------------------------------------------------------------------------- /modules/ome-ocaml.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs CC 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: ocaml-prerequisites 9 | :END: 10 | 11 | #+NAME: ocaml-prerequisites 12 | #+CAPTION: Prerequisites for ome-ocaml module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://ocaml.org/][ocaml]] | | ocaml | | | | Yes | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: ocaml-el-get-packages 20 | :END: 21 | 22 | #+NAME: ocaml-el-get-packages 23 | #+CAPTION: El-get packages for ome-ocaml module 24 | | Package | Status | Description | 25 | |-------------+----------+------------------------------------------------| 26 | | [[http://caml.inria.fr/svn/ocaml/trunk/emacs][caml-mode]] | Required | OCaml code editing commands for Emacs | 27 | | [[http://tuareg.forge.ocamlcore.org/][tuareg-mode]] | Required | A GOOD Emacs mode to edit Objective Caml code. | 28 | 29 | * Things you should know about OCaml 30 | I'm a newbie in OCaml, so I can't provide too much help about how to do OCaml 31 | programming effectively in Emacs. [[https://realworldocaml.org/beta3/en/html/installation.html][Real World Ocaml]] provide really detailed 32 | instructions about how to install necessary tools to develop with 33 | OCaml. There're also some good resources about OCaml: 34 | - http://batteries.forge.ocamlcore.org/ 35 | - http://www.camlcity.org/ 36 | - http://ocaml.org/ 37 | - http://search.ocaml.jp/: OCaml API search 38 | - http://caml.inria.fr/index.en.html: The Caml language 39 | 40 | * OCaml-mode 41 | :PROPERTIES: 42 | :CUSTOM_ID: ocaml-mode 43 | :END: 44 | 45 | Unlike python, there are not too many choices for OCaml in Emacs. 46 | 47 | #+NAME: ocaml-mode 48 | #+BEGIN_SRC emacs-lisp 49 | ;; Keep an empty hook function for later customization. 50 | (defun ome-caml-mode-setup ()) 51 | 52 | (when (executable-find "ocaml") 53 | (ome-install 'caml-mode)) 54 | #+END_SRC 55 | 56 | * Tuareg-mode 57 | :PROPERTIES: 58 | :CUSTOM_ID: tuareg 59 | :END: 60 | 61 | You may wonder what's the relations between =caml-mode= and =tuareg-mode=? In 62 | fact, you can use =tuareg-mode= without =caml-mode=, but some basic functions 63 | depends on =caml-mode=, so we install both. See typerex's [[http://www.typerex.org/faq.html][FAQ]] for details. 64 | 65 | #+BEGIN_SRC emacs-lisp 66 | (defun ome-tuareg-mode-setup () 67 | ;; The following settings comes from tuareg-mode's README 68 | ;; use new SMIE engine 69 | (setq tuareg-use-smie t) 70 | ;; Indent `=' like a standard keyword. 71 | (setq tuareg-lazy-= t) 72 | ;; Indent [({ like standard keywords. 73 | (setq tuareg-lazy-paren t) 74 | ;; No indentation after `in' keywords. 75 | (setq tuareg-in-indent 0) 76 | ;; set ocaml library path 77 | (setq tuareg-library-path "/usr/lib/ocaml") 78 | (add-hook 'tuareg-mode-hook 79 | (lambda () 80 | (define-key tuareg-mode-map (kbd "RET") 81 | 'newline-and-indent)))) 82 | 83 | (when (executable-find "ocaml") 84 | (ome-install 'tuareg-mode)) 85 | #+END_SRC 86 | 87 | * Todos 88 | - Integrate [[https://github.com/def-lkb/merlin][merlin]] for auto-complete support. 89 | - Define a =C-c C-z= keybinding which switch to OCaml's REPL buffer, just like 90 | SLIME/Geiser. 91 | - More investigation on [[http://www.typerex.org/][Typerex]]. 92 | - Find a portable way to integrate [[https://github.com/diml/utop][utop]] to Emacs. 93 | -------------------------------------------------------------------------------- /modules/ome-php.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs PHP 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: php-prerequisites 9 | :END: 10 | 11 | #+NAME: php-prerequisites 12 | #+CAPTION: Prerequisites for ome-php module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+------------------------+-----------+--------+----------+------------| 15 | | [[http://php.net/][php]] | | php5 php5-cli php-pear | | | | No | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: php-el-get-packages 20 | :END: 21 | 22 | #+NAME: php-el-get-packages 23 | #+CAPTION: El-get packages for ome-php module 24 | | Package | Status | Description | 25 | |----------+----------+---------------------| 26 | | [[https://github.com/ejmr/php-mode][php-mode]] | Required | Major mode for php. | 27 | 28 | * php-mode 29 | :PROPERTIES: 30 | :CUSTOM_ID: php-mode 31 | :END: 32 | 33 | I know little about php, and I found little resources about how to do PHP 34 | programming in Emacs, so any pull request will be appreciated. 35 | 36 | #+NAME: php-mode 37 | #+BEGIN_SRC emacs-lisp 38 | (defun ome-php-mode-setup ()) 39 | 40 | (ome-install 'php-mode) 41 | #+END_SRC 42 | -------------------------------------------------------------------------------- /modules/ome-python.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Python 2 | #+OPTIONS: toc:nil num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: python-prerequisites 9 | :END: 10 | 11 | #+NAME: python-prerequisites 12 | #+CAPTION: Prerequisites for ome-python module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |------------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://www.python.org/][Python]] | | python | | | | Yes | 16 | | [[http://www.pip-installer.org/en/latest/][pip]] | | python-pip | | | | Yes | 17 | | [[http://ipython.org/][IPython]] | | ipython | | | | No | 18 | | [[http://nose.readthedocs.org/en/latest/][nose]] | | [pip] | [pip] | [pip] | [pip] | No | 19 | | [[http://www.virtualenv.org/en/latest/][virtualenv]] | | [pip] | [pip] | [pip] | [pip] | No | 20 | | [[https://github.com/yyuu/pyenv][pyenv]] | | [web] | [web] | [web] | [web] | Yes | 21 | 22 | Notes: 23 | - [[http://www.python.org/][Python]], currently, I only tested Python 2. 24 | 25 | * El-get packages 26 | :PROPERTIES: 27 | :CUSTOM_ID: python-el-get-packages 28 | :END: 29 | 30 | #+NAME: python-el-get-packages 31 | #+CAPTION: El-get packages for ome-python module 32 | | Package | Status | Description | 33 | |----------+----------+------------------------------------------------| 34 | | [[https://github.com/jorgenschaefer/elpy][elpy]] | Required | Elpy is the one for all Emacs python solution. | 35 | | [[https://github.com/shellbj/pyenv.el][pyenv.el]] | Required | Emacs integration for pyenv. | 36 | 37 | * Elpy 38 | :PROPERTIES: 39 | :CUSTOM_ID: elpy 40 | :END: 41 | 42 | The first time I tried to write Python with emacs, I've found there're really 43 | really too many choices, which may make newbies confusing and disgusting. 44 | 45 | Say =python-mode=, before [[http://www.gnu.org/software/emacs/news/NEWS.24.3][Emacs 24.3]], there're at least three choices: 46 | - The old =python.el= from Emacs, which has some minor problems when dealing 47 | with docstring, Python 3k, etc. 48 | - The =python-mode.el= from the Python community, which provides lots of dirty 49 | menu items. It's a tedious long journey to make all this menu items just 50 | work. 51 | - The wonderful =python.el= from [[https://github.com/fgallina/python.el][fgallina]], which overcomes many drawbacks of 52 | the old Emacs builtin =python.el=, and has been [[http://from-the-cloud.com/en/emacs/2012/06/18_pythonel-has-landed-on-emacs-trunk.html][integrated to Emacs trunk]]. I 53 | think this is the best choice of the three. 54 | 55 | Say code checking tools, 56 | - What is [[https://pypi.python.org/pypi/pep8][pep8]]? 57 | - What is [[https://pypi.python.org/pypi/pylint][pylint]]? 58 | - What is [[https://pypi.python.org/pypi/pyflakes/][pyflakes]]? 59 | - What is [[https://pypi.python.org/pypi/flake8][flake8]]? 60 | - What's the differences between all these fucking wonderful code checking 61 | tools? How and when should I use it? Which one to use? Any shortcuts to fire 62 | these tools within =python-mode=? 63 | 64 | Say developing tools, 65 | - What is [[http://www.virtualenv.org/en/latest/][virtualenv]]? 66 | - What about code completion? Maybe after two days' google, you finally make 67 | [[http://cx4a.org/software/auto-complete/][auto-complete]] works with a completion backend, such as [[http://rope.sourceforge.net/][rope]] or [[https://github.com/davidhalter/jedi][jedi]], but how 68 | can you make completion be virtualenv-awared? 69 | 70 | Choices, choices, choices, choices are where all happiness and headaches 71 | begins. Just google a minute you'll find articles which use different 72 | =python-mode=, different dotemacs, different way to get necessary packages, 73 | are, what's the fuck[1]! I'm just a newbie, any out-of-box solutions? 74 | Fortunately, there comes [[https://github.com/jorgenschaefer/elpy][elpy]], which saves our lifes. 75 | 76 | Just like other big emacs packages, elpy has some external dependencies. But 77 | don't be afraid, believe me, within minutes, you'll get an out-of-box Emacs 78 | Python "IDE". First, make sure you have =python= and =pip= installed, and then 79 | type =pip install elpy= with root priviledge[2], then choose a completion 80 | backend, either =pip install rope= or =pip install jedi= [3]. 81 | 82 | Make sure you have others necessary python tools installed: 83 | - =pip install virtualenv= 84 | - =pip install pyflakes= 85 | - =pip install nose= 86 | 87 | If you're lucky enough, you can fire up Emacs and start python work right now. 88 | 89 | There're other annoying problems, one of them is the division between Python 2 90 | and Python 3. So you may need to replace =pip= with =pip2=, or =python= with 91 | =python2=, etc. Ah, different systems has different favors and naming rules. 92 | 93 | The second thing is, elpy requires Emacs version >= 24.3, since Emacs 24.3 94 | ships with a new =python.el= [4], which, actually, is the aforementioned 95 | [[https://github.com/fgallina/python.el][fgallina]]'s =python.el=. So you may need to upgrade your builin =python.el=, but 96 | don't worry, oh-my-emacs will handle this for you! 97 | 98 | Third, current elpy use [[http://www.gnu.org/software/emacs/manual/html_node/flymake/index.html][flymake]] as its syntax checker, while oh-my-emacs favors 99 | [[https://github.com/flycheck/flycheck][flycheck]]. Seems elpy has a [[https://github.com/jorgenschaefer/elpy/issues/137][plan]] to support both flycheck and flymake. 100 | 101 | There's also a [[https://github.com/gabrielelanaro/emacs-for-python][emacs-for-python]] project in github, which attracts more github 102 | stars than elpy, but I don't like its approach, since it will clean out all 103 | your existing dotemacs and replace with a wholly new, which is just useful for 104 | Python. However, elpy is just a plugin, though it implements lots of features 105 | with the help from other packages, you can still disable or enable elpy, 106 | without breaking your existing precious dotemacs. 107 | 108 | Thanks [[https://github.com/jorgenschaefer/elpy][elpy]] again, for time it saves for us, through which we can focus more 109 | on Python, on our life, instead of the details to make choices. Elpy is the 110 | ultimate out-of-box Emacs Python "IDE" solution. 111 | 112 | By default, =(elpy-enable)= will [[https://github.com/jorgenschaefer/elpy/blob/master/elpy.el#L343][modify]] auto-complete's keymap, which would 113 | make auto-complete unoperative when you try to complete function arguments with 114 | [[https://github.com/brianjcj/auto-complete-clang/blob/master/screenshot/clang-3.png][auto-complete-clang]] by utilize =yas-expand= from YASnippet. I've spent a whole 115 | day to trace this problem and finally find here. So I use =(elpy-enable t)= 116 | instead. Please =C-h f elpy-enable RET= to get details. 117 | 118 | From version 1.3, elpy replaced [[https://github.com/aculich/virtualenv.el][virtualenv.el]] with [[https://github.com/jorgenschaefer/pyvenv][pyvenv]], see [[https://github.com/jorgenschaefer/elpy/issues/149][here]] for 119 | details. 120 | 121 | Also, elpy integrates with [[http://nose.readthedocs.org/en/latest/][nosetests]], =C-c C-t= will run nose on your 122 | project. So you should =pip install nose= if you want to use nosetests with 123 | elpy. 124 | 125 | #+NAME: elpy 126 | #+BEGIN_SRC emacs-lisp 127 | (when (version< emacs-version "24.3") 128 | (ome-install 'python24)) 129 | 130 | (defun ome-elpy-setup () 131 | (elpy-enable) 132 | (setq elpy-rpc-backend "jedi") 133 | (when (executable-find "ipython") 134 | (elpy-use-ipython)) 135 | (setq elpy-modules '(elpy-module-sane-defaults 136 | elpy-module-company 137 | elpy-module-eldoc 138 | elpy-module-highlight-indentation 139 | elpy-module-pyvenv 140 | elpy-module-yasnippet)) 141 | (define-key python-mode-map (kbd "RET") 142 | 'newline-and-indent) 143 | (add-hook 'python-mode-hook 144 | (lambda () 145 | (set (make-local-variable 'comment-inline-offset) 2) 146 | (auto-complete-mode -1)))) 147 | 148 | (ome-install 'elpy) 149 | #+END_SRC 150 | 151 | Some python web frameworks often provide a =*.wsgi= file to application 152 | initialization, which is just a plain python file. 153 | 154 | #+BEGIN_SRC emacs-lisp 155 | (add-to-list 'auto-mode-alist '("\\.wsgi\\'" . python-mode)) 156 | #+END_SRC 157 | 158 | * pyenv 159 | :PROPERTIES: 160 | :CUSTOM_ID: pyenv 161 | :END: 162 | 163 | Just like Ruby, sometimes we need to work with different versions of Python, so 164 | it's helpful if there's some tool to help use manage and switch different 165 | versions of Python. 166 | 167 | As I know, there're three projects for this purpose: 168 | 169 | - [[https://github.com/utahta/pythonbrew][pythonbrew]] 170 | - [[https://github.com/saghul/pythonz][pythonz]] 171 | - [[https://github.com/yyuu/pyenv][pyenv]] 172 | 173 | However, pythonbrew is "no longer under active development" any more, pythonz 174 | is a fork of original pythonbrew, and pythonbrew recommand pyenv. 175 | 176 | Actually, [[https://github.com/yyuu/pyenv][pyenv]] was forked from [[https://github.com/sstephenson/rbenv][rbenv]] and [[https://github.com/sstephenson/ruby-build][ruby-build]], so if you're an old user 177 | of rbenv, you're all right. It's quite easy to get and install pyenv. 178 | 179 | Emacs has a [[https://github.com/cyberved/pyenv.el][pyenv.el]] package for integrating pyenv with Emacs, which, was also 180 | forked from the corresponding [[https://github.com/senny/rbenv.el][rbenv.el]]. 181 | 182 | #+NAME: pyenv 183 | #+BEGIN_SRC emacs-lisp 184 | (defun ome-pyenv-setup () 185 | ;; when user installed pyenv via homebrew on Mac OS X 186 | (when (and (memq window-system '(mac ns)) 187 | (file-exists-p "/usr/local/opt/pyenv")) 188 | (setq pyenv-installation-dir "/usr/local/opt/pyenv")) 189 | (require 'pyenv) 190 | (global-pyenv-mode t)) 191 | 192 | (when (file-exists-p "~/.pyenv/version") 193 | (ome-install 'pyenv)) 194 | #+END_SRC 195 | 196 | * Todo 197 | - Add some django-mode support? Maybe 198 | https://github.com/fgallina/python-django.el is a good candidate. 199 | - Auto-complete support for completion in =inferior-python-mode= like 200 | SLIME. Maybe the general auto-complete readline backend 201 | https://github.com/monsanto/readline-complete.el is the ultimate solution 202 | for REPL languages. 203 | 204 | 205 | [1] See [[http://www.jesshamrick.com/2012/09/18/emacs-as-a-python-ide/][here]], [[http://caisah.info/emacs-for-python/][here]], [[http://pedrokroger.net/2010/07/configuring-emacs-as-a-python-ide-2/][here]], [[http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/][here]], and [[http://www.enigmacurry.com/2008/05/09/emacs-as-a-powerful-python-ide/][here]]. 206 | [2] =pip install pkg= with root can make =pkg= accessible in newly created 207 | virtualenvs. 208 | [3] See [[https://github.com/jorgenschaefer/elpy/wiki/Backends][elpy wiki]] to get basic knowledge of elpy completion backend. 209 | [4] Check [[http://from-the-cloud.com/en/emacs/2013/03/19_emacs-243-release-and-pythonel.html][Emacs 24.3 release and python.el]] for the author's blog. 210 | -------------------------------------------------------------------------------- /modules/ome-ruby.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Ruby 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: ruby-prerequisites 9 | :END: 10 | 11 | This is a experimental prerequisites matrix. Somebody said we can convert this 12 | type of matrix into a runnable script, however, I think it requires too much 13 | work. Maybe [[http://www.ansibleworks.com/][ansible]] script is a good choice. 14 | 15 | #+NAME: ruby-prerequisites-matrix 16 | #+CAPTION: Prerequisites for ome-ruby module 17 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 18 | |---------+---------+--------------------+-----------+--------+----------+------------| 19 | | ruby | | ruby | ruby | ruby | | Yes | 20 | | [[https://github.com/sstephenson/rbenv][rbenv]] | | [web] | [web] | [web] | [web] | Yes | 21 | | pry | | [gem] | [gem] | [gem] | [gem] | No | 22 | 23 | * El-get packages 24 | :PROPERTIES: 25 | :CUSTOM_ID: ruby-el-get-packages 26 | :END: 27 | 28 | #+NAME: ruby-el-get-packages 29 | #+CAPTION: El-get packages for ome-ruby module 30 | | Package | Status | Description | 31 | |--------------------+------------+---------------------------------------------------------------| 32 | | [[https://github.com/qoobaa/ruby-electric][ruby-electric]] | Deprecated | [[https://github.com/Fuco1/smartparens][smartparens]] is amazing. | 33 | | [[https://github.com/adolfosousa/ruby-block.el][ruby-block]] | Deprecated | [[https://github.com/Fuco1/smartparens][smartparens]] is amazing. | 34 | | [[https://github.com/rejeep/ruby-end][ruby-end]] | Deprecated | [[https://github.com/Fuco1/smartparens/blob/master/smartparens-ruby.el][smartparens-ruby]] is amazing, too. | 35 | | [[http://rubygems.org/gems/rcodetools][rcodetools]] | Deprecated | Long time no update. | 36 | | [[http://www.cx4a.org/pub/auto-complete-ruby.el][auto-complete-ruby]] | Deprecated | Depends on [[http://rubygems.org/gems/rcodetools][rcodetools]]. | 37 | | [[https://github.com/nonsequitur/inf-ruby][inf-ruby]] | Required | Ruby [[http://en.wikipedia.org/wiki/Read%25E2%2580%2593eval%25E2%2580%2593print_loop][REPL]] in Emacs. | 38 | | [[https://github.com/dgutov/robe][robe-mode]] | Required | Code navigation, documentation lookup and completion for Ruby | 39 | | [[https://github.com/pd/yard-mode.el][yard-mode]] | Required | Emacs minor mode for editing YARD tags | 40 | | [[https://github.com/Fuco1/smartparens][smartparens]] | Required | Smartparens is amazing. | 41 | | [[https://github.com/senny/rbenv.el][rbenv.el]] | Required | Emacs integration for [[https://github.com/sstephenson/rbenv][rbenv]]. | 42 | 43 | * Ruby-mode 44 | :PROPERTIES: 45 | :CUSTOM_ID: ruby-mode 46 | :END: 47 | 48 | The builtin =ruby-mode= in Emacs is quite simple, it just provides some simple 49 | functions for font-locking, indentation and code navigation. 50 | 51 | #+NAME: ruby-mode 52 | #+BEGIN_SRC emacs-lisp 53 | (defun ome-ruby-mode-setup () 54 | ;; Ah, this huge auto-mode-alist list comes from emacs prelude 55 | (add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode)) 56 | (add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode)) 57 | (add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode)) 58 | (add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode)) 59 | (add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode)) 60 | (add-to-list 'auto-mode-alist '("Guardfile\\'" . ruby-mode)) 61 | (add-to-list 'auto-mode-alist '("Capfile\\'" . ruby-mode)) 62 | (add-to-list 'auto-mode-alist '("\\.thor\\'" . ruby-mode)) 63 | (add-to-list 'auto-mode-alist '("Thorfile\\'" . ruby-mode)) 64 | (add-to-list 'auto-mode-alist '("Vagrantfile\\'" . ruby-mode)) 65 | (add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . ruby-mode)) 66 | (add-hook 'ruby-mode-hook 67 | (lambda () 68 | (indent-guide-mode 1)))) 69 | 70 | (ome-ruby-mode-setup) 71 | #+END_SRC 72 | 73 | * Inf-ruby 74 | :PROPERTIES: 75 | :CUSTOM_ID: inf-ruby 76 | :END: 77 | 78 | I have a dream that one day the builtin =ruby-mode= and [[https://github.com/nonsequitur/inf-ruby][inf-ruby]] will merge 79 | together to form a new, more powerful =ruby-mode=, just like the builtin 80 | =python-mode=. 81 | 82 | Fortunately, inf-ruby support multiple ruby implementations in a simple 83 | way. Oh-my-emacs will use [[http://pryrepl.org/][pry]] if available. 84 | 85 | There still lacks a good auto-complete support, however, I think it shouldn't 86 | be too hard to add auto-complete support by leveraging =inf-ruby-complete= 87 | provided by =inf-ruby=. 88 | 89 | Oh-my-emacs also bind =C-c C-z= to =run-ruby=, instead of the original 90 | =ruby-switch-to-inf= to make the workflow smoother when you just want to 91 | evaluate ruby code snippets. 92 | 93 | #+NAME: inf-ruby 94 | #+BEGIN_SRC emacs-lisp 95 | (defun ome-inf-ruby-setup () 96 | (require 'inf-ruby) 97 | (define-key inf-ruby-minor-mode-map (kbd "C-c C-z") 'run-ruby) 98 | (when (executable-find "pry") 99 | (add-to-list 'inf-ruby-implementations '("pry" . "pry")) 100 | (setq inf-ruby-default-implementation "pry"))) 101 | 102 | (ome-install 'inf-ruby) 103 | #+END_SRC 104 | 105 | * Robe-mode 106 | :PROPERTIES: 107 | :CUSTOM_ID: robe-mode 108 | :END: 109 | 110 | #+BEGIN_QUOTE 111 | Robe is a code assistance tool that uses a Ruby REPL subprocess with your 112 | application or gem code loaded, to provide information about loaded classes and 113 | modules, and where each method is defined. 114 | #+END_QUOTE 115 | 116 | The general work flow with [[https://github.com/dgutov/robe][robe]] is: 117 | - start an =inf-ruby= buffer by =C-c C-z= 118 | - =M-x robe-start= 119 | 120 | Basic features of robe: 121 | - Jump to method definition 122 | - Jump to =super= or a constructor called at point 123 | - Jump to a module or class (provided it has at least one method defined) 124 | - Display method documentation 125 | - Display information about method called at point using ElDoc 126 | - Method and constant name completion 127 | 128 | #+NAME: robe-mode 129 | #+BEGIN_SRC emacs-lisp 130 | (defun ome-robe-mode-setup () 131 | (add-hook 'robe-mode-hook 'ac-robe-setup) 132 | (add-to-list 'ac-modes 'inf-ruby-mode) 133 | (add-hook 'inf-ruby-mode-hook 'ac-robe-setup)) 134 | 135 | (ome-install 'robe-mode) 136 | #+END_SRC 137 | 138 | * Smartparens-ruby 139 | :PROPERTIES: 140 | :CUSTOM_ID: smartparens-ruby 141 | :END: 142 | 143 | [[https://github.com/Fuco1/smartparens][smartparens]] is amazing, which deprecates [[https://github.com/qoobaa/ruby-electric][ruby-electric]]. In fact, it is so 144 | amazing that one single [[https://github.com/Fuco1/smartparens/blob/master/smartparens-ruby][smartparens-ruby]] deprecates other two el-get packages: 145 | [[https://github.com/adolfosousa/ruby-block.el][ruby-block]] and [[https://github.com/rejeep/ruby-end][ruby-end]]. Just enjoy it! Thanks [[https://github.com/Fuco1/smartparens/blob/master/smartparens-ruby][Matus Goljer]] again for this 146 | amazing, elegant package. 147 | 148 | #+NAME: smartparens-ruby 149 | #+BEGIN_SRC emacs-lisp 150 | (when (require 'smartparens nil 'noerror) 151 | (require 'smartparens-ruby)) 152 | #+END_SRC 153 | 154 | * Rbenv 155 | :PROPERTIES: 156 | :CUSTOM_ID: rbenv 157 | :END: 158 | 159 | Ruby is an actively evolving language. Things often happen when you need to 160 | support multiple versions of ruby with your code base. So you need tools to 161 | install, and switch between multiple versions of ruby. [[http://rvm.io/][RVM]] is one of the most 162 | famous ruby version manager tools, however, IMHO, it's just too bloated. I 163 | prefer [[https://github.com/sstephenson/rbenv][rbenv]] for now. There're other [[https://github.com/postmodern/chruby#alternatives][choices]], but rbenv has [[https://github.com/senny/rbenv.el][emacs support]], and 164 | various [[https://github.com/sstephenson/rbenv/wiki/Plugins][plugins]], which will make your life much more easier. 165 | 166 | Generally, you can get rbenv via plain old =git clone=, if you are a Mac OS X 167 | user, you can get it via homebrew, check the [[https://github.com/sstephenson/rbenv#installation][installation]] guide. When you get 168 | rbenv via homebrew, we need to do some tricks to make [[https://github.com/senny/rbenv.el][rbenv.el]] work in 169 | emacs. So I recommand you install rbenv via direct ~git clone~. 170 | 171 | [[https://github.com/sstephenson/ruby-build][ruby-build]] is one of the most important plugins of rbenv, actually, you can 172 | consider it as a sister project of rbenv. Just as its name, it helps to install 173 | ruby. Please do read its [[https://github.com/sstephenson/ruby-build/wiki][wiki]] to ensure your have necessary packages installed 174 | before you do your ruby-build. 175 | 176 | By default, rbenv will designate the global ruby version via 177 | =~/.rbenv/version=, so if =(file-exists-p "~/.rbenv/version")=, we know that 178 | the user has installed and configured rbenv successfully, then we can install 179 | emacs rbenv support. By default, oh-my-emacs enables =global-rbenv-mode=. 180 | 181 | #+NAME: rbenv 182 | #+BEGIN_SRC emacs-lisp 183 | (defun ome-rbenv-setup () 184 | ;; when user installed rbenv via homebrew on Mac OS X 185 | (when (and (memq window-system '(mac ns)) 186 | (file-exists-p "/usr/local/opt/rbenv")) 187 | (setq rbenv-installation-dir "/usr/local/opt/rbenv")) 188 | (require 'rbenv) 189 | (global-rbenv-mode t)) 190 | 191 | (when (file-exists-p "~/.rbenv/version") 192 | (ome-install 'rbenv)) 193 | #+END_SRC 194 | 195 | * Yard-mode 196 | :PROPERTIES: 197 | :CUSTOM_ID: yard-mode 198 | :END: 199 | 200 | [[https://github.com/pd/yard-mode.el][yard-mode]] is a minor mode that provide rudimentary support for fontifying [[http://yardoc.org/][YARD]] 201 | tags and directives in ruby comments. 202 | 203 | #+NAME: yard-mode 204 | #+BEGIN_SRC emacs-lisp 205 | (defun ome-yard-mode-setup () 206 | (add-hook 'ruby-mode-hook 'yard-mode) 207 | (add-hook 'ruby-mode-hook 'eldoc-mode)) 208 | 209 | (ome-install 'yard-mode) 210 | #+END_SRC 211 | 212 | * Todo 213 | - Ah, rails support, lots of works, so, as it always said, any help will be 214 | appreciated. 215 | -------------------------------------------------------------------------------- /modules/ome-scheme.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Scheme 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This file contains some settings [[* Scheme][Scheme]] programming language. 7 | 8 | * Prerequisites 9 | :PROPERTIES: 10 | :CUSTOM_ID: scheme-prerequisites 11 | :END: 12 | 13 | #+NAME: scheme-prerequisites 14 | #+CAPTION: Prerequisites for ome-scheme module 15 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 16 | |---------+---------+--------------------+-----------+--------+----------+------------| 17 | | [[http://www.gnu.org/software/guile/][Guile]] | | guile-2.0 | | | | Yes | 18 | 19 | Note: 20 | - [[http://www.gnu.org/software/guile/][Guile]] or [[http://racket-lang.org/][Racket]] as a Scheme implementation. Geiser requires Guile >= 2.0. 21 | 22 | * El-get packages 23 | :PROPERTIES: 24 | :CUSTOM_ID: scheme-el-get-packages 25 | :END: 26 | 27 | #+NAME: scheme-el-get-packages 28 | #+CAPTION: El-get packages for ome-scheme module 29 | | Package | Status | Description | 30 | |-----------+----------+------------------------------------------------| 31 | | [[http://www.nongnu.org/geiser/][geiser]] | Required | Geiser to Scheme is what slime to Common Lisp. | 32 | | [[https://github.com/xiaohanyu/ac-geiser][ac-geiser]] | Required | Auto-complete backend for geiser. | 33 | 34 | * Scheme 35 | :PROPERTIES: 36 | :CUSTOM_ID: scheme 37 | :END: 38 | 39 | [[http://en.wikipedia.org/wiki/Scheme_(programming_language)][Scheme]] is my favourite programming language, it is small, elegant and 40 | powerful. Unfortunately, there're too many choices for scheme implementation, 41 | which makes it a headache when you want to do some real world job with scheme. 42 | 43 | Oh-my-emacs adopts [[http://www.nongnu.org/geiser/][geiser]], which provides a similar SLIME way to work with 44 | scheme. To install geiser, you need install =automake= and =autoconf=. And to 45 | run geiser, you need install at least one of the geiser supported scheme 46 | implementation, namely, [[http://www.gnu.org/software/guile/][guile]] or [[http://racket-lang.org/][racket]]. 47 | 48 | Geiser also provide flexible methods for user customization, check its [[http://geiser.nongnu.org/geiser_3.html#Customization-and-tips][manual]] 49 | for details. For guile, I just =(setq geiser-guile-load-init-file-p t)= to make 50 | it load =$HOME/.guile= when start. 51 | 52 | There's a new experimental [[https://github.com/xiaohanyu/ac-geiser][ac-geiser]] project, written by me --- yeah, it's me, 53 | I am the author, which provides a auto-complete backend for geiser. It is 54 | still in beta version, however, and will be sent to el-get when stable. 55 | 56 | #+NAME: geiser 57 | #+BEGIN_SRC emacs-lisp 58 | (defun ome-geiser-setup () 59 | (setq ome-geiser-impl 60 | (or (and (executable-find "racket") 'racket) 61 | (and (executable-find "guile") 'guile) 62 | (and (executable-find "csi") 'chicken))) 63 | (setq geiser-default-implementation ome-geiser-impl) 64 | (setq geiser-guile-load-init-file-p t) 65 | (add-hook 'geiser-mode-hook 66 | (lambda () (setq geiser-impl--implementation ome-geiser-impl)))) 67 | 68 | (defun ome-ac-geiser-setup () 69 | (add-hook 'geiser-mode-hook 'ac-geiser-setup) 70 | (add-hook 'geiser-repl-mode-hook 'ac-geiser-setup) 71 | (eval-after-load "auto-complete" 72 | '(add-to-list 'ac-modes 'geiser-repl-mode))) 73 | 74 | (when (or (executable-find "racket") 75 | (executable-find "guile") 76 | (executable-find "chicken")) 77 | (ome-install 'geiser) 78 | (ome-install 'ac-geiser)) 79 | 80 | ;; (ome-install 'quack) 81 | #+END_SRC 82 | 83 | Actually, the official SLIME contrib has some swank backends for scheme 84 | implementations, you can try it if you like. There's a [[https://github.com/nickg/swank-chicken][swank-chicken]] for 85 | [[http://www.call-cc.org/][chicken scheme]], but it only provides a small part of SLIME features. So it is 86 | disabled by default. 87 | 88 | #+NAME: chicken 89 | #+BEGIN_SRC emacs-lisp :tangle no 90 | (defun ome-swank-chicken-setup () 91 | (setq swank-chicken-path "~/.emacs.d/el-get/swank-chicken/swank-chicken.scm") 92 | (add-hook 'scheme-mode-hook 93 | (lambda () 94 | (slime-mode t)))) 95 | 96 | (ome-install 'swank-chicken) 97 | #+END_SRC 98 | -------------------------------------------------------------------------------- /modules/ome-sml.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs SML 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: sml-prerequisites 9 | :END: 10 | 11 | #+NAME: sml-prerequisites 12 | #+CAPTION: Prerequisites for ome-sml module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |---------+---------+--------------------+-----------+--------+----------+------------| 15 | | [[http://www.smlnj.org][SML/NJ]] | | smlnj | | | | Yes | 16 | 17 | * El-get packages 18 | :PROPERTIES: 19 | :CUSTOM_ID: sml-el-get-packages 20 | :END: 21 | 22 | #+NAME: sml-el-get-packages 23 | #+CAPTION: El-get packages for ome-sml module 24 | | Package | Status | Description | 25 | |----------+----------+-----------------------------------------------| 26 | | [[http://www.iro.umontreal.ca/~monnier/elisp/][sml-mode]] | Required | This is a package for developing sml in Emacs | 27 | 28 | * What's SML 29 | 30 | Standard ML is a safe, modular, strict, functional, polymorphic programming 31 | language with compile-time type checking and type inference, garbage 32 | collection, exception handling, immutable data types and updatable references, 33 | abstract data types, and parametric modules. It has efficient implementations 34 | and a formal definition with a proof of soundness. 35 | 36 | Check for more details of SML and SML/NJ [[http://www.smlnj.org][here]]. 37 | 38 | * sml-mode 39 | :PROPERTIES: 40 | :CUSTOM_ID: sml-mode 41 | :END: 42 | 43 | SML Mode is an extension to Emacs that is not Emacs itself or SML/NJ itself. 44 | It displays SML code nicely with syntax coloring and clean indentation, and 45 | provides a way to run SML from within Emacs. The website is: 46 | http://www.iro.umontreal.ca/~monnier/elisp/ 47 | 48 | #+NAME: sml-mode 49 | #+BEGIN_SRC emacs-lisp 50 | (defun ome-sml-mode-setup ()) 51 | 52 | (when (executable-find "sml") 53 | (ome-install 'sml-mode)) 54 | #+END_SRC 55 | -------------------------------------------------------------------------------- /modules/ome-tex.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs TeX 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | * Prerequisites 7 | :PROPERTIES: 8 | :CUSTOM_ID: tex-prerequisites 9 | :END: 10 | 11 | #+NAME: tex-prerequisites 12 | #+CAPTION: Prerequisites for ome-tex module 13 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 14 | |----------+---------+---------------------------+--------------------------+-------------+----------+------------| 15 | | [[http://www.tug.org/texlive/][texlive]] | | texlive-full latex-beamer | texlive-most texlive-cjk | texlive-all | [[http://tug.org/mactex/][MacTeX]] | Yes | 16 | | [[http://pygments.org/][pygments]] | | [pip] | [pip] | [pip] | [pip] | No | 17 | 18 | Note: 19 | - [[http://www.tug.org/texlive/][texlive]], the full texlive distribution is really huge, so install necessary 20 | parts as you need. 21 | - [[http://en.wikipedia.org/wiki/MacTeX][MacTeX]] is a redistribution of texlive, which includes Mac-specific utilities 22 | and front-ends. It is also pre-configured to work out-of-the-box with Mac OS 23 | X as it provides sensible defaults for configuration options that, in TeX 24 | Live, are left up to the user to allow for its cross-platform compatibility. 25 | 26 | * El-get packages 27 | :PROPERTIES: 28 | :CUSTOM_ID: tex-el-get-packages 29 | :END: 30 | 31 | #+NAME: tex-el-get-packages 32 | #+CAPTION: El-get packages for ome-tex module 33 | | Package | Status | Description | 34 | |---------+----------+--------------------------| 35 | | [[http://www.gnu.org/software/auctex/][AUCTeX]] | Required | You need it, believe me. | 36 | | [[http://staff.science.uva.nl/~dominik/Tools/cdlatex/][CDLaTeX]] | Optional | Speedy \LaTeX{} typing. | 37 | 38 | * AUCTeX 39 | :PROPERTIES: 40 | :CUSTOM_ID: auctex 41 | :END: 42 | 43 | [[http://www.gnu.org/software/auctex/][AUCTeX]] is the predominant \TeX{}/\LaTeX{} writing environment for 44 | Emacs/XEmacs. 45 | 46 | ** Prerequisites and Installation 47 | \TeX{} is a long history legend in computer typesetting. To configure a 48 | working \TeX{} environment is far beyond the scope of this project. However, 49 | I can give you some hint to install a \TeX{} system on Linux. If you are 50 | - a Ubuntu/Debian/Mint user, install texlive by =sudo apt-get install 51 | texlive-full= 52 | - a Arch Linux user, install texlive by =sudo pacman -S texlive-most 53 | texlive-langcjk= 54 | - a Fedora user, install texlive by =sudo yum -S texlive-all= 55 | - a SuSE user, install texlive by =sudo zypper in texlive-xetex= 56 | 57 | For Mac OS X users, [[http://tug.org/mactex/][MacTeX]] is the best choice. You can install it directly from 58 | its website or via [[https://github.com/phinze/homebrew-cask][homebrew-cask]]. By default, MacTeX install all binary 59 | executables to =/usr/texbin/=, which is different from Linux. 60 | 61 | If you are not lucky enough, you should follow the official [[http://www.tug.org/texlive/][texlive]] 62 | instructions to install it. 63 | 64 | There're other annoying problems if you're a [[http://en.wikipedia.org/wiki/CJK_characters][CJK]] user, such as fonts and 65 | package configuration in \TeX{} documents, but this is further beyond the scope 66 | of this project. So refer to necessary [[https://tug.org/][TUG]]s, or BBS for help. For Chinese user, 67 | [[http://www.ctex.org/][CTEX]] is a good place to start your journey. [[http://zzg34b.w3.c361.com/][LaTeX编辑部]] also provides lots of 68 | useful resources written in Chinese. 69 | 70 | For all \TeX{} users, the Comprehensive TEX Archive Network ([[http://www.ctan.org/][CTAN]]) is your 71 | lifelong friend, which act as the central place for all kinds of material 72 | around \TeX{}. The famous Stack Exchange Network also provides a 73 | http://tex.stackexchange.com/ which focus on \TeX{} related questions. 74 | 75 | Enough, enjoy your journey to \TeX{} world! Now it's time to come back to 76 | AUCTeX. Besides a working \TeX{} installation, you also need =autoconf= and 77 | =texinfo= package for =el-get-install auctex=, and a recent [[http://www.ghostscript.com/][Ghostscript]] for 78 | =preview-latex= in both [[http://en.wikipedia.org/wiki/Device_independent_file_format][DVI]] and [[http://en.wikipedia.org/wiki/Pdf][PDF]] mode. 79 | 80 | Finally, if you're tired or afraid to setup a working \TeX{} environment, 81 | [[https://www.writelatex.com/][writelatex]] provides a really instance starting point with no pain, just try it 82 | before you fall in love with \TeX{} world. 83 | 84 | ** Keybindings 85 | AUCTeX is really flexible and customizable, it also provides a rich set of 86 | menubar entries. Here's a list of most commonly used keybindings in AUCTeX: 87 | - Editing 88 | - =C-c C-s= =LaTeX-section= 89 | - =C-c C-e= =LaTeX-environment= 90 | - =C-c C-m= =TeX-insert-macro= 91 | - =C-c ]= =LaTeX-close-environment= 92 | - Marking and Commenting 93 | - =C-c *= =LaTeX-mark-section= 94 | - =C-c .= =LaTeX-mark-environment= 95 | - =C-c ;= =TeX-comment-or-uncomment-region= 96 | - =C-c %= =TeX-comment-or-uncomment-paragraph= 97 | - Folding: 98 | - =C-c C-o C-b= =TeX-fold-buffer= 99 | - =C-c C-o b= =TeX-fold-clearout-buffer= 100 | - Command Controlling 101 | - =C-c C-c= =TeX-command-master= 102 | - =C-c C-r= =TeX-command-region= 103 | - =C-c C-b= =TeX-command-buffer= 104 | - =C-c C-k= =TeX-kill-job= 105 | - =C-c C-l= =TeX-recenter-output-buffer= 106 | - =C-c ^= =TeX-home-buffer= 107 | 108 | ** Checking 109 | [[http://www.ctan.org/tex-archive/support/lacheck/][lacheck]] and [[http://baruch.ev-en.org/proj/chktex/][chktex]] is the lint tool for \TeX{}, you can install them in Ubuntu 110 | by =sudo apt-get install lacheck chktex=. AUCTeX has direct support for 111 | =lacheck= and =chktex=. You can start =lacheck= with =C-c C-c Check = and 112 | =chktex= with =C-c C-c ChkTeX =. 113 | 114 | Each of the two utilities will find some errors the other doesn't, but =chktex= 115 | is more configurable, allowing you to create your own errors 116 | 117 | ** Reftex 118 | - =C-c == =reftex-toc= will show a table of contents of the document. 119 | - =C-c (= =reftex-label= to insert a label at point. 120 | - =C-c [= =reftex-citation= to insert a citations from BibTeX database. 121 | 122 | ** Coordinations with other packages 123 | Oh-my-emacs adopts some other awesome packages such as =smartparens= and 124 | =evil=, which has some conflicts with AUCTeX. so there need some hack, which, 125 | is always the main topic with Emacs. 126 | 127 | =smartparens-latex= provide some goodies for \TeX{} editing. But we need to 128 | ensure =smartparens= is available before we =require 'smartparens-latex=. 129 | 130 | =smartparens= still has some weird problems for inserting "$" in \TeX{}, which 131 | is a weird problem. In fact, both AUCTeX and =smartparens= provides some pair 132 | management functions, which may be overlapping. AUCTeX provide a 133 | =TeX-electric-math=, while =smartparens= was born for pair management. Worse, 134 | the following =cdlatex.el= also provides some pair management functions. Ah, we 135 | need some coordination between them. So any ideas or patches will be 136 | appreciated. 137 | 138 | Another oh-my-emacs package, =evil=, shadowed some keybindings for AUCTeX's 139 | =reftex-toc-mode=. However, I only enable =evil-mode= in =text-mode-hook= and 140 | =prog-mode-hook=, and =reftex-toc-mode= is derived from =fundamental-mode=, I 141 | have no idea why =evil-local-mode= is enabled by default when entering 142 | =reftex-toc-mode=, so I have to =turn-off-evil-mode= explicitly. 143 | 144 | ** Oh-my-emacs settings 145 | - Use =xetex= as the default =TeX-engine= for better support for \TeX{} font 146 | selection and PDF export. 147 | - Enable =outline-minor-mode= and =flyspell-mode=. 148 | - Enable =TeX-interactive-mode=, =TeX-PDF-mode=, =TeX-fold-mode= and 149 | =reftex-mode=. 150 | - Favors [[http://okular.kde.org/][Okular]] and [[https://projects.gnome.org/evince/][Evince]] as the default viewer in Linux, and fallbacks to 151 | =xdg-open= if both Okular and Evince is unavailable. Since I don't have a 152 | Windows or Mac OS X environment, patches are always welcome. 153 | 154 | #+NAME: auctex 155 | #+BEGIN_SRC emacs-lisp 156 | (defun ome-auctex-setup () 157 | (when (require 'smartparens nil 'noerror) 158 | (require 'smartparens-latex)) 159 | (setq TeX-auto-save t) ; Automatically save style information 160 | ; when saving the buffer 161 | (setq TeX-parse-self t) ; Parse file after loading it if no 162 | ; style hook is found for it. 163 | (setq LaTeX-syntactic-comment t) 164 | (setq TeX-auto-untabify t) ; remove all tabs before saving 165 | (setq reftex-plug-into-AUCTeX t) 166 | (setq-default TeX-engine 'xetex) ; use xelatex by default 167 | 168 | ;; Mac OS X fallback to the "open" program as the default viewer for all 169 | ;; types of files. 170 | (cond 171 | ;; settings for Linux 172 | ((eq system-type 'gnu/linux) 173 | (cond 174 | ((executable-find "okular") 175 | (setq TeX-view-program-selection 176 | '((output-pdf "Okular") 177 | (output-dvi "Okular")))) 178 | ((executable-find "evince") 179 | (setq TeX-view-program-selection 180 | '((output-pdf "Evince") 181 | (output-dvi "Evince")))) 182 | (t 183 | (setq TeX-view-program-selection 184 | '((output-pdf "xdg-open") 185 | (output-dvi "xdg-open"))))))) 186 | 187 | (add-hook 'TeX-mode-hook 188 | (lambda () 189 | (outline-minor-mode t) 190 | (flyspell-mode t) 191 | (TeX-interactive-mode t) 192 | (TeX-PDF-mode t) 193 | (TeX-fold-mode t))) 194 | 195 | (add-hook 'LaTeX-mode-hook 196 | (lambda () 197 | (LaTeX-math-mode t) 198 | (reftex-mode t))) 199 | 200 | (add-hook 'reftex-toc-mode-hook 201 | (lambda () 202 | (when (featurep 'evil) 203 | (turn-off-evil-mode))))) 204 | 205 | (when (executable-find 206 | (if (eq system-type 'darwin) 207 | ;; MacTeX install all its executables to /usr/texbin directory 208 | "/usr/texbin/pdflatex" 209 | "pdflatex")) 210 | (ome-install 'auctex)) 211 | #+END_SRC 212 | 213 | ** Tips and Tricks 214 | [[http://tex.stackexchange.com/questions/52179/what-is-your-favorite-emacs-and-or-auctex-command-trick][Here]]'s some tips and tricks about AUCTeX. 215 | 216 | *** LaTeX shell escape 217 | 218 | \LaTeX{} supports an lesser known "shell-escape" feature. In a word, this mode 219 | can be used to incorporate dynamic content, or run external process during the 220 | compilation phase. Check this [[http://scrolls.mafgani.net/2011/03/latex-shell-escape/][post]] for details. 221 | 222 | Unfortunately, there no easy explicit way to customize command line options for 223 | various AUCTeX backend. So we need some tricks to get around this. Thanks 224 | [[http://stackoverflow.com/questions/3300497/using-minted-source-code-latex-package-with-emacs-auctex/][stackoverflow]] again, here's the code snippet for AUCTeX \LaTeX{} backend. 225 | 226 | #+BEGIN_SRC emacs-lisp 227 | (defvar ome-LaTeX-shell-escape-mode nil 228 | "Whether or not LaTeX shell escape mode is enabled.") 229 | 230 | (defun ome-LaTeX-toggle-shell-escape () 231 | (interactive) 232 | (if ome-LaTeX-shell-escape-mode 233 | (progn 234 | (setcdr (assoc "LaTeX" TeX-command-list) 235 | '("%`%l%(mode)%' %t" 236 | TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")) 237 | (setq ome-LaTeX-shell-escape-mode nil) 238 | (message "LaTeX shell escape mode turned off.")) 239 | (progn 240 | (setcdr (assoc "LaTeX" TeX-command-list) 241 | '("%`%l%(mode) -shell-escape%' %t" 242 | TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX"))) 243 | (setq ome-LaTeX-shell-escape-mode t) 244 | (message "LaTeX shell escape mode turned on."))) 245 | 246 | ;; (define-key org-mode-map (kbd "C-c C-x x") 'ome-LaTeX-toggle-shell-escape) 247 | #+END_SRC 248 | 249 | * CDLaTeX 250 | :PROPERTIES: 251 | :CUSTOM_ID: cdlatex 252 | :END: 253 | 254 | #+BEGIN_QUOTE 255 | CDLaTeX - more LaTeX functionality for Emacs and XEmacs 256 | 257 | CDLaTeX is a minor mode which re-implements many features also found in the 258 | AUCTeX LaTeX mode. The reason for this is mainly historical - much of it was 259 | written before I knew about AUCTeX. So check this out if you would like to try 260 | a different implementation. Here are some of the differences: Environment 261 | insertion is template based, and not hook based. Keyword commands (which are 262 | executed by typing a short (2-4 letters) keyword into the buffer, followed by 263 | TAB) give very rapid access to the main environment templates and mathematical 264 | constructs. CDLaTeX knows the difference between text mode and math mode in 265 | LaTeX and adapts automatically to that. You can download CDLaTeX here. 266 | 267 | -- http://staff.science.uva.nl/~dominik/Tools/cdlatex/ 268 | #+END_QUOTE 269 | 270 | The comments in =cdlatex.el= said that "CDLaTeX requires texmathp.el which is 271 | distributed with AUCTeX. Starting with Emacs 21.3, texmathp.el will be part of 272 | Emacs.", however, I didn't find any =texmathp.el= with current emacs 273 | distribution. So CDLaTeX requires AUCTeX as a dependency, which means it didn't 274 | work with Emacs builtin =tex-mode= anymore. 275 | 276 | #+NAME: cdlatex 277 | #+BEGIN_SRC emacs-lisp 278 | (defun ome-cdlatex-mode-setup () 279 | (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex) 280 | (add-hook 'latex-mode-hook 'turn-on-cdlatex)) 281 | 282 | (when (el-get-package-is-installed 'auctex) 283 | (ome-install 'cdlatex-mode)) 284 | 285 | #+END_SRC 286 | 287 | * Todo 288 | 289 | ** AUCTeX 290 | - Add auto-complete support for auctex. see 291 | https://github.com/monsanto/auto-complete-auctex. 292 | - Investigate on "What is TeX master file?" 293 | - What is SyncTeX? How to use it? 294 | - What is =TeX-interactive-mode=? 295 | -------------------------------------------------------------------------------- /modules/ome-web.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Oh My Emacs Web 2 | #+OPTIONS: toc:2 num:nil ^:nil 3 | 4 | This is part of [[https://github.com/xiaohanyu/oh-my-emacs][oh-my-emacs]]. 5 | 6 | This module contains some packages for web development in Emacs. 7 | 8 | Web development is really a huge topic. There're dozens of [[http://en.wikipedia.org/wiki/Web_template_system][web template 9 | systems]], hundreds of [[http://en.wikipedia.org/wiki/Web_application_framework][web frameworks]], different ways, different standards, which 10 | makes it a dirty work to support web development in Emacs. For serious work, I 11 | recommand [[http://www.jetbrains.com/webstorm/][WebStorm]] from [[http://www.jetbrains.com/][JetBrains]]. "Hmm, you're a traitor of Emacs", you may 12 | say. Actually, that depends. I prefer proper tools for proper works. Emacs is 13 | not a one-for-all solution. For example, webstorm has really great semantic 14 | completion for JavaScript, together with a deep [[http://www.jetbrains.com/webstorm/features/index.html][understanding]] of web standards, 15 | and tricks such as incompatibilies between different browsers. As we all know, 16 | the browser compatilibity is one of the biggest nightmares of modern software 17 | engineer, so it's hard for Emacs, an editor, to compete with WebStorm. 18 | 19 | Ah, seems I'm a salesman from JetBrains. That's not bad. So why I still use 20 | Emacs, at least some times? Actually, for small project, I still prefer Emacs 21 | over huge IDEs, there're several reasons: 22 | - Though Emacs with packages(such as oh-my-emacs) may be slower than vim, it is 23 | still faster than Java based IDEs. 24 | - Though you lost some great features provide by modern IDE, you have all Emacs 25 | goodies at your fingertips. For example, you can switch buffers quickly, view 26 | man pages as you like, view info document for GNU software, fire up eshell to 27 | do some dirty work quickly. 28 | - You do not need to create workspace, create project in advance when you just 29 | want to create some tiny test file. 30 | 31 | Enough, now it's the time to see what Emacs provides for you to do basic web 32 | development. This ome module focus on html/css editing, for JavaScript things, 33 | refer to [[file:ome-javascript.org][ome-javascript.org]] module. 34 | 35 | * Prerequisites 36 | :PROPERTIES: 37 | :CUSTOM_ID: web-prerequisites 38 | :END: 39 | 40 | #+NAME: web-prerequisites 41 | #+CAPTION: Prerequisites for ome-web module 42 | | Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? | 43 | |---------+---------+--------------------+-----------+--------+----------+------------| 44 | | less | [npm] | [npm] | [npm] | [npm] | [npm] | No | 45 | 46 | * El-get packages 47 | :PROPERTIES: 48 | :CUSTOM_ID: web-el-get-packages 49 | :END: 50 | 51 | #+NAME: web-el-get-packages 52 | #+CAPTION: El-get packages for ome-web module 53 | | Package | Status | Description | 54 | |---------------+----------+------------------------------------------------| 55 | | [[http://web-mode.org/][web-mode.el]] | Required | An emacs major mode for editing html templates | 56 | | [[http://julien.danjou.info/projects/emacs-packages#rainbow-mode][rainbow-mode]] | Required | Colorize color names in buffers | 57 | | [[https://github.com/purcell/less-css-mode][less-css-mode]] | Optional | Emacs mode for LESS CSS (lesscss.org) | 58 | 59 | * Basic css settings 60 | :PROPERTIES: 61 | :CUSTOM_ID: basic-css 62 | :END: 63 | 64 | The builtin =css-mode= is derived from =fundamental-mode=, so we need an extra 65 | hook to enable =linum-mode= in =css-mode=. 66 | 67 | #+NAME: basic-css 68 | #+BEGIN_SRC emacs-lisp 69 | (setq css-indent-offset 2) 70 | 71 | (add-hook 'css-mode-hook 72 | (lambda () 73 | (linum-mode 1))) 74 | #+END_SRC 75 | 76 | * Web-mode 77 | :PROPERTIES: 78 | :CUSTOM_ID: web-mode 79 | :END: 80 | 81 | The most awful part of web page editing(or programming, if you like) is, one 82 | single web page often contains multiple types of code snippets. For example, 83 | you can put CSS/JavaScript/PHP in just one single page, which make it difficult 84 | for an editor to work properly, such as proper indentation, syntax 85 | highlighting, etc. 86 | 87 | The modern web development is ruled by the [[http://en.wikipedia.org/wiki/Model%25E2%2580%2593view%25E2%2580%2593controller][MVC]] pattern, in which the various 88 | [[http://en.wikipedia.org/wiki/Web_template_system][web template system]] is an important component. Just like normal html page, you 89 | can mix together HTML, CSS, JavaScript and a special web template language 90 | together as you like. You may wonder, is it possible for Emacs, an editor, to 91 | edit all different code snippets without switching between different modes? 92 | 93 | The answer is yes, web have [[http://web-mode.org/][web-mode]], a really genius emacs package. You can 94 | even edit normal html page using web-mode. 95 | 96 | There're still a minor problem, different web projects often has different 97 | coding styles, such as indentation spaces. So it is not possible for us to set 98 | various web-mode options in our =.emacs= and expect that it will works for all 99 | web projects. The answer lies in the [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][Emacs Manual]]. 100 | 101 | #+NAME: web-mode 102 | #+BEGIN_SRC emacs-lisp 103 | (defun ome-web-mode-setup () 104 | (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) 105 | (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) 106 | (add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode)) 107 | (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) 108 | (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) 109 | (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) 110 | (add-to-list 'auto-mode-alist '("\\.hbs\\'" . web-mode)) 111 | (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) 112 | (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) 113 | 114 | (defun ome-web-mode-hook () 115 | ;; indentation 116 | ;; HTML offset indentation 117 | (setq web-mode-markup-indent-offset 2) 118 | ;; CSS offset indentation 119 | (setq web-mode-code-indent-offset 2) 120 | ;; Script offset indentation (for JavaScript, Java, PHP, etc.) 121 | (setq web-mode-css-indent-offset 2) 122 | ;; HTML content indentation 123 | (setq web-mode-indent-style 2) 124 | 125 | ;; padding 126 | ;; For