Steckemacs

Table of Contents

1 Usage

steckemacs is an Emacs configuration that integrates around 60 modes (packages). Stock Emacs is not very usable and lacks many convenient commands. Over the years I've discovered many good extensions and added them to this setup. I want to keep everything in one file steckemacs.org (plus .emacs for the initialization) and not as many others to split it over lots of files and directories. Packages are built directly from source code using quelpa (my homegrown tool for this purpose).

The source code is hosted on Github: https://github.com/steckerhalter/steckemacs

To use this setup please use Emacs 24.3.50 or later (currently that's the development snapshot). Older versions don't work because I use some of the new features of what is to become Emacs 24.4

I once thought this could become sort of a prelude kind of thing but going forward I realized that an Emacs configuration should really just be my (or your) own baby.

hell is other people's .emacs

If you want to adapt this setup I suggest that you use it as template and build your own thing out of it :).

1.1 Installation

Change to a directory of your choice and clone steckemacs:

cd <my directory>
git clone https://github.com/steckerhalter/steckemacs.git

And symlink .emacs into your home directory:

cd ~
ln -s <path to the directory from above>/.emacs

That's it. Then you can run emacs and it should pick up the config, install all the packages and make you happy ;)

1.2 How does it work?

I'm using org-mode to manage steckemacs. .emacs (sometimes called init file) loads steckemacs.org, exports all the code blocks (this process is called "tangling") to steckemacs.el. If a block is marked with :tangle no it will be skipped. When the tangling is finished steckemacs.el is loaded to initialize Emacs.

You can find more information about Literate Programming and org-mode here: http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming

The cool thing about this setup is that you can export the same file as documentation to HTML quite easily. Take a look at the Makefile to see how this done with a script. To do it from Org mode directly press C-c C-e, choose h and then one of the options to produce HTML output.

1.3 Keyboard shortcuts

By using the key-chord mode we can avoid having to type C- or M- all the time. It allows for using keys pressed simultaneously and I'm using it quite often.

When I write fg as a key combo it means you would have to press f and g at the same time.

I only describe my custom key combinations currently. To learn the standard Emacs commands, go through the Tutorial C-h t, use C-h b or M-x to see/filter the available commands/shortcuts.

1.3.1 General

C-c n Show file name + path, save to clipboard
C-x a s Toggle auto saving of buffers
C-c d Change dictionary
C-c C-f Toggle flyspell mode (spellchecking)
M-x Helm M-x (execute command)
C-h C-h Helm M-x (execute command)
C-h h Helm navigate project files
<C-S-iso-lefttab> Helm for files
=C-h ,= Helm: find commands, functions, variables and faces
C-h . Helm: Emacs info manual
C-h 4 Helm: Elisp info manual
C-h 3 Helm: Locate an Elisp library
C-h C-p Open file
cg Customize group

1.3.2 Interface

C-c m Toggle the menu bar
<C-mouse-5> Decrease the font size
<C-mouse-4> Increase the font size
C-S-z Zoom frame, give menu to reset size etc.
ln Show/hide the line numbers

1.3.3 Internet

C-x C-u Prompt for URL and insert contents at point
C-c C-w Browse URL under cursor

1.3.4 Editing

C-z Undo - but do not trigger redo
<M-f10> Move line or region up
<M-f9> Move line or region down
C-S-c C-S-c Edit region with multiple cursors
C-< Multiple cursors up
C-> Multiple cursors down
C-* Mark all like "this" with multiple cursors
vr Visual regexp/replace
i9 Toggle electric indent mode
ac Align nearby elements
C-8 Select symbol under cursor, repeat to expand
M-8 Contract the current selection
M-W Delete region (but don't put it into kill ring)
fc Toggle flycheck mode
C-c q Toggle word wrap
C-c w Cleanup whitespaces
C-h C-v Toggle visual line mode
C-h TAB Indent the whole buffer

1.3.5 Source

M-5 Helm select etags
M-6 Find tag in a new window
C-h C-0 Edebug defun at point
C-h C-b Evaluate the current buffer
C-h C-e Toggle debug on error
C-h C-j Pretty print the last sexp into the current buffer
C-h C-k Pretty print the last sexp into other buffer

1.3.6 Directory

C-h C-d Open dired in current file location
sb Open the speedbar
C-c T Open terminal in current directory
C-c t Open terminal in current project root
C-h C-/ Use fasd to navigate to a file or directory

1.3.7 Buffers

C-h C-s Save the current buffer
C-c r Revert a buffer to the saved state
C-x C-b use ido to switch buffers
<f6> Kill current buffer
<f8> Switch to "other" buffer
jn Switch to "other" buffer
fv Kill current buffer
sv Save the current buffer
sc Switch to scratch buffer
<f9> Split window and show/hide last buffer

1.3.8 History

C-h C-SPC Helm show the kill ring
C-h SPC Helm show all mark rings
C-3 Go backward in movement history
C-4 Go forward in movement history

1.3.9 Occur

M-2 Show all symbols like the one cursor is located at
M-3 Previous symbol like the one the cursor is on
M-4 Next symbol like the one the cursor is on
34 Helm imenu
M-i Helm swoop
M-I Helm swoop back to last point
ok Projectile multiple occur

1.3.10 Windows

C-0 Select previous window
C-9 Select next window
<f2> Split window vertically
<f3> Split window horizontally
<f4> Delete current window (not the buffer)
<f5> Only keep the current window and delete all others
<f7> Toggle arrangement of two windows horizontally/vertically
M-9 Switch to the minibuffer
<M-up> Move the current buffer window up
<M-down> Move the current buffer window down
<M-left> Move the current buffer window left
<M-right> Move the current buffer window right
C-h C-8 Enable/disable dedicated minor-mode for current window

1.3.11 Find/Grep

vg VC git grep
C-h C-f Grep find
C-S-h C-S-f Find files in dired
C-h C-o list matching regexp
C-h C-g Use the ag cli tool to grep project
C-h C-l Helm locate
C-h C-z Projectile find file
C-h g Projectile grep
C-h z Projectile ack

1.3.12 VCS

C-c g Magit status - manual: http://magit.github.io/magit/
C-c l Magit log
bm Magit blame mode

1.3.13 Open

C-c s Open emacs shell
C-h r Open/hide dedicated term
C-h C-c Next multi-term buffer
C-h C-r Previous multi-term buffer
C-h n New multi-term buffer
C-c c Open deft (quick notes tool)
nm Open mu4e
C-c e Open/connect with ERC
C-h C-m Popup discover-my-major window
C-h C-<return> Emacs Web Wowser (internal Webbrowser)
C-h M-RET Emacs Web Wowser do what I mean
C-h C-- Helm: Google
C-h C-4 Google translate
C-h C-3 Open Howdoi with query
=C-\"= Open new terminal with shell-switcher

1.3.14 Org

C-h o Helm: Org info manual
C-h C-n Open Org mode agenda
C-h t Cpture simple task (todo)
C-h T Capture selection (todo)
C-c i Start the clock on the current item
C-c o Stop the clock on the current item
C-S-g Goto the current org clock
C-c C-9 Insert a new subheading and demote it
C-c C-0 Insert a new TODO subheading
C-h C-. Open/switch to home.org
C-h C-u Open/switch to work.org
C-h C-w Cut the current subtree into the clipboard

1.3.15 PHP

C-c v var dump die template
C-c V var dump template

This table is generated with an Elisp block keys-doc from an Org table which is also used in the code further below.

2 Code

2.1 Always maximize Emacs

(modify-all-frames-parameters '((fullscreen . maximized)))

This will maximize the current and all future Emacs frames. The parameter has been added in Emacs 24.4

2.2 Load Path

The variable load-path lists all the directories where Emacs should look for Elisp files. The first file found is used, therefore the order of the directories is relevant.

load-path is documented in the Emacs Online Manual, in chapter Libraries of Lisp Code for Emacs. Useful tips are also on EmacsWiki.

(let ((default-directory "~/.emacs.d/elisp/"))
  (unless (file-exists-p default-directory)
    (make-directory default-directory))
  (add-to-list 'load-path default-directory))

Here we create the directory ~/.emacs.d/elisp if it does not exist, add it to the load-path. Doing that any .el or .elc files in this directory can be required from emacs.

2.3 Package Archives

(setq package-archives nil)

Remove the default GNU package archive since I use quelpa to install packages from source.

2.4 Quelpa

Build and install your Emacs Lisp packages on-the-fly directly from source

All the packaging solutions that existed annoyed me so I wrote my own and called it quelpa.

Given a recipe in melpa's format, it gets the package source code, builds an elpa compatible package and installs that. Packages can be managed in the usual way with list-packages.

Github: https://github.com/quelpa/quelpa

(if (require 'quelpa nil t)
    (quelpa '(quelpa :repo "quelpa/quelpa" :fetcher github) :upgrade t)
  (with-temp-buffer
    (url-insert-file-contents "https://raw.github.com/quelpa/quelpa/master/bootstrap.el")
    (eval-buffer)))

Bootstrapping quelpa here. The quelpa command is used throughout this config to install all the packages. The only other package-archive I tolerate is the one from org-mode :)

2.5 Key Bindings

(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")

This is a custom keymap. It is used for a minor mode that is activated at the end. This is the only way I know of to protect special combos (like C-<return>) from being overridden by other modes.

(quelpa '(key-chord :fetcher wiki))
(key-chord-mode 1)
(setq key-chord-two-keys-delay 0.03)

Key-chord lets you bind commands to combination of key-strokes. Here a "key chord" means two keys pressed simultaneously, or a single key quickly pressed twice.

The source code can be found on EmacsWiki.

We need to turn the mode on here so that we can map keys further below. We lower the delay so that chords are not triggered too easily.

(global-set-key (kbd "C-h x") (lambda () (interactive) (shell-command "pkill emacs")))
(global-set-key (kbd "C-S-l") 'package-list-packages)
(global-set-key (kbd "C-c n") 'my-show-file-name)
(global-set-key (kbd "C-x a s") 'auto-save-buffers-enhanced-toggle-activity)
(global-set-key (kbd "C-c d") 'ispell-change-dictionary)
(global-set-key (kbd "C-c C-f") 'flyspell-mode)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-h C-h") 'helm-M-x)
(global-set-key (kbd "C-h h") 'helm-projectile)
(global-set-key (kbd "<C-S-iso-lefttab>") 'helm-for-files)
(global-set-key (kbd "C-h ,") 'helm-apropos)
(global-set-key (kbd "C-h .") 'helm-info-emacs)
(global-set-key (kbd "C-h 4") 'helm-info-elisp)
(global-set-key (kbd "C-h 3") 'helm-locate-library)
(global-set-key (kbd "C-h C-p") 'find-file)
(key-chord-define-global "cg" 'customize-group)
(global-set-key (kbd "C-c m") 'menu-bar-mode)
(global-set-key (kbd "<C-mouse-5>") 'zoom-frm-out)
(global-set-key (kbd "<C-mouse-4>") 'zoom-frm-in)
(global-set-key (kbd "C-S-z") (lambda () (interactive) (zoom-in/out t)))
(key-chord-define-global "ln" 'linum-mode)
(global-set-key (kbd "C-x C-u") 'my-url-insert-file-contents)
(global-set-key (kbd "C-c C-w") 'browse-url-at-point)
(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "<M-f10>") 'move-text-up)
(global-set-key (kbd "<M-f9>") 'move-text-down)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-*") 'mc/mark-all-like-this)
(key-chord-define-global "vr" 'vr/replace)
(key-chord-define-global "i9" 'electric-indent-mode)
(key-chord-define-global "ac" 'align-current)
(global-set-key (kbd "C-8") 'er/expand-region)
(global-set-key (kbd "M-8") 'er/contract-region)
(global-set-key (kbd "M-W") 'delete-region)
(key-chord-define-global "fc" 'flycheck-mode)
(global-set-key (kbd "C-c q") 'auto-fill-mode)
(global-set-key (kbd "C-c w") 'whitespace-cleanup)
(global-set-key (kbd "C-h C-v") 'visual-line-mode)
(global-set-key (kbd "C-h TAB") 'my-indent-whole-buffer)
(global-set-key (kbd "M-5") 'helm-etags-select)
(global-set-key (kbd "M-6") 'find-tag-other-window)
(global-set-key (kbd "C-h C-0") 'edebug-defun)
(global-set-key (kbd "C-h C-b") 'eval-buffer)
(global-set-key (kbd "C-h C-e") 'toggle-debug-on-error)
(global-set-key (kbd "C-h C-j") 'ipretty-last-sexp)
(global-set-key (kbd "C-h C-k") 'ipretty-last-sexp-other-buffer)
(global-set-key (kbd "C-h C-d") 'dired-jump)
(key-chord-define-global "sb" 'speedbar)
(global-set-key (kbd "C-c T") (lambda () (interactive) (my-open-terminal nil)))
(global-set-key (kbd "C-c t") (lambda () (interactive) (my-open-terminal t)))
(global-set-key (kbd "C-h C-/") 'fasd-find-file)
(global-set-key (kbd "C-h C-s") 'save-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)
(global-set-key (kbd "<f6>") (lambda () (interactive) (kill-buffer (buffer-name))))
(global-set-key (kbd "<f8>") (lambda () (interactive) (switch-to-buffer nil)))
(key-chord-define-global "jn" (lambda () (interactive) (switch-to-buffer nil)))
(key-chord-define-global "fv" (lambda () (interactive) (kill-buffer (buffer-name))))
(key-chord-define-global "sv" 'save-buffer)
(key-chord-define-global "sc" (lambda () (interactive)(switch-to-buffer "*scratch*")))
(global-set-key (kbd "<f9>") 'my-split-window)
(global-set-key (kbd "C-h C-SPC") 'helm-show-kill-ring)
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
(global-set-key (kbd "C-3") 'back-button-local-backward)
(global-set-key (kbd "C-4") 'back-button-local-forward)
(global-set-key (kbd "M-2") 'highlight-symbol-occur)
(global-set-key (kbd "M-3") (lambda () (interactive) (highlight-symbol-jump -1)))
(global-set-key (kbd "M-4") (lambda () (interactive) (highlight-symbol-jump 1)))
(key-chord-define-global "34" 'helm-imenu)
(global-set-key (kbd "M-i") 'helm-swoop)
(global-set-key (kbd "M-I") 'helm-swoop-back-to-last-point)
(key-chord-define-global "ok" 'projectile-multi-occur)
(global-set-key (kbd "C-0") (lambda () (interactive) (select-window (previous-window))))
(global-set-key (kbd "C-9") (lambda () (interactive) (select-window (next-window))))
(global-set-key (kbd "<f2>") 'split-window-vertically)
(global-set-key (kbd "<f3>") 'split-window-horizontally)
(global-set-key (kbd "<f4>") 'delete-window)
(global-set-key (kbd "<f5>") 'delete-other-windows)
(global-set-key (kbd "<f7>") 'my-toggle-window-split)
(global-set-key (kbd "M-9") 'my-switch-to-minibuffer-window)
(global-set-key (kbd "<M-up>") 'buf-move-up)
(global-set-key (kbd "<M-down>") 'buf-move-down)
(global-set-key (kbd "<M-left>") 'buf-move-left)
(global-set-key (kbd "<M-right>") 'buf-move-right)
(global-set-key (kbd "C-h C-8") 'dedicated-mode)
(key-chord-define-global "vg" 'vc-git-grep)
(global-set-key (kbd "C-h C-f") 'grep-find)
(global-set-key (kbd "C-S-h C-S-f") 'find-grep-dired)
(global-set-key (kbd "C-h C-o") 'occur)
(global-set-key (kbd "C-h C-g") 'ag-project)
(global-set-key (kbd "C-h C-l") 'helm-locate)
(global-set-key (kbd "C-h C-z") 'projectile-find-file)
(global-set-key (kbd "C-h g") 'projectile-grep)
(global-set-key (kbd "C-h z") 'projectile-ack)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c l") 'magit-log)
(key-chord-define-global "bm" 'magit-blame-mode)
(global-set-key (kbd "C-c s") 'shell)
(global-set-key (kbd "C-h r") 'multi-term-dedicated-toggle)
(global-set-key (kbd "C-h C-c") 'multi-term-next)
(global-set-key (kbd "C-h C-r") 'multi-term-prev)
(global-set-key (kbd "C-h n") 'multi-term)
(global-set-key (kbd "C-c c") 'deft)
(key-chord-define-global "nm" 'mu4e)
(global-set-key (kbd "C-c e") 'my-erc-connect)
(global-set-key (kbd "C-h C-m") 'discover-my-major)
(global-set-key (kbd "C-h C-<return>") 'eww)
(global-set-key (kbd "C-h M-RET") 'my-eww-browse-dwim)
(global-set-key (kbd "C-h C--") 'helm-google)
(global-set-key (kbd "C-h C-4") 'google-translate-query-translate)
(global-set-key (kbd "C-h C-3") 'howdoi-query)
(global-set-key (kbd "C-\"") 'shell-switcher-new-shell)
(global-set-key (kbd "C-h o") 'helm-info-org)
(global-set-key (kbd "C-h C-n") (lambda () (interactive) (org-agenda nil "n")))
(global-set-key (kbd "C-h t") (lambda () (interactive) (org-capture nil "s")))
(global-set-key (kbd "C-h T") 'org-capture)
(global-set-key (kbd "C-c i") 'org-clock-in-last)
(global-set-key (kbd "C-c o") 'org-clock-out)
(global-set-key (kbd "C-S-g") 'org-clock-goto)
(global-set-key (kbd "C-c C-9") 'org-insert-subheading)
(global-set-key (kbd "C-c C-0") 'org-insert-todo-subheading)
(global-set-key (kbd "C-h C-.") (lambda () (interactive) (find-file "~/org/home.org")))
(global-set-key (kbd "C-h C-u") (lambda () (interactive) (find-file "~/org/work.org")))
(global-set-key (kbd "C-h C-w") 'org-cut-subtree)
(global-set-key (kbd "C-c v") 'var_dump-die)
(global-set-key (kbd "C-c V") 'var_dump)

The code for the keys is generated from data in an Org table named keys using a bit of Elisp code gen-keys and is spit out inside a code block via Noweb syntax. The same data is also used in the Keyboard shortcuts section to generate the documentation. I'd like to be able to have only one place to change key information and have it updated wherever necessary.

(define-key key-translation-map (kbd "C-t") (kbd "C-p"))
(define-key my-keys-minor-mode-map (kbd "<C-return>") 'helm-mini)

C-t is translated to C-p (move up), this helps me with navigating using the Dvorak keyboard layout. my-keys-minor-mode-map is used to set C-return in this case in a way so that other minor modes cannot override it.

2.6 Settings

2.6.1 User Settings

(when (file-readable-p "~/.user.el") (load "~/.user.el"))

Loads user settings if the file is available. I put all my personal modifications or sensitive information into this file.

2.6.2 Encoding

(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)

Kind of a sweeping blow to make sure UTF-8 is used everywhere.

2.6.3 General Settings

(setq
 inhibit-startup-message t
 backup-directory-alist `((".*" . ,temporary-file-directory)) ;don't clutter my fs and put backups into tmp
 auto-save-file-name-transforms `((".*" ,temporary-file-directory t))
 require-final-newline t                ;auto add newline at the end of file
 column-number-mode t                   ;show the column number
 default-major-mode 'text-mode          ;use text mode per default
 mouse-yank-at-point t                  ;middle click with the mouse yanks at point
 history-length 250                     ;default is 30
 locale-coding-system 'utf-8            ;utf-8 is default
 tab-always-indent 'complete            ;try to complete before identing
 confirm-nonexistent-file-or-buffer nil ;don't ask to create a buffer
 vc-follow-symlinks t                   ;follow symlinks automatically
 recentf-max-saved-items 5000           ;same up to 5000 recent files
 eval-expression-print-length nil       ;do not truncate printed expressions
 eval-expression-print-level nil        ;print nested expressions
 send-mail-function 'sendmail-send-it
 kill-ring-max 5000                     ;truncate kill ring after 5000 entries
 mark-ring-max 5000                     ;truncate mark ring after 5000 entries
 mouse-autoselect-window -.1            ;window focus follows the mouse pointer
 mouse-wheel-scroll-amount '(1 ((shift) . 5) ((control))) ;make mouse scrolling smooth
 indicate-buffer-boundaries 'left       ;fringe markers
 split-height-threshold 110             ;more readily split horziontally
 enable-recursive-minibuffers t
 custom-unlispify-menu-entries nil      ;M-x customize should not cripple menu entries
 custom-unlispify-tag-names nil         ;M-x customize should not cripple tags
 show-paren-delay 0
 )

(put 'narrow-to-region 'disabled nil)   ;narrow to region should be enabled by default

This is kind of random stuff. I would like to organize this better but I didn't have a good idea for that yet.

2.6.4 Default Settings

(setq-default
 tab-width 4
 indent-tabs-mode nil                   ;use spaces instead of tabs
 c-basic-offset 4                       ;"tab" with in c-related modes
 c-hungry-delete-key t                  ;delete more than one space
 )

Some variables like tab-width cannot be set globally:

tab-width is a variable defined in `C source code'. … Automatically becomes buffer-local when set.

Whenever they are set the value becomes buffer-local. To be able to set such a variable globally we have to use setq-default which modifies the default value of the variable.

2.6.5 Global Modes

(global-auto-revert-mode 1)  ;auto revert buffers when changed on disk
(show-paren-mode t)          ;visualize()
(iswitchb-mode t)            ;use advanced tab switching
(blink-cursor-mode -1)       ;no cursor blinking
(tool-bar-mode -1)           ;disable the awful toolbar
(menu-bar-mode -1)           ;no menu, you can toggle it with C-c m
(scroll-bar-mode -1)         ;disable the sroll bar

These are built-in global modes/settings. Not sure where to put them so they ended up here…

2.6.6 Prompt Behavior

(defalias 'yes-or-no-p 'y-or-n-p)

(setq kill-buffer-query-functions
  (remq 'process-kill-buffer-query-function
         kill-buffer-query-functions))

All "yes" or "no" questions are aliased to "y" or "n". We don't really want to type a full word to answer a question from Emacs, yet Emacs imposes that silly behavior on us. No!

Also Emacs should be able to kill processes without asking which is achieved in the second expression. Got that snippet from: http://www.masteringemacs.org/articles/2010/11/14/disabling-prompts-emacs/

2.7 Theme, Faces, Frame

(quelpa '(grandshell-theme :repo "steckerhalter/grandshell-theme" :fetcher github))
(load-theme 'grandshell t)

Loading my very own Grand Shell Theme here. It can be installed via MELPA too. It looks like this:

grandshell-theme.png

Figure 1: Grand Shell Theme

(set-face-attribute 'default nil :family "Bitstream Vera Sans Mono" :height 89)

I put that line into ~/.user.el which is loaded in this init file too. To avoid getting this line into the config I use :tangle no as an option in the org-mode source block header.

(defun my-after-make-frame (frame)
  (when (find-font (font-spec :name "Symbola") frame)
    (dolist (range '((#x2600 . #x26ff)
                     (#x1f300 . #x1f5ff)
                     (#x1f600 . #x1f640)
                     (#x1f680 . #x1f6ff)))
      (set-fontset-font "fontset-default" range "Symbola"))))
(add-to-list 'after-make-frame-functions 'my-after-make-frame)

This will set Symbola as fallback-font for Emojis when it is available for the created frame. On Debian the font can be installed like this:

sudo aptitude install ttf-ancient-fonts
(setq frame-title-format
      '((:eval (if (buffer-file-name)
                   (abbreviate-file-name (buffer-file-name))
                 "%b"))))

For the frame title either show a file or a buffer name (if the buffer isn't visiting a file).

2.8 Custom Functions

2.8.1 my-find-function-or-variable-at-point

(defun my-find-function-or-variable-at-point ()
  "Find directly the function/variable at point in the other window."
  (interactive)
  (let ((var (variable-at-point))
        (func (function-called-at-point)))
    (cond
     ((not (eq var 0)) (find-variable-other-window var))
      (func (find-function-other-window func))
       (t (message "Neither function nor variable found!")))))
(define-key emacs-lisp-mode-map (kbd "M-.") 'my-find-function-or-variable-at-point)
(define-key lisp-interaction-mode-map (kbd "M-.") 'my-find-function-or-variable-at-point)

I don't care if is a function or a variable… just go there, Emacs!

2.8.2 my-indent-whole-buffer

(defun my-indent-whole-buffer ()
  (interactive)
  (indent-region (point-min) (point-max)))

Indent the whole buffer with one command. Bound to C-h TAB.

2.8.3 my-isearch-goto-match-beginning

(defun my-isearch-goto-match-beginning ()
  (when (and isearch-forward (not isearch-mode-end-hook-quit)) (goto-char isearch-other-end)))
(add-hook 'isearch-mode-end-hook 'my-isearch-goto-match-beginning)

Make isearch-forward put the cursor at the start of the search, not the end, so that isearch can be used for navigation. See also http://www.emacswiki.org/emacs/IsearchOtherEnd.

2.8.4 my-show-file-name

(defun my-show-file-name ()
  "Show the full path file name in the minibuffer."
  (interactive)
  (message (buffer-file-name))
  (kill-new (file-truename buffer-file-name)))

Display and copy the full path of the file associated with the current buffer to the kill ring.

2.8.5 my-show-help

(quelpa '(pos-tip
          :repo "syohex/pos-tip"
          :fetcher github
          :files ("pos-tip.el")))
(require 'pos-tip)
(defun my-show-help (doc-function)
  "Show docs for symbol at point or at beginning of list if not on a symbol.
Pass symbol-name to the function DOC-FUNCTION."
  (interactive)
  (let ((s (symbol-name
            (save-excursion
              (or (symbol-at-point)
                  (progn (backward-up-list)
                         (forward-char)
                         (symbol-at-point)))))))
    (let ((doc-string (funcall doc-function s)))
      (if doc-string
          (pos-tip-show doc-string 'popup-tip-face (point) nil -1 60)
        (message "No documentation for %s" s)))))
(define-key lisp-mode-shared-map (kbd "C-c C-d")
  (lambda ()
    (interactive)
    (my-show-help #'ac-symbol-documentation)))

I wanted to be able to get a documentation popup without having to trigger auto-complete. It's mostly stolen from Scott Jaderholm (the code is on Emacswiki), but has been made more general to also work with other completion functions.

2.8.6 my-split-window

(defun my-split-window()
  "Split the window to see the most recent buffer in the other window.
Call a second time to restore the original window configuration."
  (interactive)
  (if (eq last-command 'my-split-window)
      (progn
        (jump-to-register :my-split-window)
        (setq this-command 'my-unsplit-window))
    (window-configuration-to-register :my-split-window)
    (switch-to-buffer-other-window nil)))

I often use this to get back to the buffer I was editing just before. It has some problems and…

  1. TODO I should be improving my-split-window

2.8.7 my-switch-to-minibuffer-window

Sometimes the minibuffer loses focus and I almost can get back to it. This function does it quickly.

(defun my-switch-to-minibuffer-window ()
  "Switch to minibuffer window (if active)."
  (interactive)
  (when (active-minibuffer-window)
    (select-window (active-minibuffer-window))))

2.8.8 my-tks

(defun my-tks (ipos tables params)
  "Formatting function for org `clocktable' that generates TKS compatible output.
Usage example:
#+BEGIN: clocktable :scope agenda :block today :formatter my-tks :properties (\"project\")
#+END: clocktable
"
  (insert-before-markers (format-time-string "%d/%m/%Y\n\n"))
  (let (tbl entry entries time)
    (while (setq tbl (pop tables))
      (setq entries (nth 2 tbl))
      (while (setq entry (pop entries))
        (when (string-match org-todo-regexp (nth 1 entry))
          (let* ((level (car entry))
                 (headline (replace-regexp-in-string (concat org-todo-regexp "\\( +\\|[ \t]*$\\)") "" (nth 1 entry)))
                 (rest (mod (nth 3 entry) 60))
                 (hours (/ (nth 3 entry) 60))
                 (mins (cond
                        ((<= rest 15) 0.25)
                        ((<= rest 30) 0.5)
                        ((<= rest 45) 0.75)
                        (t 1)))
                 (project (cdr (assoc "project" (nth 4 entry))))
                 )
            (insert-before-markers
             (format "%s %s %s\n" (if project project "?") (+ hours mins) headline ))
            ))))))

2.8.9 my-toggle-window-split

(defun my-toggle-window-split ()
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
             (next-win-buffer (window-buffer (next-window)))
             (this-win-edges (window-edges (selected-window)))
             (next-win-edges (window-edges (next-window)))
             (this-win-2nd (not (and (<= (car this-win-edges)
                                         (car next-win-edges))
                                     (<= (cadr this-win-edges)
                                         (cadr next-win-edges)))))
             (splitter
              (if (= (car this-win-edges)
                     (car (window-edges (next-window))))
                  'split-window-horizontally
                'split-window-vertically)))
        (delete-other-windows)
        (let ((first-win (selected-window)))
          (funcall splitter)
          (if this-win-2nd (other-window 1))
          (set-window-buffer (selected-window) this-win-buffer)
          (set-window-buffer (next-window) next-win-buffer)
          (select-window first-win)
          (if this-win-2nd (other-window 1))))))

This function allows to get two vertically splitted windows into a horizontal split and back.

2.8.10 my-url-insert-file-contents

(defun my-url-insert-file-contents (url)
  "Prompt for URL and insert file contents at point."
  (interactive "sURL: ")
  (url-insert-file-contents url))

2.9 Advices

(defadvice kill-ring-save (before slick-copy activate compile)
  "When called interactively with no active region, copy a single
line instead."
  (interactive
    (if mark-active (list (region-beginning) (region-end))
      (message "Copied line")
      (list (line-beginning-position)
               (line-beginning-position 2)))))

(defadvice kill-region (before slick-cut activate compile)
  "When called interactively with no active region, kill a single
line instead."
  (interactive
    (if mark-active (list (region-beginning) (region-end))
      (list (line-beginning-position)
        (line-beginning-position 2)))))

Make killing a bit more intelligent, so that when having no region the current line in operated on. See http://www.emacswiki.org/emacs/SlickCopy where this is copied from…

(defadvice kill-buffer (around kill-buffer-around-advice activate)
  (let ((buffer-to-kill (ad-get-arg 0)))
    (if (equal buffer-to-kill "*scratch*")
        (bury-buffer)
      ad-do-it)))

Bury scratch buffer instead of killing it. I can't stand having to re-create scratch.

2.10 Modes

Now get ready for setting up all the modes I use…

2.10.1 auctex-mode

AUCTEX is an extensible package for writing and formatting TEX files in GNU Emacs and XEmacs. It supports many different TEX macro packages, including AMS-TEX, LATEX, Texinfo, ConTEXt, and docTEX (dtx files).

preview-screenshot.png

Homepage: https://www.gnu.org/software/auctex/

(setq TeX-PDF-mode t)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(setq TeX-save-query nil)
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
(add-hook 'TeX-mode-hook
          '(lambda ()
             (define-key TeX-mode-map (kbd "<C-f8>")
               (lambda ()
                 (interactive)
                 (TeX-command-menu "LaTeX")))))

When I do LaTeX I want to have a sane config. I install auctex only when I really need it.

2.10.2 ag

(quelpa '(ag :repo "Wilfred/ag.el" :fetcher github))

2.10.3 apache-mode

(quelpa '(apache-mode :fetcher wiki))

2.10.4 back-button

Back-button provides an alternative method for navigation by analogy with the "back" button in a web browser.

Every Emacs command which pushes the mark leaves behind an invisible record of the location of the point at that moment. Back-button moves the point back and forth over all the positions where some command pushed the mark. Visual navigation through mark rings in Emacs.

back_button_example.png

Figure 2: back-button

back-button is written by Roland Walker. For more information see the Github page.

(quelpa '(back-button :repo "rolandwalker/back-button" :fetcher github))
(setq back-button-local-keystrokes nil) ;don't overwrite C-x SPC binding
(require 'back-button)
(back-button-mode 1)

2.10.5 buffer-move

(quelpa '(buffer-move :fetcher wiki))

2.10.6 cider

CIDER is Clojure IDE and REPL for Emacs, built on top of nREPL, the Clojure networked REPL server. It's a great alternative to the now deprecated combination of SLIME + swank-clojure.

cider-logo-w480.png

It was formerly called nrepl.el and is written by Bozhidar Batsov.

Github: https://github.com/clojure-emacs/cider

I wrote a company-backend for Cider which is living at https://github.com/clojure-emacs/company-cider.

(quelpa '(cider :fetcher github :repo "clojure-emacs/cider" :old-names (nrepl)))
(setq cider-popup-stacktraces nil)
(setq cider-repl-popup-stacktraces nil)
(setq cider-repl-pop-to-buffer-on-connect t)
(setq cider-repl-use-clojure-font-lock t)

Don't popup nasty stacktraces all over the place, please.

2.10.7 company

Company stands for "complete anything". It uses pluggable back-ends and front-ends to retrieve and display completion candidates.

It comes with several back-ends such as Elisp, Clang, Semantic, Eclim, Ropemacs, Ispell, dabbrev, etags, gtags, files, keywords and a few others.

company-semantic.png

Figure 3: company

(quelpa '(company :repo "company-mode/company-mode" :fetcher github))
(quelpa '(company-cider :fetcher github :repo "clojure-emacs/company-cider"))
(require 'company)
(setq company-idle-delay 0.3)
(setq company-tooltip-limit 20)
(setq company-minimum-prefix-length 2)
(setq company-echo-delay 0)
(setq company-auto-complete nil)
(global-company-mode 1)
(add-to-list 'company-backends 'company-dabbrev t)
(add-to-list 'company-backends 'company-ispell t)
(add-to-list 'company-backends 'company-files t)
(add-to-list 'company-backends 'company-cider)

I started using company because auto-complete seemed to be buggy and slow. Some of the company features are pretty cool, for example the ability to search within completions with C-s or to show the symbol definition with C-w. <f1> shows the full documentation of a symbol. I miss the popup from auto-complete a bit but I guess that's not so important in the end.

(defun my-pcomplete-capf ()
  (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
(add-hook 'org-mode-hook #'my-pcomplete-capf)

This enables company completion for org-mode built-in commands and tags.

(defun my-company-elisp-setup ()
  (set (make-local-variable 'company-backends)
       '((company-capf :with company-dabbrev-code))))

(dolist (hook '(emacs-lisp-mode-hook lisp-interaction-mode-hook))
  (add-hook hook 'my-company-elisp-setup))

For Elisp add code dabbrev as second company source so that not only interned symbols can be completed, but also what was just written (and not yet evaluated).

2.10.8 conf-mode

(add-to-list 'auto-mode-alist '("\\.tks\\'" . org-mode))

2.10.9 dedicated

This minor mode allows you to toggle a window's "dedicated" flag. When a window is "dedicated", Emacs will not select files into that window. This can be quite handy since many commands will use another window to show results (e.g., compilation mode, starting info, etc.) A dedicated window won't be used for such a purpose.

Github: https://github.com/emacsmirror/dedicated

(quelpa '(dedicated :fetcher github :repo "emacsmirror/dedicated"))
(require 'dedicated)

I'm quite fond of dedicated. Now when a buffer is supposed to be left alone, I can dedicate it!

2.10.10 deft

Deft is an Emacs mode for quickly browsing, filtering, and editing directories of plain text notes.

Homepage: http://jblevins.org/projects/deft/

browser.png

Figure 4: deft

(quelpa '(deft :url "git://jblevins.org/git/deft.git" :fetcher git))
(setq
 deft-extension "org"
 deft-directory "~/deft"
 deft-text-mode 'org-mode
 deft-use-filename-as-title t
 deft-auto-save-interval 20
 )

I'm using org-mode as the default format for deft. I mostly use deft to record some random notes and later archive them using the command provided by deft.

2.10.11 diff-hl

diff-hl-mode highlights uncommitted changes on the left side of the window, allows you to jump between and revert them selectively.

Github: https://github.com/dgutov/diff-hl

screenshot.png

Figure 5: diff-hl

(quelpa '(diff-hl :fetcher github :repo "dgutov/diff-hl"))
(global-diff-hl-mode)

(defadvice git-commit-commit (after git-commit-commit-after activate)
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (when diff-hl-mode
        (diff-hl-update)))))

Turn on the global mode and advice the commit-function so that after a commit the diff-hl-enabled buffers are updated.

2.10.12 dired and dired+

Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files.

Dired is nice way to browse the directory tree. I have added dired+ which

extends functionalities provided by standard GNU Emacs libraries dired.el, dired-aux.el, and dired-x.el. The standard functions are all available, plus many more.

DrewsEmacsDiredLine.jpg

See the EmacsWiki for detailed information on dired+.

Being in a dired buffer it is possible to make the buffer writable and thus rename files and permissions by editing the buffer. Use C-x C-q which runs the command dired-toggle-read-only to make that possible.

I often use dired-jump (mapped to C-h C-d) which jumps to Dired buffer corresponding to current buffer.

(quelpa '(dired+ :fetcher wiki))
(setq dired-auto-revert-buffer t)
(setq wdired-allow-to-change-permissions t) ; allow changing of file permissions
(toggle-diredp-find-file-reuse-dir 1)
(setq diredp-hide-details-initially-flag nil)
(setq diredp-hide-details-propagate-flag nil)

It seems that both flags are necessary to make dired+ not hide the details. toggle-diredp-find-file-reuse-dir will make sure that there is only one buffer kept around for dired. Normally dired creates a buffer for every opened directory.

2.10.13 discover-my-major

Discover key bindings and their meaning for the current Emacs major mode.

The command is inspired by discover.el and also uses the makey library. I thought, "Hey! Why not parse the information about the major mode bindings somehow and display that like discover.el does…"

Github: https://github.com/steckerhalter/discover-my-major

(quelpa '(discover-my-major :fetcher github :repo "steckerhalter/discover-my-major"))

2.10.14 eval-sexp-fu

Flash some lights when evaluating expressions. See the EmacsWiki for some more info: http://www.emacswiki.org/emacs/EvalSexpFu

(quelpa '(eval-sexp-fu :fetcher wiki :files ("eval-sexp-fu.el")))
(require 'eval-sexp-fu)
(setq eval-sexp-fu-flash-duration 0.4)
(turn-on-eval-sexp-fu-flash-mode)
(define-key lisp-interaction-mode-map (kbd "C-c C-c") 'eval-sexp-fu-eval-sexp-inner-list)
(define-key lisp-interaction-mode-map (kbd "C-c C-e") 'eval-sexp-fu-eval-sexp-inner-sexp)
(define-key emacs-lisp-mode-map (kbd "C-c C-c") 'eval-sexp-fu-eval-sexp-inner-list)
(define-key emacs-lisp-mode-map (kbd "C-c C-e") 'eval-sexp-fu-eval-sexp-inner-sexp)

2.10.15 erc mode

ERC is a powerful, modular, and extensible IRC client for Emacs.

I tried several IRC clients for Emacs but ERC is still my favorite.

EmacsWiki: http://www.emacswiki.org/emacs/ERC

(quelpa '(erc-hl-nicks :fetcher github :repo "leathekd/erc-hl-nicks"))
(add-hook 'erc-mode-hook (lambda ()
                           (erc-truncate-mode t)
                           (erc-fill-disable)
                           (set (make-local-variable 'scroll-conservatively) 1000)
                           (visual-line-mode)))
(setq erc-timestamp-format "%H:%M "
      erc-fill-prefix "      "
      erc-insert-timestamp-function 'erc-insert-timestamp-left)
(setq erc-interpret-mirc-color t)
(setq erc-kill-buffer-on-part t)
(setq erc-kill-server-buffer-on-quit t)
(setq erc-kill-queries-on-quit t)
(setq erc-kill-server-buffer-on-quit t)
(setq erc-server-send-ping-interval 45)
(setq erc-server-send-ping-timeout 180)
(setq erc-server-reconnect-timeout 60)
(erc-track-mode t)
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
                                "324" "329" "332" "333" "353" "477"))
(setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))

;; ------ template for .user.el
;; (setq erc-prompt-for-nickserv-password nil)
;; (setq erc-server "hostname"
;;       erc-port 7000
;;       erc-nick "user"
;;       erc-user-full-name "user"
;;       erc-email-userid "user"
;;       erc-password "user:pw"
;;       )
(defun my-erc-connect ()
  "Connect with ERC or open the last active buffer."
  (interactive)
  (if (erc-buffer-list)
      (erc-track-switch-buffer 1)
    (erc-tls :server erc-server :port erc-port :nick erc-nick :full-name erc-user-full-name :password erc-password)))

I use this function so that do not accidentally connect twice with ERC which happened quite often before.

2.10.16 eww

Emacs Web Wowser is the bult-in Emacs Webbrowser (Emacs 24.4 and later).

eww.png

Rationale: http://lars.ingebrigtsen.no/2013/06/eww.html

(setq eww-search-prefix "https://startpage.com/do/m/mobilesearch?query=")

Using startpage.com mobile view here as default search because the default duckduckgo is just too slow for my taste.

(defun my-eww-browse-dwim ()
  "`eww' browse \"do what I mean\".
 Browse the url at point if there is one. Otherwise use the last
 kill-ring item and provide that to `eww'. If it is an url `eww'
 will browse it, if not `eww' will search for it using a search
 engine."
  (interactive)
  (let ((arg (or
              (url-get-url-at-point)
              (current-kill 0 t))))
    (eww arg)))

2.10.17 expand-region

(quelpa '(expand-region :repo "magnars/expand-region.el" :fetcher github))

2.10.18 fasd

Fasd (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like autojump

The command-line tool is available an Github: https://github.com/clvv/fasd

The global-fasd-mode was written by myself. It's purpose is to make the quick access DB from fasd available in Emacs and also to add visited files and directories from Emacs to the fasd DB.

Github: https://github.com/steckerhalter/emacs-fasd

(quelpa '(fasd :repo "steckerhalter/emacs-fasd" :fetcher github))
(global-fasd-mode 1)

2.10.19 fixmee

Fixmee-mode tracks fixme notices in code comments, highlights them, ranks them by urgency, and lets you navigate to them quickly.

A distinguishing feature of this library is that it tracks the urgency of each notice, allowing the user to jump directly to the most important problems.

fixmee was written by Roland Walker and lives on Github: https://github.com/rolandwalker/fixmee

(quelpa '(fixmee :repo "rolandwalker/fixmee" :fetcher github))
(global-fixmee-mode 1)

I had tried similar modes like fic-ext=mode but fount them lacking a bit. Let's see how this one performs…

2.10.20 flycheck-mode

  • Automatic on-the-fly syntax checking while editing
  • Fully automatic selection of the best syntax checker

Supports many languages: AsciiDoc, C/C++, CFEngine, Chef cookbooks, CoffeeScript, CSS, D, Elixir, Emacs Lisp, Erlang, Go, Haml, Handlebars, Haskell, HTML, Javascript, JSON, LESS, Lua, Perl, PHP, Puppet, Python, Ruby, Rust, RST (ReStructuredText), Sass, Scala, SCSS, Slim, Shell scripts (POSIX Shell, Bash and Zsh), TeX/LaTeX, XML, YAML

Flycheck is written by Sebastian Wiesner a.ka lunaryorn.

Github: https://github.com/flycheck/flycheck

screenshot.png

(quelpa '(flycheck :repo "flycheck/flycheck" :fetcher github))
(add-hook 'php-mode-hook 'flycheck-mode)
(add-hook 'sh-mode-hook 'flycheck-mode)
(add-hook 'json-mode-hook 'flycheck-mode)
(add-hook 'nxml-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
(add-hook 'lisp-interaction-mode-hook 'flycheck-mode)
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) ;disable the annoying doc checker
(setq flycheck-indication-mode 'left-fringe)

The modes where flycheck should be enabled.

2.10.21 grizzl

Grizzl is a small utility library to be used in other Elisp code needing fuzzy search behaviour. It is optimized for large data sets, using a special type of lookup table and supporting incremental searches (searches where the result can be narrowed-down by only searching what is already matched).

The source code for Grizzl can be found on Github. It is written by Chris Corbyn who also wrote the PHP REPL Boris.

n3EweV3.png

Currently it is used by Projectile in my config. I quite like Grizzl. It offers some benefits for when entries are longer. For most cases IDO is better suited though.

(quelpa '(grizzl :repo "d11wtq/grizzl" :fetcher github))
(setq *grizzl-read-max-results* 30)

I would like to see more than just the default results of 10.

2.10.22 google-translate

(quelpa '(google-translate :fetcher github :repo "atykhonov/google-translate"))
(setq google-translate-default-source-language "de")
(setq google-translate-default-target-language "en")

2.10.23 haskell-mode

Github: https://github.com/haskell/haskell-mode

(quelpa '(haskell-mode :repo "haskell/haskell-mode" :fetcher github :files ("*.el" "haskell-mode.texi" "NEWS" "logo.svg")))
(require 'haskell-mode)
(setq haskell-indent-thenelse 3)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)

I still have this lingering around here from way back then when I used the xmonad tiling window manager.

2.10.24 helm

Helm is incremental completion and selection narrowing framework for Emacs. It will help steer you in the right direction when you're looking for stuff in Emacs (like buffers, files, etc).

Helm is a fork of anything.el originaly written by Tamas Patrovic and can be considered to be its successor. Helm sets out to clean up the legacy code in anything.el and provide a cleaner, leaner and more modular tool, that's not tied in the trap of backward compatibility.

The Helm source code can be found at Github.

You might want to checkout the Helm Wiki for detailed instructions on how Helm works.

(quelpa '(helm :repo "emacs-helm/helm" :fetcher github :files ("*.el" "emacs-helm.sh")))
(quelpa '(helm-descbinds :repo "emacs-helm/helm-descbinds" :fetcher github))
(quelpa '(helm-gtags :repo "syohex/emacs-helm-gtags" :fetcher github :files ("helm-gtags.el")))
(quelpa '(helm-projectile :repo "bbatsov/projectile" :fetcher github :files ("helm-projectile.el")))
(require 'helm-config)
(setq helm-mode-handle-completion-in-region nil) ; don't use helm for `completion-at-point'
(helm-mode 1)
(helm-gtags-mode 1)
(helm-descbinds-mode)
(setq helm-idle-delay 0.1)
(setq helm-input-idle-delay 0.1)
(setq helm-buffer-max-length 50)
(setq helm-M-x-always-save-history t)
(setq helm-buffer-details-flag nil)
(add-to-list 'helm-completing-read-handlers-alist '(org-refile)) ; helm-mode does not do org-refile well
(add-to-list 'helm-completing-read-handlers-alist '(org-agenda-refile)) ; same goes for org-agenda-refile

I'm not using Helm Find Files to browse files anymore. I tried using it but gave up after a while. I found it to be more cumbersome than ido-mode. But in general I really like to have Helm around especially for buffer-switching. But it is also very useful to look up Elisp variable/function documentation and for finding stuff in the Info Manuals (e.g. helm-info-elisp or helm-info-emacs).

I use Helm M-x and also the separate Helm Descbinds (C-h b) to get a quick key bindings overview.

2.10.25 helm-google

Emacs Helm Interface for quick Google searches

screenshot.png

Not yet perfect but quite handy not having to resort to the browser for searches, just to view the results.

(quelpa '(helm-google :fetcher github :repo "steckerhalter/helm-google"))

2.10.26 helm-swoop

helm-swoop is a great Helm powered buffer search/occur interface:

helm-multi-swoop.gif

Figure 6: helm-swoop

Github: https://github.com/ShingoFukuyama/helm-swoop

(quelpa '(helm-swoop :repo "ShingoFukuyama/helm-swoop" :fetcher github))
(define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)

2.10.27 highlight-symbol

Automatic and manual symbol highlighting for Emacs

Highlights the word/symbol at point and any other occurrences in view. Also allows to jump to the next or previous occurrence.

Homepage: http://nschum.de/src/emacs/highlight-symbol/ Github: https://github.com/nschum/highlight-symbol.el

highlight-symbol.png

(quelpa '(highlight-symbol :fetcher github :repo "nschum/highlight-symbol.el"))
(setq highlight-symbol-on-navigation-p t)
(add-hook 'prog-mode-hook 'highlight-symbol-mode)

2.10.28 howdoi

Do you find yourself constantly Googling for how to do basic programing tasks? Suppose you want to know how to format a date in bash. Why open your browser and read through blogs when you can just M-x howdoi-query RET format date bash RET

Howdoi.el is a way to query Stack Overflow directly from the Emacs and get back the most upvoted answer to the first question that comes up for that query.

Github: https://github.com/atykhonov/emacs-howdoi

Very useful. Saves a lot of time by not having to go through that boring "emacs -> browser -> search engine -> stackoverflow -> emacs" loop…

(quelpa '(howdoi :repo "atykhonov/emacs-howdoi" :fetcher github))

2.10.29 ido-mode

Interactively do things with buffers and files

Great mode to quickly select buffers/files etc. Is built into Emacs since v22.

Select the previous match with C-r and next match with C-s. To open dired at the current location press C-d. Make a directory with M-m.

Use C-j if you want to create a file with what you have entered (and not the match).

(setq ido-enable-flex-matching t
      ido-auto-merge-work-directories-length -1
      ido-create-new-buffer 'always
      ido-everywhere t
      ido-default-buffer-method 'selected-window
      ido-max-prospects 32
      ido-use-filename-at-point 'guess
      )
(ido-mode 1)
(quelpa '(flx-ido :repo "lewang/flx" :fetcher github :files ("flx-ido.el")))
(flx-ido-mode 1)
(setq ido-use-faces nil)

I added flx-ido quite recently which does indeed improve the flex matching. A shout out to Le Wang who coded it.

Github: https://github.com/lewang/flx

2.10.30 iedit

Iedit allows you to edit one occurrence of some text in a buffer (possibly narrowed) or region, and simultaneously have other occurrences edited in the same way, with visual feedback as you type.

Github: https://github.com/victorhge/iedit

(quelpa '(iedit :repo "victorhge/iedit" :fetcher github))
(require 'iedit)
(setq iedit-unmatched-lines-invisible-default t)

The option here makes only the lines with matches visible and hides the rest of the buffer.

2.10.31 ielm

IELM is short for Inferior Emacs Lisp Mode. It is a REPL for Emacs Lisp that is sometimes useful if you want to get immediate feedback and a prompt to work with. I tend to use the *scratch* buffer for explorations like that usually but would be probably better off to use IELM more often :)

(eval-after-load 'ielm
  '(progn
     (add-hook 'inferior-emacs-lisp-mode-hook
               (lambda ()
                 (turn-on-eldoc-mode)))))

We need to tweak IELM a bit so we get completion and eldoc hints.

2.10.32 ipretty

ipretty.el provides interactive functions to pretty-print the result of an expression and a global mode ipretty-mode that advices eval-print-last-sexp to pretty print.

ipretty.png

That's quite useful if you develop elisp.

(quelpa '(ipretty :fetcher github :repo "steckerhalter/ipretty"))
(ipretty-mode t)

2.10.33 js2-mode

Improved JavaScript editing mode for GNU Emacs

Github: https://github.com/mooz/js2-mode

(quelpa '(js2-mode :repo "mooz/js2-mode" :fetcher github))
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook 'flycheck-mode)

2.10.34 json-mode

Major mode for editing JSON files. Extends the builtin js-mode to add better syntax highlighting for JSON.

Github: https://github.com/joshwnj/json-mode

(quelpa '(json-mode :fetcher github :repo "joshwnj/json-mode"))
(add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))

2.10.35 magit

Magit is the king of Git interaction for Emacs.

Screenshot-from-2013-12-06-142317.png

There's a short Crash Course on Emacswiki:

- M-x magit-status to see git status, and in the status buffer:
- s to stage files
- c to commit (type in your commit message then C-c C-c to save the message and commit)
- b b to switch to a branch

Other handy keys:

- P P to do a git push
- F F to do a git pull

try to press TAB

I have bound magit-status to C-c g and magit-log to C-c l.

See the Magit manual for more information.

(quelpa '(magit :fetcher github
                :repo "magit/magit"
                :files ("magit.el" "magit-bisect.el" "magit-blame.el" "magit-key-mode.el" "magit-popup.el" "magit-wip.el" "magit.texi" "AUTHORS.md" "README.md")))
(quelpa '(helm-git :repo "maio/helm-git" :fetcher github)) ; helm-git needs magit
(require 'helm-git)
(when (fboundp 'file-notify-add-watch)
  (quelpa '(magit-filenotify :fetcher github :repo "magit/magit-filenotify"))
  (add-hook 'magit-status-mode-hook 'magit-filenotify-mode))
(setq magit-save-some-buffers nil) ;don't ask to save buffers
(setq magit-set-upstream-on-push t) ;ask to set upstream
(setq magit-diff-refine-hunk t) ;show word-based diff for current hunk
(setq magit-default-tracking-name-function 'magit-default-tracking-name-branch-only) ;don't track with origin-*

Committing should act like git commit -a by default.

When Emacs has been compiled with inotiy support…

./configure --with-file-notification=inotify

…the function file-notify-add-watch is bound and we add magit-filenotify-mode to the hook so that file updates get reflected automatically in magit status.

2.10.36 markdown-mode

(quelpa '(markdown-mode :url "git://jblevins.org/git/markdown-mode.git" :fetcher git))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))

Enable markdown-mode when the file suffixes match.

2.10.37 move-text

Allows to move the current line or region up/down. The source code is on the Wiki: http://www.emacswiki.org/emacs/move-text.el

(quelpa '(move-text :fetcher wiki))
(require 'move-text)

2.10.38 mu4e

Mail client for Emacs by Dirk-Jan Binnema a.k.a djcb

mu.jpg

Website: http://www.djcbsoftware.nl/code/mu/ Github: https://github.com/djcb/mu

mu4e-splitview.png

(when (file-exists-p "/usr/local/share/emacs/site-lisp/mu4e")
  (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
  (autoload 'mu4e "mu4e" "Mail client based on mu (maildir-utils)." t)
  (require 'org-mu4e)
  ;; enable inline images
  (setq mu4e-view-show-images t)
  ;; use imagemagick, if available
  (when (fboundp 'imagemagick-register-types)
    (imagemagick-register-types))
  (setq mu4e-html2text-command "html2text -utf8 -width 72")
  (setq mu4e-update-interval 60)
  (setq mu4e-auto-retrieve-keys t)
  (setq mu4e-headers-leave-behavior 'apply)
  (setq mu4e-headers-visible-lines 20)
  (setq mu4e-hide-index-messages t)

  (add-hook 'mu4e-headers-mode-hook (lambda () (local-set-key (kbd "X") (lambda () (interactive) (mu4e-mark-execute-all t)))))
  (add-hook 'mu4e-view-mode-hook (lambda () (local-set-key (kbd "X") (lambda () (interactive) (mu4e-mark-execute-all t)))))

  (defun mu4e-headers-mark-all-unread-read ()
    (interactive)
    (mu4e~headers-mark-for-each-if
     (cons 'read nil)
     (lambda (msg param)
       (memq 'unread (mu4e-msg-field msg :flags)))))

  (defun mu4e-flag-all-read ()
    (interactive)
    (mu4e-headers-mark-all-unread-read)
    (mu4e-mark-execute-all t))

  (setq message-kill-buffer-on-exit t))

2.10.39 multiple-cursors

(quelpa '(multiple-cursors :fetcher github :repo "magnars/multiple-cursors.el"))

2.10.40 nrepl-eval-sexp-fu

Flashes the evaluated expression (visual feedback)

(quelpa '(nrepl-eval-sexp-fu :fetcher github :repo "samaaron/nrepl-eval-sexp-fu"))
(require 'nrepl-eval-sexp-fu)
(setq nrepl-eval-sexp-fu-flash-duration 0.4)

2.10.41 ob-php

(quelpa '(ob-php :fetcher github :repo "steckerhalter/ob-php"))
(add-to-list 'org-babel-load-languages '(php . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)

2.10.42 org-mode

Org mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system.

Org mode is the most amazing tool for Emacs. Even this Emacs configuration is written and annotated with it.

Homepage: http://orgmode.org/

  1. General settings
    ;; we get `org' with contrib, so if the included `htmlize' is not available we need to force an upgrade
    (let ((quelpa-upgrade-p (not (require 'htmlize nil t))))
      (quelpa '(org :url "git://orgmode.org/org-mode.git" :fetcher git
                    :files ("lisp/*.el" "contrib/lisp/*.el" "doc/dir" "doc/*.texi"))))
    (require 'org)
    (require 'ox-org)
    (require 'ox-md)
    (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
    (setq org-startup-folded t)
    (setq org-startup-indented nil)
    (setq org-startup-with-inline-images t)
    (setq org-startup-truncated t)
    (setq org-src-fontify-natively t)
    (setq org-src-tab-acts-natively t)
    (setq org-edit-src-content-indentation 0)
    (setq org-confirm-babel-evaluate nil)
    (setq org-use-speed-commands t)
    (setq org-refile-targets '((org-agenda-files :maxlevel . 3)))
    (setq org-refile-use-outline-path 'file)
    (setq org-default-notes-file (concat org-directory "/notes.org"))
    (add-to-list 'org-modules 'org-habit)
    (setq org-habit-graph-column 60)
    
    ;; Don't use the same TODO state as the current heading for new heading
    (defun my-org-insert-todo-heading () (interactive) (org-insert-todo-heading t))
    (define-key org-mode-map (kbd "<M-S-return>") 'my-org-insert-todo-heading)
    
  2. Agenda
    ;; create the file for the agendas if it doesn't exist
    (let ((agendas "~/.agenda_files"))
      (unless (file-readable-p agendas)
        (with-temp-file agendas nil))
      (setq org-agenda-files agendas))
    
    ;; display the agenda first
    (setq org-agenda-custom-commands
          '(("n" "Agenda and all TODO's"
            ((alltodo "")
             (agenda "")))))
    
    (defun my-initial-buffer-choice ()
      (org-agenda nil "n")
      (delete-other-windows)
      (current-buffer))
    (setq initial-buffer-choice #'my-initial-buffer-choice)
    
    (setq org-agenda-start-with-log-mode t)
    (setq org-agenda-todo-ignore-scheduled 'future) ; don't show future scheduled
    (setq org-agenda-todo-ignore-deadlines 'far)    ; show only near deadlines
    
    (setq
     appt-message-warning-time 30
     appt-display-interval 15
     appt-display-mode-line t      ; show in the modeline
     appt-display-format 'window)
    (appt-activate 1)              ; activate appt (appointment notification)
    
    (org-agenda-to-appt)           ; add appointments on startup
    
    ;; add new appointments when saving the org buffer, use 'refresh argument to do it properly
    (defun my-org-agenda-to-appt-refresh () (org-agenda-to-appt 'refresh))
    (defun my-org-mode-hook ()
      (add-hook 'after-save-hook 'my-org-agenda-to-appt-refresh nil 'make-it-local))
    (add-hook 'org-mode-hook 'my-org-mode-hook)
    
    (require 'notifications)
    (defun my-appt-disp-window-function (min-to-app new-time msg)
      (notifications-notify :title (format "Appointment in %s min" min-to-app) :body msg))
    (setq appt-disp-window-function 'my-appt-disp-window-function)
    (setq appt-delete-window-function (lambda (&rest args)))
    
    ;; add state to the sorting strategy of todo
    (setcdr (assq 'todo org-agenda-sorting-strategy) '(todo-state-up priority-down category-keep))
    
  3. Templates
    (setq org-capture-templates
          '(
            ("t" "Task" entry (file "") "* TODO %?\n %a")
            ("s" "Simple Task" entry (file "") "* TODO %?\n")
            ))
    
    (add-to-list 'org-structure-template-alist '("E" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC\n"))
    (add-to-list 'org-structure-template-alist '("S" "#+BEGIN_SRC shell-script\n?\n#+END_SRC\n"))
    
  4. Todo
    (setq org-todo-keywords
          '((sequence
             "TODO(t)"
             "WAITING(w)"
             "SCHEDULED(s)"
             "FUTURE(f)"
             "|"
             "DONE(d)"
             )))
    (setq org-todo-keyword-faces
          '(
            ("SCHEDULED" . warning)
            ("WAITING" . font-lock-doc-face)
            ("FUTURE" . "white")
            ))
    (setq org-log-into-drawer t) ; don't clutter files with state logs
    
  5. Clocking
    (setq org-clock-idle-time 15)
    (setq org-clock-in-resume t)
    (setq org-clock-persist t)
    (setq org-clock-persist-query-resume nil)
    (when (executable-find "xprintidle")
      (setq org-x11idle-exists-p t)
      (setq org-clock-x11idle-program-name "xprintidle"))
    (org-clock-persistence-insinuate)
    (setq org-clock-frame-title-format (append '((t org-mode-line-string)) '(" ") frame-title-format))
    (setq org-clock-clocked-in-display 'both)
    
  6. org-mode-blog

    Load the project template for my blog

    (let ((file (expand-file-name "elisp/org-mode-blog-setup.el" "~/org-mode-blog")))
      (when (file-exists-p file)
        (load file t t t)))
    

    Don't forget to set org-mode-blog-publishing-directory to the desired export location in ~/.user.el.

  7. org-mobile-sync-mode
    (when (and (boundp 'org-mobile-directory) (version<= "24.3.50" emacs-version))
      (quelpa '(org-mobile-sync :repo "steckerhalter/org-mobile-sync" :fetcher github))
      (setq org-mobile-inbox-for-pull (concat org-directory "/notes.org"))
      (org-mobile-sync-mode 1))
    

    Enable sync mode only if org-mobile-directory is set.

  8. LaTeX
    (require 'ox-latex)
    (add-to-list 'org-latex-packages-alist '("" "minted"))
    (setq org-latex-listings 'minted)
    
    (setq org-latex-pdf-process
          '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
            "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
            "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
    

2.10.43 php-mode

The well maintained version of PHP mode by Eric James Michael Ritz or ejmr

Github: https://github.com/ejmr/php-mode

(quelpa '(geben :fetcher svn :url "http://geben-on-emacs.googlecode.com/svn/trunk/"))
(quelpa '(php-align :fetcher github :repo "tetsujin/emacs-php-align"))
(quelpa '(php-boris :repo "tomterl/php-boris" :fetcher github))
(quelpa '(php-boris-minor-mode :fetcher github :repo "steckerhalter/php-boris-minor-mode"))
(quelpa '(php-eldoc :repo "sabof/php-eldoc" :fetcher github :files ("*.el" "*.php")))
(quelpa '(php-mode :repo "ejmr/php-mode" :fetcher github))

(require 'php-mode)
(add-to-list 'auto-mode-alist '("\\.module\\'" . php-mode))
(setq php-mode-coding-style "Symfony2")
(setq php-template-compatibility nil)

(let ((manual "/usr/share/doc/php-doc/html/"))
  (when (file-readable-p manual)
    (setq php-manual-path manual)))

(defun my-php-completion-at-point ()
  "Provide php completions for completion-at-point.
Relies on functions of `php-mode'."
  (let ((pattern (php-get-pattern)))
    (when pattern
      (list (- (point) (length pattern)) (point) (php-completion-table) :exclusive 'no))))

(defun setup-php-mode ()
  (require 'php-align nil t)
  (add-hook 'completion-at-point-functions 'my-php-completion-at-point nil t)
  (set (make-local-variable 'company-backends)
       '((company-capf :with company-dabbrev-code)))
  (php-align-setup)
  (set (make-local-variable 'electric-indent-mode) nil)
  (php-eldoc-enable))
(add-hook 'php-mode-hook 'setup-php-mode)

Adding some goodies like php-documentor to add docstrings and php-align to align on \=.

(defun var_dump-die ()
  (interactive)
  (let ((expression (if (region-active-p)
                        (buffer-substring (region-beginning) (region-end))
                      (sexp-at-point)))
        (line (thing-at-point 'line))
        (pre "die(var_dump(")
        (post "));"))
    (if expression
        (progn
          (beginning-of-line)
          (if (string-match "return" line)
              (progn
                (newline)
                (previous-line))
            (next-line)
            (newline)
            (previous-line))
          (insert pre)
          (insert (format "%s" expression))
          (insert post))
      ()
      (insert pre)
      (insert post)
      (backward-char (length post)))))

(defun var_dump ()
  (interactive)
  (if (region-active-p)
    (progn
      (goto-char (region-end))
      (insert ");")
      (goto-char (region-beginning))
      (insert "var_dump("))
    (insert "var_dump();")
    (backward-char 3)))

Two functions to insert var_dump... quickly.

2.10.44 prog-mode

(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))

Show whitespace errors in all programming modes by turning on show-trailing-whitespace in these modes.

2.10.45 projectile

Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies(when feasible). For instance - finding project files has a portable implementation written in pure Emacs Lisp without the use of GNU find(but for performance sake an indexing mechanism backed by external commands exists as well).

Projectile is written by Bozhidar Batsov.

Github: https://github.com/bbatsov/projectile

projectile.png

(quelpa '(projectile :repo "bbatsov/projectile" :fetcher github :files ("projectile.el")))
(require 'projectile nil t)
(setq projectile-completion-system 'grizzl)

2.10.46 rainbow-mode

rainbow-mode is a minor mode for Emacs which displays strings representing colors with the color they represent as background.

rainbow-mode.png

Homepage: http://julien.danjou.info/projects/emacs-packages#rainbow-mode

(unless (require 'rainbow-mode nil t)
  (with-temp-buffer
    (url-insert-file-contents
     "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/rainbow-mode/rainbow-mode.el")
    (package-install-from-buffer)))

(dolist (hook '(css-mode-hook
                html-mode-hook
                js-mode-hook
                emacs-lisp-mode-hook
                org-mode-hook
                text-mode-hook
                ))
  (add-hook hook 'rainbow-mode))

2.10.47 recentf

This package maintains a menu for visiting files that were operated on recently. When enabled a new "Open Recent" sub menu is displayed in the "File" menu. The recent files list is automatically saved across Emacs sessions. You can customize the number of recent files displayed, the location of the menu and others options (see the source code for details).

(setq recentf-save-file (expand-file-name "~/.recentf"))
(recentf-mode 1)

2.10.48 robe

Code navigation, documentation lookup and completion for Ruby

Github: https://github.com/dgutov/robe

(quelpa '(robe :repo "dgutov/robe" :fetcher github :files ("robe*.el" "lib")))
(push 'company-robe company-backends)
(add-hook 'ruby-mode-hook 'robe-mode)

Enable robe for ruby buffers and since I'm using company I'm adding the backend here.

2.10.49 saveplace

Automatically save place in each file. This means when you visit a file, point goes to the last place where it was when you previously visited the same file.

(require 'saveplace)
(setq-default save-place t)

I find this quite practical…

2.10.50 savehist

Many editors (e.g. Vim) have the feature of saving minibuffer history to an external file after exit. This package provides the same feature in Emacs. When set up, it saves recorded minibuffer histories to a file.

(setq savehist-additional-variables '(kill-ring mark-ring global-mark-ring search-ring regexp-search-ring extended-command-history))
(savehist-mode 1)

I'm adding a few variables like the extended-command-history that I would like to persist too.

2.10.51 seqential-command

Do different things on repeated keypresses.

EmacsWiki: http://www.emacswiki.org/emacs/sequential-command.el

(quelpa '(sequential-command :fetcher wiki :files ("sequential-command.el" "sequential-command-config.el")))
(require 'sequential-command)
(define-sequential-command my-beg back-to-indentation beginning-of-line)
(global-set-key "\C-a" 'my-beg)

Pressing C-a once goes back to the indentation, pressing it twice goes the beginning of the line. Pressing C-e once goes back to the end of the line, pressing it twice advances to the next line's indentation.

2.10.52 shell-switcher

An emacs minor mode to easily switch between shell buffers (like with alt+tab)

Github: https://github.com/DamienCassou/shell-switcher

(quelpa '(shell-switcher :fetcher github :repo "DamienCassou/shell-switcher" :files ("rswitcher.el" "shell-switcher.el")))
(setq shell-switcher-new-shell-function 'shell-switcher-make-ansi-term)
(setq shell-switcher-mode t)
(require 'shell-switcher)

2.10.53 skewer

Provides live interaction with JavaScript, CSS, and HTML in a web browser. Expressions are sent on-the-fly from an editing buffer to be evaluated in the browser, just like Emacs does with an inferior Lisp process in Lisp modes.

The following bookmarklet will load skewer on demand on any website:

javascript:(function) {
    var d=document;
    var s=d.createElement('script');
    s.src='http://localhost:8080/skewer';
    d.body.appendChild(s);
})()

Instructions and the source code can be found on Github.

(quelpa '(skewer-mode :repo "skeeto/skewer-mode" :fetcher github :files ("*.html" "*.js" "*.el")))
(skewer-setup)

2.10.54 smart-mode-line

Smart Mode Line is a sexy mode-line for Emacs, that aims to be easy to read from small to large monitors by using a prefix feature and smart truncation.

screenshot-2013-11-11-dark.png

It is written by Artur Bruce-Connor. The default Emacs mode-line has some shortcomings and sml does a good job at improving it.

Github: https://github.com/Bruce-Connor/smart-mode-line

(quelpa '(smart-mode-line :repo "Bruce-Connor/smart-mode-line" :fetcher github))
(setq sml/vc-mode-show-backend t)
(sml/setup)
(sml/apply-theme 'respectful)

Show the encoding and add VC information to the mode-line. Respect the theme-colors and customize some of the sml colors.

2.10.55 smartparens

Smartparens is minor mode for Emacs that deals with parens pairs and tries to be smart about it. It started as a unification effort to combine functionality of several existing packages in a single, compatible and extensible way to deal with parentheses, delimiters, tags and the like.

Github: https://github.com/Fuco1/smartparens

(quelpa '(smartparens :fetcher github :repo "Fuco1/smartparens"))
(require 'smartparens-config)
(smartparens-global-mode t)
;; "fix"" highlight issue in scratch buffer
(custom-set-faces '(sp-pair-overlay-face ((t ()))))
(define-key sp-keymap (kbd "C--") 'sp-forward-sexp)
(define-key sp-keymap (kbd "C-=") 'sp-backward-sexp)
(define-key sp-keymap (kbd "C-.") 'sp-down-sexp)
(define-key sp-keymap (kbd "C-,") 'sp-backward-down-sexp)
(define-key sp-keymap (kbd "C-S-a") 'sp-beginning-of-sexp)
(define-key sp-keymap (kbd "C-S-e") 'sp-end-of-sexp)
(define-key sp-keymap (kbd "C-M-e") 'sp-up-sexp)
(define-key sp-keymap (kbd "C-M-u") 'sp-backward-up-sexp)
(define-key sp-keymap (kbd "C-M-n") 'sp-next-sexp)
(define-key sp-keymap (kbd "C-M-p") 'sp-previous-sexp)
(define-key sp-keymap (kbd "C-S-k") 'sp-kill-sexp)
(define-key sp-keymap (kbd "C-S-w") 'sp-copy-sexp)
(define-key sp-keymap (kbd "M-S-<backspace>") 'sp-unwrap-sexp)
(define-key sp-keymap (kbd "M-<backspace>") 'sp-backward-unwrap-sexp)
(define-key sp-keymap (kbd "C-)") 'sp-forward-slurp-sexp)
(define-key sp-keymap (kbd "C-}") 'sp-forward-barf-sexp)
(define-key sp-keymap (kbd "C-(") 'sp-backward-slurp-sexp)
(define-key sp-keymap (kbd "C-{") 'sp-backward-barf-sexp)
(define-key sp-keymap (kbd "M-D") 'sp-splice-sexp)
(define-key sp-keymap (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-forward)
(define-key sp-keymap (kbd "C-M-<backspace>") 'sp-splice-sexp-killing-backward)
(define-key sp-keymap (kbd "C-S-f") 'sp-select-next-thing)
(define-key sp-keymap (kbd "C-S-b") 'sp-select-previous-thing)
(define-key sp-keymap (kbd "C-]") 'sp-select-next-thing-exchange)
(define-key sp-keymap (kbd "C-\\") 'sp-select-previous-thing-exchange)
(define-key sp-keymap (kbd "C-M-]") 'sp-select-next-thing)
(define-key sp-keymap (kbd "M-F") 'sp-forward-symbol)
(define-key sp-keymap (kbd "M-B") 'sp-backward-symbol)
(define-key sp-keymap (kbd "M-S") 'sp-split-sexp)
(define-key sp-keymap (kbd "M-r") 'sp-splice-sexp-killing-around)
(sp-with-modes sp--lisp-modes
  (sp-local-pair "(" nil :wrap "C-M-9"))

I have finally started learning the smartparens-bindings and already customized the sp-smartparens-bindings a bit.

2.10.56 sgml

(setq sgml-basic-offset 4)
(add-hook 'sgml-mode-hook 'sgml-electric-tag-pair-mode)

Use 4 spaces for identation and enable sgml-electric-tag-pair-mode so that editing an opening markup tag automatically updates the closing tag.

2.10.57 slime

SLIME, the Superior Lisp Interaction Mode for Emacs, is an Emacs mode for developing Common Lisp applications.

more-slime.png

Homepage: http://www.common-lisp.net/project/slime/ Github: https://github.com/slime/slime

(when (file-exists-p "~/quicklisp/slime-helper.el") (load "~/quicklisp/slime-helper.el"))

2.10.58 term-mode

The Emacs Terminal Emulator uses Term mode, which has two input modes. In line mode, Term basically acts like Shell mode. In char mode, each character is sent directly to the subshell, except for the Term escape character, normally ‘C-c’.

(defun my-term-toggle-char-line-mode ()
  "Toggle between `term-char-mode' and `term-line-mode'."
  (interactive)
  (when (equal major-mode 'term-mode)
    (if (term-in-line-mode)
        (term-char-mode)
      (term-line-mode))))

(defun my-term-setup ()
  (interactive)
  (define-key term-raw-map (kbd "C-y") 'term-send-raw)
  (define-key term-raw-map (kbd "C-p") 'term-send-raw)
  (define-key term-raw-map (kbd "C-n") 'term-send-raw)
  (define-key term-raw-map (kbd "C-s") 'term-send-raw)
  (define-key term-raw-map (kbd "C-r") 'term-send-raw)
  (define-key term-raw-map (kbd "M-d") (lambda () (interactive) (term-send-raw-string "\ed")))
  (define-key term-raw-map (kbd "<C-backspace>") (lambda () (interactive) (term-send-raw-string "\e\C-?")))
  (define-key term-raw-map (kbd "M-p") (lambda () (interactive) (term-send-raw-string "\ep")))
  (define-key term-raw-map (kbd "M-n") (lambda () (interactive) (term-send-raw-string "\en")))
  (define-key term-raw-map (kbd "M-,") 'term-send-input)
  (define-key term-raw-map (kbd "C-c y") 'term-paste)
  (define-key term-raw-map (kbd "C-S-y") 'term-paste)
  (define-key term-raw-map (kbd "C-h") nil) ; unbind C-h
  (define-key term-raw-map (kbd "M-x") nil) ; unbind M-x
  (define-key term-raw-map (kbd "C-7") 'my-term-toggle-char-line-mode)
  (define-key term-mode-map (kbd "C-7") 'my-term-toggle-char-line-mode))
(add-hook 'term-mode-hook 'my-term-setup t)

I'd like to have the terminal respect the default keys of the shell as much as possible hence I remap the non-standard bindings to the defaults. Furthermore I want to switch between Emacs-style navigation (term-line-mode) and raw terminal input (term-char-mode) quickly.

2.10.59 uniqify

Unique buffer names dependent on file name

(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(setq uniquify-min-dir-content 2)

2.10.60 vlf

Emacs minor mode that allows viewing, editing, searching and comparing large files in batches. Batch size can be adjusted on the fly and bounds the memory that is to be used for operations on the file. This way multiple large files can be instantly and simultaneously accessed without swapping and degraded performance.

Github: https://github.com/m00natic/vlfi

(quelpa '(vlf :repo "m00natic/vlfi" :fetcher github :old-names (vlfi)))
(setq vlf-application 'dont-ask)        ; just do it
(setq vlf-batch-size 8192)              ; a bit more text per batch please
(require 'vlf-integrate)                ; just do it for real

2.10.61 web-mode

web-mode.el is an autonomous emacs major-mode for editing web templates: HTML documents embedding parts (CSS / JavaScript) and blocks (client/server side)

web-mode.png

Homepage: http://web-mode.org/ Github: https://github.com/fxbois/web-mode

(quelpa '(web-mode :repo "fxbois/web-mode" :fetcher github))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

Enable web-mode for html buffers. Disable font-locking in web-mode because it's conflicting with other modes that do font-locking.

2.10.62 w3m

An Emacs client for the command line web-browser w3m

(when (require 'w3m nil t)
  (setq
   w3m-use-favicon nil
   w3m-default-display-inline-images t
   w3m-search-word-at-point nil
   w3m-use-cookies t
   w3m-home-page "http://en.wikipedia.org/"
   w3m-cookie-accept-bad-cookies t
   w3m-session-crash-recovery nil)
  (add-hook 'w3m-mode-hook
            (function (lambda ()
                        (set-face-foreground 'w3m-anchor-face "LightSalmon")
                        (set-face-foreground 'w3m-arrived-anchor-face "LightGoldenrod")
                        ;;(set-face-background 'w3m-image-anchor "black")
                        (load "w3m-lnum")
                        (defun w3m-go-to-linknum ()
                          "Turn on link numbers and ask for one to go to."
                          (interactive)
                          (let ((active w3m-lnum-mode))
                            (when (not active) (w3m-lnum-mode))
                            (unwind-protect
                                (w3m-move-numbered-anchor (read-number "Anchor number: "))
                              (when (not active) (w3m-lnum-mode))))
                          (w3m-view-this-url)
                          )
                        (define-key w3m-mode-map "f" 'w3m-go-to-linknum)
                        (define-key w3m-mode-map "L" 'w3m-lnum-mode)
                        (define-key w3m-mode-map "o" 'w3m-previous-anchor)
                        (define-key w3m-mode-map "i" 'w3m-next-anchor)
                        (define-key w3m-mode-map "w" 'w3m-search-new-session)
                        (define-key w3m-mode-map "p" 'w3m-previous-buffer)
                        (define-key w3m-mode-map "n" 'w3m-next-buffer)
                        (define-key w3m-mode-map "z" 'w3m-delete-buffer)
                        (define-key w3m-mode-map "O" 'w3m-goto-new-session-url)
                        )))
  )

2.10.63 zoom-frm

Commands to zoom into and out of text. They zoom a frame or a buffer, so that the text appears larger or smaller.

Another library written by Drew Adams.

Code: http://www.emacswiki.org/emacs/zoom-frm.el

What I usually want is to have Emacs increase or decrease the text size for the whole frame (with mode-line and mini-buffer). There is nothing built in that can do that so I use this library.

(quelpa 'zoom-frm)

I bind the mouse wheel and C-S-z, similar to this:

(global-set-key (kbd "C-S-z") (lambda () (interactive) (zoom-in/out t)))
(global-set-key (kbd "<C-mouse-5>") 'zoom-frm-out)
(global-set-key (kbd "<C-mouse-4>") 'zoom-frm-in)

2.11 end

2.11.1 my-keys-minor-mode

(define-minor-mode my-keys-minor-mode
  "A minor mode so that my key settings override annoying major modes."
  t " K" 'my-keys-minor-mode-map)
(my-keys-minor-mode 1)

Author: steckerhalter

Created: 2014-04-12 Sat 13:31

Emacs 24.4.50.1 (Org mode 8.2.5c)

Validate