emacs/Makefile, emacs/eshell-init.el, emacs/init.el

This commit is contained in:
Tom Willemsen 2012-08-19 00:26:15 +02:00
parent c93b49d167
commit c2efea9e6b
3 changed files with 137 additions and 87 deletions

View file

@ -1,13 +1,13 @@
EMACS = emacs EMACS = emacs
files = init.el init.elc files = init.el init.elc eshell-init.el eshell-init.elc
install-files = $(addprefix install-,$(files)) install-files = $(addprefix install-,$(files)) install-loaddefs.el
submodules = eshell submodules = eshell
install-submodules = $(addprefix install-,$(submodules)) install-submodules = $(addprefix install-,$(submodules))
.PHONY: all $(submodules) install $(install-submodules) $(install-files) .PHONY: all $(submodules) install $(install-submodules) $(install-files)
all: $(files) $(submodules) all: loaddefs.el $(files) $(submodules)
$(submodules): $(submodules):
$(MAKE) -C $@/ $(MAKE) -C $@/
@ -15,9 +15,13 @@ $(submodules):
$(filter %.elc,$(files)): %.elc: %.el $(filter %.elc,$(files)): %.elc: %.el
$(EMACS) -batch -eval "(byte-compile-file \"$^\")" $(EMACS) -batch -eval "(byte-compile-file \"$^\")"
loaddefs.el: $(files)
$(EMACS) -batch -eval "(let ((generated-autoload-file \"${CURDIR}/loaddefs.el\")) \
(update-directory-autoloads \"${CURDIR}\"))"
install: $(install-files) $(install-submodules) install: $(install-files) $(install-submodules)
$(install-files): install-%: $(install-files): install-%: $*
install -Dm 444 $* ${HOME}/.emacs.d/$* install -Dm 444 $* ${HOME}/.emacs.d/$*
$(install-submodules): install-%: $(install-submodules): install-%:

63
emacs/eshell-init.el Normal file
View file

