GithubHelp home page GithubHelp logo

wilfred / with-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from magit/with-editor

0.0 2.0 0.0 84 KB

Use the Emacsclient as the $EDITOR of child processes

Home Page: http://magit.vc/manual/with-editor

License: GNU General Public License v3.0

Makefile 11.28% Emacs Lisp 88.72%

with-editor's Introduction

With-Editor

This library makes it possible to reliably use the Emacsclient as the $EDITOR of child processes. It makes sure that they know how to call home. For remote processes a substitute is provided, which communicates with Emacs on standard output/input instead of using a socket as the Emacsclient does.

It provides the commands with-editor-async-shell-command and with-editor-shell-command, which are intended as 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. To always use these variants add this to your init file:

(define-key (current-global-map)
  [remap async-shell-command] 'with-editor-async-shell-command)
(define-key (current-global-map)
  [remap shell-command] 'with-editor-shell-command)

Alternatively use the global shell-command-with-editor-mode, which always sets $EDITOR for all Emacs commands which ultimately 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:

(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)

Some variants of this function exist, these two forms are equivalent:

(add-hook 'shell-mode-hook
          (apply-partially 'with-editor-export-editor "GIT_EDITOR"))
(add-hook 'shell-mode-hook 'with-editor-export-git-editor)

This library can also be used by other packages which need to use the current Emacs instance as editor. In fact this library was written for Magit and its git-commit-mode and git-rebase-mode. Consult git-rebase.el and the related code in magit-sequence.el for a simple example.

with-editor's People

Contributors

justbur avatar kyleam avatar marsam avatar npostavs avatar phst avatar suvayu avatar tarsius avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.