eshell/emacs: fix default-directory (for real this time)

This commit is contained in:
MitchMarq42 2023-01-03 18:13:11 -09:00
parent fb524eea38
commit d9bbf546b7

View File

@ -158,7 +158,8 @@
"Edit library called NAME if it exists, otherwise edit FILE. "Edit library called NAME if it exists, otherwise edit FILE.
If the current window occupies the whole frame, split it." If the current window occupies the whole frame, split it."
(let* ((old-default-dir default-directory) ; needed to preserve environment (let* ((old-buffer (current-buffer))
(old-default-dir default-directory) ; needed to preserve environment
find-fun lib-fun ; scope these so we can bind them later find-fun lib-fun ; scope these so we can bind them later
(openfun (lambda (arg) (openfun (lambda (arg)
"Implicit function for opening a file or library." "Implicit function for opening a file or library."
@ -174,8 +175,10 @@ If the current window occupies the whole frame, split it."
lib-fun #'find-library-other-window) lib-fun #'find-library-other-window)
(setq find-fun #'find-file (setq find-fun #'find-file
lib-fun #'find-library)) lib-fun #'find-library))
(let ((return (funcall openfun name))) ; default-directory needs to reset (let ((result (funcall openfun name)))
(setq default-directory old-default-dir) return))) ; but we return bufs (with-current-buffer old-buffer
(setq default-directory old-default-dir))
result)))
(defun eshell/emacs (&rest args) (defun eshell/emacs (&rest args)
"run external Emacs." "run external Emacs."
(eshell-eval-using-options ; this is somewhat broken but works okay (eshell-eval-using-options ; this is somewhat broken but works okay