{"id":24085714,"url":"https://github.com/szermatt/emacsclient-commands","last_synced_at":"2025-05-02T22:46:32.153Z","repository":{"id":38433805,"uuid":"254156939","full_name":"szermatt/emacsclient-commands","owner":"szermatt","description":"a collection of small shell utilities that connect to a local Emacs server.","archived":false,"fork":false,"pushed_at":"2024-04-01T18:34:00.000Z","size":226,"stargazers_count":13,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-02T22:46:27.084Z","etag":null,"topics":["ediff","emacs","emacs-server","git","hg"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szermatt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-08T17:33:24.000Z","updated_at":"2025-04-07T10:44:21.000Z","dependencies_parsed_at":"2024-06-19T09:59:40.288Z","dependency_job_id":"03954f02-798a-41ea-b147-51ab137e57a1","html_url":"https://github.com/szermatt/emacsclient-commands","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szermatt%2Femacsclient-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szermatt%2Femacsclient-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szermatt%2Femacsclient-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szermatt%2Femacsclient-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szermatt","download_url":"https://codeload.github.com/szermatt/emacsclient-commands/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252118307,"owners_count":21697583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ediff","emacs","emacs-server","git","hg"],"created_at":"2025-01-10T01:54:19.850Z","updated_at":"2025-05-02T22:46:32.121Z","avatar_url":"https://github.com/szermatt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis is a collection of small shell utilities that connect to a local\nEmacs server. \n\nThese utilities make it easy for shell commands and scripts to\nintegrate with Emacs. This is especially useful when running from a\nshell from within an Emacs instance.\n\n* [e](#e) - execute an elisp expression and print the result\n* [ebuf](#ebuf) - send stdin into an Emacs buffer\n* [ecat](#ecat) - send the content of an Emacs buffer to stdout\n* [ecompile](#ecompile) - execute a command using Emacs compile\n* [ereg](#ereg) - manipulate the kill ring and registers\n* [erun](#erun) - run a command in an Emacs comint buffer\n* [emerge](#emerge) - merge files using Ediff on Emacs\n\nThese tools connect to Emacs through a UNIX or TCP socket created by the\n[Emacs server]\n\n[Emacs server]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html\n\n## Getting Started\n\nAssuming that you have [golang tools](https://golang.org/doc/install) installed, just run:\n\n```shell\nmake \nsudo make install\n```\n\nand you'll find the commands in `/usr/local/bin`. \n\nTo install it in your home directory instead, run:\n\n```shell\nDESTDIR=~/ make install\n```\n\n## Commands\n\n### e\n\n`e` evaluates a lisp expression and prints the result.\n\nThe main difference between `e` and [`emacsclient -eval`] is that `e`\ncleans up the result, so you'll get:\n\n```\n$ e '(concat \"hello \" \"world\")'\nhello world\n```\n\nand not `\"hello world\"`. This kind of output is easier to use in\nshell scripts.\n\n[`emacsclient -eval`]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Invoking-emacsclient.html\n\n### epipe\n\n`epipe` allows piping short command output to the shell and large\ncommand output into an Emacs buffer.\n\nFor example:\n```\ngit log | epipe\n```\noutputs the first 15 lines in the shell, then redirects the rest to a\nnew buffer.\n\nYou can configure the number of lines to output in the shell, the\nbuffer name and whether a new buffer is created every time. See the\noutput of `epipe -help` for details.\n\n`epipe` makes a good default pager, when running in a shell inside\nof emacs. Try adding the following to your `.bashrc`:\n\n```shell\nif [ -n \"$INSIDE_EMACS\" ]; then\n  export PAGER=\"epipe --limit 30\" \n  export GIT_PAGER=\"epipe --limit 10 '*git*'\"\nfi\n```\n\nIn some cases, Emacs can detect the type of content that is piped and\nchoose the appropriate major mode. This can be configured on the Emacs\nside. See the documentation of `magic-mode-alist` in the section [Auto\nMajor Mode] of the Emacs manual.\n\n[Auto Major Mode]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Auto-Major-Mode.html\n\nFor example, with the following snippet in  `~/.emacs.d/init.el`:\n\n```elisp\n(push '(\"^diff\" . diff-mode) magic-mode-alist)\n```\n\nEmacs will detect diffs and format them nicely with `diff-mode` when\nusing `git diff | epipe`\n\n\n### ebuf\n\n`ebuf` allows piping the output of shell commands to a new Emacs\nbuffer.\n\nExample:\n\n```shell\ngrep cat ~/.bash_history | ebuf cats\n```\n\n`ebuf` works like `epipe`, with the difference that even short command\noutput are put into the buffer.\n\n### erun\n\n`erun` tells Emacs to execute a command inside of a buffer. This can\nbe more convenient than piping and works with interactive commands. \n\nYou can customize the buffer name, whether a buffer is created,\nwhether the buffer is selected and whether the point stays at the\nbeginning or follows the end of the file. See the output of `erun\n-help` for details.\n\nExample:\n\n```shell\nerun grep cat ~/.bash_history\n```\n\n### ecat\n\n`ecat` outputs a buffer to stdout. The buffer is identified by its\nname. \n\nThis lets you process the content of buffers from inside the shell.\n\nExample:\n\n```shell\necat cats | wc -l\n```\n\n### ereg\n\n`ereg` can both set and read the content of the kill ring.\n\n`ereg` alone outputs the content of the kill ring, while `ereg -i`\nputs stdin into the kill ring.\n\nExample:\n\n```\n$ echo hello | ereg -i\n$ ereg\nhello\n```\n\nAdd the name of a register to read or write to a register instead of\nthe kill ring.\n\n### ecompile\n\n`ecompile` executes a command in a compilation buffer.\n\nExample:\n\n```shell\necompile make\n```\n\n### emerge\n\n`emerge` helps resolve conflicts using [Ediff](https://www.gnu.org/software/emacs/manual/html_node/ediff/index.html#Top).\n\nThe command starts an Ediff merge session and waits for the user to end\nthe session, usually by pressing q in the buffer \"Ediff Control Panel\". \n\nIf the session ends with all conflicts resolved, the merge is reported\nas successful to the caller. If there are conflicts left, the session\nis reported as failed.\n\nNormally, `emerge` reuses Emacs current frame, to change that specify\neither `-tty` to run Ediff in the current terminal or `-frame` to open\na new frame.\n\nThe tool also installs the following command bindings to the Ediff\ncontrol panel:\n\nC-c C-k\n: ends the Ediff session unsuccessfully\n\nC-c C-c\n: ends the Ediff session successfully\n\nTo use it with git, add the following to `~/.gitconfig`:\n\n```\n[mergetool \"ediff\"]\n    cmd = /usr/local/bin/emerge -local \"$LOCAL\" -remote \"$REMOTE\" -base \"$BASE\" -merged \"$MERGED\"\n    trustExitCode = true\n\n[merge]\n    tool = ediff\n```\n\n\nTo use it with Mercurial, add the following to `~/.hgrc`:\n\n```\n[ui]\nmerge = emacs\n\n[merge-tools]\nemacs.executable = /usr/local/bin/emerge\nemacs.args = -local $local -remote $other -base $base -merged $output\n```\n\n## Connection to Emacs\n\nThese tools communicate with Emacs through a UNIX socket. The\ndefault matches the default socket name created by `server-start`.\n\nIf you use more than one server, you'll need to either pass it to the\ncommand, using the argument `-socket-name` or set the env variable\n`EMACS_SOCKET_NAME`, or `-server-file` and `EMACS_SERVER_FILE` respectively if using a TCP server.\n\n---\n\nLicense GPL2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszermatt%2Femacsclient-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszermatt%2Femacsclient-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszermatt%2Femacsclient-commands/lists"}