diff options
author | thing1 <thing1@seacrossedlovers.xyz> | 2025-04-01 20:27:39 +0100 |
---|---|---|
committer | thing1 <thing1@seacrossedlovers.xyz> | 2025-04-01 20:27:39 +0100 |
commit | d3a5ddb4189ef7c04df0cc47a0f9642b23292d2d (patch) | |
tree | 14264483e4d2e6481abc74feea6d9cbcae3666d1 /elpa/with-editor-3.4.3/docs | |
parent | dabaff03992c102c395314629f63ce93a2c1bd3a (diff) |
added magit and other general configs
Diffstat (limited to 'elpa/with-editor-3.4.3/docs')
-rw-r--r-- | elpa/with-editor-3.4.3/docs/.orgconfig | 18 | ||||
-rw-r--r-- | elpa/with-editor-3.4.3/docs/Makefile | 110 | ||||
-rw-r--r-- | elpa/with-editor-3.4.3/docs/htmlxref.cnf | 42 | ||||
-rw-r--r-- | elpa/with-editor-3.4.3/docs/with-editor.org | 311 | ||||
-rw-r--r-- | elpa/with-editor-3.4.3/docs/with-editor.texi | 344 |
5 files changed, 825 insertions, 0 deletions
diff --git a/elpa/with-editor-3.4.3/docs/.orgconfig b/elpa/with-editor-3.4.3/docs/.orgconfig new file mode 100644 index 0000000..bdaba4a --- /dev/null +++ b/elpa/with-editor-3.4.3/docs/.orgconfig @@ -0,0 +1,18 @@ +# -*- mode:org -*- +# Copyright (C) 2021-2024 Jonas Bernoulli +# SPDX-License-Identifier: GPL-3.0-or-later +# URL: https://github.com/emacscollective/org-macros +# Visit that to see these macros in a human-readable format. + +#+language: en + +#+options: H:4 num:3 toc:2 compact-itemx:t +#+property: header-args :eval never + +#+macro: year (eval (format-time-string "%Y")) +#+macro: version (eval (if-let ((tag (ignore-errors (car (process-lines "git" "describe" "--exact-match"))))) (concat "version " (substring tag 1)) (or (ignore-errors (car (process-lines "git" "describe"))) (concat "version " (or $1 "<unknown>"))))) +#+macro: kbd (eval (format "@@texinfo:@kbd{@@%s@@texinfo:}@@" (let (case-fold-search) (replace-regexp-in-string (regexp-opt '("BS" "TAB" "RET" "ESC" "SPC" "DEL" "LFD" "DELETE" "SHIFT" "Ctrl" "Meta" "Alt" "Cmd" "Super" "UP" "LEFT" "RIGHT" "DOWN") 'words) "@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t)))) +#+macro: kbdvar (eval (format "@@texinfo:@kbd{@@%s@@texinfo:}@@" (let (case-fold-search) (replace-regexp-in-string "<\\([a-zA-Z-]+\\)>" "@@texinfo:@var{@@\\1@@texinfo:}@@" (replace-regexp-in-string (regexp-opt '("BS" "TAB" "RET" "ESC" "SPC" "DEL" "LFD" "DELETE" "SHIFT" "Ctrl" "Meta" "Alt" "Cmd" "Super" "UP" "LEFT" "RIGHT" "DOWN") 'words) "@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t) t)))) +#+macro: codevar (eval (format "@@texinfo:@code{@@%s@@texinfo:}@@" (let (case-fold-search) (replace-regexp-in-string "\\([A-Z][A-Z-]+\\)" "@@texinfo:@var{@@\\&@@texinfo:}@@" $1 t)))) +#+macro: var @@texinfo:@var{@@$1@@texinfo:}@@ +#+macro: dfn @@texinfo:@dfn{@@$1@@texinfo:}@@ diff --git a/elpa/with-editor-3.4.3/docs/Makefile b/elpa/with-editor-3.4.3/docs/Makefile new file mode 100644 index 0000000..0eaf142 --- /dev/null +++ b/elpa/with-editor-3.4.3/docs/Makefile @@ -0,0 +1,110 @@ +-include ../config.mk +include ../default.mk + +docs: texi info html html-dir pdf + +texi: $(PKG).texi +info: $(PKG).info dir +html: $(PKG).html +html-dir: $(PKG)/index.html +pdf: $(PKG).pdf + +ORG_ARGS = --batch -Q $(ORG_LOAD_PATH) +ORG_EVAL += --eval "(setq indent-tabs-mode nil)" +ORG_EVAL += --eval "(setq org-src-preserve-indentation nil)" +ORG_EVAL += --funcall org-texinfo-export-to-texinfo + +redo-docs: + @touch $(PKG).org + @make docs + +.revdesc: ; +_ := $(shell test "$(REVDESC)" = "$$(cat .revdesc 2> /dev/null)" ||\ + echo "$(REVDESC)" > .revdesc) + +%.texi: %.org .orgconfig .revdesc + @printf "Generating $@\n" + @$(EMACS) $(ORG_ARGS) $< $(ORG_EVAL) + +%.info: %.texi + @printf "Generating $@\n" + @$(MAKEINFO) --no-split $< -o $@ + +dir: $(PKG).info + @printf "Generating $@\n" + @printf "%s" $^ | xargs -n 1 $(INSTALL_INFO) --dir=$@ + +HTML_FIXUP_CSS = '/<link rel="stylesheet" type="text\/css" href="\/assets\/page.css">/a\ +<link rel="icon" href="/assets/magit_alt1.ico">\ +\n<link class="s-css-s--style" rel="stylesheet" title="Default" href="/assets/themes/default.css">\ +\n<link class="s-css-s--style" rel="stylesheet alternate" title="Default high contrast" href="/assets/themes/default-high-contrast.css">\ +\n<link class="s-css-s--style" rel="stylesheet alternate" title="Solarized dark xterm" href="/assets/themes/solarized-dark-xterm.css">\ +\n<link class="s-css-s--style" rel="stylesheet alternate" title="Black on white" href="/assets/themes/black-on-white.css">\ +\n<script src="/assets/js/simple-css-switch.js"></script>' +HTML_FIXUP_ONLOAD = 's/<body lang="en">/<body lang="en" onload="simpleCssSwitch()">/' +HTML_FIXUP_MENU = '/<\/body>/i<div id="s-css-s--menu"><\/div>' + +%.html: %.texi + @printf "Generating $@\n" + @$(MAKEINFO) --html --no-split $(MANUAL_HTML_ARGS) $< + @sed -i -e $(HTML_FIXUP_CSS) -e $(HTML_FIXUP_ONLOAD) -e $(HTML_FIXUP_MENU) $@ + +%/index.html: %.texi + @printf "Generating $(PKG)/*.html\n" + @rm -rf $(PKG) + @$(MAKEINFO) --html -o $(PKG)/ $(MANUAL_HTML_ARGS) $< + @for f in $$(find $(PKG) -name '*.html') ; do \ + sed -i -e $(HTML_FIXUP_CSS) -e $(HTML_FIXUP_ONLOAD) -e $(HTML_FIXUP_MENU) $$f ; \ + done + +%.pdf: %.texi + @printf "Generating $@\n" + @texi2pdf --clean $< > /dev/null + +PUBLISH_PATH ?= /manual/ +RELEASE_PATH ?= /manual/$(VERSION)/ +S3_BUCKET ?= s3://$(DOMAIN) +PUBLISH_TARGET = $(S3_BUCKET)$(PUBLISH_PATH) +RELEASE_TARGET = $(S3_BUCKET)$(RELEASE_PATH) +CFRONT_PATHS = $(PKG).html $(PKG).pdf $(PKG)/* + +comma := , +empty := +space := $(empty) $(empty) + +publish: redo-docs + @aws s3 cp $(PKG).html $(PUBLISH_TARGET) + @aws s3 cp $(PKG).pdf $(PUBLISH_TARGET) + @aws s3 sync $(PKG) $(PUBLISH_TARGET)$(PKG)/ + @printf "Generating CDN invalidation\n" + @aws cloudfront create-invalidation --distribution-id $(CFRONT_DIST) --paths \ + "$(subst $(space),$(comma),$(addprefix $(PUBLISH_PATH),$(CFRONT_PATHS)))" > /dev/null + +release: redo-docs + @aws s3 cp $(PKG).html $(RELEASE_TARGET) + @aws s3 cp $(PKG).pdf $(RELEASE_TARGET) + @aws s3 sync $(PKG) $(RELEASE_TARGET)$(PKG)/ + @aws s3 cp $(PUBLISH_TARGET)dir.html $(RELEASE_TARGET)dir.html + @aws s3 cp $(PUBLISH_TARGET)dir/index.html $(RELEASE_TARGET)dir/index.html + @printf "Generating CDN invalidation\n" + @aws cloudfront create-invalidation --distribution-id $(CFRONT_DIST) --paths \ + "$(subst $(space),$(comma),$(addprefix $(RELEASE_PATH),$(CFRONT_PATHS)))" > /dev/null + +.PHONY: stats +stats: + @printf "Generating statistics\n" + @$(GITSTATS) $(GITSTATS_ARGS) $(TOP) $(GITSTATS_DIR) + +stats-upload: + @printf "Uploading statistics...\n" + @aws s3 sync $(GITSTATS_DIR) $(S3_BUCKET)/stats/$(PKG) + @printf "Uploaded to $(S3_BUCKET)/stats/$(PKG)\n" + @printf "Generating CDN invalidation\n" + @aws cloudfront create-invalidation \ + --distribution-id $(CFRONT_DIST) --paths "/stats/*" > /dev/null + +CLEAN = $(PKG).info dir $(PKG) $(PKG).html $(PKG).pdf + +clean: + @printf " Cleaning docs/*...\n" + @rm -rf $(CLEAN) diff --git a/elpa/with-editor-3.4.3/docs/htmlxref.cnf b/elpa/with-editor-3.4.3/docs/htmlxref.cnf new file mode 100644 index 0000000..54c3421 --- /dev/null +++ b/elpa/with-editor-3.4.3/docs/htmlxref.cnf @@ -0,0 +1,42 @@ +# https://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Configuration.html + +EMACS = https://www.gnu.org/software/emacs/manual + +auth mono ${EMACS}/html_mono/auth.html +auth node ${EMACS}/html_node/auth/ + +ediff mono ${EMACS}/html_mono/ediff.html +ediff node ${EMACS}/html_node/ediff/ + +elisp mono ${EMACS}/html_mono/elisp.html +elisp node ${EMACS}/html_node/elisp/ + +emacs mono ${EMACS}/html_mono/emacs.html +emacs node ${EMACS}/html_node/emacs/ + + +MAGIT = https://magit.vc/manual + +forge mono ${MAGIT}/forge.html +forge node ${MAGIT}/forge/ + +ghub mono ${MAGIT}/ghub.html +ghub node ${MAGIT}/ghub/ + +magit mono ${MAGIT}/magit.html +magit node ${MAGIT}/magit/ + +transient mono ${MAGIT}/transient.html +transient node ${MAGIT}/transient/ + +with-editor mono ${MAGIT}/with-editor.html +with-editor node ${MAGIT}/with-editor/ + + +MIRROR = https://emacsmirror.net/manual + +borg mono ${MAGIT}/borg.html +borg node ${MAGIT}/borg/ + +epkg mono ${MAGIT}/epkg.html +epkg node ${MAGIT}/epkg/ diff --git a/elpa/with-editor-3.4.3/docs/with-editor.org b/elpa/with-editor-3.4.3/docs/with-editor.org new file mode 100644 index 0000000..00352d3 --- /dev/null +++ b/elpa/with-editor-3.4.3/docs/with-editor.org @@ -0,0 +1,311 @@ +#+title: With-Editor User Manual +:PREAMBLE: +#+author: Jonas Bernoulli +#+email: emacs.with-editor@jonas.bernoulli.dev +#+date: 2015-{{{year}}} + +#+texinfo_dir_category: Emacs +#+texinfo_dir_title: With-Editor: (with-editor). +#+texinfo_dir_desc: Using the Emacsclient as $EDITOR +#+subtitle: for version 3.4.3 + +#+setupfile: .orgconfig + +The library ~with-editor~ makes it easy to use the Emacsclient as the +~$EDITOR~ of child processes, making sure they know how to call home. +For remote processes a substitute is provided, which communicates with +Emacs on standard output instead of using a socket as the Emacsclient +does. + +This library was written because Magit has to be able to do the above +to allow the user to edit commit messages gracefully and to edit +rebase sequences, which wouldn't be possible at all otherwise. + +Because other packages can benefit from such functionality, this +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. + +#+texinfo: @noindent +This manual is for With-Editor version 3.4.3. + +#+texinfo: @insertcopying +:END: +* Using the With-Editor package + +The ~With-Editor~ package is used internally by Magit when editing +commit messages and rebase sequences. It also provides some commands +and features which are useful by themselves, even if you don't use +Magit. + +For information about using this library in your own package, see +[[*Using With-Editor as a library]]. + +** Configuring With-Editor + +With-Editor tries very hard to locate a suitable ~emacsclient~ +executable, so ideally you should never have to customize the option +~with-editor-emacsclient-executable~. When it fails to do so, then the +most likely reason is that someone found yet another way to package +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 processes of + this Emacs instance. By using this executable, child processes can + call home to their parent process. + + This option is automatically set at startup by looking in ~exec-path~, + and other places where the executable could be installed, to find + the ~emacsclient~ executable most suitable for the current Emacs + instance. + + You should *not* customize this option permanently. If you have to do + it, then you should consider that a temporary kludge and inform the + Magit maintainer as described in [[*Debugging][Debugging]]. + + If With-Editor fails to find a suitable ~emacsclient~ on your system, + then this should be fixed for all users at once, by teaching + ~with-editor-locate-emacsclient~ how to do so on your system and + systems like yours. Doing it this way has the advantage, that you + won't have do it again every time you update Emacs, and that other + users who have installed Emacs the same way as you have, won't have + to go through the same trouble. + + Note that there also is a nuclear option; setting this variable to + ~nil~ causes the "sleeping editor" described below to be used even for + local child processes. Obviously we don't recommend that you use + this except in "emergencies", i.e., before we had a change to add a + kludge appropriate for your 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. + +The ~emacsclient~ cannot be used when using Tramp to run a process on a +remote machine. (Theoretically it could, but that would be hard to +setup, very fragile, and rather insecure). + +With-Editor provides an alternative "editor" which can be used by +remote processes in much the same way as local processes use an +~emacsclient~ executable. This alternative is known as the "sleeping +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. + + This fallback is used for asynchronous processes started inside the + macro ~with-editor~, when the process runs on a remote machine or for + local processes when ~with-editor-emacsclient-executable~ is ~nil~. + + Where the latter uses a socket to communicate with Emacs' server, + this substitute prints edit requests to its standard output on + which a process filter listens for such requests. As such it is + not a complete substitute for a proper ~emacsclient~, it can only + be used as ~$EDITOR~ of child process of the current Emacs instance. + + Some shells do not execute traps immediately when waiting for a + child process, but by default we do use such a blocking child + process. + + If you use such a shell (e.g., ~csh~ on FreeBSD, but not Debian), then + you have to edit this option. You can either replace ~sh~ with ~bash~ + (and install that), or you can use the older, less performant + implementation: + + #+BEGIN_SRC emacs-lisp + "sh -c '\ + echo \"WITH-EDITOR: $$ OPEN $0$1 IN $(pwd)\"; \ + trap \"exit 0\" USR1; \ + trap \"exit 1\" USR2; \ + while true; do sleep 1; done'" + #+END_SRC + + Note that the unit separator character () right after the file + name ($0) is required. + + Also note that using this alternative implementation leads to a + delay of up to a second. The delay can be shortened by replacing + ~sleep 1~ with ~sleep 0.01~, or if your implementation does not support + floats, then by using ~nanosleep~ instead. + +** Using With-Editor commands + +This section describes how to use the ~with-editor~ library /outside/ of +Magit. You don't need to know any of this just to create commits +using Magit. + +The commands ~with-editor-async-shell-command~ and +~with-editor-shell-command~ are intended as drop in replacements for +~async-shell-command~ and ~shell-command~. They automatically export +~$EDITOR~ making sure the executed command uses the current Emacs +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~. + +To always use these variants add this to your init file: + +#+begin_src emacs-lisp + (keymap-global-set "<remap> <async-shell-command>" + #'with-editor-async-shell-command) + (keymap-global-set "<remap> <shell-command>" + #'with-editor-shell-command) +#+end_src + +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 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~, ~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 '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) +#+end_src + +Some variants of this function exist; these two forms are equivalent: + +#+begin_src emacs-lisp + (add-hook 'shell-mode-hook + (apply-partially 'with-editor-export-editor "GIT_EDITOR")) + (add-hook 'shell-mode-hook 'with-editor-export-git-editor) +#+end_src + +- 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~. + +* Using With-Editor as a library + +This section describes how to use the ~with-editor~ library /outside/ of +Magit to teach another package how to have its child processes call +home, just like Magit does. You don't need to know any of this just +to create commits using Magit. You can also ignore this if you use +~with-editor~ outside of Magit, but only as an end-user. + +For information about interactive use and options that affect both +interactive and non-interactive use, see [[*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 the + user edits a file. + + This is done by establishing a local binding for ~process-environment~ + and changing the value of the ~EDITOR~ environment variable in that + scope. This affects all (asynchronous) processes started by forms + (dynamically) inside BODY. + + If BODY begins with a literal string, then that variable is set + instead of ~EDITOR~. + +- Macro: with-editor* envvar &rest body :: + + This macro is like ~with-editor~, except 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 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. + +* Debugging + +With-Editor tries very hard to locate a suitable ~emacsclient~ +executable, and then sets option ~with-editor-emacsclient-executable~ +accordingly. In very rare cases this fails. When it does fail, then +the most likely reason is that someone found yet another way to +package Emacs (most likely on macOS) without putting the executable on +~$PATH~, and we have to add another kludge to find it anyway. + +If you are having problems using ~with-editor~, e.g., you cannot commit +in Magit, then please open a new issue at +https://github.com/magit/with-editor/issues and provide information +about your Emacs installation. Most importantly how did you install +Emacs and what is the output of ~M-x with-editor-debug RET~. + +* Function and Command Index +:PROPERTIES: +:APPENDIX: t +:INDEX: fn +:END: +* Variable Index +:PROPERTIES: +:APPENDIX: t +:INDEX: vr +:END: +* Copying +:PROPERTIES: +:COPYING: t +:END: + +#+begin_quote +Copyright (C) 2015-{{{year}}} Jonas Bernoulli <emacs.with-editor@jonas.bernoulli.dev> + +You can redistribute this document and/or modify it under the terms +of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any +later version. + +This document 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. +#+end_quote + +# LocalWords: LocalWords +# LocalWords: Magit Emacs emacsclient FreeBSD macOS texinfo +# LocalWords: async eval hg init performant rebase startup + +# IMPORTANT: Also update ORG_ARGS and ORG_EVAL in the Makefile. +# Local Variables: +# eval: (require 'magit-utils nil t) +# indent-tabs-mode: nil +# org-src-preserve-indentation: nil +# End: diff --git a/elpa/with-editor-3.4.3/docs/with-editor.texi b/elpa/with-editor-3.4.3/docs/with-editor.texi new file mode 100644 index 0000000..0cdf62c --- /dev/null +++ b/elpa/with-editor-3.4.3/docs/with-editor.texi @@ -0,0 +1,344 @@ +\input texinfo @c -*- texinfo -*- +@c %**start of header +@setfilename with-editor.info +@settitle With-Editor User Manual +@documentencoding UTF-8 +@documentlanguage en +@c %**end of header + +@copying +@quotation +Copyright (C) 2015-2024 Jonas Bernoulli <emacs.with-editor@@jonas.bernoulli.dev> + +You can redistribute this document and/or modify it under the terms +of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any +later version. + +This document 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. + +@end quotation +@end copying + +@dircategory Emacs +@direntry +* With-Editor: (with-editor). Using the Emacsclient as $EDITOR. +@end direntry + +@finalout +@titlepage +@title With-Editor User Manual +@subtitle for version 3.4.3 +@author Jonas Bernoulli +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@ifnottex +@node Top +@top With-Editor User Manual + +The library @code{with-editor} makes it easy to use the Emacsclient as the +@code{$EDITOR} of child processes, making sure they know how to call home. +For remote processes a substitute is provided, which communicates with +Emacs on standard output instead of using a socket as the Emacsclient +does. + +This library was written because Magit has to be able to do the above +to allow the user to edit commit messages gracefully and to edit +rebase sequences, which wouldn't be possible at all otherwise. + +Because other packages can benefit from such functionality, this +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. + +@noindent +This manual is for With-Editor version 3.4.3. + +@insertcopying +@end ifnottex + +@menu +* Using the With-Editor package:: +* Using With-Editor as a library:: +* Debugging:: +* Function and Command Index:: +* Variable Index:: + +@detailmenu +--- The Detailed Node Listing --- + +Using the With-Editor package + +* Configuring With-Editor:: +* Using With-Editor commands:: + +@end detailmenu +@end menu + +@node Using the With-Editor package +@chapter Using the With-Editor package + +The @code{With-Editor} package is used internally by Magit when editing +commit messages and rebase sequences. It also provides some commands +and features which are useful by themselves, even if you don't use +Magit. + +For information about using this library in your own package, see +@ref{Using With-Editor as a library}. + +@menu +* Configuring With-Editor:: +* Using With-Editor commands:: +@end menu + +@node Configuring With-Editor +@section Configuring With-Editor + +With-Editor tries very hard to locate a suitable @code{emacsclient} +executable, so ideally you should never have to customize the option +@code{with-editor-emacsclient-executable}. When it fails to do so, then the +most likely reason is that someone found yet another way to package +Emacs (most likely on macOS) without putting the executable on @code{$PATH}, +and we have to add another kludge to find it anyway. + +@defopt with-editor-emacsclient-executable +The @code{emacsclient} executable used as the editor by child processes of +this Emacs instance. By using this executable, child processes can +call home to their parent process. + +This option is automatically set at startup by looking in @code{exec-path}, +and other places where the executable could be installed, to find +the @code{emacsclient} executable most suitable for the current Emacs +instance. + +You should @strong{not} customize this option permanently. If you have to do +it, then you should consider that a temporary kludge and inform the +Magit maintainer as described in @ref{Debugging, , Debugging}. + +If With-Editor fails to find a suitable @code{emacsclient} on your system, +then this should be fixed for all users at once, by teaching +@code{with-editor-locate-emacsclient} how to do so on your system and +systems like yours. Doing it this way has the advantage, that you +won't have do it again every time you update Emacs, and that other +users who have installed Emacs the same way as you have, won't have +to go through the same trouble. + +Note that there also is a nuclear option; setting this variable to +@code{nil} causes the "sleeping editor" described below to be used even for +local child processes. Obviously we don't recommend that you use +this except in "emergencies", i.e., before we had a change to add a +kludge appropriate for your setup. +@end defopt + +@defun with-editor-locate-emacsclient +The function used to set the initial value of the option +@code{with-editor-emacsclient-executable}. There's a lot of voodoo here. +@end defun + +The @code{emacsclient} cannot be used when using Tramp to run a process on a +remote machine. (Theoretically it could, but that would be hard to +setup, very fragile, and rather insecure). + +With-Editor provides an alternative "editor" which can be used by +remote processes in much the same way as local processes use an +@code{emacsclient} executable. This alternative is known as the "sleeping +editor" because it is implemented as a shell script which sleeps until +it receives a signal. + +@defopt with-editor-sleeping-editor +The sleeping editor is a shell script used as the editor of child +processes when the @code{emacsclient} executable cannot be used. + +This fallback is used for asynchronous processes started inside the +macro @code{with-editor}, when the process runs on a remote machine or for +local processes when @code{with-editor-emacsclient-executable} is @code{nil}. + +Where the latter uses a socket to communicate with Emacs' server, +this substitute prints edit requests to its standard output on +which a process filter listens for such requests. As such it is +not a complete substitute for a proper @code{emacsclient}, it can only +be used as @code{$EDITOR} of child process of the current Emacs instance. + +Some shells do not execute traps immediately when waiting for a +child process, but by default we do use such a blocking child +process. + +If you use such a shell (e.g., @code{csh} on FreeBSD, but not Debian), then +you have to edit this option. You can either replace @code{sh} with @code{bash} +(and install that), or you can use the older, less performant +implementation: + +@lisp +"sh -c '\ +echo \"WITH-EDITOR: $$ OPEN $0$1 IN $(pwd)\"; \ +trap \"exit 0\" USR1; \ +trap \"exit 1\" USR2; \ +while true; do sleep 1; done'" +@end lisp + +Note that the unit separator character () right after the file +name ($0) is required. + +Also note that using this alternative implementation leads to a +delay of up to a second. The delay can be shortened by replacing +@code{sleep 1} with @code{sleep 0.01}, or if your implementation does not support +floats, then by using @code{nanosleep} instead. +@end defopt + +@node Using With-Editor commands +@section Using With-Editor commands + +This section describes how to use the @code{with-editor} library @emph{outside} of +Magit. You don't need to know any of this just to create commits +using Magit. + +The commands @code{with-editor-async-shell-command} and +@code{with-editor-shell-command} are intended as drop in replacements for +@code{async-shell-command} and @code{shell-command}. They automatically export +@code{$EDITOR} making sure the executed command uses the current Emacs +instance as "the editor". With a prefix argument these commands +prompt for an alternative environment variable such as @code{$GIT_EDITOR}. + +@deffn Command with-editor-async-shell-command +This command is like @code{async-shell-command}, but it runs the shell +command with the current Emacs instance exported as @code{$EDITOR}. +@end deffn + +@deffn Command with-editor-shell-command +This command is like @code{shell-command}, but if the shell command ends +with @code{&} and is therefore run asynchronously, then the current Emacs +instance is exported as @code{$EDITOR}. +@end deffn + +To always use these variants add this to your init file: + +@lisp +(keymap-global-set "<remap> <async-shell-command>" + #'with-editor-async-shell-command) +(keymap-global-set "<remap> <shell-command>" + #'with-editor-shell-command) +@end lisp + +Alternatively use the global @code{shell-command-with-editor-mode}. + +@defvar shell-command-with-editor-mode +When this mode is active, then @code{$EDITOR} is exported whenever +ultimately @code{shell-command} is called to asynchronously run some shell +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{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 '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) +@end lisp + +Some variants of this function exist; these two forms are equivalent: + +@lisp +(add-hook 'shell-mode-hook + (apply-partially 'with-editor-export-editor "GIT_EDITOR")) +(add-hook 'shell-mode-hook 'with-editor-export-git-editor) +@end lisp + +@deffn Command with-editor-export-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 + +@deffn Command with-editor-export-git-editor +This command is like @code{with-editor-export-editor} but exports +@code{$GIT_EDITOR}. +@end deffn + +@deffn Command with-editor-export-hg-editor +This command is like @code{with-editor-export-editor} but exports +@code{$HG_EDITOR}. +@end deffn + +@node Using With-Editor as a library +@chapter Using With-Editor as a library + +This section describes how to use the @code{with-editor} library @emph{outside} of +Magit to teach another package how to have its child processes call +home, just like Magit does. You don't need to know any of this just +to create commits using Magit. You can also ignore this if you use +@code{with-editor} outside of Magit, but only as an end-user. + +For information about interactive use and options that affect both +interactive and non-interactive use, see @ref{Using the With-Editor package}. + +@defmac with-editor &rest body +This macro arranges for the @code{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 the +user edits a file. + +This is done by establishing a local binding for @code{process-environment} +and changing the value of the @code{EDITOR} environment variable in that +scope. This affects all (asynchronous) processes started by forms +(dynamically) inside BODY@. + +If BODY begins with a literal string, then that variable is set +instead of @code{EDITOR}. +@end defmac + +@defmac with-editor* envvar &rest body +This macro is like @code{with-editor}, except that the ENVVAR argument is +required and that it is evaluated at run-time. +@end defmac + +@defun with-editor-set-process-filter process filter +This function is like @code{set-process-filter} but ensures that adding the +new FILTER does not remove the @code{with-editor-process-filter}. This is +done by wrapping the two filter functions using a lambda, 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 +@code{with-editor-process-filter}, passing @code{t} as NO-STANDARD-FILTER@. +@end defun + +@node Debugging +@chapter Debugging + +With-Editor tries very hard to locate a suitable @code{emacsclient} +executable, and then sets option @code{with-editor-emacsclient-executable} +accordingly. In very rare cases this fails. When it does fail, then +the most likely reason is that someone found yet another way to +package Emacs (most likely on macOS) without putting the executable on +@code{$PATH}, and we have to add another kludge to find it anyway. + +If you are having problems using @code{with-editor}, e.g., you cannot commit +in Magit, then please open a new issue at +@uref{https://github.com/magit/with-editor/issues} and provide information +about your Emacs installation. Most importantly how did you install +Emacs and what is the output of @code{M-x with-editor-debug RET}. + +@node Function and Command Index +@appendix Function and Command Index + +@printindex fn + +@node Variable Index +@appendix Variable Index + +@printindex vr + +@bye |