dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

README-elpa (2509B)


      1 1 With-Editor
      2 ═════════════
      3 
      4   This library makes it possible to reliably use the Emacsclient as the
      5   `$EDITOR' of child processes.  It makes sure that they know how to
      6   call home.  For remote processes a substitute is provided, which
      7   communicates with Emacs on standard output/input instead of using a
      8   socket as the Emacsclient does.
      9 
     10   It provides the commands `with-editor-async-shell-command' and
     11   `with-editor-shell-command', which are intended as replacements for
     12   `async-shell-command' and `shell-command'.  They automatically export
     13   `$EDITOR' making sure the executed command uses the current Emacs
     14   instance as "the editor".  With a prefix argument these commands
     15   prompt for an alternative environment variable such as `$GIT_EDITOR'.
     16   To always use these variants add this to your init file:
     17 
     18   ┌────
     19   │ (keymap-global-set "<remap> <async-shell-command>"
     20   │ 		   #'with-editor-async-shell-command)
     21   │ (keymap-global-set "<remap> <shell-command>"
     22   │ 		   #'with-editor-shell-command)
     23   └────
     24 
     25   Alternatively use the global `shell-command-with-editor-mode', which
     26   always sets `$EDITOR' for all Emacs commands which ultimately use
     27   `shell-command' to asynchronously run some shell command.
     28 
     29   The command `with-editor-export-editor' exports `$EDITOR' or another
     30   such environment variable in `shell-mode', `eshell-mode', `term-mode'
     31   and `vterm-mode' buffers.  Use this Emacs command before executing a
     32   shell command which needs the editor set, or always arrange for the
     33   current Emacs instance to be used as editor by adding it to the
     34   appropriate mode hooks:
     35 
     36   ┌────
     37   │ (add-hook 'shell-mode-hook  'with-editor-export-editor)
     38   │ (add-hook 'eshell-mode-hook 'with-editor-export-editor)
     39   │ (add-hook 'term-exec-hook   'with-editor-export-editor)
     40   │ (add-hook 'vterm-mode-hook  'with-editor-export-editor)
     41   └────
     42 
     43   Some variants of this function exist, these two forms are equivalent:
     44 
     45   ┌────
     46   │ (add-hook 'shell-mode-hook
     47   │ 	  (apply-partially 'with-editor-export-editor "GIT_EDITOR"))
     48   │ (add-hook 'shell-mode-hook 'with-editor-export-git-editor)
     49   └────
     50 
     51   This library can also be used by other packages which need to use the
     52   current Emacs instance as editor.  In fact this library was written
     53   for Magit and its `git-commit-mode' and `git-rebase-mode'.  Consult
     54   `git-rebase.el' and the related code in `magit-sequence.el' for a
     55   simple example.