summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-11-11 22:17:26 +0000
committerjao <jao@gnu.org>2021-11-11 22:17:26 +0000
commit2f4b7f51aa8bd18af1bb31006a59c29c2adae885 (patch)
tree70f14d31d7cf1f29d3435dabe471bbb3f88d76e8
parenta97fadefaf7b86182de5fb6ed3d97c2f900c6d32 (diff)
downloadelibs-2f4b7f51aa8bd18af1bb31006a59c29c2adae885.tar.gz
elibs-2f4b7f51aa8bd18af1bb31006a59c29c2adae885.tar.bz2
nih: i like my eshell toggling better
-rw-r--r--attic/misc.org60
-rw-r--r--init.org60
2 files changed, 65 insertions, 55 deletions
diff --git a/attic/misc.org b/attic/misc.org
index c3df4b7..9ca8e01 100644
--- a/attic/misc.org
+++ b/attic/misc.org
@@ -572,50 +572,22 @@
(jao-define-attached-buffer "^\\* vrepl - .+ \\*.*")
#+end_src
* eshell here
- #+begin_src emacs-lisp
- (defun jao-shell-here--find-window (b)
- (when-let (w (seq-find (lambda (w) (eq (window-buffer w) b))
- (window-list)))
- (select-window w)))
-
- (defun jao-shell-frame-buffer (&optional b)
- (let ((p 'jao-eshell-buffer))
- (if b (set-frame-parameter nil p b) (frame-parameter nil p))))
-
- (defun jao-shell--cd-here (dir)
- (eshell-kill-input)
- (eshell/cd dir)
- (insert "\n")
- (eshell-send-input))
-
- (defun jao-shell-here (&optional stay)
- (interactive)
- (let* ((dir default-directory)
- (b (jao-shell-frame-buffer)))
- (jao-with-attached-buffer "^\\*eshell" 35
- (if (buffer-live-p b)
- (pop-to-buffer b nil t)
- (eshell)
- (jao-shell-frame-buffer (current-buffer))))
- (eshell-save-some-history)
- (unless stay (jao-shell--cd-here dir))))
-
- (defun eshell/x ()
- (when (derived-mode-p 'eshell-mode)
- (when (fboundp 'eshell-autojump-save)
- (eshell-autojump-save))
- (eshell-save-some-history))
- (if (> (frame-height) (window-height)) (delete-window) (bury-buffer)))
-
- (defun jao-shell-here-toggle ()
- (interactive)
- (if (eq (current-buffer) (jao-shell-frame-buffer))
- (eshell/x)
- (jao-shell-here t)))
-
- (global-set-key (kbd "C-!") #'jao-shell-here)
- (global-set-key [(f1)] #'jao-shell-here-toggle)
- #+end_src
+ #+begin_src emacs-lisp
+ (use-package eshell-toggle
+ :ensure t
+ :demand t
+ :custom ((eshell-toggle-use-git-root t)))
+
+ (defun jao-eshell-toggle (current)
+ (interactive "P")
+ (when (eq eshell-toggle--toggle-buffer-p t)
+ (eshell-save-some-history)
+ (eshell-autojump-save))
+ (let ((eshell-toggle-use-git-root (not current)))
+ (eshell-toggle)))
+
+ (global-set-key (kbd "<f1>") #'jao-eshell-toggle)
+ #+end_src
* scrolling
#+begin_src emacs-lisp
(use-package iscroll
diff --git a/init.org b/init.org
index 2efe61f..c8dd9f7 100644
--- a/init.org
+++ b/init.org
@@ -1,5 +1,4 @@
#+property: header-args :lexical t :tangle yes :comments yes :results silent :shebang ";; -*- lexical-binding: t -*-" :tangle-mode (identity #o644)
-#+auto_tangle: t
* Packages
*** Use package
@@ -1924,16 +1923,55 @@
#+END_SRC
***** Toggle
#+begin_src emacs-lisp
- (use-package eshell-toggle
- :ensure t
- :demand t)
-
- (defun jao-eshell-toggle (git-root)
- (interactive "P")
- (let ((eshell-toggle-use-git-root git-root))
- (eshell-toggle)))
-
- (global-set-key (kbd "<f1>") #'jao-eshell-toggle)
+ (defun jao-eshell-here--find-window (b)
+ (when-let (w (seq-find (lambda (w) (eq (window-buffer w) b))
+ (window-list)))
+ (select-window w)))
+
+ (defun jao-eshell-frame-buffer (&optional b)
+ (let ((p 'jao-eshell-buffer))
+ (if b (set-frame-parameter nil p b) (frame-parameter nil p))))
+
+ (defun jao-eshell--cd-here (&optional dir)
+ (eshell-kill-input)
+ (eshell/cd (or dir default-directory))
+ (insert "\n")
+ (eshell-send-input))
+
+ (defun jao-eshell-here (&optional stay)
+ (interactive "p")
+ (message "%s" stay)
+ (let ((b (jao-eshell-frame-buffer))
+ (dir (cond ((> stay 4) default-directory)
+ ((> stay 1)
+ (project-root
+ (or (project-current)
+ `(transient . ,default-directory)))))))
+ (jao-with-attached-buffer "^\\*eshell" 30
+ (if (buffer-live-p b)
+ (progn (pop-to-buffer b nil t)
+ (eshell-save-some-history)
+ (when dir (jao-eshell--cd-here dir)))
+ (let ((default-directory (or dir default-directory)))
+ (eshell))
+ (jao-eshell-frame-buffer (current-buffer))))))
+
+ (defun eshell/x ()
+ (when (derived-mode-p 'eshell-mode)
+ (when (fboundp 'eshell-autojump-save)
+ (eshell-autojump-save))
+ (eshell-save-some-history)
+ (if (> (frame-height) (window-height))
+ (delete-window)
+ (bury-buffer))))
+
+ (defun jao-eshell-here-toggle (stay)
+ (interactive "p")
+ (if (eq (current-buffer) (jao-eshell-frame-buffer))
+ (eshell/x)
+ (jao-eshell-here stay)))
+
+ (global-set-key [(f1)] #'jao-eshell-here-toggle)
#+end_src
***** Workarounds
#+begin_src emacs-lisp