@ -0,0 +1,63 @@
;; Eshell settings
(eval-when-compile
'(load "init.el"))
(eval-after-load "em-term"
'(add-to-list 'eshell-visual-commands
"unison"))
(defun oni:eshell-mode-func ()
"Function for `eshell-mode-hook'."
(setq truncate-lines nil))
(defun oni:eshell-prompt-function ()
(let ((status (if (zerop eshell-last-command-status) ?+ ?-))
(hostname (shell-command-to-string "hostname"))
(dir (abbreviate-file-name (eshell/pwd)))
(branch
(shell-command-to-string
"git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))
(userstatus (if (zerop (user-uid)) ?# ?$)))
(concat
(propertize (char-to-string status)
'face `(:foreground ,(if (= status ?+)
(oni:color chameleon-1)
(oni:color scarlet-red-2))))
" "
(propertize (substring hostname 0 -1) 'face 'mode-line-buffer-id)
" "
(propertize (oni:shorten-dir dir) 'face 'font-lock-string-face)
" "
(propertize (when (not (string= branch ""))
;; Cut off "* " and "\n"
(substring branch 2 -1))
'face 'font-lock-function-name-face)
" \n"
(propertize (char-to-string userstatus)
'face `(:foreground ,(oni:color sky-blue-1)))
"> ")))
;;;###autoload
(defun oni:raise-eshell ()
"Start or switch back to `eshell'. Also change directories to
current working directory."
(interactive)
(let ((dir (file-name-directory
(or (buffer-file-name) "~/")))
(hasfile (not (eq (buffer-file-name) nil))))
(eshell)
(if (and hasfile (eq eshell-process-list nil))
(progn
(eshell/cd dir)
(eshell-reset)))))
(defun oni:shorten-dir (dir)
"Shorten a directory, (almost) like fish does it."
(while (string-match "\\(/\\.?.\\)[^/]+/" dir)
(setq dir (replace-match "\\1/" nil nil dir)))
dir)
(setq eshell-prompt-regexp "^[#$]> ")
(setq eshell-highlight-prompt nil)
(setq eshell-prompt-function 'oni:eshell-prompt-function)
(add-hook 'eshell-mode-hook 'oni:eshell-mode-func)

View file

@ -5,17 +5,52 @@
(add-to-list 'load-path directory) (add-to-list 'load-path directory)
(let ((default-directory directory)) (let ((default-directory directory))
(normal-top-level-add-subdirs-to-load-path))) (normal-top-level-add-subdirs-to-load-path)))
'("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp"))) '("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp"))
(add-to-list 'load-path "~/.emacs.d/"))
(eval-when-compile (eval-when-compile
(require 'appt)
(require 'browse-url)
(require 'em-dirs)
(require 'em-prompt)
(require 'emms-source-file)
(require 'erc-join)
(require 'erc-stamp)
(require 'fill-column-indicator)
(require 'geiser-repl)
(require 'gtags)
(require 'hideshow)
(require 'jabber)
(require 'message)
(require 'mu4e)
(require 'org-capture)
(require 'org-contacts) (require 'org-contacts)
(require 'sauron)) (require 'org-feed)
(require 'org-html)
(require 'php-mode)
(require 'rainbow-delimiters)
(require 'sauron)
(require 'sendmail)
(require 'smex)
(require 'time-stamp)
(require 'whitespace)
(require 'yasnippet))
(autoload 'identica-mode "identica-mode" nil t) (autoload 'identica-mode "identica-mode" nil t)
(autoload 'mu4e "mu4e" nil t) (autoload 'mu4e "mu4e" nil t)
(autoload 'naquadah-get-colors "naquadah-theme")
(load (expand-file-name "~/.emacs.d/site-lisp/loaddefs.el"))
(load (expand-file-name "~/.emacs.d/loaddefs.el"))
(defalias 'yes-or-no-p 'y-or-n-p) (defalias 'yes-or-no-p 'y-or-n-p)
(defconst oni:c-outline-regex
(eval-when-compile
(concat
"\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)"
"\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$"))
"Regex for `outline-minor-mode' for `c-mode'.")
(defmacro oni:define-mailbox (name email &optional signature longname) (defmacro oni:define-mailbox (name email &optional signature longname)
"Define a mailbox function." "Define a mailbox function."
`(defun ,(make-symbol (concat "oni:" name "-mailbox")) () `(defun ,(make-symbol (concat "oni:" name "-mailbox")) ()
@ -38,6 +73,25 @@
(hide-body) (hide-body)
(local-set-key [C-tab] 'outline-toggle-children))) (local-set-key [C-tab] 'outline-toggle-children)))
(defmacro oni:color (name)
`(naquadah-get-colors (quote ,name)))
(defvar oni:mailbox-map
'("top" ("menu"
("ryulash.org" . "ryuslash")
("ninthfloor" . "ninthfloor")
("gmail" . "gmail")
("aethon" . "aethon")))
"A mailbox map for use with `tmm-prompt'.")
(defvar oni:required-packages
'(graphviz-dot-mode htmlize magit rainbow-delimiters
rainbow-mode yasnippet markdown-mode flymake
flymake-cursor pony-mode sauron dispass
expand-region fill-column-indicator
git-auto-commit-mode idomenu magit smex)
"List of all the packages I have (want) installed")
(defun oni:after-save-func () (defun oni:after-save-func ()
"Function for `after-save-hook'." "Function for `after-save-hook'."
(oni:compile-el) (oni:compile-el)
@ -147,21 +201,8 @@ for easy selection."
(funcall (intern (concat "oni:" inbox "-mailbox"))) (funcall (intern (concat "oni:" inbox "-mailbox")))
(mu4e))))) (mu4e)))))
(defvar oni:mailbox-map (eval-after-load "info"
'("top" ("menu" '(require 'info+))
("ryulash.org" . "ryuslash")
("ninthfloor" . "ninthfloor")
("gmail" . "gmail")
("aethon" . "aethon")))
"A mailbox map for use with `tmm-prompt'.")
(defvar oni:required-packages
'(graphviz-dot-mode htmlize magit rainbow-delimiters
rainbow-mode yasnippet markdown-mode flymake
flymake-cursor pony-mode sauron dispass
expand-region fill-column-indicator
git-auto-commit-mode idomenu magit smex)
"List of all the packages I have (want) installed")
(eval-after-load "mu4e" (eval-after-load "mu4e"
'(add-to-list '(add-to-list
@ -193,7 +234,6 @@ for easy selection."
(setq jabber-chatstates-confirm nil) (setq jabber-chatstates-confirm nil)
(setq jabber-history-dir "~/.emacs.d/jabber") (setq jabber-history-dir "~/.emacs.d/jabber")
(setq jabber-roster-show-bindings nil) (setq jabber-roster-show-bindings nil)
(setq jabber-roster-show-offline-contacts nil)
(setq mail-header-separator "") (setq mail-header-separator "")
(setq mu4e-headers-date-format "%d-%m %H:%M") (setq mu4e-headers-date-format "%d-%m %H:%M")
(setq mu4e-headers-fields '((:date . 11) (setq mu4e-headers-fields '((:date . 11)
@ -227,6 +267,7 @@ for easy selection."
(add-hook 'prog-mode-hook 'oni:prog-mode-func) (add-hook 'prog-mode-hook 'oni:prog-mode-func)
(global-set-key (kbd "<f6>") 'jabber-switch-to-roster-buffer) (global-set-key (kbd "<f6>") 'jabber-switch-to-roster-buffer)
(global-set-key (kbd "<f8>") 'oni:raise-eshell)
(global-set-key (kbd "M-n") 'idomenu) (global-set-key (kbd "M-n") 'idomenu)
(unless (oni:required-packages-installed-p) (unless (oni:required-packages-installed-p)
@ -238,13 +279,6 @@ for easy selection."
(package-install package))) (package-install package)))
oni:required-packages)) oni:required-packages))
(defconst oni:c-outline-regex
(eval-when-compile
(concat
"\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)"
"\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$"))
"Regex for `outline-minor-mode' for `c-mode'.")
(defun oni:c-mode-func () (defun oni:c-mode-func ()
"Function for `c-mode-hook'." "Function for `c-mode-hook'."
(local-set-key [f9] 'compile) (local-set-key [f9] 'compile)
@ -550,58 +584,6 @@ for easy selection."
(setq erc-hide-list '("JOIN" "PART" "QUIT")) (setq erc-hide-list '("JOIN" "PART" "QUIT"))
(defun oni:eshell-mode-func ()
"Function for `eshell-mode-hook'."
(setq truncate-lines nil))
(add-hook 'eshell-mode-hook 'oni:eshell-mode-func)
(require 'cl)
(defun oni:shorten-dir (dir)
"Shorten a directory, (almost) like fish does it."
(let ((scount (1- (count ?/ dir))))
(dotimes (i scount)
(string-match "\\(/\\.?.\\)[^/]+" dir)
(setq dir (replace-match "\\1" nil nil dir))))
dir)
(defun oni:eshell-prompt-function ()
(let ((status (if (zerop eshell-last-command-status) ?+ ?-))
(hostname (shell-command-to-string "hostname"))
(dir (abbreviate-file-name (eshell/pwd)))
(branch
(shell-command-to-string
"git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))
(userstatus (if (zerop (user-uid)) ?# ?$)))
(format "%c%s:%s@%s %c "
status
(substring hostname 0 -1)
(oni:shorten-dir dir)
(when (not (string= branch ""))
(substring branch 2 -1))
userstatus)))
(setq eshell-prompt-function 'oni:eshell-prompt-function)
(defun oni:raise-eshell ()
"Start or switch back to `eshell'. Also change directories to
current working directory."
(interactive)
(let ((dir (file-name-directory
(or (buffer-file-name) "~/")))
(hasfile (not (eq (buffer-file-name) nil))))
(eshell)
(if (and hasfile (eq eshell-process-list nil))
(progn
(eshell/cd dir)
(eshell-reset)))))
(global-set-key [f8] 'oni:raise-eshell)
(eval-after-load "em-term"
'(add-to-list 'eshell-visual-commands
"unison"))
(defun oni:flymake-mode-func () (defun oni:flymake-mode-func ()
"Function for `flymake-mode-hook'." "Function for `flymake-mode-hook'."
(local-set-key [M-P] 'flymake-goto-prev-error) (local-set-key [M-P] 'flymake-goto-prev-error)
@ -1008,9 +990,6 @@ its major mode."
(setq message-log-max 1000) (setq message-log-max 1000)
(setq org-blog-directory "~/code/projects/orgweb/blog"
org-blog-unfinished-directory "~/documents/blog/drafts")
(setq org-contacts-files '("~/documents/org/misc/contacts.org")) (setq org-contacts-files '("~/documents/org/misc/contacts.org"))
(setq rainbow-delimiters-max-face-count 12) (setq rainbow-delimiters-max-face-count 12)
@ -1122,3 +1101,7 @@ its major mode."
(load custom-file) (load custom-file)
(load "rudel-loaddefs.el") (load "rudel-loaddefs.el")
(load (expand-file-name "~/quicklisp/slime-helper.el")) (load (expand-file-name "~/quicklisp/slime-helper.el"))
;; Local Variables:
;; no-update-autoloads: t
;; End: