Giter VIP home page Giter VIP logo

emacs.d's Introduction

Checklist

  • You can make this setup more stable
  • Emacs 24.3.1 or 24.4 recommended
  • Tested with Emacs 24.3.1, 24.4, 24.5 on Linux/Windows/Cygwin/Mac
  • Please check section “About Emacs 23” if you uses Emacs 23.4
  • Please read FAQ to disable Vim key bindings
  • I intentionally make packages from melpa-unstable uninstallable by default. You can modify variable melpa-include-packages in ~/.emacs.d/lisp/init-elpa.el to add packages from melpa-unstable
  • Other issues are covered in FAQ

Features

  • Stability is the first priority
  • I do NOT re-define key bindings to override original ones usually
  • Usable in emacs-nox (Emacs in Shell)
  • Popular programming languages supported (C/C++/Java/Ruby/Perl/Python/C#/Lua/Javascript …)
  • Robust (For example, you can install packages behind corp firewall)
  • Optimized for cross-platform C++ development

Installation

Most users should follow the section “Install in normal way”.

You need read the section “Install stable version in easiest way” if and only if:

  • You are absolutely newbie, knowing nothing about Linux/Unix
  • You are living in North Korea without internet access

Install in normal way

Please remove the file ~/.emacs.d/init.el and ~/.emacs. ~ is Home directory.

Please uninstall any package which is not installed at ~/.emacs.d. For example, run apt-get autoremove emacs-w3m on Debian/Ubuntu.

If you don’t know what I mean, then do nothing.

All packages should be placed at ~/.emacs.d from now on.

There are TWO ways to install this setup:

  • Way 1, download latest setup and extract its content into ~/.emacs.d, OR run command cd ~; git clone https://github.com/redguardtoo/emacs.d.git .emacs.d in shell.
  • Way 2, use stable setup, OR run command cd ~; git clone https://github.com/redguardtoo/emacs.d.git .emacs.d; cd .emacs.d; git reset --hard stable in shell.

Ensure that the init.el contained in this repo ends up at ~/.emacs.d/init.el.

By default, all packages will be installed automatically during Emacs startup. Edit ~/.emacs.d/init-elpa.el to avoid certain package be installed automatically.

Install stable version in easiest way (OPTIONAL)

You only need two zip files instead of git or network.

Here are the exact steps,

Now you are using local package repository ~/projs/melpa.

You can switch to online repositories like http://elpa.gnu.org or http://melpa.org by modifying ~/.emacs.d/lisp/init-elpa.el.

Third party tools (OPTIONAL)

Install

You can install them in any way you like. But OS package manager is easier.

OS package manager means:

  • apt-cyg at Cygwin
  • homebrew at Mac
  • any package manager at Linux (apt-get at Ubuntu, yum at Redhat, pacman at Arch, emerge at Gentoo …)

List of tools

These tools are OPTIONAL.

Please ignore any related error message. For example, if aspell and hunspell are not installed, you can ignore all the flyspell error messages.

w3m (web browser in console)

  • Needed by w3m (w3m is emacs package name written in elisp)
  • Install through OS package manager
  • Please note only emacs with GUI can display image

lua

  • Required by flymake-lua
  • Install through OS package manager

aspell or hunspell

  • Needed by flyspell
  • hunspell is the alternative of aspell. So you need only one of them.
  • Install through OS package manager
  • For aspell, you may need its dictionary aspell-en
  • I force the dictionary to “en_US” in ~/.emacs./lisp/init-spelling.el. You can modify it.
  • I recommend aspell for programmers

sbcl (lisp environment)

  • Needed by lisp slime
  • Install through OS package manager

tidy

  • Needed by web-mode for syntax check and tidy.el html formatting
  • Install through OS package manager

csslint

  • Install node.js through OS package manager, then sudo npm install -g csslint

identify from ImageMagick

  • Needed by org-mode to export org file to odt file when image embedded
  • Install through OS package manager

zip and unzip

  • Needed by org-mode to export org file to odt file
  • Install through OS package manager

jshint

  • Install node.js through OS package manager, then sudo npm install -g jshint
  • required by js-mode
  • by default I use js2-mode which does NOT need jshint

xsel

  • Needed by my clipboard command copy-to-x-clipboard and paste-from-x-clipboard under Linux
  • Install through OS package manager
  • Needed by cpputils-cmake, company-clang
  • Install through OS package manager
  • If you use cpputils-cmake and cmake, cpputils-cmake will do all the setup for you. You don’t need read next item! But please spend a few minutes to learn the basics of cmake! There is a one minute step-by-step-guide in README of cpputils-cmake to teach you how to use cmake.
  • If you use company-clang, add (setq company-clang-arguments '("-I/example1/dir" "-I/example2/dir")) into ~/.emacs.d/init.el

GCC/Make

  • Needed by flymake
  • Install through OS package manager
  • Needed by MozRepl
  • Used by Firefox
  • Needed by ggtags.el
  • It creates index files for code navigation
  • More advanced than ctags, supports references and has better performance
  • Install through OS package manager

LibreOffice

  • Only one executable soffice needed when converting odt file into doc/pdf
  • conversion happens automatically when exporting org-mode to odt
  • The conversion command is in variable org-export-odt-convert-processes
  • Install through OS package manager

js-beautify

  • Beautify javascript code
  • Install pip through OS package manager, then pip install jsbeautifier

syntaxerl

jedi & flake8

  • Required by elpy which is python IDE
  • At least pip install jedi flake8. Check elpy website for more tips.

sdcv (console version of StarDict)

  • Required by sdcv.el
  • Install through OS package manager
  • Run curl http://abloz.com/huzheng/stardict-dic/dict.org/stardict-dictd_www.dict.org_wn-2.4.2.tar.bz2 | tar jx -C ~/.stardict/dic to install dictionary

Tutorial (OPTIONAL)

~/.emacs.d/lisp/init-evil.el contains my most frequently used key bindings.

Basic tutorial

Everyone should finish this tutorial at first.

Step 1, learn OS basics

At minimum you need know,

Step 2, read official tutorial at least once

Press C-h t in Emacs (“C” means Ctrl key, “M” means Alt key) to read bundled tutorial.

At minimum you need know:

  • How to move cursor
  • How to read help by pressing C-h v and C-h f.

Step 3, know org-mode basics

Org-mode is for notes-keeping and planning.

Please watch the Carsten Dominik’s talk. It’s really simple. The only hot key to remember is Tab.

Step 4, solve your first problem

For that problem, you can visit EmacsWiki for the solution. Newbies can ask for help at http://www.reddit.com/r/emacs/.

Evil-mode tutorial

Required for vim user,

  • Finish vimtutor.
  • Read ~/.emacs.d/site-lisp/evil/doc/evil.pdf

Methodology

See Master Emacs in One Year.

FAQ

Toggle color theme

By default color-theme-molokai is used.

But you can run the M-x my-toggle-color-theme to switch to the fallback theme color-theme-deep-blue.

You can change the definition of my-toggle-color-theme in init-color-theme.el.

Start a shell inside Emacs

Please M-x multi-term.

If you want to use Zsh instead of Bash, please modify init-term-mode.el

Use HTTPS instead of HTTP to download packages

(setq melpa-use-https-repo t). melpa-use-https-repo is defined in init-elpa.el.

Setup fonts in GUI Emacs

Non-Chinese use unicode-fonts and Chinese use chinese-fonts-setup.

Neither package is included in this setup. You need install them manually.

Synchronize setup with Git

Most people should synchronize from my stable setup which is updated every 6 months:

git pull https://[email protected]/redguardtoo/emacs.d.git stable

But advanced users can use latest setup:

git pull https://[email protected]/redguardtoo/emacs.d.git

If you don’t like my commits, you can revert them:

# always start from the latest related commit
git revert commit-2014-12-01
git revert commit-2014-11-01

Indentation

Learn basics.

Then use my solution.

Editing Lisp

Please note paredit-mode is enabled when editing Lisp. Search “paredit cheat sheet” to learn its key bindings.

Comment out (require 'init-modeline) in init.el at first.

Key bindings doesn’t work?

Other software may intercept the key bindings. For example, someone reported QQ on windows 8 can intercept =M-x=.

Plugins doesn’t work?

If two plugins conflicts, the more frequently used plugin takes priority.

But there exists workaround for less used plugin. Check “~/.emacs.d/lisp/init-evil.el” for the list of alternative.

For example, if which-func-mode cannot display function name at mode-line, you can use M-x popup-which-function instead.

popup-which-function is mentioned in init-evil.el.

How to use org-mode

Press M-x org-version, then read corresponding online manual.

If you find anything doesn’t work out of the box, it’s because you haven’t do the required setup required by official setup yet.

For example, org-capture need your manual setup.

OS X user?

You need replace legacy Emacs 22 and ctags with the new versions.

The easiest way is change Environment variable PATH.

Locked packages

Some packages (Evil, Helm, Web-mode …) are so important to my workflow that I locked their versions.

Those packages are placed at ~/.emacs.d/site-lisp.

They will not be upgraded through ELPA automatically unless you delete corresponding folders.

Customize global variables

Some variables are hard coded so you cannot “M-x customize” to modify them.

Here are the steps to change their values:

  • Find the variable description by M-x customize
  • For text “Company Clang Insert Arguments”, search company-clang-insert-argument in ~/.emacs.d/lisp/
  • You will find ~/.emacs.d/lisp/init-company.el and modify company-clang-insert-argument

BTW, please read my comments above the code at first.

Open file with Ido

If you press C-x C-f to open a file, Ido will show the completions.

You can keep pressing C-f to ignore the completions.

Windows

I strongly suggest Cygwin version of Emacs. But native windows version is OK if you declare Environment variable HOME which points to a user directory C:\Users\<username> on Windows 7+. You need extract .emacs.d into the directory HOME points to.

Yasnippet key bindings

Instead of M-x yas-expand or press TAB key, you may press M-j instead.

Non-English users

Locale must be UTF-8 compatible. For example, as I type locale in shell, I got the output “zh_CN.UTF-8”.

Behind corporate firewall

Type below command in shell:

http_proxy=http://yourname:[email protected]:8080 emacs -nw

Government blocks the internet?

People in China, North Korea, Cuba, Iran need goagent. Run command http_proxy=http://127.0.0.1:8087 emacs -nw in shell after starting goagent server.

Email

If you use Gnus for email, check init-gnus.el and read my Gnus tutorial.

Cannot download ELPA packages?

Some package cannot be downloaded automatically because of network problem.

You could

  • M-x list-packages to manually install it
  • Or M-x package-refresh-content and restart Emacs. the package will be installed automatically

Disable vim keybinding

By default EVIL (Vim emulation in Emacs) is used. You can comment out line containing “(require ‘init-evil)” in init.el to unload it.

Evil setup

It’s defined in “~/.emacs.d/lisp/init-evil.el”. Press C-z to switch between Emacs and Vim key bindings.

Please reading its PDF manual before using evil-mode.

C++ auto-completion doesn’t work?

I assume you are using company-mode. Other packages have similar setup.

At minimum:

  • You need install clang
  • Make sure your code is syntax correct at the beginning
  • assign reasonable value into company-clang-arguments

Here is sample code:

(setq company-clang-arguments '("-I/home/myname/projs/test-cmake" "-I/home/myname/projs/test-cmake/inc"))

In “friendly” Visual C++, you need do similar setup.

Color theme

Preview color theme

Check http://emacsthemes.caisah.info/.

Write down the name of color theme (for example, molokai).

Setup color theme manually (recommended)

Insert below code into “~/.emacs.d/lisp/init-color-theme.el”,

;; the color theme name "molokai"" could be replaced with other theme name
(require 'color-theme-molokai)
(color-theme-molokai)

“M-x color-theme-select” may not work because of some design flaw in Emacs.

Please note there is NO unified way to enable color theme. You need read color theme’s documentation at first.

My sample code works for most color themes.

If you insist on configuring the color theme in a different way, please,

  • Comment out the line containing (require 'init-color-theme) in “~/.emacs.d/init.el” at first
  • Read EmacsWiki

Use color theme in terminal

TERM=xterm-256color emacs -nw

Chinese Input Method Editor

Run command M-x toggle-input-method to toggle input method. A 20M Chinese dictionary is already provided.

If your personal word file ~/.eim/pyim-personal.txt exists, it will be used.

Or else ~/.emacs.d/pyim/pyim-personal.txt will be created.

Install Emacs elsewhere

Run below commands:

mkdir -p ~/tmp;
curl http://ftp.gnu.org/gnu/emacs/emacs-24.3.tar.gz | tar xvz -C ~/tmp/emacs-24.3
cd ~/tmp/emacs-24.3;
mkdir -p ~/myemacs/24.3;
rm -rf ~/myemacs/24.3/*;
./configure --prefix=~/myemacs/24.3 --without-gtk --without-gtk3 --without-aqua --without-x --without-xpm --without-png --without-gif --without-alsa --without-tiff --without-jpeg --without-aqua --without-rsvg --without-xft --without-xaw3d --without-xim --without-xpm --without-dbus --without-makeinfo --with-x-toolkit=no --without-sound --without-sync-input --without-pop;make;make install

Feel free to replace 24.3 with other version number.

Directory structure

~/.emacs.d/init.el is the main file. It includes all the other *.el files.

~/.emacs.d/lisp/init-elpa.el defines how and what packages will be installed from MELPA.

The package manager will extract packages into ~/.emacs.d/elpa/.

I also manually download and extract some packages into ~/.emacs.d/site-lisp/. Packages in ~/.emacs.d/site-lisp/ is not visible to the package manager.

My own snippets for Yasnippet is at ~/.emacs.d/snippets.

Other directories don’t matter.

About Emacs 23

Emacs 23 support was dropped on <2015-04-21>.

The latest Emacs23 compatible version of setup is 1.2!

Here are the steps to use that setup:

Since most third party plugins don’t support Emacs 23 any more. I strongly recommend you upgrading to Emacs 24 instead!

Emacs is portable on any platform. So you can install Emacs even when you are not root of the Linux server. Please read “Install Emacs at home directory” for HOW

Tips

  • Never turn off any bundled mode if it’s on by default. Future version of Emacs may assume it’s on. Tweak its flag in mode hook instead!
  • Git skills are extremely useful. Please read the chapters “Git Basics”, “Git Branching”, “Git Tools” from Pro Git

Report bug

Check EmacsWiki and my FAQ at first, please.

File bug report at https://github.com/redguardtoo/emacs.d. Don’t email me directly!

Please contact the original developer if you find any bug from third party packages.

Bug report should include details (OS, Emacs version …) plus the output of emacs --debug-init at minimum.

emacs.d's People

Contributors

chen-bin-newscorp avatar demon386 avatar lesleylai avatar ozanmakes avatar phye avatar purcell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.