warbo-utilities: 208a50dfe2270315655c5ba70ff98ec7f6e45068
1: From: Chris Warburton
2: Date: Mon, 12 Jun 2017 13:50:08 +0100
3: State: resolved
4: Subject: Make emacsclient work as artemis editor
5: Message-Id: <afbc1cc47d3479cf-0-artemis@nixos>
6: resolution: fixed
7:
8: git-artemis makes files called /tmp/tmpXXX.txt for issues, opens them in
9: EDITOR, then uses the result to create the actual issue. Fair
10: enough. The problem is, we want to use emacsclient as EDITOR, and that
11: will treat /tmp/tmpXXX.txt as a text file (and rightly so!).
12:
13: What we need to do is open the file in emacsclient, then trigger some
14: Emacs Lisp to set the mode. Note that we can't do this with a single
15: emacsclient call, since opening files and evaluating code are treated as
16: mutually exclusive options.
17:
18: We must open the file first, so that the buffer's available when we run
19: our ELisp. However, our ELisp evaluation will exit immediately, rather
20: than waiting for us to finish editing the file.
21:
22: So, the solution seems to be:
23:
24: - Write a wrapper around git-artemis. Might as well call it
25: "artemis". This will set the EDITOR to a custom script.
26: - The custom script accepts a filename as $1, then calls emacsclient
27: with that filename, using & to run it in the background.
28: - We sleep for a second, to give Emacs chance to open the file, then we
29: run emacsclient again, passing '--eval "(some-custom-lisp \"$1\")"'
30: where some-custom-lisp will switch to the given filename's buffer and
31: set the right mode.
32: - We then need to `wait` for the first emacsclient process to finish
33: (i.e. wait until we've finished editing). Otherwise we'll exit
34: immediately, artemis will see the unmodified text and abort (since it
35: checks whether the text is modified). Meanwhile we'll be in Emacs,
36: blissfully unaware that artemis has already finished, and the issue
37: we're entering will just end up cluttering /tmp without being
38: processed.
Generated by git2html.