Emacs: Rewrite part of index.org
This commit is contained in:
parent
a5c9f6c9c3
commit
9da019d7e8
1 changed files with 65 additions and 143 deletions
208
emacs/init.org
208
emacs/init.org
|
@ -4,164 +4,86 @@
|
||||||
#+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
|
#+BEGIN_SRC emacs-lisp
|
||||||
want it to as quickly as is possible.
|
(menu-bar-mode -1)
|
||||||
|
(scroll-bar-mode -1)
|
||||||
|
(tool-bar-mode -1)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** menu-bar-mode
|
Define a macro for deferring code until after emacs has started up.
|
||||||
|
|
||||||
Disable =menu-bar-mode= since I haven't used the menu bar much ever,
|
#+BEGIN_SRC emacs-lisp
|
||||||
even when I first started using Emacs.
|
(defmacro eval-after-init (&rest body)
|
||||||
|
"Defer execution of BODY until after Emacs init."
|
||||||
|
`(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
Add ~/usr/share/emacs/site-lisp~ and
|
||||||
(menu-bar-mode -1)
|
~/usr/local/emacs/share/emacs/site-lisp~ and all their sub-directories
|
||||||
#+END_SRC
|
to the ~load-path~ so I can use modules from both Emacs from the
|
||||||
|
official repository *and* the self-compiled one.
|
||||||
|
|
||||||
** scroll-bar-mode
|
This should be done both when compiling the elisp file and when
|
||||||
|
loading it so it doesn't complain about missing modules and such.
|
||||||
|
|
||||||
Since Emacs gives a pretty good indication of where in the buffer
|
#+BEGIN_SRC emacs-lisp
|
||||||
I'm working I really don't need to have the scroll bar visible.
|
(eval-and-compile
|
||||||
|
(defun oni:path-init (dir)
|
||||||
|
"Add DIR to `load-path' and all its subdirectories, unless
|
||||||
|
DIR is already in `load-path'."
|
||||||
|
(unless (or (member dir load-path) (not (file-exists-p dir)))
|
||||||
|
(let ((default-directory dir))
|
||||||
|
(add-to-list 'load-path dir t)
|
||||||
|
(normal-top-level-add-subdirs-to-load-path))))
|
||||||
|
(oni:path-init "/usr/share/emacs/site-lisp")
|
||||||
|
(oni:path-init "/usr/local/emacs/share/emacs/site-lisp"))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
Defer loading my theme until after emacs initialization. This is
|
||||||
(scroll-bar-mode -1)
|
because it has been installed with ~package.el~, and the packages aren't
|
||||||
#+END_SRC
|
added to the ~load-path~ until _after_ ~init.el~ has been run through.
|
||||||
|
|
||||||
** tool-bar-mode
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(eval-after-init (load-theme 'yoshi t))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
I've never used the tool bar much, so remove it.
|
Add some of my project directories and other important 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
|
||||||
(tool-bar-mode -1)
|
(mapc #'(lambda (dir)
|
||||||
#+END_SRC
|
(add-to-list 'load-path dir)
|
||||||
|
(let ((loaddefs (concat dir "/loaddefs.el")))
|
||||||
|
(when (file-exists-p loaddefs)
|
||||||
|
(load loaddefs))))
|
||||||
|
'("~/projects/emacs/mode-icons" "~/.emacs.d/site-lisp"
|
||||||
|
"~/projects/emacs/pony-mode/src" "~/projects/emacs/php-mode"
|
||||||
|
"/usr/local/org-mode/share/emacs/site-lisp/org"))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
* load-path
|
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
|
||||||
|
too much work.
|
||||||
|
|
||||||
Before doing anything else I should make sure that both the
|
#+BEGIN_SRC emacs-lisp
|
||||||
directories ~/usr/local/emacs/share/emacs/site-lisp~ and
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
~/usr/share/emacs/site-list~ are included in =load-path=, along with
|
#+END_SRC
|
||||||
their subdirectories, but only if they haven't already been added
|
|
||||||
and exist. Place them at the end of =load-path= so they don't mess up
|
|
||||||
package precedence.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
Replace these functions with better alternatives. They offer the same
|
||||||
(eval-and-compile
|
functionality, plus more.
|
||||||
(defun oni:path-init (dir)
|
|
||||||
"Add DIR to `load-path' and all its subdirectories, unless
|
|
||||||
DIR is already in `load-path'."
|
|
||||||
(unless (or (member dir load-path) (not (file-exists-p dir)))
|
|
||||||
(let ((default-directory dir))
|
|
||||||
(add-to-list 'load-path dir t)
|
|
||||||
(normal-top-level-add-subdirs-to-load-path))))
|
|
||||||
(oni:path-init "/usr/share/emacs/site-lisp")
|
|
||||||
(oni:path-init "/usr/local/emacs/share/emacs/site-lisp"))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Load my preferred theme after emacs has finished starting up. Use
|
#+BEGIN_SRC emacs-lisp
|
||||||
the ~emacs-startup-hook~ to wait until we're sure all ELPA packages
|
(defalias 'list-buffers 'ibuffer)
|
||||||
have been loaded.
|
(defalias 'dabbrev-expand 'hippie-expand)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(add-hook 'emacs-startup-hook (lambda () (load-theme 'yoshi t)))
|
(setq compilation-scroll-output t)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Add any other interesting paths to =load-path= and, if it exists,
|
|
||||||
load the ~loaddefs.el~ file from these directories.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(mapc #'(lambda (dir)
|
|
||||||
(add-to-list 'load-path dir)
|
|
||||||
(let ((loaddefs (concat dir "/loaddefs.el")))
|
|
||||||
(when (file-exists-p loaddefs)
|
|
||||||
(load loaddefs))))
|
|
||||||
'("~/projects/emacs/mode-icons" "~/.emacs.d/site-lisp"
|
|
||||||
"~/projects/emacs/pony-mode/src" "~/projects/emacs/php-mode"
|
|
||||||
"/usr/local/org-mode/share/emacs/site-lisp/org"))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* y-or-n-p
|
|
||||||
|
|
||||||
Don't ask ~yes~ or ~no~, ask ~y~ or ~n~, I've never had an accidental ~y~ so
|
|
||||||
far.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* ibuffer
|
|
||||||
|
|
||||||
Use =ibuffer= instead of the default =list-buffers= because it has many
|
|
||||||
more features.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(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)
|
|
||||||
#+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
|
|
||||||
(eval-after-load "eldoc" '(diminish 'eldoc-mode))
|
|
||||||
#+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
|
|
||||||
|
|
||||||
* flymake
|
* flymake
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue