From c2efea9e6bb44dde3d4dd559568b48a22407f14f Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 19 Aug 2012 00:26:15 +0200 Subject: [PATCH] emacs/Makefile, emacs/eshell-init.el, emacs/init.el --- emacs/Makefile | 12 ++-- emacs/eshell-init.el | 63 ++++++++++++++++++ emacs/init.el | 149 +++++++++++++++++++------------------------ 3 files changed, 137 insertions(+), 87 deletions(-) create mode 100644 emacs/eshell-init.el diff --git a/emacs/Makefile b/emacs/Makefile index 45151ef..6d986ef 100644 --- a/emacs/Makefile +++ b/emacs/Makefile @@ -1,13 +1,13 @@ EMACS = emacs -files = init.el init.elc -install-files = $(addprefix install-,$(files)) +files = init.el init.elc eshell-init.el eshell-init.elc +install-files = $(addprefix install-,$(files)) install-loaddefs.el submodules = eshell install-submodules = $(addprefix install-,$(submodules)) .PHONY: all $(submodules) install $(install-submodules) $(install-files) -all: $(files) $(submodules) +all: loaddefs.el $(files) $(submodules) $(submodules): $(MAKE) -C $@/ @@ -15,9 +15,13 @@ $(submodules): $(filter %.elc,$(files)): %.elc: %.el $(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-files): install-%: +$(install-files): install-%: $* install -Dm 444 $* ${HOME}/.emacs.d/$* $(install-submodules): install-%: diff --git a/emacs/eshell-init.el b/emacs/eshell-init.el new file mode 100644 index 0000000..1dd8773 --- /dev/null +++ b/emacs/eshell-init.el @@ -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) diff --git a/emacs/init.el b/emacs/init.el index 9dadf1c..3887354 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -2,20 +2,55 @@ (package-initialize) (mapc #'(lambda (directory) - (add-to-list 'load-path directory) - (let ((default-directory directory)) - (normal-top-level-add-subdirs-to-load-path))) - '("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp"))) + (add-to-list 'load-path directory) + (let ((default-directory directory)) + (normal-top-level-add-subdirs-to-load-path))) + '("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp")) + (add-to-list 'load-path "~/.emacs.d/")) (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 '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 '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) +(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) "Define a mailbox function." `(defun ,(make-symbol (concat "oni:" name "-mailbox")) () @@ -38,6 +73,25 @@ (hide-body) (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 () "Function for `after-save-hook'." (oni:compile-el) @@ -147,21 +201,8 @@ for easy selection." (funcall (intern (concat "oni:" inbox "-mailbox"))) (mu4e))))) -(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") +(eval-after-load "info" + '(require 'info+)) (eval-after-load "mu4e" '(add-to-list @@ -193,7 +234,6 @@ for easy selection." (setq jabber-chatstates-confirm nil) (setq jabber-history-dir "~/.emacs.d/jabber") (setq jabber-roster-show-bindings nil) -(setq jabber-roster-show-offline-contacts nil) (setq mail-header-separator "") (setq mu4e-headers-date-format "%d-%m %H:%M") (setq mu4e-headers-fields '((:date . 11) @@ -227,6 +267,7 @@ for easy selection." (add-hook 'prog-mode-hook 'oni:prog-mode-func) (global-set-key (kbd "") 'jabber-switch-to-roster-buffer) +(global-set-key (kbd "") 'oni:raise-eshell) (global-set-key (kbd "M-n") 'idomenu) (unless (oni:required-packages-installed-p) @@ -238,13 +279,6 @@ for easy selection." (package-install package))) 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 () "Function for `c-mode-hook'." (local-set-key [f9] 'compile) @@ -550,58 +584,6 @@ for easy selection." (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 () "Function for `flymake-mode-hook'." (local-set-key [M-P] 'flymake-goto-prev-error) @@ -1008,9 +990,6 @@ its major mode." (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 rainbow-delimiters-max-face-count 12) @@ -1122,3 +1101,7 @@ its major mode." (load custom-file) (load "rudel-loaddefs.el") (load (expand-file-name "~/quicklisp/slime-helper.el")) + +;; Local Variables: +;; no-update-autoloads: t +;; End: