Add enhanced eval-after-load
This commit is contained in:
parent
607cc269c5
commit
856660ebda
1 changed files with 102 additions and 66 deletions
114
emacs/init.org
114
emacs/init.org
|
@ -36,6 +36,37 @@
|
|||
"~/.emacs.d/vendor-lisp/org/contrib/lisp"))
|
||||
#+END_SRC
|
||||
|
||||
* Enhanced eval-after-load
|
||||
|
||||
[[http://lunaryorn.com/blog/2013/05/31/byte-compiling-eval-after-load/][This post]] has brought to my attention that =eval-after-load= does not
|
||||
byte compile its contents. It makes sense, but I'd never thought
|
||||
about it before.
|
||||
|
||||
It offers a better wrapper around it that should speed things up.
|
||||
|
||||
I've modified it a little to suit my stylistic preferences.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defmacro stante-after (feature &rest forms)
|
||||
"After FEATURE is loaded, evaluate FORMS.
|
||||
|
||||
FEATURE may be an unquoted feature symbol or a file name, see
|
||||
`eval-after-load'."
|
||||
(declare (indent 1) (debug t))
|
||||
;; Byte compile the body. If the feature is not available, ignore
|
||||
;; warnings. Taken from
|
||||
;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2012-11/msg01262.html
|
||||
(let ((loaded (if (symbolp feature)
|
||||
(require feature nil :no-error)
|
||||
(load feature :no-error :no-message))))
|
||||
`(,(if loaded
|
||||
'progn
|
||||
(message "stante-after: cannot find %s" feature)
|
||||
'with-no-warnings)
|
||||
(eval-after-load ',feature
|
||||
`(funcall (function ,(lambda () ,@forms)))))))
|
||||
#+END_SRC
|
||||
|
||||
* Load other functions
|
||||
|
||||
Including all the functions being used here would make this file
|
||||
|
@ -296,10 +327,9 @@
|
|||
has been loaded.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load "flycheck"
|
||||
'(progn
|
||||
(stante-after flycheck
|
||||
(mapc (lambda (c) (delq c flycheck-checkers))
|
||||
'(python-pylint python-pyflakes))))
|
||||
'(python-pylint python-pyflakes)))
|
||||
#+END_SRC
|
||||
|
||||
* Make ^L look pretty :ppcL:
|
||||
|
@ -395,8 +425,8 @@
|
|||
module loads.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load "em-term"
|
||||
'(add-to-list 'eshell-visual-commands "unison"))
|
||||
(stante-after em-term
|
||||
(add-to-list 'eshell-visual-commands "unison"))
|
||||
#+END_SRC
|
||||
|
||||
* Disable prompt highlighting in eshell :eshell:
|
||||
|
@ -537,8 +567,8 @@
|
|||
only run it after that module has been loaded.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load "jabber"
|
||||
'(remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo))
|
||||
(stante-after jabber
|
||||
(remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo))
|
||||
#+END_SRC
|
||||
|
||||
* Use libnotify for jabber notifications :jabber:
|
||||
|
@ -630,21 +660,12 @@
|
|||
execution until it is loaded.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun oni:ido-init ()
|
||||
"Initialization functionn for ido."
|
||||
(stante-after ido
|
||||
(setq ido-ignore-buffers
|
||||
(list "^\\` " "^irc\\." "^\\#" "^\\*Customize Option:"
|
||||
(eval-when-compile
|
||||
(regexp-opt
|
||||
'("*-jabber-roster-*"
|
||||
"*Messages*"
|
||||
"*fsm-debug*"
|
||||
"*magit-process*"
|
||||
"*magit-edit-log*"
|
||||
"*Backtrace*"
|
||||
"*Ibuffer*"))))))
|
||||
|
||||
(eval-after-load "ido" '(oni:ido-init))
|
||||
(rx (or "*-jabber-roster-*" "*Messages*" "*fsm-debug*"
|
||||
"*magit-process*" "*magit-edit-log*" "*Backtrace*"
|
||||
"*Ibuffer*")))))
|
||||
#+END_SRC
|
||||
|
||||
* Disable automatic merging in ido :ido:
|
||||
|
@ -759,7 +780,7 @@
|
|||
run =jedi:setup= when =python-mode= starts to enable it.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load "jedi" '(setcar jedi:server-command "python2"))
|
||||
(stante-after jedi (setcar jedi:server-command "python2"))
|
||||
(add-hook 'python-mode-hook 'jedi:setup)
|
||||
#+END_SRC
|
||||
|
||||
|
@ -1299,8 +1320,7 @@
|
|||
absolute file names into something nicer.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load "emms"
|
||||
`(progn
|
||||
(stante-after emms
|
||||
(emms-minimalistic)
|
||||
(emms-default-players)
|
||||
|
||||
|
@ -1310,7 +1330,7 @@
|
|||
|
||||
(require 'emms-mode-line)
|
||||
(setq emms-mode-line-mode-line-function 'oni:mode-line-current-song)
|
||||
(emms-mode-line 1)))
|
||||
(emms-mode-line 1))
|
||||
#+END_SRC
|
||||
|
||||
* Enable some smartparen keybindings in python :smartparens:python:
|
||||
|
@ -1382,7 +1402,9 @@
|
|||
(setq eap-playlist-library "~/music/playlists")
|
||||
#+END_SRC
|
||||
|
||||
* Don't close some more buffers :desktop:
|
||||
* Desktop :desktop:
|
||||
|
||||
** Don't close some more buffers
|
||||
|
||||
Add some regular expressions to the "don't kill" list of the ~desktop~
|
||||
module.
|
||||
|
@ -1396,30 +1418,44 @@
|
|||
|
||||
- Don't close the IELM buffer.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load 'desktop
|
||||
'(setq desktop-clear-preserve-buffers
|
||||
(append '("^++.*" "^dailies$" "^bookmarks.org$" "^contacts.org$"
|
||||
"^work$" "^tasks$" "\\*ielm\\*" "\\*magit.*\\*"
|
||||
"\\*-jabber-roster-\\*" "\\*scratch-.*\\*"
|
||||
"\\*eshell\\*")
|
||||
desktop-clear-preserve-buffers)))
|
||||
#+NAME: desktop-dont-clear
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(setq desktop-clear-preserve-buffers
|
||||
(append (list (rx (and bol (or (and "+" (1+ anything))
|
||||
"dailies" "work" "tasks"
|
||||
(or "bookmarks.org"
|
||||
"contacts.org")) eol))
|
||||
(rx (or "*ielm*" "*-jabber-roster-*" "*eshell*"))
|
||||
(rx (and "*" (or "magit" "scratch-") (1+ anything)
|
||||
"*")))
|
||||
desktop-clear-preserve-buffers))
|
||||
#+END_SRC
|
||||
|
||||
* Don't save some more buffers :desktop:
|
||||
** Don't save some more buffers
|
||||
|
||||
Add some regular expressions to the "don't save" list of the ~desktop~
|
||||
module.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(eval-after-load 'desktop
|
||||
'(setq desktop-files-not-to-save
|
||||
#+NAME: desktop-dont-save
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(setq desktop-files-not-to-save
|
||||
(rx (or (regexp "\\(^/[^/:]*:\\|(ftp)$\\)")
|
||||
(and "/" (or "dailies" "tasks" "bookmarks.org"
|
||||
"contacts.org" "work") eol)))))
|
||||
"contacts.org" "work") eol))))
|
||||
#+END_SRC
|
||||
|
||||
* Add some desktop keybindings :desktop:
|
||||
** Putting it together
|
||||
|
||||
Put it in a =stante-after= call so they only evaluate after ~desktop~
|
||||
has been loaded.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :noweb no-export
|
||||
(stante-after desktop
|
||||
<<desktop-dont-clear>>
|
||||
<<desktop-dont-save>>)
|
||||
#+END_SRC
|
||||
|
||||
** Add some desktop keybindings
|
||||
|
||||
As seen [[http://ericjmritz.wordpress.com/2013/05/28/emacs-desktops/][here]].
|
||||
|
||||
|
|
Loading…
Reference in a new issue