mirror of
https://github.com/larstvei/dot-emacs.git
synced 2024-11-26 07:28:31 +00:00
November update.
- Added possibility for private file. - Removed `try` and instead relay on the package Try. - Made `clear-shell` to a more general `clear-comint`. - Delay loading slime-helper until its needed. - Added `cycle-theme`, and changed default to leuven.
This commit is contained in:
parent
42e5a1af33
commit
90b6af78fe
78
README.md
78
README.md
@ -98,6 +98,18 @@ tangled, and the tangled file is compiled."
|
|||||||
(add-hook 'after-save-hook 'tangle-init)
|
(add-hook 'after-save-hook 'tangle-init)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
I'd like to keep a few settings private, so we load a `private.el` if it
|
||||||
|
exists after the init-file has loaded.
|
||||||
|
|
||||||
|
```emacs-lisp
|
||||||
|
(add-hook
|
||||||
|
'after-init-hook
|
||||||
|
(lambda ()
|
||||||
|
(let ((private-file (concat user-emacs-directory "private.el")))
|
||||||
|
(when (file-exists-p private-file)
|
||||||
|
(load-file private-file)))))
|
||||||
|
```
|
||||||
|
|
||||||
## Package<a id="sec-2-2" name="sec-2-2"></a>
|
## Package<a id="sec-2-2" name="sec-2-2"></a>
|
||||||
|
|
||||||
Managing extensions for Emacs is simplified using `package` which is
|
Managing extensions for Emacs is simplified using `package` which is
|
||||||
@ -223,7 +235,6 @@ configurations are also dependent on them).
|
|||||||
(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)
|
||||||
|
|
||||||
(let* ((packages
|
(let* ((packages
|
||||||
'(ac-geiser ; Auto-complete backend for geiser
|
'(ac-geiser ; Auto-complete backend for geiser
|
||||||
ac-slime ; An auto-complete source using slime completions
|
ac-slime ; An auto-complete source using slime completions
|
||||||
@ -252,7 +263,8 @@ configurations are also dependent on them).
|
|||||||
pretty-lambdada ; the word `lambda' as the Greek letter.
|
pretty-lambdada ; the word `lambda' as the Greek letter.
|
||||||
slime ; Superior Lisp Interaction Mode for Emacs
|
slime ; Superior Lisp Interaction Mode for Emacs
|
||||||
smex ; M-x interface with Ido-style fuzzy matching.
|
smex ; M-x interface with Ido-style fuzzy matching.
|
||||||
undo-tree)) ; Treat undo history as a tree
|
undo-tree ; Treat undo history as a tree
|
||||||
|
try)) ; Try out Emacs packages.
|
||||||
;; Fetch dependencies from all packages.
|
;; Fetch dependencies from all packages.
|
||||||
(reqs (mapcar 'dependencies packages))
|
(reqs (mapcar 'dependencies packages))
|
||||||
;; Append these to the original list, and remove any duplicates.
|
;; Append these to the original list, and remove any duplicates.
|
||||||
@ -457,17 +469,30 @@ This makes `.md`-files open in `markdown-mode`.
|
|||||||
|
|
||||||
## Visual<a id="sec-2-7" name="sec-2-7"></a>
|
## Visual<a id="sec-2-7" name="sec-2-7"></a>
|
||||||
|
|
||||||
Change the color-theme to `monokai` (downloaded using `package`).
|
Change the color-theme to `leuven`.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(load-theme 'monokai t)
|
(load-theme 'leuven t)
|
||||||
|
```
|
||||||
|
|
||||||
|
`leuven` is my preferred light theme, but `monokai` makes a very nice
|
||||||
|
dark theme. I want to be able to cycle between these.
|
||||||
|
|
||||||
|
```emacs-lisp
|
||||||
|
(defun cycle-themes ()
|
||||||
|
"Returns a function that lets you cycle your themes."
|
||||||
|
(lexical-let ((themes '#1=(leuven monokai . #1#)))
|
||||||
|
(lambda ()
|
||||||
|
(interactive)
|
||||||
|
;; Rotates the thme cycle and changes the current theme.
|
||||||
|
(load-theme (car (setq themes (cdr themes))) t))))
|
||||||
```
|
```
|
||||||
|
|
||||||
Use the [Inconsolata](http://www.levien.com/type/myfonts/inconsolata.html) font if it's installed on the system.
|
Use the [Inconsolata](http://www.levien.com/type/myfonts/inconsolata.html) font if it's installed on the system.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(when (member "Inconsolata-g" (font-family-list))
|
(when (member "Inconsolata" (font-family-list))
|
||||||
(set-face-attribute 'default nil :font "Inconsolata-g-11"))
|
(set-face-attribute 'default nil :font "Inconsolata-13"))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ido<a id="sec-2-8" name="sec-2-8"></a>
|
## Ido<a id="sec-2-8" name="sec-2-8"></a>
|
||||||
@ -661,7 +686,7 @@ I use `org-agenda` for appointments and such.
|
|||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(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/cal.org") ; A list of agenda files.
|
||||||
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -677,9 +702,11 @@ This is quite an ugly fix for allowing code markup for expressions like
|
|||||||
`"this string"`, because the quotation marks causes problems.
|
`"this string"`, because the quotation marks causes problems.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(require 'org)
|
;;(require 'org)
|
||||||
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
(eval-after-load "org"
|
||||||
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))
|
'(progn
|
||||||
|
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
||||||
|
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Interactive functions<a id="sec-2-13" name="sec-2-13"></a>
|
## Interactive functions<a id="sec-2-13" name="sec-2-13"></a>
|
||||||
@ -797,17 +824,6 @@ To tidy up a buffer we define this function borrowed from [simenheg](https://git
|
|||||||
(untabify beg (if (< end (point-max)) end (point-max)))))
|
(untabify beg (if (< end (point-max)) end (point-max)))))
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have a link to a raw `.el`-file, run `M-x try` and yank an URL
|
|
||||||
into the minibuffer, and the file will be evaluated.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(defun try (url)
|
|
||||||
"Takes an URL to a .el-file, and evaluates it."
|
|
||||||
(interactive (list (read-from-minibuffer "url: ")))
|
|
||||||
(with-current-buffer (url-retrieve-synchronously url)
|
|
||||||
(eval-region (search-forward-regexp "^$") (point-max))))
|
|
||||||
```
|
|
||||||
|
|
||||||
## Advice<a id="sec-2-14" name="sec-2-14"></a>
|
## Advice<a id="sec-2-14" name="sec-2-14"></a>
|
||||||
|
|
||||||
An advice can be given to a function to make it behave differently. This
|
An advice can be given to a function to make it behave differently. This
|
||||||
@ -892,7 +908,7 @@ does not remove anything. In Emacs removing stuff is less of a worry,
|
|||||||
since we can always undo!
|
since we can always undo!
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(defun clear-shell ()
|
(defun clear-comint ()
|
||||||
"Runs `comint-truncate-buffer' with the
|
"Runs `comint-truncate-buffer' with the
|
||||||
`comint-buffer-maximum-size' set to zero."
|
`comint-buffer-maximum-size' set to zero."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -905,7 +921,7 @@ global binding (because we want to be able to switch to a shell from any
|
|||||||
buffer), but the `clear-shell` should only affect `shell-mode`.
|
buffer), but the `clear-shell` should only affect `shell-mode`.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(add-hook 'shell-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-shell)))
|
(add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-comint)))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Lisp<a id="sec-3-2" name="sec-3-2"></a>
|
## Lisp<a id="sec-3-2" name="sec-3-2"></a>
|
||||||
@ -951,8 +967,14 @@ and you can install Slime following the instructions from the site along
|
|||||||
with this snippet.
|
with this snippet.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(when (file-exists-p "~/.quicklisp/slime-helper.el")
|
(defun activate-slime-helper ()
|
||||||
(load (expand-file-name "~/.quicklisp/slime-helper.el")))
|
(when (file-exists-p "~/.quicklisp/slime-helper.elc")
|
||||||
|
(load (expand-file-name "~/.quicklisp/slime-helper.elc"))
|
||||||
|
(define-key slime-repl-mode-map (kbd "C-l")
|
||||||
|
'slime-repl-clear-buffer))
|
||||||
|
(remove-hook 'lisp-mode-hook #'activate-slime-helper))
|
||||||
|
|
||||||
|
(add-hook 'lisp-mode-hook #'activate-slime-helper)
|
||||||
```
|
```
|
||||||
|
|
||||||
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).
|
||||||
@ -981,7 +1003,6 @@ More sensible `loop` indentation, borrowed from [simenheg](https://github.com/si
|
|||||||
```
|
```
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(define-key slime-repl-mode-map (kbd "C-l") 'slime-repl-clear-buffer)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Scheme<a id="sec-3-2-3" name="sec-3-2-3"></a>
|
### Scheme<a id="sec-3-2-3" name="sec-3-2-3"></a>
|
||||||
@ -1158,7 +1179,7 @@ Bindings for [expand-region](https://github.com/magnars/expand-region.el).
|
|||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
||||||
(define-key custom-bindings-map (kbd "C-;") 'er/contract-region)
|
(define-key custom-bindings-map (kbd "C-\"") 'er/contract-region)
|
||||||
```
|
```
|
||||||
|
|
||||||
Bindings for [multiple-cursors](https://github.com/magnars/multiple-cursors.el).
|
Bindings for [multiple-cursors](https://github.com/magnars/multiple-cursors.el).
|
||||||
@ -1212,8 +1233,11 @@ Bind some native Emacs functions.
|
|||||||
Bind the functions defined above.
|
Bind the functions defined above.
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
|
(define-key global-map (kbd "M-p") 'jump-to-previous-like-this)
|
||||||
|
(define-key global-map (kbd "M-n") 'jump-to-next-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
||||||
|
(define-key custom-bindings-map (kbd "C-c .") (cycle-themes))
|
||||||
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
||||||
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
||||||
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
||||||
|
73
init.el
73
init.el
@ -21,6 +21,16 @@ tangled, and the tangled file is compiled."
|
|||||||
|
|
||||||
(add-hook 'after-save-hook 'tangle-init)
|
(add-hook 'after-save-hook 'tangle-init)
|
||||||
|
|
||||||
|
;; I'd like to keep a few settings private, so we load a =private.el= if it
|
||||||
|
;; exists after the init-file has loaded.
|
||||||
|
|
||||||
|
(add-hook
|
||||||
|
'after-init-hook
|
||||||
|
(lambda ()
|
||||||
|
(let ((private-file (concat user-emacs-directory "private.el")))
|
||||||
|
(when (file-exists-p private-file)
|
||||||
|
(load-file private-file)))))
|
||||||
|
|
||||||
;; Package
|
;; Package
|
||||||
|
|
||||||
;; Managing extensions for Emacs is simplified using =package= which is
|
;; Managing extensions for Emacs is simplified using =package= which is
|
||||||
@ -131,7 +141,6 @@ PACKAGE is installed and the current version is deleted."
|
|||||||
(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)
|
||||||
|
|
||||||
(let* ((packages
|
(let* ((packages
|
||||||
'(ac-geiser ; Auto-complete backend for geiser
|
'(ac-geiser ; Auto-complete backend for geiser
|
||||||
ac-slime ; An auto-complete source using slime completions
|
ac-slime ; An auto-complete source using slime completions
|
||||||
@ -160,7 +169,8 @@ PACKAGE is installed and the current version is deleted."
|
|||||||
pretty-lambdada ; the word `lambda' as the Greek letter.
|
pretty-lambdada ; the word `lambda' as the Greek letter.
|
||||||
slime ; Superior Lisp Interaction Mode for Emacs
|
slime ; Superior Lisp Interaction Mode for Emacs
|
||||||
smex ; M-x interface with Ido-style fuzzy matching.
|
smex ; M-x interface with Ido-style fuzzy matching.
|
||||||
undo-tree)) ; Treat undo history as a tree
|
undo-tree ; Treat undo history as a tree
|
||||||
|
try)) ; Try out Emacs packages.
|
||||||
;; Fetch dependencies from all packages.
|
;; Fetch dependencies from all packages.
|
||||||
(reqs (mapcar 'dependencies packages))
|
(reqs (mapcar 'dependencies packages))
|
||||||
;; Append these to the original list, and remove any duplicates.
|
;; Append these to the original list, and remove any duplicates.
|
||||||
@ -336,14 +346,25 @@ PACKAGE is installed and the current version is deleted."
|
|||||||
|
|
||||||
;; Visual
|
;; Visual
|
||||||
|
|
||||||
;; Change the color-theme to =monokai= (downloaded using =package=).
|
;; Change the color-theme to =leuven=.
|
||||||
|
|
||||||
(load-theme 'monokai t)
|
(load-theme 'leuven t)
|
||||||
|
|
||||||
|
;; =leuven= is my preferred light theme, but =monokai= makes a very nice
|
||||||
|
;; dark theme. I want to be able to cycle between these.
|
||||||
|
|
||||||
|
(defun cycle-themes ()
|
||||||
|
"Returns a function that lets you cycle your themes."
|
||||||
|
(lexical-let ((themes '#1=(leuven monokai . #1#)))
|
||||||
|
(lambda ()
|
||||||
|
(interactive)
|
||||||
|
;; Rotates the thme cycle and changes the current theme.
|
||||||
|
(load-theme (car (setq themes (cdr themes))) t))))
|
||||||
|
|
||||||
;; 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.
|
||||||
|
|
||||||
(when (member "Inconsolata-g" (font-family-list))
|
(when (member "Inconsolata" (font-family-list))
|
||||||
(set-face-attribute 'default nil :font "Inconsolata-g-11"))
|
(set-face-attribute 'default nil :font "Inconsolata-13"))
|
||||||
|
|
||||||
;; Ido
|
;; Ido
|
||||||
|
|
||||||
@ -509,7 +530,7 @@ the languages in ISPELL-LANGUAGES when invoked."
|
|||||||
;; I use =org-agenda= for appointments and such.
|
;; I use =org-agenda= for appointments and such.
|
||||||
|
|
||||||
(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/cal.org") ; A list of agenda files.
|
||||||
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
||||||
|
|
||||||
;; 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
|
||||||
@ -521,9 +542,11 @@ the languages in ISPELL-LANGUAGES when invoked."
|
|||||||
;; This is quite an ugly fix for allowing code markup for expressions like
|
;; This is quite an ugly fix for allowing code markup for expressions like
|
||||||
;; ="this string"=, because the quotation marks causes problems.
|
;; ="this string"=, because the quotation marks causes problems.
|
||||||
|
|
||||||
(require 'org)
|
;;(require 'org)
|
||||||
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
(eval-after-load "org"
|
||||||
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))
|
'(progn
|
||||||
|
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
||||||
|
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))))
|
||||||
|
|
||||||
;; Interactive functions
|
;; Interactive functions
|
||||||
;; <<sec:defuns>>
|
;; <<sec:defuns>>
|
||||||
@ -627,15 +650,6 @@ the buffer is buried."
|
|||||||
(whitespace-cleanup)
|
(whitespace-cleanup)
|
||||||
(untabify beg (if (< end (point-max)) end (point-max)))))
|
(untabify beg (if (< end (point-max)) end (point-max)))))
|
||||||
|
|
||||||
;; If you have a link to a raw =.el=-file, run =M-x try= and yank an URL
|
|
||||||
;; into the minibuffer, and the file will be evaluated.
|
|
||||||
|
|
||||||
(defun try (url)
|
|
||||||
"Takes an URL to a .el-file, and evaluates it."
|
|
||||||
(interactive (list (read-from-minibuffer "url: ")))
|
|
||||||
(with-current-buffer (url-retrieve-synchronously url)
|
|
||||||
(eval-region (search-forward-regexp "^$") (point-max))))
|
|
||||||
|
|
||||||
;; Advice
|
;; Advice
|
||||||
|
|
||||||
;; An advice can be given to a function to make it behave differently. This
|
;; An advice can be given to a function to make it behave differently. This
|
||||||
@ -707,7 +721,7 @@ the buffer is buried."
|
|||||||
;; does not remove anything. In Emacs removing stuff is less of a worry,
|
;; does not remove anything. In Emacs removing stuff is less of a worry,
|
||||||
;; since we can always undo!
|
;; since we can always undo!
|
||||||
|
|
||||||
(defun clear-shell ()
|
(defun clear-comint ()
|
||||||
"Runs `comint-truncate-buffer' with the
|
"Runs `comint-truncate-buffer' with the
|
||||||
`comint-buffer-maximum-size' set to zero."
|
`comint-buffer-maximum-size' set to zero."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -718,7 +732,7 @@ the buffer is buried."
|
|||||||
;; global binding (because we want to be able to switch to a shell from any
|
;; global binding (because we want to be able to switch to a shell from any
|
||||||
;; buffer), but the =clear-shell= should only affect =shell-mode=.
|
;; buffer), but the =clear-shell= should only affect =shell-mode=.
|
||||||
|
|
||||||
(add-hook 'shell-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-shell)))
|
(add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-comint)))
|
||||||
|
|
||||||
;; Lisp
|
;; Lisp
|
||||||
|
|
||||||
@ -756,8 +770,14 @@ the buffer is buried."
|
|||||||
;; 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.
|
||||||
|
|
||||||
(when (file-exists-p "~/.quicklisp/slime-helper.el")
|
(defun activate-slime-helper ()
|
||||||
(load (expand-file-name "~/.quicklisp/slime-helper.el")))
|
(when (file-exists-p "~/.quicklisp/slime-helper.elc")
|
||||||
|
(load (expand-file-name "~/.quicklisp/slime-helper.elc"))
|
||||||
|
(define-key slime-repl-mode-map (kbd "C-l")
|
||||||
|
'slime-repl-clear-buffer))
|
||||||
|
(remove-hook 'lisp-mode-hook #'activate-slime-helper))
|
||||||
|
|
||||||
|
(add-hook 'lisp-mode-hook #'activate-slime-helper)
|
||||||
|
|
||||||
;; 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).
|
||||||
|
|
||||||
@ -778,7 +798,7 @@ the buffer is buried."
|
|||||||
lisp-simple-loop-indentation 2
|
lisp-simple-loop-indentation 2
|
||||||
lisp-loop-keyword-indentation 6)
|
lisp-loop-keyword-indentation 6)
|
||||||
|
|
||||||
(define-key slime-repl-mode-map (kbd "C-l") 'slime-repl-clear-buffer)
|
|
||||||
|
|
||||||
;; Scheme
|
;; Scheme
|
||||||
|
|
||||||
@ -925,7 +945,7 @@ math-block around the region."
|
|||||||
;; Bindings for [[https://github.com/magnars/expand-region.el][expand-region]].
|
;; Bindings for [[https://github.com/magnars/expand-region.el][expand-region]].
|
||||||
|
|
||||||
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
||||||
(define-key custom-bindings-map (kbd "C-;") 'er/contract-region)
|
(define-key custom-bindings-map (kbd "C-\"") 'er/contract-region)
|
||||||
|
|
||||||
;; Bindings for [[https://github.com/magnars/multiple-cursors.el][multiple-cursors]].
|
;; Bindings for [[https://github.com/magnars/multiple-cursors.el][multiple-cursors]].
|
||||||
|
|
||||||
@ -963,8 +983,11 @@ math-block around the region."
|
|||||||
|
|
||||||
;; Bind the functions defined [[sec:defuns][above]].
|
;; Bind the functions defined [[sec:defuns][above]].
|
||||||
|
|
||||||
|
(define-key global-map (kbd "M-p") 'jump-to-previous-like-this)
|
||||||
|
(define-key global-map (kbd "M-n") 'jump-to-next-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
||||||
|
(define-key custom-bindings-map (kbd "C-c .") (cycle-themes))
|
||||||
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
||||||
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
||||||
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
||||||
|
78
init.org
78
init.org
@ -67,6 +67,18 @@
|
|||||||
(add-hook 'after-save-hook 'tangle-init)
|
(add-hook 'after-save-hook 'tangle-init)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
I'd like to keep a few settings private, so we load a =private.el= if it
|
||||||
|
exists after the init-file has loaded.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(add-hook
|
||||||
|
'after-init-hook
|
||||||
|
(lambda ()
|
||||||
|
(let ((private-file (concat user-emacs-directory "private.el")))
|
||||||
|
(when (file-exists-p private-file)
|
||||||
|
(load-file private-file)))))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Package
|
** Package
|
||||||
|
|
||||||
Managing extensions for Emacs is simplified using =package= which is
|
Managing extensions for Emacs is simplified using =package= which is
|
||||||
@ -192,7 +204,6 @@
|
|||||||
(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)
|
||||||
|
|
||||||
(let* ((packages
|
(let* ((packages
|
||||||
'(ac-geiser ; Auto-complete backend for geiser
|
'(ac-geiser ; Auto-complete backend for geiser
|
||||||
ac-slime ; An auto-complete source using slime completions
|
ac-slime ; An auto-complete source using slime completions
|
||||||
@ -221,7 +232,8 @@
|
|||||||
pretty-lambdada ; the word `lambda' as the Greek letter.
|
pretty-lambdada ; the word `lambda' as the Greek letter.
|
||||||
slime ; Superior Lisp Interaction Mode for Emacs
|
slime ; Superior Lisp Interaction Mode for Emacs
|
||||||
smex ; M-x interface with Ido-style fuzzy matching.
|
smex ; M-x interface with Ido-style fuzzy matching.
|
||||||
undo-tree)) ; Treat undo history as a tree
|
undo-tree ; Treat undo history as a tree
|
||||||
|
try)) ; Try out Emacs packages.
|
||||||
;; Fetch dependencies from all packages.
|
;; Fetch dependencies from all packages.
|
||||||
(reqs (mapcar 'dependencies packages))
|
(reqs (mapcar 'dependencies packages))
|
||||||
;; Append these to the original list, and remove any duplicates.
|
;; Append these to the original list, and remove any duplicates.
|
||||||
@ -428,17 +440,31 @@
|
|||||||
|
|
||||||
** Visual
|
** Visual
|
||||||
|
|
||||||
Change the color-theme to =monokai= (downloaded using =package=).
|
Change the color-theme to =leuven=.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(load-theme 'monokai t)
|
(load-theme 'leuven t)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
=leuven= is my preferred light theme, but =monokai= makes a very nice
|
||||||
|
dark theme. I want to be able to cycle between these.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun cycle-themes ()
|
||||||
|
"Returns a function that lets you cycle your themes."
|
||||||
|
(lexical-let ((themes '#1=(leuven monokai . #1#)))
|
||||||
|
(lambda ()
|
||||||
|
(interactive)
|
||||||
|
;; Rotates the thme cycle and changes the current theme.
|
||||||
|
(load-theme (car (setq themes (cdr themes))) 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
|
#+BEGIN_SRC emacs-lisp
|
||||||
(when (member "Inconsolata-g" (font-family-list))
|
(when (member "Inconsolata" (font-family-list))
|
||||||
(set-face-attribute 'default nil :font "Inconsolata-g-11"))
|
(set-face-attribute 'default nil :font "Inconsolata-13"))
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
@ -666,7 +692,7 @@
|
|||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(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/cal.org") ; A list of agenda files.
|
||||||
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
org-agenda-default-appointment-duration 120) ; 2 hours appointments.
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
@ -683,9 +709,11 @@
|
|||||||
="this string"=, because the quotation marks causes problems.
|
="this string"=, because the quotation marks causes problems.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'org)
|
;;(require 'org)
|
||||||
|
(eval-after-load "org"
|
||||||
|
'(progn
|
||||||
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\n,")
|
||||||
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))
|
(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Interactive functions
|
** Interactive functions
|
||||||
@ -802,17 +830,6 @@
|
|||||||
(untabify beg (if (< end (point-max)) end (point-max)))))
|
(untabify beg (if (< end (point-max)) end (point-max)))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
If you have a link to a raw =.el=-file, run =M-x try= and yank an URL
|
|
||||||
into the minibuffer, and the file will be evaluated.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(defun try (url)
|
|
||||||
"Takes an URL to a .el-file, and evaluates it."
|
|
||||||
(interactive (list (read-from-minibuffer "url: ")))
|
|
||||||
(with-current-buffer (url-retrieve-synchronously url)
|
|
||||||
(eval-region (search-forward-regexp "^$") (point-max))))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Advice
|
** Advice
|
||||||
|
|
||||||
An advice can be given to a function to make it behave differently. This
|
An advice can be given to a function to make it behave differently. This
|
||||||
@ -896,7 +913,7 @@
|
|||||||
since we can always undo!
|
since we can always undo!
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun clear-shell ()
|
(defun clear-comint ()
|
||||||
"Runs `comint-truncate-buffer' with the
|
"Runs `comint-truncate-buffer' with the
|
||||||
`comint-buffer-maximum-size' set to zero."
|
`comint-buffer-maximum-size' set to zero."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -909,7 +926,7 @@
|
|||||||
buffer), but the =clear-shell= should only affect =shell-mode=.
|
buffer), but the =clear-shell= should only affect =shell-mode=.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(add-hook 'shell-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-shell)))
|
(add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-comint)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Lisp
|
** Lisp
|
||||||
@ -955,8 +972,14 @@
|
|||||||
with this snippet.
|
with this snippet.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(when (file-exists-p "~/.quicklisp/slime-helper.el")
|
(defun activate-slime-helper ()
|
||||||
(load (expand-file-name "~/.quicklisp/slime-helper.el")))
|
(when (file-exists-p "~/.quicklisp/slime-helper.elc")
|
||||||
|
(load (expand-file-name "~/.quicklisp/slime-helper.elc"))
|
||||||
|
(define-key slime-repl-mode-map (kbd "C-l")
|
||||||
|
'slime-repl-clear-buffer))
|
||||||
|
(remove-hook 'lisp-mode-hook #'activate-slime-helper))
|
||||||
|
|
||||||
|
(add-hook 'lisp-mode-hook #'activate-slime-helper)
|
||||||
#+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).
|
||||||
@ -985,7 +1008,7 @@
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(define-key slime-repl-mode-map (kbd "C-l") 'slime-repl-clear-buffer)
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Scheme
|
*** Scheme
|
||||||
@ -1174,7 +1197,7 @@
|
|||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
(define-key custom-bindings-map (kbd "C-'") 'er/expand-region)
|
||||||
(define-key custom-bindings-map (kbd "C-;") 'er/contract-region)
|
(define-key custom-bindings-map (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]].
|
||||||
@ -1228,8 +1251,11 @@
|
|||||||
Bind the functions defined [[sec:defuns][above]].
|
Bind the functions defined [[sec:defuns][above]].
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(define-key global-map (kbd "M-p") 'jump-to-previous-like-this)
|
||||||
|
(define-key global-map (kbd "M-n") 'jump-to-next-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
(define-key custom-bindings-map (kbd "M-,") 'jump-to-previous-like-this)
|
||||||
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
(define-key custom-bindings-map (kbd "M-.") 'jump-to-next-like-this)
|
||||||
|
(define-key custom-bindings-map (kbd "C-c .") (cycle-themes))
|
||||||
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
(define-key custom-bindings-map (kbd "C-x k") 'kill-this-buffer-unless-scratch)
|
||||||
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
(define-key custom-bindings-map (kbd "C-x t") 'toggle-shell)
|
||||||
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
(define-key custom-bindings-map (kbd "C-c j") 'cycle-spacing-delete-newlines)
|
||||||
|
Loading…
Reference in New Issue
Block a user