eshell/emacs: add find-library integration and window control

This commit is contained in:
MitchMarq42 2022-12-24 14:17:09 -09:00
parent 2bb6a6acd0
commit 79eb891d9e
2 changed files with 37 additions and 8 deletions

View File

@ -11,9 +11,22 @@ file organization suggests.
*** Corfu *** Corfu
**** clean up orderless **** clean up orderless
**** integrate with yasnippets **** integrate with yasnippets
** eshell/emacs ** eshell/emacs DWIM
CONTROL FLOW
#+begin_quote
1. Check arguments
1. No args: run new Emacs instance, separate frame, windowed
2. existing file names: open each in new buffer (`find-file`?) ?(and window)?
1. non-existent file names
1. if name of library, edit that library
1. otherwise edit new file of that name in default-directory
3. dash options
1. =-nw=: open in same window
2. =--client=: use =emacsclient= instead of =emacs=
3. Pass rest of options to exe
#+end_quote
*** /usr/bin/emacs or emacsclient fallback for options *** /usr/bin/emacs or emacsclient fallback for options
*** find-library etc *** DONE find-library etc
** eshell/dat ** eshell/dat
*** fix naming and loading *** fix naming and loading
*** "bcat" *** "bcat"

View File

@ -158,12 +158,28 @@
"Basically you can edit ARGS and it will open in a new buffer. "Basically you can edit ARGS and it will open in a new buffer.
When your shell is Emacs, your Emacs is but an oyster... When your shell is Emacs, your Emacs is but an oyster...
This is taken from a website that I can't remember at the moment." This is taken from a website that I can't remember at the moment."
(if (null args) (bury-buffer) (let* ((exe (if (member "--client" args)
(let ((open-func (if (one-window-p) (executable-find "emacsclient")
#'find-file-other-window (executable-find "emacs")))
#'find-file))) (args (remove "--client" args))
(mapc open-func (openfun (lambda (arg)
(mapcar #'expand-file-name (flatten-tree (reverse args))))))) (let ((arg-file-name (expand-file-name arg))
(arg-lib-name (locate-library arg)))
(if (file-exists-p arg-file-name)
(funcall find-fun arg-file-name)
(if arg-lib-name
(funcall lib-fun arg)
(funcall find-fun arg-file-name)))))))
(if (and (one-window-p) (not (member "-nw" args)))
(setq find-fun #'find-file-other-window
lib-fun #'find-library-other-window)
(setq find-fun #'find-file
lib-fun #'find-library))
(setq args (remove "-nw" args))
(if (null args)
(async-shell-command exe)
(mapcar openfun
(flatten-tree (reverse args))))))
(defun mitch/eshell-setup-keys () (defun mitch/eshell-setup-keys ()
(evil-collection-define-key (evil-collection-define-key
'normal 'normal