emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/with-editor a339d65 126/140: with-editor-export-editor: Su


From: Jonas Bernoulli
Subject: [nongnu] elpa/with-editor a339d65 126/140: with-editor-export-editor: Support vterm
Date: Fri, 6 Aug 2021 12:51:34 -0400 (EDT)

branch: elpa/with-editor
commit a339d6590096829a274c1901e407873e1fc1016e
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    with-editor-export-editor: Support vterm
    
    Closes #81.
---
 with-editor.el   | 33 ++++++++++++++++++++++++++-------
 with-editor.org  | 25 +++++++++++++------------
 with-editor.texi | 25 +++++++++++++------------
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/with-editor.el b/with-editor.el
index 5603b81..4d4df6b 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -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:
@@ -97,11 +98,15 @@
   (progn (require 'dired nil t)
          (require 'eshell nil t)
          (require 'term nil t)
+         (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
 
@@ -692,7 +697,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 +716,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))
diff --git a/with-editor.org b/with-editor.org
index 89c079c..402b762 100644
--- a/with-editor.org
+++ b/with-editor.org
@@ -8,7 +8,7 @@
 #+TEXINFO_DIR_CATEGORY: Emacs
 #+TEXINFO_DIR_TITLE: With-Editor: (with-editor).
 #+TEXINFO_DIR_DESC: Using the Emacsclient as $EDITOR
-#+SUBTITLE: for version 2.9.4
+#+SUBTITLE: for version 2.9.4 (v2.9.4-2-gc4768f5+1)
 
 #+TEXINFO_DEFFN: t
 #+PROPERTY: header-args :eval never
@@ -32,7 +32,7 @@ additional functionality which makes it useful even for 
end-users, who
 don't use Magit or another package which uses it internally.
 
 #+TEXINFO: @noindent
-This manual is for With-Editor version 2.9.4.
+This manual is for With-Editor version 2.9.4 (v2.9.4-2-gc4768f5+1).
 
 #+BEGIN_QUOTE
 Copyright (C) 2015-2020 Jonas Bernoulli <jonas@bernoul.li>
@@ -193,17 +193,18 @@ Alternatively use the global 
~shell-command-with-editor-mode~.
   command.  This affects most variants of that command, whether they
   are defined in Emacs or in some third-party package.
 
-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:
+The command ~with-editor-export-editor~ exports ~$EDITOR~ or 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:
 
 #+BEGIN_SRC emacs-lisp
   (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-exec-hook  'with-editor-export-editor)
 #+END_SRC
 
 Some variants of this function exist; these two forms are equivalent:
@@ -216,9 +217,9 @@ Some variants of this function exist; these two forms are 
equivalent:
 
 - Command: with-editor-export-editor
 
-  When invoked in a ~shell-mode~, ~term-mode~, or ~eshell-mode~ buffer, this
-  command teaches shell commands to use the current Emacs instance as
-  the editor, by exporting ~$EDITOR~.
+  When invoked in a ~shell-mode~, ~eshell-mode~, ~term-mode~ or ~vterm-mode~
+  buffer, this command teaches shell commands to use the current Emacs
+  instance as the editor, by exporting ~$EDITOR~.
 
 - Command: with-editor-export-git-editor
 
diff --git a/with-editor.texi b/with-editor.texi
index a4e1cc8..6211632 100644
--- a/with-editor.texi
+++ b/with-editor.texi
@@ -31,7 +31,7 @@ General Public License for more details.
 @finalout
 @titlepage
 @title With-Editor User Manual
-@subtitle for version 2.9.4
+@subtitle for version 2.9.4 (v2.9.4-2-gc4768f5+1)
 @author Jonas Bernoulli
 @page
 @vskip 0pt plus 1filll
@@ -60,7 +60,7 @@ additional functionality which makes it useful even for 
end-users, who
 don't use Magit or another package which uses it internally.
 
 @noindent
-This manual is for With-Editor version 2.9.4.
+This manual is for With-Editor version 2.9.4 (v2.9.4-2-gc4768f5+1).
 
 @quotation
 Copyright (C) 2015-2020 Jonas Bernoulli <jonas@@bernoul.li>
@@ -258,17 +258,18 @@ command.  This affects most variants of that command, 
whether they
 are defined in Emacs or in some third-party package.
 @end defvar
 
-The command @code{with-editor-export-editor} exports @code{$EDITOR} or
-another such environment variable in @code{shell-mode}, @code{term-mode} and
-@code{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:
+The command @code{with-editor-export-editor} exports @code{$EDITOR} or another
+such environment variable in @code{shell-mode}, @code{eshell-mode}, 
@code{term-mode} and
+@code{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:
 
 @lisp
 (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-exec-hook  'with-editor-export-editor)
 @end lisp
 
 Some variants of this function exist; these two forms are equivalent:
@@ -282,9 +283,9 @@ Some variants of this function exist; these two forms are 
equivalent:
 @cindex with-editor-export-editor
 @deffn Command with-editor-export-editor
 
-When invoked in a @code{shell-mode}, @code{term-mode}, or @code{eshell-mode} 
buffer, this
-command teaches shell commands to use the current Emacs instance as
-the editor, by exporting @code{$EDITOR}.
+When invoked in a @code{shell-mode}, @code{eshell-mode}, @code{term-mode} or 
@code{vterm-mode}
+buffer, this command teaches shell commands to use the current Emacs
+instance as the editor, by exporting @code{$EDITOR}.
 @end deffn
 
 @cindex with-editor-export-git-editor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]