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.
This commit is contained in:
parent
e390a5dae4
commit
f54d8a5930
3 changed files with 80 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
55
emacs/.emacs.d/site-lisp/oni-eshell-prompt.el
Normal file
55
emacs/.emacs.d/site-lisp/oni-eshell-prompt.el
Normal file
|
@ -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
|
Loading…
Reference in a new issue