update packages
This commit is contained in:
@@ -54,15 +54,16 @@
|
||||
;; use `shell-command' to asynchronously run some shell command.
|
||||
|
||||
;; The command `with-editor-export-editor' exports `$EDITOR' or
|
||||
;; another such environment variable in `shell-mode', `term-mode' and
|
||||
;; `eshell-mode' buffers. Use this Emacs command before executing a
|
||||
;; shell command which needs the editor set, or always arrange for the
|
||||
;; current Emacs instance to be used as editor by adding it to the
|
||||
;; appropriate mode hooks:
|
||||
;; another such environment variable in `shell-mode', `eshell-mode',
|
||||
;; `term-mode' and `vterm-mode' buffers. Use this Emacs command
|
||||
;; before executing a shell command which needs the editor set, or
|
||||
;; always arrange for the current Emacs instance to be used as editor
|
||||
;; by adding it to the appropriate mode hooks:
|
||||
;;
|
||||
;; (add-hook 'shell-mode-hook 'with-editor-export-editor)
|
||||
;; (add-hook 'term-exec-hook 'with-editor-export-editor)
|
||||
;; (add-hook 'eshell-mode-hook 'with-editor-export-editor)
|
||||
;; (add-hook 'term-exec-hook 'with-editor-export-editor)
|
||||
;; (add-hook 'vterm-mode-hook 'with-editor-export-editor)
|
||||
|
||||
;; Some variants of this function exist, these two forms are
|
||||
;; equivalent:
|
||||
@@ -80,8 +81,9 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
;; `pcase-dolist' is not autoloaded on Emacs 24.
|
||||
(eval-when-compile (require 'pcase))
|
||||
(eval-when-compile
|
||||
(require 'pcase) ; `pcase-dolist' is not autoloaded on Emacs 24.
|
||||
(require 'subr-x))
|
||||
(require 'server)
|
||||
(require 'shell)
|
||||
|
||||
@@ -97,11 +99,18 @@
|
||||
(progn (require 'dired nil t)
|
||||
(require 'eshell nil t)
|
||||
(require 'term nil t)
|
||||
(condition-case err
|
||||
(require 'vterm nil t)
|
||||
(error (message "Error: %S" err)))
|
||||
(require 'vterm nil t)
|
||||
(require 'warnings nil t)))
|
||||
(declare-function dired-get-filename 'dired)
|
||||
(declare-function term-emulate-terminal 'term)
|
||||
(declare-function vterm-send-return 'vterm)
|
||||
(declare-function vterm-send-string 'vterm)
|
||||
(defvar eshell-preoutput-filter-functions)
|
||||
(defvar git-commit-post-finish-hook)
|
||||
(defvar vterm--process)
|
||||
|
||||
;;; Options
|
||||
|
||||
@@ -540,7 +549,7 @@ at run-time.
|
||||
server-window))
|
||||
|
||||
(defun server-switch-buffer--with-editor-server-window-alist
|
||||
(fn &optional next-buffer killed-one filepos)
|
||||
(fn &optional next-buffer &rest args)
|
||||
"Honor `with-editor-server-window-alist' (which see)."
|
||||
(let ((server-window (with-current-buffer
|
||||
(or next-buffer (current-buffer))
|
||||
@@ -548,7 +557,7 @@ at run-time.
|
||||
(setq with-editor-previous-winconf
|
||||
(current-window-configuration)))
|
||||
(with-editor-server-window))))
|
||||
(funcall fn next-buffer killed-one filepos)))
|
||||
(apply fn next-buffer args)))
|
||||
|
||||
(advice-add 'server-switch-buffer :around
|
||||
'server-switch-buffer--with-editor-server-window-alist)
|
||||
@@ -692,7 +701,8 @@ Set and export the environment variable ENVVAR, by default
|
||||
\"EDITOR\". The value is automatically generated to teach
|
||||
commands to use the current Emacs instance as \"the editor\".
|
||||
|
||||
This works in `shell-mode', `term-mode' and `eshell-mode'."
|
||||
This works in `shell-mode', `term-mode', `eshell-mode' and
|
||||
`vterm'."
|
||||
(interactive (list (with-editor-read-envvar)))
|
||||
(cond
|
||||
((derived-mode-p 'comint-mode 'term-mode)
|
||||
@@ -710,6 +720,19 @@ This works in `shell-mode', `term-mode' and `eshell-mode'."
|
||||
(add-to-list 'eshell-preoutput-filter-functions
|
||||
'with-editor-output-filter)
|
||||
(setenv envvar with-editor-sleeping-editor))
|
||||
((derived-mode-p 'vterm-mode)
|
||||
(if with-editor-emacsclient-executable
|
||||
(let ((with-editor--envvar envvar)
|
||||
(process-environment process-environment))
|
||||
(with-editor--setup)
|
||||
(while (accept-process-output vterm--process 0.1))
|
||||
(when-let ((v (getenv envvar)))
|
||||
(vterm-send-string (format "export %s=%S" envvar v))
|
||||
(vterm-send-return))
|
||||
(when-let ((v (getenv "EMACS_SERVER_FILE")))
|
||||
(vterm-send-string (format "export EMACS_SERVER_FILE=%S" v))
|
||||
(vterm-send-return)))
|
||||
(error "Cannot use sleeping editor in this buffer")))
|
||||
(t
|
||||
(error "Cannot export environment variables in this buffer")))
|
||||
(message "Successfully exported %s" envvar))
|
||||
|
||||
Reference in New Issue
Block a user