Make sure the Nyan prompt in eshell always works
This commit is contained in:
		| @@ -1314,9 +1314,7 @@ The cookies are from the Hungarian version an ancient MS-DOS based program calle | |||||||
| #+BEGIN_SRC emacs-lisp | #+BEGIN_SRC emacs-lisp | ||||||
| (when (display-graphic-p) | (when (display-graphic-p) | ||||||
|   (use-package nyan-prompt |   (use-package nyan-prompt | ||||||
|     :ensure nil |     :ensure nil)) | ||||||
|     :config |  | ||||||
|     (add-hook 'eshell-load-hook 'nyan-prompt-enable))) |  | ||||||
| #+END_SRC | #+END_SRC | ||||||
|  |  | ||||||
| *** Zone out with Nyancat | *** Zone out with Nyancat | ||||||
| @@ -1439,7 +1437,9 @@ Highlight point.  Sometimes it’s not easy to see. | |||||||
|   (with-eval-after-load "esh-opt" |   (with-eval-after-load "esh-opt" | ||||||
|     (autoload 'epe-theme-lambda "eshell-prompt-extras") |     (autoload 'epe-theme-lambda "eshell-prompt-extras") | ||||||
|     (setq eshell-highlight-prompt nil |     (setq eshell-highlight-prompt nil | ||||||
|         eshell-prompt-function 'epe-theme-lambda))) |           eshell-prompt-function 'epe-theme-lambda) | ||||||
|  |     (when (featurep 'nyan-prompt) | ||||||
|  |       (nyan-prompt-enable)))) | ||||||
| #+END_SRC | #+END_SRC | ||||||
|  |  | ||||||
| *** Show form feeds as a horizontal line | *** Show form feeds as a horizontal line | ||||||
|   | |||||||
| @@ -34,18 +34,26 @@ | |||||||
|   (propertize nyan-prompt-nyan-cat-emoticon |   (propertize nyan-prompt-nyan-cat-emoticon | ||||||
|               'display nyan-prompt-nyan-cat-image)) |               'display nyan-prompt-nyan-cat-image)) | ||||||
|  |  | ||||||
| (defvar nyan-prompt-original-prompt 'eshell-prompt-function | (defvar nyan-prompt-original-prompt nil | ||||||
|   "The eshell prompt function before enabling nyan-prompt") |   "The eshell prompt function before enabling nyan-prompt") | ||||||
|  |  | ||||||
|  | (defvar nyan-prompt-enabled nil | ||||||
|  |   "t if nyan-prompt is enabled") | ||||||
|  |  | ||||||
| (defun eshell-nyan-prompt () | (defun eshell-nyan-prompt () | ||||||
|   (concat nyan-prompt-nyan-cat-string " " (funcall nyan-prompt-original-prompt))) |   (concat nyan-prompt-nyan-cat-string " " (funcall nyan-prompt-original-prompt))) | ||||||
|  |  | ||||||
| (defun nyan-prompt-disable () | (defun nyan-prompt-disable () | ||||||
|   (setq eshell-prompt-function 'nyan-prompt-original-prompt)) |   (when nyan-prompt-enabled | ||||||
|  |     (setq nyan-prompt-enabled nil | ||||||
|  |           eshell-prompt-function nyan-prompt-original-prompt))) | ||||||
|  |  | ||||||
| ;;;###autoload | ;;;###autoload | ||||||
| (defun nyan-prompt-enable () | (defun nyan-prompt-enable () | ||||||
|   (setq eshell-prompt-function 'eshell-nyan-prompt)) |   (when (not nyan-prompt-enabled) | ||||||
|  |     (setq nyan-prompt-enabled t | ||||||
|  |           nyan-prompt-original-prompt eshell-prompt-function | ||||||
|  |           eshell-prompt-function 'eshell-nyan-prompt))) | ||||||
|  |  | ||||||
|  |  | ||||||
| (provide 'nyan-prompt) | (provide 'nyan-prompt) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user