update packages
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
(define-package "with-editor" "20201030.1232" "Use the Emacsclient as $EDITOR"
|
||||
'((emacs "24.4")
|
||||
(async "1.9"))
|
||||
:commit "6735180e73e787b79535c245b162249b70dbf841" :authors
|
||||
(define-package "with-editor" "20220101.1316" "Use the Emacsclient as $EDITOR"
|
||||
'((emacs "24.4"))
|
||||
:commit "36d36957628621e8340f755b22082e1f4ed8e2d7" :authors
|
||||
'(("Jonas Bernoulli" . "jonas@bernoul.li"))
|
||||
:maintainer
|
||||
'("Jonas Bernoulli" . "jonas@bernoul.li")
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
;;; with-editor.el --- Use the Emacsclient as $EDITOR -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2014-2020 The Magit Project Contributors
|
||||
;; Copyright (C) 2014-2022 The Magit Project Contributors
|
||||
;;
|
||||
;; You should have received a copy of the AUTHORS.md file. If not,
|
||||
;; see https://github.com/magit/with-editor/blob/master/AUTHORS.md.
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
;; Package-Requires: ((emacs "24.4") (async "1.9"))
|
||||
;; Keywords: tools
|
||||
;; Homepage: https://github.com/magit/with-editor
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;; Package-Requires: ((emacs "24.4"))
|
||||
;; Package-Version: 3.0.5
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;;
|
||||
;; This file is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with Magit. If not, see http://www.gnu.org/licenses.
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library makes it possible to reliably use the Emacsclient as
|
||||
@@ -87,22 +90,13 @@
|
||||
(require 'server)
|
||||
(require 'shell)
|
||||
|
||||
(and (require 'async-bytecomp nil t)
|
||||
(let ((pkgs (bound-and-true-p async-bytecomp-allowed-packages)))
|
||||
(if (consp pkgs)
|
||||
(cl-intersection '(all magit) pkgs)
|
||||
(memq pkgs '(all t))))
|
||||
(fboundp 'async-bytecomp-package-mode)
|
||||
(async-bytecomp-package-mode 1))
|
||||
|
||||
(eval-when-compile
|
||||
(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)
|
||||
(error (message "Error(vterm): %S" err)))
|
||||
(require 'warnings nil t)))
|
||||
(declare-function dired-get-filename 'dired)
|
||||
(declare-function term-emulate-terminal 'term)
|
||||
@@ -327,12 +321,9 @@ And some tools that do not handle $EDITOR properly also break."
|
||||
(put 'with-editor-post-finish-hook 'permanent-local t)
|
||||
(put 'with-editor-post-cancel-hook 'permanent-local t)
|
||||
|
||||
(defvar with-editor-show-usage t)
|
||||
(defvar with-editor-cancel-message nil)
|
||||
(defvar with-editor-previous-winconf nil)
|
||||
(make-variable-buffer-local 'with-editor-show-usage)
|
||||
(make-variable-buffer-local 'with-editor-cancel-message)
|
||||
(make-variable-buffer-local 'with-editor-previous-winconf)
|
||||
(defvar-local with-editor-show-usage t)
|
||||
(defvar-local with-editor-cancel-message nil)
|
||||
(defvar-local with-editor-previous-winconf nil)
|
||||
(put 'with-editor-cancel-message 'permanent-local t)
|
||||
(put 'with-editor-previous-winconf 'permanent-local t)
|
||||
|
||||
@@ -637,9 +628,9 @@ Give PROCESS the new FILTER but keep `with-editor-process-filter'
|
||||
if that was added earlier by the advised `start-file-process'.
|
||||
|
||||
Do so by wrapping the two filter functions using a lambda, which
|
||||
becomes the actual filter. It calls `with-editor-process-filter'
|
||||
first, passing t as NO-STANDARD-FILTER. Then it calls FILTER,
|
||||
which may or may not insert the text into the PROCESS's buffer."
|
||||
becomes the actual filter. It calls FILTER first, which may or
|
||||
may not insert the text into the PROCESS's buffer. Then it calls
|
||||
`with-editor-process-filter', passing t as NO-STANDARD-FILTER."
|
||||
(set-process-filter
|
||||
process
|
||||
(if (eq (process-filter process) 'with-editor-process-filter)
|
||||
@@ -650,33 +641,49 @@ which may or may not insert the text into the PROCESS's buffer."
|
||||
|
||||
(defvar with-editor-filter-visit-hook nil)
|
||||
|
||||
(defun with-editor-output-filter (string)
|
||||
(defconst with-editor-sleeping-editor-regexp
|
||||
"^WITH-EDITOR: \\([0-9]+\\) OPEN \\([^]+?\\)\\(?: IN \\([^\r]+?\\)\\)?\r?$")
|
||||
|
||||
(defvar with-editor--max-incomplete-length 1000)
|
||||
|
||||
(defun with-editor-sleeping-editor-filter (process string)
|
||||
(when-let ((incomplete (and process (process-get process 'incomplete))))
|
||||
(setq string (concat incomplete string)))
|
||||
(save-match-data
|
||||
(if (string-match "^WITH-EDITOR: \
|
||||
\\([0-9]+\\) OPEN \\([^]+?\\)\
|
||||
\\(?: IN \\([^\r]+?\\)\\)?\r?$" string)
|
||||
(let ((pid (match-string 1 string))
|
||||
(file (match-string 2 string))
|
||||
(dir (match-string 3 string)))
|
||||
(unless (file-name-absolute-p file)
|
||||
(setq file (expand-file-name file dir)))
|
||||
(when default-directory
|
||||
(setq file (concat (file-remote-p default-directory) file)))
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(with-editor-mode 1)
|
||||
(setq with-editor--pid pid)
|
||||
(run-hooks 'with-editor-filter-visit-hook)
|
||||
(funcall (or (with-editor-server-window) 'switch-to-buffer)
|
||||
(current-buffer))
|
||||
(kill-local-variable 'server-window))
|
||||
nil)
|
||||
string)))
|
||||
(cond
|
||||
((and process (not (string-match-p "\n\\'" string)))
|
||||
(let ((length (length string)))
|
||||
(when (> length with-editor--max-incomplete-length)
|
||||
(setq string
|
||||
(substring string
|
||||
(- length with-editor--max-incomplete-length)))))
|
||||
(process-put process 'incomplete string)
|
||||
nil)
|
||||
((string-match with-editor-sleeping-editor-regexp string)
|
||||
(when process
|
||||
(process-put process 'incomplete nil))
|
||||
(let ((pid (match-string 1 string))
|
||||
(file (match-string 2 string))
|
||||
(dir (match-string 3 string)))
|
||||
(unless (file-name-absolute-p file)
|
||||
(setq file (expand-file-name file dir)))
|
||||
(when default-directory
|
||||
(setq file (concat (file-remote-p default-directory) file)))
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(with-editor-mode 1)
|
||||
(setq with-editor--pid pid)
|
||||
(run-hooks 'with-editor-filter-visit-hook)
|
||||
(funcall (or (with-editor-server-window) 'switch-to-buffer)
|
||||
(current-buffer))
|
||||
(kill-local-variable 'server-window)))
|
||||
nil)
|
||||
(t string))))
|
||||
|
||||
(defun with-editor-process-filter
|
||||
(process string &optional no-default-filter)
|
||||
"Listen for edit requests by child processes."
|
||||
(let ((default-directory (process-get process 'default-dir)))
|
||||
(with-editor-output-filter string))
|
||||
(with-editor-sleeping-editor-filter process string))
|
||||
(unless no-default-filter
|
||||
(internal-default-process-filter process string)))
|
||||
|
||||
@@ -706,7 +713,7 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
|
||||
(interactive (list (with-editor-read-envvar)))
|
||||
(cond
|
||||
((derived-mode-p 'comint-mode 'term-mode)
|
||||
(let ((process (get-buffer-process (current-buffer))))
|
||||
(when-let ((process (get-buffer-process (current-buffer))))
|
||||
(goto-char (process-mark process))
|
||||
(process-send-string
|
||||
process (format " export %s=%s\n" envvar
|
||||
@@ -731,7 +738,9 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
|
||||
(vterm-send-return))
|
||||
(when-let ((v (getenv "EMACS_SERVER_FILE")))
|
||||
(vterm-send-string (format "export EMACS_SERVER_FILE=%S" v))
|
||||
(vterm-send-return)))
|
||||
(vterm-send-return))
|
||||
(vterm-send-string "clear")
|
||||
(vterm-send-return))
|
||||
(error "Cannot use sleeping editor in this buffer")))
|
||||
(t
|
||||
(error "Cannot export environment variables in this buffer")))
|
||||
@@ -749,10 +758,16 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
|
||||
(interactive)
|
||||
(with-editor-export-editor "HG_EDITOR"))
|
||||
|
||||
(defun with-editor-output-filter (string)
|
||||
"Handle edit requests on behalf of `comint-mode' and `eshell-mode'."
|
||||
(with-editor-sleeping-editor-filter nil string))
|
||||
|
||||
(defun with-editor-emulate-terminal (process string)
|
||||
"Like `term-emulate-terminal' but also handle edit requests."
|
||||
(when (with-editor-output-filter string)
|
||||
(term-emulate-terminal process string)))
|
||||
(let ((with-editor-sleeping-editor-regexp
|
||||
(substring with-editor-sleeping-editor-regexp 1)))
|
||||
(with-editor-sleeping-editor-filter process string))
|
||||
(term-emulate-terminal process string))
|
||||
|
||||
(defvar with-editor-envvars '("EDITOR" "GIT_EDITOR" "HG_EDITOR"))
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
This is with-editor.info, produced by makeinfo version 6.5 from
|
||||
This is with-editor.info, produced by makeinfo version 6.7 from
|
||||
with-editor.texi.
|
||||
|
||||
Copyright (C) 2015-2020 Jonas Bernoulli <jonas@bernoul.li>
|
||||
Copyright (C) 2015-2022 Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
You can redistribute this document and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software
|
||||
@@ -39,9 +39,9 @@ library is made available as a separate package. It also defines some
|
||||
additional functionality which makes it useful even for end-users, who
|
||||
don’t use Magit or another package which uses it internally.
|
||||
|
||||
This manual is for With-Editor version 2.9.4 (v2.9.4-2-gc4768f5+1).
|
||||
This manual is for With-Editor version v3.1.0.
|
||||
|
||||
Copyright (C) 2015-2020 Jonas Bernoulli <jonas@bernoul.li>
|
||||
Copyright (C) 2015-2022 Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
You can redistribute this document and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software
|
||||
@@ -58,8 +58,7 @@ This manual is for With-Editor version 2.9.4 (v2.9.4-2-gc4768f5+1).
|
||||
* Using the With-Editor package::
|
||||
* Using With-Editor as a library::
|
||||
* Debugging::
|
||||
* Command Index::
|
||||
* Function Index::
|
||||
* Function and Command Index::
|
||||
* Variable Index::
|
||||
|
||||
— The Detailed Node Listing —
|
||||
@@ -103,7 +102,6 @@ Emacs (most likely on macOS) without putting the executable on ‘$PATH’,
|
||||
and we have to add another kludge to find it anyway.
|
||||
|
||||
-- User Option: with-editor-emacsclient-executable
|
||||
|
||||
The ‘emacsclient’ executable used as the editor by child process of
|
||||
this Emacs instance. By using this executable, child processes can
|
||||
call home to their parent process.
|
||||
@@ -132,7 +130,6 @@ and we have to add another kludge to find it anyway.
|
||||
add a kludge appropriate for you setup.
|
||||
|
||||
-- Function: with-editor-locate-emacsclient
|
||||
|
||||
The function used to set the initial value of the option
|
||||
‘with-editor-emacsclient-executable’. There’s a lot of voodoo
|
||||
here.
|
||||
@@ -148,7 +145,6 @@ editor" because it is implemented as a shell script which sleeps until
|
||||
it receives a signal.
|
||||
|
||||
-- User Option: with-editor-sleeping-editor
|
||||
|
||||
The sleeping editor is a shell script used as the editor of child
|
||||
processes when the ‘emacsclient’ executable cannot be used.
|
||||
|
||||
@@ -205,12 +201,10 @@ instance as "the editor". With a prefix argument these commands prompt
|
||||
for an alternative environment variable such as ‘$GIT_EDITOR’.
|
||||
|
||||
-- Command: with-editor-async-shell-command
|
||||
|
||||
This command is like ‘async-shell-command’, but it runs the shell
|
||||
command with the current Emacs instance exported as ‘$EDITOR’.
|
||||
|
||||
-- Command: with-editor-shell-command
|
||||
|
||||
This command is like ‘shell-command’, but if the shell command ends
|
||||
with ‘&’ and is therefore run asynchronously, then the current
|
||||
Emacs instance is exported as ‘$EDITOR’.
|
||||
@@ -225,7 +219,6 @@ for an alternative environment variable such as ‘$GIT_EDITOR’.
|
||||
Alternatively use the global ‘shell-command-with-editor-mode’.
|
||||
|
||||
-- Variable: shell-command-with-editor-mode
|
||||
|
||||
When this mode is active, then ‘$EDITOR’ is exported whenever
|
||||
ultimately ‘shell-command’ is called to asynchronously run some
|
||||
shell command. This affects most variants of that command, whether
|
||||
@@ -250,18 +243,15 @@ appropriate mode hooks:
|
||||
(add-hook 'shell-mode-hook 'with-editor-export-git-editor)
|
||||
|
||||
-- Command: with-editor-export-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
|
||||
|
||||
This command is like ‘with-editor-export-editor’ but exports
|
||||
‘$GIT_EDITOR’.
|
||||
|
||||
-- Command: with-editor-export-hg-editor
|
||||
|
||||
This command is like ‘with-editor-export-editor’ but exports
|
||||
‘$HG_EDITOR’.
|
||||
|
||||
@@ -282,7 +272,6 @@ interactive and non-interactive use, see *note Using the With-Editor
|
||||
package::.
|
||||
|
||||
-- Macro: with-editor &rest body
|
||||
|
||||
This macro arranges for the ‘emacsclient’ or the sleeping editor to
|
||||
be used as the editor of child processes, effectively teaching them
|
||||
to call home to the current Emacs instance when they require that
|
||||
@@ -298,21 +287,20 @@ package::.
|
||||
instead of ‘EDITOR’.
|
||||
|
||||
-- Macro: with-editor envvar &rest body
|
||||
|
||||
This macro is like ‘with-editor’ instead that the ENVVAR argument
|
||||
is required and that it is evaluated at run-time.
|
||||
|
||||
-- Function: with-editor-set-process-filter process filter
|
||||
|
||||
This function is like ‘set-process-filter’ but ensures that adding
|
||||
the new FILTER does not remove the ‘with-editor-process-filter’.
|
||||
This is done by wrapping the two filter functions using a lambda,
|
||||
which becomes the actual filter. It calls
|
||||
‘with-editor-process-filter’ first, passing ‘t’ as
|
||||
NO-STANDARD-FILTER. Then it calls FILTER.
|
||||
which becomes the actual filter. It calls FILTER first, which may
|
||||
or may not insert the text into the PROCESS’s buffer. Then it
|
||||
calls ‘with-editor-process-filter’, passing t as
|
||||
NO-STANDARD-FILTER.
|
||||
|
||||
|
||||
File: with-editor.info, Node: Debugging, Next: Command Index, Prev: Using With-Editor as a library, Up: Top
|
||||
File: with-editor.info, Node: Debugging, Next: Function and Command Index, Prev: Using With-Editor as a library, Up: Top
|
||||
|
||||
3 Debugging
|
||||
***********
|
||||
@@ -331,30 +319,10 @@ about your Emacs installation. Most importantly how did you install
|
||||
Emacs and what is the output of ‘M-x with-editor-debug RET’.
|
||||
|
||||
|
||||
File: with-editor.info, Node: Command Index, Next: Function Index, Prev: Debugging, Up: Top
|
||||
File: with-editor.info, Node: Function and Command Index, Next: Variable Index, Prev: Debugging, Up: Top
|
||||
|
||||
Appendix A Command Index
|
||||
************************
|
||||
|
||||
| ||||