summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-07-08 12:38:23 +0200
committerGravatar Tom Willemse2015-07-08 12:38:23 +0200
commitf54d8a59305b6c628456c8ba8eb2459213c517d5 (patch)
tree8575ceef85204c53331d3c4db1b3fd6e9e55b37c
parente390a5dae43ed9472da8a66ce3d780fafdf57434 (diff)
downloaddotfiles-f54d8a59305b6c628456c8ba8eb2459213c517d5.tar.gz
dotfiles-f54d8a59305b6c628456c8ba8eb2459213c517d5.zip
Move my eshell prompt to separate module
To help with autoloading, also update the Makefile to create a `site-lisp/site-autoloads.el' file which is loaded by emacs.
-rw-r--r--emacs/.emacs.d/Makefile27
-rw-r--r--emacs/.emacs.d/init.el18
-rw-r--r--emacs/.emacs.d/site-lisp/oni-eshell-prompt.el55
3 files changed, 80 insertions, 20 deletions
diff --git a/emacs/.emacs.d/Makefile b/emacs/.emacs.d/Makefile
index 687f646..b0701fb 100644
--- a/emacs/.emacs.d/Makefile
+++ b/emacs/.emacs.d/Makefile
@@ -1,7 +1,10 @@
-.PHONY: all site-lisp
-all: init2.elc init.elc site-lisp/oni-smt.elc site-lisp/appt-init.elc \
+SITE_LISPS = site-lisp/oni-smt.elc site-lisp/appt-init.elc \
site-lisp/jabber-init.elc site-lisp/org-init.elc \
- site-lisp/gnus-init.elc site-lisp/drd.elc
+ site-lisp/gnus-init.elc site-lisp/drd.elc \
+ site-lisp/oni-eshell-prompt.elc
+
+.PHONY: all site-lisp
+all: init2.elc init.elc $(SITE_LISPS) site-lisp/site-autoloads.el
%.elc: %.el
@echo "ELC $<"
@@ -12,15 +15,29 @@ init2.el: init.org org/intro.org
@echo "OBT $<"
@emacs -Q -batch -l "ob-tangle" -eval "(org-babel-tangle-file \"init.org\")"
+site-lisp/site-autoloads.el: $(SITE_LISPS)
+ @echo "GEN $@"
+ @cask exec emacs -Q -batch \
+ -eval "(setq generated-autoload-file \"$(CURDIR)/$@\")" \
+ -eval "(update-directory-autoloads \"$(CURDIR)/site-lisp/\")"
+
rudel:
git clone git://github.com/scymtym/rudel.git packages/rudel
emacs -Q --batch --visit packages/rudel/rudel-compile.el \
--eval "(eval-buffel)"
-clean:
+clean-byte-compiled:
+ rm -f $(SITE_LISPS) init2.elc init.elc
+
+clean-autoloads:
+ rm -f site-lisp/site-autoloads.el init2.el
+
+clean-export:
rm -rf _publish/*.*
-export: clean
+clean: clean-export clean-byte-compiled clean-generated
+
+export: clean-export
emacs -L $(CURDIR) -L ~/.emacs.d/vendor-lisp/org/lisp \
-L ~/.emacs.d/vendor-lisp/org/contrib/lisp -batch -l project.el \
-f org-publish-all
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index b61bbf4..3a22c60 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -251,12 +251,6 @@ But only if it is a maildir inbox."
'action (lambda (button)
(browse-url (button-label button)))))))
-(defun oni:eshell-prompt ()
- "Show a pretty shell prompt."
- (concat (if (not (looking-back "\n" nil)) "\n")
- (oni:shorten-dir (abbreviate-file-name (eshell/pwd)))
- " > "))
-
(defun oni:go-mode-func ()
"Function for `go-mode-hook'."
(setq indent-tabs-mode nil))
@@ -710,12 +704,6 @@ For `python-mode' I prefer `python-imenu-create-flat-index'."
(insert "`" command "':\n"))
(shell-command command output-buffer))
-(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)
-
(defun oni:show-buffer-position ()
"Show the position in the current buffer."
(interactive)
@@ -1011,9 +999,7 @@ from myaethon2.core.decorators import (
(setq eltuki-blog-dir "~/documents/blog"))
(stante-after em-prompt
- (setq eshell-highlight-prompt nil)
- (setq eshell-prompt-function 'oni:eshell-prompt)
- (setq eshell-prompt-regexp "^[~/].* > "))
+ (setq eshell-highlight-prompt nil))
(stante-after em-term
(add-to-list 'eshell-visual-commands "unison"))
@@ -1287,6 +1273,7 @@ from myaethon2.core.decorators import (
;;;; Hooks
+(add-hook 'eshell-first-time-mode-hook 'oni-eshell-set-prompt)
(add-hook 'after-save-hook 'oni:after-save-func t)
(add-hook 'before-save-hook 'oni:before-save-func)
(add-hook 'css-mode-hook #'rainbow-mode)
@@ -1504,6 +1491,7 @@ from myaethon2.core.decorators import (
(windmove-default-keybindings)
(load (system-name) :noerror)
+(load "site-autoloads")
;;; Test
diff --git a/emacs/.emacs.d/site-lisp/oni-eshell-prompt.el b/emacs/.emacs.d/site-lisp/oni-eshell-prompt.el
new file mode 100644
index 0000000..540f9f0
--- /dev/null
+++ b/emacs/.emacs.d/site-lisp/oni-eshell-prompt.el
@@ -0,0 +1,55 @@
+;;; oni-eshell-prompt.el --- Oni's eshell prompt functions -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; These are the functions I use to provide my eshell prompt.
+
+;; You can use it by adding `oni-eshell-set-prompt' to the
+;; `eshell-first-time-mode-hook'.
+
+;;; Code:
+
+(require 'em-dirs)
+(require 'em-prompt)
+
+(defvar oni:eshell-prompt-regexp "^[~/].* > "
+ "A regular expression that matches the prompt.")
+
+(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)
+
+(defun oni:eshell-prompt ()
+ "Show a pretty shell prompt."
+ (concat (if (not (looking-back "\n" nil)) "\n")
+ (oni:shorten-dir (abbreviate-file-name (eshell/pwd)))
+ " > "))
+
+;;;###autoload
+(defun oni-eshell-set-prompt ()
+ "Prepare eshell for using the prompt."
+ (setq eshell-prompt-function #'oni:eshell-prompt
+ eshell-prompt-regexp oni:eshell-prompt-regexp))
+
+(provide 'oni-eshell-prompt)
+;;; oni-eshell-prompt.el ends here