README in markdown again.

This commit is contained in:
larstvei 2014-04-06 03:25:13 +02:00
parent 9ec8783b83
commit 60c669024f
3 changed files with 486 additions and 487 deletions

View File

@ -1 +0,0 @@
init.org

View File

@ -10,6 +10,8 @@ tangled, and the tangled file is compiled."
(add-hook 'after-save-hook 'init-hook) (add-hook 'after-save-hook 'init-hook)
(require 'package) (require 'package)
(setq package-enable-at-startup nil)
(package-initialize)
(add-to-list 'package-archives (add-to-list 'package-archives
'("MELPA" . "http://melpa.milkbox.net/packages/") t) '("MELPA" . "http://melpa.milkbox.net/packages/") t)
@ -109,10 +111,8 @@ PACKAGE is installed and the current version is deleted."
;; This package is only relevant for Mac OS X. ;; This package is only relevant for Mac OS X.
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(upgrade-or-install-package 'exec-path-from-shell))) (upgrade-or-install-package 'exec-path-from-shell))
(package-initialize))
(setq package-enable-at-startup nil)
(package-initialize)
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(setq mac-option-modifier nil (setq mac-option-modifier nil

152
init.org
View File

@ -21,7 +21,7 @@
the =after-save-hook= ensuring to always tangle and byte-compile the the =after-save-hook= ensuring to always tangle and byte-compile the
=org=-document after changes. =org=-document after changes.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun init-hook () (defun init-hook ()
"If the current buffer is 'init.org' the code-blocks are "If the current buffer is 'init.org' the code-blocks are
tangled, and the tangled file is compiled." tangled, and the tangled file is compiled."
@ -39,14 +39,16 @@
is built in to Emacs 24 and newer. To load downloaded packages we is built in to Emacs 24 and newer. To load downloaded packages we
need to initialize =package=. need to initialize =package=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(require 'package) (require 'package)
(setq package-enable-at-startup nil)
(package-initialize)
#+END_SRC #+END_SRC
Packages can be fetched from different mirrors, [[http://melpa.milkbox.net/#/][melpa]] is the largest Packages can be fetched from different mirrors, [[http://melpa.milkbox.net/#/][melpa]] is the largest
archive and is well maintained. archive and is well maintained.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'package-archives (add-to-list 'package-archives
'("MELPA" . "http://melpa.milkbox.net/packages/") t) '("MELPA" . "http://melpa.milkbox.net/packages/") t)
#+END_SRC #+END_SRC
@ -54,7 +56,7 @@
We can define a predicate that tells us wither or not the newest version We can define a predicate that tells us wither or not the newest version
of a package is installed. of a package is installed.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun newest-package-installed-p (package) (defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed." "Return true if the newest available PACKAGE is installed."
(when (package-installed-p package) (when (package-installed-p package)
@ -70,7 +72,7 @@
upgrades it if a new version has been released. Here our predicate comes upgrades it if a new version has been released. Here our predicate comes
in handy. in handy.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun upgrade-or-install-package (package) (defun upgrade-or-install-package (package)
"Unless the newest available version of PACKAGE is installed "Unless the newest available version of PACKAGE is installed
PACKAGE is installed and the current version is deleted." PACKAGE is installed and the current version is deleted."
@ -85,7 +87,7 @@
Also, we will need a function to find all dependencies from a given package. Also, we will need a function to find all dependencies from a given package.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun dependencies (package) (defun dependencies (package)
"Returns a list of dependencies from a given PACKAGE." "Returns a list of dependencies from a given PACKAGE."
(let* ((pkg-desc (assq package package-alist)) (let* ((pkg-desc (assq package package-alist))
@ -101,7 +103,7 @@
third is a path to a file where a time-stamp is stored in order to check third is a path to a file where a time-stamp is stored in order to check
when packages were updated last. when packages were updated last.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defvar days-between-updates 1) (defvar days-between-updates 1)
(defvar do-package-update-on-init t) (defvar do-package-update-on-init t)
(defvar package-last-update-file (defvar package-last-update-file
@ -114,7 +116,7 @@
update. After that we must run the =time-stamp=-function to update the update. After that we must run the =time-stamp=-function to update the
time-stamp. time-stamp.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(require 'time-stamp) (require 'time-stamp)
;; Open the package-last-update-file ;; Open the package-last-update-file
(with-temp-file package-last-update-file (with-temp-file package-last-update-file
@ -144,7 +146,7 @@
up to date. Here are some packages I find useful (some of these up to date. Here are some packages I find useful (some of these
configurations are also dependent on them). configurations are also dependent on them).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(when (and do-package-update-on-init (when (and do-package-update-on-init
(y-or-n-p "Update all packages?")) (y-or-n-p "Update all packages?"))
(package-refresh-contents) (package-refresh-contents)
@ -184,10 +186,8 @@
;; This package is only relevant for Mac OS X. ;; This package is only relevant for Mac OS X.
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(upgrade-or-install-package 'exec-path-from-shell))) (upgrade-or-install-package 'exec-path-from-shell))
(package-initialize))
(setq package-enable-at-startup nil)
(package-initialize)
#+END_SRC #+END_SRC
** Mac OS X ** Mac OS X
@ -199,7 +199,7 @@
along with external processes a lot simpler. I also prefer using the along with external processes a lot simpler. I also prefer using the
=Command=-key as the =Meta=-key. =Command=-key as the =Meta=-key.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(setq mac-option-modifier nil (setq mac-option-modifier nil
mac-command-modifier 'meta mac-command-modifier 'meta
@ -212,7 +212,7 @@
Some features are not loaded by default to minimize initialization time, Some features are not loaded by default to minimize initialization time,
so they have to be required (or loaded, if you will). so they have to be required (or loaded, if you will).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (feature (dolist (feature
'(auto-compile ; auto-compile .el files '(auto-compile ; auto-compile .el files
auto-complete-config ; a configuration for auto-complete-mode auto-complete-config ; a configuration for auto-complete-mode
@ -234,7 +234,7 @@
We can set variables to whatever value we'd like using =setq=. We can set variables to whatever value we'd like using =setq=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq initial-scratch-message nil ; Clean scratch buffer. (setq initial-scratch-message nil ; Clean scratch buffer.
inhibit-startup-message t ; No splash screen please. inhibit-startup-message t ; No splash screen please.
default-input-method "TeX" ; Use TeX when toggeling input method. default-input-method "TeX" ; Use TeX when toggeling input method.
@ -252,7 +252,7 @@
change them in a single buffer. Using =setq-default= we change the change them in a single buffer. Using =setq-default= we change the
buffer-local variable's default value. buffer-local variable's default value.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq-default fill-column 76 ; Maximum line width. (setq-default fill-column 76 ; Maximum line width.
indent-tabs-mode nil ; Use spaces instead of tabs. indent-tabs-mode nil ; Use spaces instead of tabs.
split-width-threshold 100 ; Split verticly by default. split-width-threshold 100 ; Split verticly by default.
@ -264,7 +264,7 @@
extensions that have been installed manually (these are mostly my own extensions that have been installed manually (these are mostly my own
projects). projects).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(let ((default-directory (concat user-emacs-directory "site-lisp/"))) (let ((default-directory (concat user-emacs-directory "site-lisp/")))
(when (file-exists-p default-directory) (when (file-exists-p default-directory)
(normal-top-level-add-to-load-path '(".")) (normal-top-level-add-to-load-path '("."))
@ -274,14 +274,14 @@
Answering /yes/ and /no/ to each question from Emacs can be tedious, a Answering /yes/ and /no/ to each question from Emacs can be tedious, a
single /y/ or /n/ will suffice. single /y/ or /n/ will suffice.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(fset 'yes-or-no-p 'y-or-n-p) (fset 'yes-or-no-p 'y-or-n-p)
#+END_SRC #+END_SRC
To avoid file system clutter we put all auto saved files in a single To avoid file system clutter we put all auto saved files in a single
directory. directory.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defvar emacs-autosave-directory (defvar emacs-autosave-directory
(concat user-emacs-directory "autosaves/") (concat user-emacs-directory "autosaves/")
"This variable dictates where to put auto saves. It is set to a "This variable dictates where to put auto saves. It is set to a
@ -297,7 +297,7 @@
Set =utf-8= as preferred coding system. Set =utf-8= as preferred coding system.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(set-language-environment "UTF-8") (set-language-environment "UTF-8")
#+END_SRC #+END_SRC
@ -305,20 +305,20 @@
warning, because it might confuse new users. I find it useful sometimes, warning, because it might confuse new users. I find it useful sometimes,
and don't want to be warned. and don't want to be warned.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(put 'narrow-to-region 'disabled nil) (put 'narrow-to-region 'disabled nil)
#+END_SRC #+END_SRC
Call =auto-complete= default configuration, which enables =auto-complete= Call =auto-complete= default configuration, which enables =auto-complete=
globally. globally.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(ac-config-default) (ac-config-default)
#+END_SRC #+END_SRC
Automaticly revert =doc-view=-buffers when the file changes on disk. Automaticly revert =doc-view=-buffers when the file changes on disk.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'doc-view-mode-hook 'auto-revert-mode) (add-hook 'doc-view-mode-hook 'auto-revert-mode)
#+END_SRC #+END_SRC
@ -328,7 +328,7 @@
particularly useful. We create a list of these modes, and disable all of particularly useful. We create a list of these modes, and disable all of
these. these.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (mode (dolist (mode
'(tool-bar-mode ; No toolbars, more room for text. '(tool-bar-mode ; No toolbars, more room for text.
scroll-bar-mode ; No scroll bars either. scroll-bar-mode ; No scroll bars either.
@ -339,7 +339,7 @@
Let's apply the same technique for enabling modes that are disabled by Let's apply the same technique for enabling modes that are disabled by
default. default.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (mode (dolist (mode
'(abbrev-mode ; E.g. sopl -> System.out.println. '(abbrev-mode ; E.g. sopl -> System.out.println.
auto-compile-on-load-mode ; Compile .el files on load ... auto-compile-on-load-mode ; Compile .el files on load ...
@ -354,7 +354,7 @@
This makes =.md=-files open in =markdown-mode=. This makes =.md=-files open in =markdown-mode=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
#+END_SRC #+END_SRC
@ -362,13 +362,13 @@
Change the color-theme to =monokai= (downloaded using =package=). Change the color-theme to =monokai= (downloaded using =package=).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(load-theme 'monokai t) (load-theme 'monokai t)
#+END_SRC #+END_SRC
Use the [[http://www.levien.com/type/myfonts/inconsolata.html][Inconsolata]] font if it's installed on the system. Use the [[http://www.levien.com/type/myfonts/inconsolata.html][Inconsolata]] font if it's installed on the system.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(when (member "Inconsolata-g" (font-family-list)) (when (member "Inconsolata-g" (font-family-list))
(set-face-attribute 'default nil :font "Inconsolata-g-11")) (set-face-attribute 'default nil :font "Inconsolata-g-11"))
#+END_SRC #+END_SRC
@ -376,7 +376,7 @@
[[https://github.com/milkypostman/powerline][Powerline]] is an extension to customize the mode line. This is modified [[https://github.com/milkypostman/powerline][Powerline]] is an extension to customize the mode line. This is modified
version =powerline-nano-theme=. version =powerline-nano-theme=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq-default (setq-default
mode-line-format mode-line-format
'("%e" '("%e"
@ -414,7 +414,7 @@
possibilities. Using =ido-vertical-mode= changes the way possibilities possibilities. Using =ido-vertical-mode= changes the way possibilities
are displayed, and =flx-ido-mode= enables fuzzy matching. are displayed, and =flx-ido-mode= enables fuzzy matching.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (mode (dolist (mode
'(ido-mode ; Interactivly do. '(ido-mode ; Interactivly do.
ido-everywhere ; Use Ido for all buffer/file reading. ido-everywhere ; Use Ido for all buffer/file reading.
@ -426,7 +426,7 @@
We can set the order of file selections in =ido=. I prioritize source We can set the order of file selections in =ido=. I prioritize source
files along with =org=- and =tex=-files. files along with =org=- and =tex=-files.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq ido-file-extensions-order (setq ido-file-extensions-order
'(".el" ".scm" ".lisp" ".java" ".c" ".h" ".org" ".tex")) '(".el" ".scm" ".lisp" ".java" ".c" ".h" ".org" ".tex"))
#+END_SRC #+END_SRC
@ -435,7 +435,7 @@
the way, so we set it to be ignored (it can be accessed using =C-h e=, so the way, so we set it to be ignored (it can be accessed using =C-h e=, so
there is really no need for it in the buffer list). there is really no need for it in the buffer list).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'ido-ignore-buffers "*Messages*") (add-to-list 'ido-ignore-buffers "*Messages*")
#+END_SRC #+END_SRC
@ -443,7 +443,7 @@
package. It needs to be initialized, and we can replace the binding to package. It needs to be initialized, and we can replace the binding to
the standard =execute-extended-command= with =smex=. the standard =execute-extended-command= with =smex=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(smex-initialize) (smex-initialize)
(global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "M-x") 'smex)
#+END_SRC #+END_SRC
@ -453,7 +453,7 @@
Define a function to display week numbers in =calender-mode=. The snippet Define a function to display week numbers in =calender-mode=. The snippet
is from [[http://www.emacswiki.org/emacs/CalendarWeekNumbers][EmacsWiki]]. is from [[http://www.emacswiki.org/emacs/CalendarWeekNumbers][EmacsWiki]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun calendar-show-week (arg) (defun calendar-show-week (arg)
"Displaying week number in calendar-mode." "Displaying week number in calendar-mode."
(interactive "P") (interactive "P")
@ -473,13 +473,13 @@
Evaluate the =calendar-show-week= function. Evaluate the =calendar-show-week= function.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(calendar-show-week t) (calendar-show-week t)
#+END_SRC #+END_SRC
Set Monday as the first day of the week, and set my location. Set Monday as the first day of the week, and set my location.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq calendar-week-start-day 1 (setq calendar-week-start-day 1
calendar-latitude 60.0 calendar-latitude 60.0
calendar-longitude 10.7 calendar-longitude 10.7
@ -493,7 +493,7 @@
installed we bind =load-mail-setup= to =nil=. If the value is changed to installed we bind =load-mail-setup= to =nil=. If the value is changed to
a =non-nil= value mail is setup. a =non-nil= value mail is setup.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defvar load-mail-setup nil) (defvar load-mail-setup nil)
(when load-mail-setup (when load-mail-setup
@ -551,7 +551,7 @@
Flyspell offers on-the-fly spell checking. We can enable flyspell for all Flyspell offers on-the-fly spell checking. We can enable flyspell for all
text-modes with this snippet. text-modes with this snippet.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'text-mode-hook 'turn-on-flyspell) (add-hook 'text-mode-hook 'turn-on-flyspell)
#+END_SRC #+END_SRC
@ -560,7 +560,7 @@
programming modes using the =prog-mode-hook=. Flyspell interferes with programming modes using the =prog-mode-hook=. Flyspell interferes with
auto-complete mode, but there is a workaround provided by auto complete. auto-complete mode, but there is a workaround provided by auto complete.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'prog-mode-hook 'flyspell-prog-mode) (add-hook 'prog-mode-hook 'flyspell-prog-mode)
(ac-flyspell-workaround) (ac-flyspell-workaround)
#+END_SRC #+END_SRC
@ -568,14 +568,14 @@
To cycle through dictionary's we can define a variable containing a To cycle through dictionary's we can define a variable containing a
cyclic list of installed language packs. cyclic list of installed language packs.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defvar ispell-languages '#1=("english" "norsk" . #1#)) (defvar ispell-languages '#1=("english" "norsk" . #1#))
#+END_SRC #+END_SRC
Now we only need a small function to change set the language and shift Now we only need a small function to change set the language and shift
the list. the list.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun cycle-languages () (defun cycle-languages ()
"Changes the ispell-dictionary to whatever is the next (or cdr) in the "Changes the ispell-dictionary to whatever is the next (or cdr) in the
LANGUAGES (cyclic) list." LANGUAGES (cyclic) list."
@ -588,7 +588,7 @@
I use =org-agenda= for appointments and such. I use =org-agenda= for appointments and such.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq org-agenda-start-on-weekday nil ; Show agenda from today. (setq org-agenda-start-on-weekday nil ; Show agenda from today.
org-agenda-files '("~/Dropbox/life.org") ; A list of agenda files. org-agenda-files '("~/Dropbox/life.org") ; A list of agenda files.
org-agenda-default-appointment-duration 120) ; 2 hours appointments. org-agenda-default-appointment-duration 120) ; 2 hours appointments.
@ -597,7 +597,7 @@
When editing org-files with source-blocks, we want the source blocks to When editing org-files with source-blocks, we want the source blocks to
be themed as they would in their native mode. be themed as they would in their native mode.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq org-src-fontify-natively t) (setq org-src-fontify-natively t)
#+END_SRC #+END_SRC
@ -607,7 +607,7 @@
To search recent files useing =ido-mode= we add this snippet from To search recent files useing =ido-mode= we add this snippet from
[[http://www.emacswiki.org/emacs/CalendarWeekNumbers][EmacsWiki]]. [[http://www.emacswiki.org/emacs/CalendarWeekNumbers][EmacsWiki]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun recentf-ido-find-file () (defun recentf-ido-find-file ()
"Find a recent file using Ido." "Find a recent file using Ido."
(interactive) (interactive)
@ -620,7 +620,7 @@
negative argument it removes newlines as well. We wrap a interactive negative argument it removes newlines as well. We wrap a interactive
function around it to be able to bind it to a key. function around it to be able to bind it to a key.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun remove-whitespace-inbetween () (defun remove-whitespace-inbetween ()
"Removes whitespace before and after the point." "Removes whitespace before and after the point."
(interactive) (interactive)
@ -630,7 +630,7 @@
This interactive function switches you to a =shell=, and if triggered in This interactive function switches you to a =shell=, and if triggered in
the shell it switches back to the previous buffer. the shell it switches back to the previous buffer.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun switch-to-shell () (defun switch-to-shell ()
"Jumps to eshell or back." "Jumps to eshell or back."
(interactive) (interactive)
@ -642,7 +642,7 @@
To duplicate either selected text or a line we define this interactive To duplicate either selected text or a line we define this interactive
function. function.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun duplicate-thing () (defun duplicate-thing ()
"Ethier duplicates the line or the region" "Ethier duplicates the line or the region"
(interactive) (interactive)
@ -657,7 +657,7 @@
To tidy up a buffer we define this function borrowed from [[https://github.com/simenheg][simenheg]]. To tidy up a buffer we define this function borrowed from [[https://github.com/simenheg][simenheg]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun tidy () (defun tidy ()
"Ident, untabify and unwhitespacify current buffer, or region if active." "Ident, untabify and unwhitespacify current buffer, or region if active."
(interactive) (interactive)
@ -672,14 +672,14 @@
Bindings for [[https://github.com/magnars/expand-region.el][expand-region]]. Bindings for [[https://github.com/magnars/expand-region.el][expand-region]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-'") 'er/expand-region) (global-set-key (kbd "C-'") 'er/expand-region)
(global-set-key (kbd "C-;") 'er/contract-region) (global-set-key (kbd "C-;") 'er/contract-region)
#+END_SRC #+END_SRC
Bindings for [[https://github.com/magnars/multiple-cursors.el][multiple-cursors]]. Bindings for [[https://github.com/magnars/multiple-cursors.el][multiple-cursors]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-c e") 'mc/edit-lines) (global-set-key (kbd "C-c e") 'mc/edit-lines)
(global-set-key (kbd "C-c a") 'mc/mark-all-like-this) (global-set-key (kbd "C-c a") 'mc/mark-all-like-this)
(global-set-key (kbd "C-c n") 'mc/mark-next-like-this) (global-set-key (kbd "C-c n") 'mc/mark-next-like-this)
@ -687,26 +687,26 @@
Bindings for [[http://magit.github.io][Magit]]. Bindings for [[http://magit.github.io][Magit]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-c m") 'magit-status) (global-set-key (kbd "C-c m") 'magit-status)
#+END_SRC #+END_SRC
Bindings for [[https://github.com/winterTTr/ace-jump-mode][ace-jump-mode]]. Bindings for [[https://github.com/winterTTr/ace-jump-mode][ace-jump-mode]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-c SPC") 'ace-jump-mode) (global-set-key (kbd "C-c SPC") 'ace-jump-mode)
#+END_SRC #+END_SRC
Bindings for =move-text=. Bindings for =move-text=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "<M-S-up>") 'move-text-up) (global-set-key (kbd "<M-S-up>") 'move-text-up)
(global-set-key (kbd "<M-S-down>") 'move-text-down) (global-set-key (kbd "<M-S-down>") 'move-text-down)
#+END_SRC #+END_SRC
Bind some native Emacs functions. Bind some native Emacs functions.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-c s") 'ispell-word) (global-set-key (kbd "C-c s") 'ispell-word)
(global-set-key (kbd "C-c t") 'org-agenda-list) (global-set-key (kbd "C-c t") 'org-agenda-list)
(global-set-key (kbd "C-x k") 'kill-this-buffer) (global-set-key (kbd "C-x k") 'kill-this-buffer)
@ -715,7 +715,7 @@
Bind the functions defined [[sec:defuns][above]]. Bind the functions defined [[sec:defuns][above]].
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(global-set-key (kbd "C-c l") 'cycle-languages) (global-set-key (kbd "C-c l") 'cycle-languages)
(global-set-key (kbd "C-c j") 'remove-whitespace-inbetween) (global-set-key (kbd "C-c j") 'remove-whitespace-inbetween)
(global-set-key (kbd "C-x t") 'switch-to-shell) (global-set-key (kbd "C-x t") 'switch-to-shell)
@ -729,7 +729,7 @@
advice makes =eval-last-sexp= (bound to =C-x C-e=) replace the sexp with advice makes =eval-last-sexp= (bound to =C-x C-e=) replace the sexp with
the value. the value.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defadvice eval-last-sexp (around replace-sexp (arg) activate) (defadvice eval-last-sexp (around replace-sexp (arg) activate)
"Replace sexp when called with a prefix argument." "Replace sexp when called with a prefix argument."
(if arg (if arg
@ -745,14 +745,14 @@
installed. We can advice =turn-on=flyspell= and =flyspell-prog-mode= to installed. We can advice =turn-on=flyspell= and =flyspell-prog-mode= to
only try to enable =flyspell= if a spell-checking tool is avalible. only try to enable =flyspell= if a spell-checking tool is avalible.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defadvice turn-on-flyspell (around check nil activate) (defadvice turn-on-flyspell (around check nil activate)
"Turns on flyspell only if a spell-checking tool is installed." "Turns on flyspell only if a spell-checking tool is installed."
(when (executable-find ispell-program-name) (when (executable-find ispell-program-name)
ad-do-it)) ad-do-it))
#+END_SRC #+END_SRC
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defadvice flyspell-prog-mode (around check nil activate) (defadvice flyspell-prog-mode (around check nil activate)
"Turns on flyspell only if a spell-checking tool is installed." "Turns on flyspell only if a spell-checking tool is installed."
(when (executable-find ispell-program-name) (when (executable-find ispell-program-name)
@ -767,7 +767,7 @@
can add some extra lisp-modes. We run the =pretty-lambda-for-modes= can add some extra lisp-modes. We run the =pretty-lambda-for-modes=
function to activate =pretty-lambda-mode= in lisp modes. function to activate =pretty-lambda-mode= in lisp modes.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (mode '(slime-repl-mode geiser-repl-mode)) (dolist (mode '(slime-repl-mode geiser-repl-mode))
(add-to-list 'pretty-lambda-auto-modes mode)) (add-to-list 'pretty-lambda-auto-modes mode))
@ -777,7 +777,7 @@
I use =Paredit= when editing lisp code, we enable this for all lisp-modes I use =Paredit= when editing lisp code, we enable this for all lisp-modes
in the =pretty-lambda-auto-modes= list. in the =pretty-lambda-auto-modes= list.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(dolist (mode pretty-lambda-auto-modes) (dolist (mode pretty-lambda-auto-modes)
;; add paredit-mode to all mode-hooks ;; add paredit-mode to all mode-hooks
(add-hook (intern (concat (symbol-name mode) "-hook")) 'paredit-mode)) (add-hook (intern (concat (symbol-name mode) "-hook")) 'paredit-mode))
@ -788,7 +788,7 @@
In =emacs-lisp-mode= we can enable =eldoc-mode= to display information In =emacs-lisp-mode= we can enable =eldoc-mode= to display information
about a function or a variable in the echo area. about a function or a variable in the echo area.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
#+END_SRC #+END_SRC
@ -801,21 +801,21 @@
and you can install Slime following the instructions from the site along and you can install Slime following the instructions from the site along
with this snippet. with this snippet.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(when (file-exists-p "~/quicklisp/slime-helper.elc") (when (file-exists-p "~/quicklisp/slime-helper.elc")
(load (expand-file-name "~/quicklisp/slime-helper.elc"))) (load (expand-file-name "~/quicklisp/slime-helper.elc")))
#+END_SRC #+END_SRC
We can specify what Common Lisp program Slime should use (I use SBCL). We can specify what Common Lisp program Slime should use (I use SBCL).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq inferior-lisp-program "sbcl") (setq inferior-lisp-program "sbcl")
#+END_SRC #+END_SRC
To improve auto completion for Common Lisp editing we can use =ac-slime= To improve auto completion for Common Lisp editing we can use =ac-slime=
which uses slime completions as a source. which uses slime completions as a source.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'slime-mode-hook 'set-up-slime-ac) (add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac) (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
@ -829,7 +829,7 @@
works pretty much out of the box, we only need to add auto completion, works pretty much out of the box, we only need to add auto completion,
and specify which scheme-interpreter we prefer. and specify which scheme-interpreter we prefer.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'geiser-mode-hook 'ac-geiser-setup) (add-hook 'geiser-mode-hook 'ac-geiser-setup)
(add-hook 'geiser-repl-mode-hook 'ac-geiser-setup) (add-hook 'geiser-repl-mode-hook 'ac-geiser-setup)
(eval-after-load "auto-complete" (eval-after-load "auto-complete"
@ -843,7 +843,7 @@
languages (C, C++, Java, etc...). I like being able to quickly compile languages (C, C++, Java, etc...). I like being able to quickly compile
using =C-c C-c= (instead of =M-x compile=), a habit from =latex-mode=. using =C-c C-c= (instead of =M-x compile=), a habit from =latex-mode=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun c-setup () (defun c-setup ()
(local-set-key (kbd "C-c C-c") 'compile)) (local-set-key (kbd "C-c C-c") 'compile))
@ -856,7 +856,7 @@
Some statements in Java appear often, and become tedious to write Some statements in Java appear often, and become tedious to write
out. We can use abbrevs to speed this up. out. We can use abbrevs to speed this up.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(define-abbrev-table 'java-mode-abbrev-table (define-abbrev-table 'java-mode-abbrev-table
'(("psv" "public static void main(String[] args) {" nil 0) '(("psv" "public static void main(String[] args) {" nil 0)
("sopl" "System.out.println" nil 0) ("sopl" "System.out.println" nil 0)
@ -866,7 +866,7 @@
To be able to use the abbrev table defined above, =abbrev-mode= must be To be able to use the abbrev table defined above, =abbrev-mode= must be
activated. activated.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun java-setup () (defun java-setup ()
(abbrev-mode t) (abbrev-mode t)
(setq-local compile-command (concat "javac " (buffer-name)))) (setq-local compile-command (concat "javac " (buffer-name))))
@ -880,7 +880,7 @@
=comment-start= we can add comments using =M-;= like in other programming =comment-start= we can add comments using =M-;= like in other programming
modes. Also in assembler should one be able to compile using =C-c C-c=. modes. Also in assembler should one be able to compile using =C-c C-c=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(defun asm-setup () (defun asm-setup ()
(setq comment-start "#") (setq comment-start "#")
(local-set-key (kbd "C-c C-c") 'compile)) (local-set-key (kbd "C-c C-c") 'compile))
@ -893,14 +893,14 @@
=.tex=-files should be associated with =latex-mode= instead of =.tex=-files should be associated with =latex-mode= instead of
=tex-mode=. =tex-mode=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'auto-mode-alist '("\\.tex\\'" . latex-mode)) (add-to-list 'auto-mode-alist '("\\.tex\\'" . latex-mode))
#+END_SRC #+END_SRC
I like using the [[https://code.google.com/p/minted/][Minted]] package for source blocks in LaTeX. To make org I like using the [[https://code.google.com/p/minted/][Minted]] package for source blocks in LaTeX. To make org
use this we add the following snippet. use this we add the following snippet.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'org-latex-packages-alist '("" "minted")) (add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted) (setq org-latex-listings 'minted)
#+END_SRC #+END_SRC
@ -911,7 +911,7 @@
Tex- and LaTeX-mode, we can add the flag with a rather dirty statement Tex- and LaTeX-mode, we can add the flag with a rather dirty statement
(if anyone finds a nicer way to do this, please let me know). (if anyone finds a nicer way to do this, please let me know).
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(setq org-latex-pdf-process (setq org-latex-pdf-process
(mapcar (mapcar
(lambda (str) (lambda (str)
@ -928,7 +928,7 @@
dependent on some python programs as well, so make sure you follow the dependent on some python programs as well, so make sure you follow the
instructions from the site. instructions from the site.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
;; (setq jedi:server-command ;; (setq jedi:server-command
;; (cons "python3" (cdr jedi:server-command)) ;; (cons "python3" (cdr jedi:server-command))
;; python-shell-interpreter "python3") ;; python-shell-interpreter "python3")
@ -943,7 +943,7 @@
the echo area. Haskell has several indentation modes - I prefer using the echo area. Haskell has several indentation modes - I prefer using
=haskell-indent=. =haskell-indent=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
#+END_SRC #+END_SRC
@ -953,6 +953,6 @@
Matlab is very similar to Octave, which is supported by Emacs. We just Matlab is very similar to Octave, which is supported by Emacs. We just
need to let =.m=-files be associated with =octave-mode=. need to let =.m=-files be associated with =octave-mode=.
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC elisp
(add-to-list 'matlab-shell-command-switches "-nosplash") (add-to-list 'matlab-shell-command-switches "-nosplash")
#+END_SRC #+END_SRC