Emacs: Rewrite part of index.org

This commit is contained in:
Tom Willemsen 2013-03-22 13:34:32 +01:00
parent a5c9f6c9c3
commit 9da019d7e8

View file

@ -4,45 +4,30 @@
#+PROPERTY: tangle init2.el #+PROPERTY: tangle init2.el
#+STARTUP: showall #+STARTUP: showall
* GUI Disable the ~menu-bar-mode~, ~tool-bar-mode~ and ~scroll-bar-mode~ early on
so the disappear quickly after emacs starts up.
These things should happen early, so that Emacs will look the way I
want it to as quickly as is possible.
** menu-bar-mode
Disable =menu-bar-mode= since I haven't used the menu bar much ever,
even when I first started using Emacs.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(menu-bar-mode -1) (menu-bar-mode -1)
#+END_SRC
** scroll-bar-mode
Since Emacs gives a pretty good indication of where in the buffer
I'm working I really don't need to have the scroll bar visible.
#+BEGIN_SRC emacs-lisp
(scroll-bar-mode -1) (scroll-bar-mode -1)
#+END_SRC
** tool-bar-mode
I've never used the tool bar much, so remove it.
#+BEGIN_SRC emacs-lisp
(tool-bar-mode -1) (tool-bar-mode -1)
#+END_SRC #+END_SRC
* load-path Define a macro for deferring code until after emacs has started up.
Before doing anything else I should make sure that both the #+BEGIN_SRC emacs-lisp
directories ~/usr/local/emacs/share/emacs/site-lisp~ and (defmacro eval-after-init (&rest body)
~/usr/share/emacs/site-list~ are included in =load-path=, along with "Defer execution of BODY until after Emacs init."
their subdirectories, but only if they haven't already been added `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
and exist. Place them at the end of =load-path= so they don't mess up #+END_SRC
package precedence.
Add ~/usr/share/emacs/site-lisp~ and
~/usr/local/emacs/share/emacs/site-lisp~ and all their sub-directories
to the ~load-path~ so I can use modules from both Emacs from the
official repository *and* the self-compiled one.
This should be done both when compiling the elisp file and when
loading it so it doesn't complain about missing modules and such.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(eval-and-compile (eval-and-compile
@ -57,16 +42,17 @@
(oni:path-init "/usr/local/emacs/share/emacs/site-lisp")) (oni:path-init "/usr/local/emacs/share/emacs/site-lisp"))
#+END_SRC #+END_SRC
Load my preferred theme after emacs has finished starting up. Use Defer loading my theme until after emacs initialization. This is
the ~emacs-startup-hook~ to wait until we're sure all ELPA packages because it has been installed with ~package.el~, and the packages aren't
have been loaded. added to the ~load-path~ until _after_ ~init.el~ has been run through.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook 'emacs-startup-hook (lambda () (load-theme 'yoshi t))) (eval-after-init (load-theme 'yoshi t))
#+END_SRC #+END_SRC
Add any other interesting paths to =load-path= and, if it exists, Add some of my project directories and other important directories
load the ~loaddefs.el~ file from these directories. into ~load-path~ so I can easily load libraries in them. Also, if it
exists, load ~loaddefs.el~ in each directory for autoloads.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(mapc #'(lambda (dir) (mapc #'(lambda (dir)
@ -79,88 +65,24 @@
"/usr/local/org-mode/share/emacs/site-lisp/org")) "/usr/local/org-mode/share/emacs/site-lisp/org"))
#+END_SRC #+END_SRC
* y-or-n-p Replace the question of ~yes~ or ~no~ with just ~y~ or ~n~, I have never (yet)
accidentally typed a ~y~ or ~n~ when asked and typing ~yes~ or ~no~ is just
Don't ask ~yes~ or ~no~, ask ~y~ or ~n~, I've never had an accidental ~y~ so too much work.
far.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p) (defalias 'yes-or-no-p 'y-or-n-p)
#+END_SRC #+END_SRC
* ibuffer Replace these functions with better alternatives. They offer the same
functionality, plus more.
Use =ibuffer= instead of the default =list-buffers= because it has many
more features.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defalias 'list-buffers 'ibuffer) (defalias 'list-buffers 'ibuffer)
#+END_SRC
* hippie-expand
Do the same with =hippie-expand= and =dabbrev-expand=.
#+BEGIN_SRC emacs-lisp
(defalias 'dabbrev-expand 'hippie-expand) (defalias 'dabbrev-expand 'hippie-expand)
#+END_SRC #+END_SRC
* eldoc
Don't show it when ~eldoc~ is running, I almost assume that it is
whenever I'm working in a mode that supports it anyway. This should
only execute once ~eldoc~ has been loaded.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(eval-after-load "eldoc" '(diminish 'eldoc-mode)) (setq compilation-scroll-output t)
#+END_SRC
* emms
Use the standard EMMS configuration and add some MPD settings.
#+BEGIN_SRC emacs-lisp
(defun oni:emms-init ()
"Initialization function for EMMS."
(require 'emms-setup)
(require 'emms-player-mpd)
(emms-standard)
(add-to-list 'emms-info-functions 'emms-info-mpd)
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-server-name "localhost")
(setq emms-player-mpd-server-port "6600")
(setq emms-player-mpd-music-directory "/mnt/music/mp3"))
(eval-after-load "emms-source-file" '(oni:emms-init))
(setq emms-source-file-default-directory "/mnt/music/")
#+END_SRC
Add some keybindings for EMMS.
#+BEGIN_SRC emacs-lisp
(defun oni:emms-toggle-playing ()
"Toggle between playing/paused states."
(interactive)
(if (eq emms-player-playing-p nil)
(emms-start)
(emms-pause)))
(defun oni:start-emms ()
"Check to see if the function `emms' exists, if not call
`emms-player-mpd-connect' and assume that will have loaded it."
(interactive)
(unless (fboundp 'emms)
(emms-player-mpd-connect))
(emms))
(global-set-key (kbd "<XF86AudioNext>") 'emms-next)
(global-set-key (kbd "<XF86AudioPlay>") 'oni:emms-toggle-playing)
(global-set-key (kbd "<XF86AudioPrev>") 'emms-previous)
(global-set-key (kbd "<XF86AudioStop>") 'emms-stop)
(global-set-key (kbd "<XF86Tools>") 'oni:start-emms)
#+END_SRC #+END_SRC
* flymake * flymake