summaryrefslogtreecommitdiffstats
path: root/.emacs.d/init.org
blob: d46e7223e56d83171b80f04447610f250307f5ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#+TITLE: Emacs init
#+STYLE: <link href="http://ryuslash.ninth.su/test2.css" rel="stylesheet">
#+OPTIONS: author:nil
#+STARTUP: showall
#+LINK: yoshi-theme http://ryuslash.org/projects/yoshi-theme.html

* Emacs init

  Before doing anything else I should make sure that both the
  directories ~/usr/local/emacs/share/emacs/site-lisp~ and
  ~/usr/share/emacs/site-list~ are included in =load-path=, along with
  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 :tangle init2.el
    (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

  Add my project [[yoshi-theme]] to =custom-theme-load-path= and load it.

  #+BEGIN_SRC emacs-lisp :tangle init2.el
    (add-to-list 'custom-theme-load-path "~/projects/emacs/yoshi-theme/")
    (load-theme 'yoshi t)
  #+END_SRC

  Remove the ~menu-bar~, ~tool-bar~ and ~scroll-bar~ from the UI since I
  don't use them at all.

  #+BEGIN_SRC emacs-lisp :tangle init2.el
    (menu-bar-mode -1)
    (scroll-bar-mode -1)
    (tool-bar-mode -1)
  #+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 :tangle init2.el
    (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"))
  #+END_SRC

  Don't ask ~yes~ or ~no~, ask ~y~ or ~n~, I've never had an accidental ~y~ so
  far.

  #+BEGIN_SRC emacs-lisp :tangle init2.el
    (defalias 'yes-or-no-p 'y-or-n-p)
  #+END_SRC

  Use =ibuffer= instead of the default =list-buffers= because it has many
  more features.

  #+BEGIN_SRC emacs-lisp :tangle init2.el
    (defalias 'list-buffers 'ibuffer)
  #+END_SRC

  Do the same with =hippie-expand= and =dabbrev-expand=.

  #+BEGIN_SRC emacs-lisp :tangle init2.el
    (defalias 'dabbrev-expand 'hippie-expand)
  #+END_SRC

  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 :tangle init2.el
    (eval-after-load "eldoc" '(diminish 'eldoc-mode))
  #+END_SRC