NOTE:
NOTE: init.el has been converted to README.org
This config was tested in Arch Linux and macOS Sierra(v 10.12.5)
$ git clone https://github.com/manishmarahatta/dot-emacs ~/.emacs.d/
configure
π· , pulls down the el-get, and
stuffs.
$ ./configure
Run and let the magic happen
1.3 Script to automatically build emacs config
#!/bin/sh
echo "=========================================="
echo "Wait, while the emacs config builds itself"
echo "=========================================="
cd ~
DIRFIRST=~/.emacs.d
DIRSECOND=~/.emacs.d.backup
FILEFIRST=~/.emacs
if [ ! -f $DIRFIRST ]
then
mv ~/.emacs.d .emacs.d.backup;
fi
if [ ! -f $DIRSECOND ]
then
mv ~/.emacs.d.backup .emacs.d.backup.another;
fi
if [ ! -f $FILEFIRST ]
then
mv ~/.emacs .emacs.backup
fi
git clone https://github.com/manishmarahatta/dot-emacs.git ~/.emacs.d/
cd ~/.emacs.d
./configure
cd ~
save the above file as autoconfig.sh
chmod +x autoconfig.sh
Then type
./autoconfig.sh
. βββ auto-save-list βββ config βββ el-get β βββ cl-lib β βββ goto-chg β βββ logo β βββ methods β βββ moz-repl β βββ package β βββ popup-kill-ring β βββ pos-tip β βββ python β βββ recentf-ext β βββ recipes β βββ test β βββ issues β βββ pkgs βββ elpa β βββ archives β β βββ gnu β β βββ marmalade β β βββ melpa β βββ gnupg β βββ twittering-mode-20160921.1038 β βββ wget-1.94 βββ modules β βββ auto-dim-other-buffers.el β βββ emacs-ac-emoji β β βββ author β β βββ image β βββ emojis β β βββ emojione-v2.2.6-22 β βββ mode-icons β β βββ icons β β βββ scripts β βββ powerline β βββ powerline-iconic-theme β βββ py-exec β βββ tabbar-ruler β β βββ el-get β β βββ melpa β βββ window-numbering βββ plug-ins β βββ icons βββ scripts βββ snippets β βββ fundamental-mode β βββ html-mode β βββ org-mode β βββ python-mode βββ url 51 directories
(setq gc-cons-threshold 104857600)
St opening emacs for each file. Set default open application
using emacsclient -n -a=emacs [FILE]
.
(require 'server)
(unless (server-running-p)
(server-start))
(setq locale-coding-system 'utf-8)
(set-language-environment 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
(setq backup-directory-alist (quote ((".*" . "~/.cache/emacs_backup/"))))
(setq make-backup-files nil)
(fset 'yes-or-no-p 'y-or-n-p)
;; (recentf-mode nil)
el-get is the package manager, which is similar to apt-get.
(add-to-list 'load-path "~/.emacs.d/el-get")
(require 'el-get)
(setq el-get-git-shallow-clone 't)
(el-get 'sync)
To replicate a package set for another emacs installation is explain in el-get README. you can list current installed package using.
`(setq my-packages ',(mapcar #'el-get-as-symbol (el-get-list-package-names-with-status "installed")))
this is the same of current packages which are installed.
PS: itβs osx compatibile βchillβ
(setq dim-packages
(append
;; list of packages we use straight from official recipes
'(ample-regexps auto-complete cl-lib ctable dash
deferred ein epc epl exec-path-from-shell f flymake
flymake-cursor fuzzy git-modes goto-chg jedi json-mode
json-reformat json-snatcher magit go-eldoc go-autocomplete moz-repl multiple-cursors
pkg-info popup popup-kill-ring pos-tip pylookup python
python-environment recentf-ext request s undo-tree
web-mode websocket go-mode yasnippet ac-helm outorg outshine package)
(mapcar 'el-get-as-symbol (mapcar 'el-get-source-name
el-get-sources))))
(el-get 'sync dim-packages)
4 UI/UX
Basic configuration, like window size keybindings
(load "~/.emacs.d/config/ui.cfg.el")
these are kind of strange bindings for beginner and for me too, so lets remove it
(global-unset-key [(control prior)])
(global-unset-key [(control next)])
I find these binding quite handful.
(el-get 'sync 'fill-column-indicator)
(require 'fill-column-indicator)
(global-set-key [M-f4] 'save-buffers-kill-terminal)
(global-set-key [(control f5)] '(lambda() (interactive)
(load-file "~/.emacs.d/init.el")))
(global-set-key [f6] '(lambda() (interactive)
(toggle-truncate-lines)
(fci-mode)))
(global-set-key [f9] 'speedbar)
We donβt need font dialog options which is binded by default.
Since, font resize has been binded to C mouse scroll
does it.
(global-unset-key [(shift down-mouse-1)])
(global-set-key [(shift down-mouse-1)] 'mouse-save-then-kill)
Uses shade-color
defined in config/ui.cfg.el to compute new
intensity of given color and alpha value.
(el-get 'sync 'highline)
(require 'highline)
(set-face-background 'highline-face (shade-color 09))
(add-hook 'prog-mode-hook 'highline-mode-on)
;; not using inbuild hl-line-mode i can't seem to figure out changing
;; face for shade-color
;; (global-hl-line-mode 1)
;; (set-face-background 'hl-line "#3e4446")
;; (set-face-foreground 'highlight nil)
;; (set-face-attribute hl-line-face nil :underline nil)
(when window-system
(require 'undo-tree)
(global-undo-tree-mode 1)
(global-unset-key (kbd "C-/"))
(defalias 'redo 'undo-tree-redo)
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "C-S-z") 'redo))
4.4 modeline
;;; mode-icons directly from repo, for experiments
;;; https://github.com/ryuslash/mode-icons
(load-file "~/.emacs.d/modules/mode-icons/mode-icons.el")
;;; DID YOU GOT STUCK ABOVE? COMMENT LINE ABOVE & UNCOMMENT NEXT 2 LINES
;; (el-get 'sync 'mode-icons)
;; (require 'mode-icons)
;; (setq mode-icons-desaturate-inactive nil)
;; (setq mode-icons-desaturate-active nil)
;; (setq mode-icons-grayscale-transform nil)
(mode-icons-mode)
(el-get 'sync 'powerline)
(require 'powerline)
;;; https://github.com/manishmarahatta/powerline-iconic-theme
;; (add-to-list 'load-path "~/.emacs.d/modules/powerline-iconic-theme/")
(load-file "~/.emacs.d/modules/powerline-iconic-theme/iconic.el")
(powerline-iconic-theme)
;;; DID YOU GOT STUCK ABOVE? COMMENT 2 LINES ABOVE & UNCOMMENT NEXT LINE
;;(powerline-default-theme)
;;; modeline from spacmacs
;;; https://github.com/TheBB/spaceline
;; (add-to-list 'load-path "~/.emacs.d/modules/spaceline/")
;; (require 'spaceline-config)
;; (spaceline-spacemacs-theme)
4.5 tabbar
(el-get 'sync 'tabbar)
(require 'tabbar)
(tabbar-mode t)
;;; tabbar-ruler directly from repo, for experiments
;;; https://github.com/mattfidler/tabbar-ruler.el
(load-file "~/.emacs.d/modules/tabbar-ruler/tabbar-ruler.el")
;;; DID YOU GOT STUCK ABOVE? COMMENT LINE ABOVE & UNCOMMENT NEXT 2
;; (el-get 'sync 'tabbar-ruler)
;; (require 'tabbar-ruler)
(setq tabbar-ruler-style 'firefox)
(load "~/.emacs.d/config/tabbar.cfg.el")
(global-set-key [f7] 'tabbar-mode)
bind them as modern GUI system.
(define-key global-map [(control tab)] 'tabbar-forward)
(define-key global-map [(control next)] 'tabbar-forward)
(define-key global-map [(control prior)] 'tabbar-backward)
(define-key global-map (kbd "C-S-<iso-lefttab>") 'tabbar-backward)
Binding for the tab groups, some how I use lots of buffers.
(global-set-key [(control shift prior)] 'tabbar-backward-group)
(global-set-key [(control shift next)] 'tabbar-forward-group)
Unfortunately emacs π scrolling π is not smooth, its 2017 already.
(el-get 'sync 'smooth-scroll)
(require 'smooth-scroll)
(smooth-scroll-mode t)
(setq linum-delay t)
(setq redisplay-dont-pause t)
(setq scroll-conservatively 0) ;; cursor on the middle of the screen
(setq scroll-up-aggressively 0.01)
(setq scroll-down-aggressively 0.01)
(setq auto-window-vscroll nil)
(setq mouse-wheel-progressive-speed 10)
(setq mouse-wheel-follow-mouse 't)
Default behavious of emacs weird, I wish this was default.
(delete-selection-mode 1)
ido-mode
(ido-mode t)
;;(ido-ubiquitous t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t ;; enable fuzzy matching
ido-auto-merge-work-directories-length nil
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
;; ido-default-file-method 'select-window
ido-use-virtual-buffers t
ido-handle-duplicate-virtual-buffers 2
ido-max-prospects 10)
;; (el-get 'sync 'smex)
;; (require 'smex)
;; (smex-initialize)
;; (global-set-key (kbd "M-x") 'smex)
https://github.com/emacs-helm/helm
(el-get 'sync 'helm)
(require 'helm)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(helm-mode 1)
Highlight all search matches, most of the text editor does this why not emacs. Here is the gify from original repo.
(el-get 'sync 'anzu)
(require 'anzu)
(global-anzu-mode +1)
(global-unset-key (kbd "M-%"))
(global-unset-key (kbd "C-M-%"))
(global-set-key (kbd "M-%") 'anzu-query-replace)
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
4.11 multiple cursor
if sublime can have multiple selections, emacs can too..
Here is video from Emacs Rocks! about it in ep13.
(when window-system
(el-get 'sync 'multiple-cursors)
(require 'multiple-cursors)
(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click))
This is the gem feature, this might be true answer to the sublime mini-map which is over rated, this is what you need.
If you arenβt using el-get here is the source, guessing it its avaliable in all major repository by now.
(el-get 'sync 'goto-chg)
(require 'goto-chg)
(global-unset-key (kbd "C-j"))
(global-set-key (kbd "C-j") 'goto-last-change)
It kinda has been stuck in my config for years, just addicted to it. Seems like this is by default now.
;; (el-get 'sync 'switch-window)
;; (require 'switch-window)
;; (global-set-key (kbd "C-x o") 'switch-window)
4.14 emoji
People have emotions and so do emacs π.
(el-get 'sync 'emojify)
(require 'emojify)
(add-hook 'org-mode-hook 'emojify-mode)
(add-hook 'markdown-mode-hook 'emojify-mode)
(add-hook 'git-commit-mode-hook 'emojify-mode)
(setq-default comment-start "# ")
(add-hook 'prog-mode-hook 'which-function-mode)
(add-hook 'prog-mode-hook 'toggle-truncate-lines)
(setq show-paren-style 'expression)
(show-paren-mode 1)
(defun watch-words ()
(interactive)
(font-lock-add-keywords
nil '(("\\<\\(FIX ?-?\\(ME\\)?\\|TODO\\|BUGS?\\|TIPS?\\|TESTING\\|WARN\\(ING\\)?S?\\|WISH\\|IMP\\|NOTE\\)"
1 font-lock-warning-face t))))
(add-hook 'prog-mode-hook 'watch-words)
(el-get 'sync 'highlight-symbol)
(require 'highlight-symbol)
(global-set-key [(control f3)] 'highlight-symbol-at-point)
(global-set-key [(shift f3)] 'highlight-symbol-next)
(global-set-key [(shift f2)] 'highlight-symbol-prev)
(global-unset-key (kbd "<C-down-mouse-1>"))
(global-set-key (kbd "<C-down-mouse-1>")
(lambda (event)
(interactive "e")
(save-excursion
(goto-char (posn-point (event-start event)))
(highlight-symbol-at-point))))
(defun nuke_traling ()
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
(add-hook 'before-save-hooks 'whitespace-cleanup))
(add-hook 'prog-mode-hook 'nuke_traling)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
5.6 complie
(load "~/.emacs.d/config/compile.cfg.el")
(el-get 'sync 'fill-column-indicator)
(require 'fill-column-indicator)
(defun my-compilation-mode-hook ()
(setq truncate-lines nil) ;; automatically becomes buffer local
(set (make-local-variable 'truncate-partial-width-windows) nil)
(toggle-truncate-lines)
(fci-mode))
(add-hook 'compilation-mode-hook 'my-compilation-mode-hook)
(global-set-key (kbd "C-<f8>") 'save-and-compile-again)
(global-set-key (kbd "C-<f9>") 'ask-new-compile-command)
(global-set-key (kbd "<f8>") 'toggle-compilation-buffer)
(el-get 'sync 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
code navigation
https://github.com/leoliu/ggtags
install ggtags as mention in the repo
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode 1))))
(add-hook 'python-mode-hook 'ggtags-mode)
(global-set-key (kbd "<C-double-mouse-1>") 'ggtags-find-tag-mouse)
(add-hook 'before-save-hook #'gofmt-before-save)
(require 'go-eldoc)
(add-hook 'go-mode-hook 'go-eldoc-setup)
(require 'auto-complete)
(require 'go-autocomplete)
(require 'auto-complete-config)
(setq gofmt-command "goimports")
http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html
(setq c-tab-always-indent t)
(setq c-basic-offset 4)
(setq c-indent-level 4)
styling
https://www.emacswiki.org/emacs/IndentingC
(require 'cc-mode)
(c-set-offset 'substatement-open 0)
(c-set-offset 'arglist-intro '+)
(add-hook 'c-mode-common-hook '(lambda() (c-toggle-hungry-state 1)))
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
Welcome to flying circus πͺ.
(setq-default py-indent-offset 4)
6.3.1 jedi
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t) ; optional
;; (setq jedi:setup-keys t) ; optional
shortcut β[C-h S]β
;; (add-to-list 'load-path "~/.emacs.d/pydoc-info")
;; (require 'pydoc-info)
;; (require 'info-look)
;; (setq pdb-path '/usr/lib/python2.4/pdb.py
;; gud-pdb-command-name (symbol-name pdb-path))
;; (defadvice pdb (before gud-query-cmdline activate) "Provide a
;; better default command line when called interactively."
;; (interactive (list (gud-query-cmdline pdb-path
;; (file-name-nondirectory buffer-file-name)))))
6.3.4 py execution
ess-style executing python script.
;; (add-to-list 'load-path "~/.emacs.d/modules/py-exec/")
;; (require 'py-exec)
(load "~/.emacs.d/modules/py-exec/py-exec.el")
(setq lua-indent-level 4)
(setq default-tab-width 4)
;; (load "~/.emacs.d/config/html.cfg.el")
eww βEmacs Web Wowserβ is a web browser written entirely in elisp avaliable since version 24.4
As much awesome it sounds you will be ridiculed if you try to show of to normal users! π
As of version 25.1 webkit has been introduced although you have enable it while compiling, it pretty π feature too have π.
config is based on reddit post.
make these keys behave like normal browser
(add-hook 'xwidget-webkit-mode (lambda ()
(define-key xwidget-webkit-mode-map [mouse-4] 'xwidget-webkit-scroll-down)
(define-key xwidget-webkit-mode-map [mouse-5] 'xwidget-webkit-scroll-up)
(define-key xwidget-webkit-mode-map (kbd "<up>") 'xwidget-webkit-scroll-down)
(define-key xwidget-webkit-mode-map (kbd "<down>") 'xwidget-webkit-scroll-up)
(define-key xwidget-webkit-mode-map (kbd "M-w") 'xwidget-webkit-copy-selection-as-kill)
(define-key xwidget-webkit-mode-map (kbd "C-c") 'xwidget-webkit-copy-selection-as-kill)))
Adapt webkit according to window configuration chagne automatically
without this hook, every time you change your window configuration,
you must press a
to adapt webkit content to new window size.
(add-hook 'window-configuration-change-hook (lambda ()
(when (equal major-mode 'xwidget-webkit-mode)
(xwidget-webkit-adjust-size-dispatch))))
by default, xwidget reuses previous xwidget window, thus overriding your current website, unless a prefix argument is supplied. This function always opens a new website in a new window
(defun xwidget-browse-url-no-reuse (url &optional sessoin)
(interactive (progn
(require 'browse-url)
(browse-url-interactive-arg "xwidget-webkit URL: ")))
(xwidget-webkit-browse-url url t))
make xwidget default browser
;; (setq browse-url-browser-function (lambda (url session)
;; (other-window 1)
;; (xwidget-browse-url-no-reuse url)))
(load "~/.emacs.d/config/org-mode.cfg.el")
(load "~/.emacs.d/config/babel.cfg.el")
Org-mode is addictive, why not use it as minor-modes.
outline
(require 'outline)
(add-hook 'prog-mode-hook 'outline-minor-mode)
(add-hook 'compilation-mode-hook 'outline-minor-mode)
outshine
(require 'outshine)
(add-hook 'outline-minor-mode-hook 'outshine-hook-function)
;; (add-hook 'outline-minor-mode-hook
;; '(lambda ()
;; (define-key org-mode-map (kbd "C-j") nil)))
Goodies for π³ π³ π³
(el-get 'sync 'dockerfile-mode)
(add-to-list 'auto-mode-alist '("Dockerfile" . dockerfile-mode))
(setq auto-mode-alist
(cons '("\.json$" . json-mode) auto-mode-alist))
(el-get 'sync 'markdown-mode)
;; disable because markdown creating problem to dockerfile-mode
;; (add-to-list 'auto-mode-alist '("\.md" . markdown-mode))
(when window-system
(require 'yasnippet)
(yas-reload-all)
(add-hook 'prog-mode-hook 'yas-minor-mode-on)
(add-hook 'org-mode-hook 'yas-minor-mode-on))
Word play consist of collection of nify scripts.
(load "~/.emacs.d/scripts/wordplay.el")
(global-set-key (kbd "C-`") 'duplicate-current-line)
(global-set-key (kbd "C-~") 'duplicate-current-word)
only enable for C-<insert>
(global-set-key (kbd "C-<insert>") 'kill-ring-save-current-line)
http://www.emacswiki.org
kill π ring π
Only enable for Shift + <insert>
(global-set-key [(shift insert)] 'repetitive-yanking)
This π§ section π§ contain modes (plug-in)
which modified to extreme or π buggy. May still not be
available in el-get
.
(add-to-list 'load-path "~/.emacs.d/modules/")
There are stuff like moz-repl, skewer-mode, impatient-mode but nothing beats good old way with xdotool hail X11 for now! π
;; (add-to-list 'load-path "~/.emacs.d/modules/emacs-browser-refresh/")
;; (require 'browser-refresh)
;; (setq browser-refresh-default-browser 'firefox)
above thingi comment, lets do Makefile!
WINDOW=$(shell xdotool search --onlyvisible --class chromium) run: xdotool key --window ${WINDOW} 'F5' xdotool windowactivate ${WINDOW}
8.2 auto-complete emoji
canβt remember your emoji? this is the thing you need
Note: if you are using company mode use company-emoji requires Symbola font, to be installed.
(add-to-list 'load-path "~/.emacs.d/modules/emacs-ac-emoji/")
(require 'ac-emoji)
(add-hook 'org-mode-hook 'auto-complete-mode)
(add-hook 'org-mode-hook 'ac-emoji-setup)
(add-hook 'markdown-mode-hook 'ac-emoji-setup)
(add-hook 'git-commit-mode-hook 'ac-emoji-setup)
(set-fontset-font
t 'symbol
(font-spec :family "Symbola") nil 'prepend)
also avalible in el-get.
(add-to-list 'load-path "~/.emacs.d/modules/window-numbering/")
(require 'window-numbering)
(window-numbering-mode)
Using localreadhead fork of highlight indentation, for web-mode compatibility. See yasnippet issue #396
other color: β#aaeebaβ
(add-to-list 'load-path "~/.emacs.d/modules/indent/antonj/")
;;; DID YOU GOT STUCK ABOVE? COMMENT LINE ABOVE & UNCOMMENT NEXT LINE
;; (el-get 'sync 'highlight-indentation)
(require 'highlight-indentation)
(set-face-background 'highlight-indentation-face "olive drab")
(set-face-background 'highlight-indentation-current-column-face "#c3b3b3")
(add-hook 'prog-mode-hook 'highlight-indentation-mode)
(add-hook 'prog-mode-hook 'highlight-indentation-current-column-mode)
http://www.emacswiki.org/emacs/download/hideshowvis.el
;; (autoload 'hideshowvis-enable "hideshowvis")
;; (autoload 'hideshowvis-minor-mode
;; "hideshowvis"
;; "Will indicate regions foldable with hideshow in the fringe."
;; 'interactive)
;; (add-hook 'python-mode-hook 'hideshowvis-enable)
https://github.com/mina86/auto-dim-other-buffers.el
(when window-system
(add-to-list 'load-path "~/.emacs.d/modules/auto-dim-other-buffers.el")
(require 'auto-dim-other-buffers)
(add-hook 'after-init-hook (lambda ()
(when (fboundp 'auto-dim-other-buffers-mode)
(auto-dim-other-buffers-mode t)))))
Need to fix 265 color support. This is what I meant screenshot was produced using code.
(add-to-list 'load-path "~/.emacs.d/modules/colors")
;;; DID YOU GOT STUCK ABOVE? COMMENT LINE ABOVE
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
http://www.emacswiki.org/LineNumbers http://elpa.gnu.org/packages/nlinum-1.1.el
(require 'nlinum)
(setq nlinum-delay t)
(add-hook 'find-file-hook (lambda () (nlinum-mode 1)))
;; (add-to-list 'load-path "~/.emacs.d/modules/isend-mode/")
;; (require 'isend)
;; (setq xle-buffer-process-coding-system 'utf-8)
;; (load-library "/opt/xle/emacs/lfg-mode")
Well itβs a crap, requires lots of dependencies
;;(global-wakatime-mode)
;;(require 'ac-helm) ;; Not necessary if using ELPA package
;;(global-set-key (kbd "C-:") 'ac-complete-with-helm)
;;(define-key ac-complete-mode-map (kbd "C-:") 'ac-complete-with-helm)
(add-to-list 'load-path "~/.emacs.d/modules/gocode")
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "GOPATH"))
;;(add-to-list 'load-path "~/.emacs.d/modules/stock-ticker.el")
;;(require 'stock-ticker)