<div>Hello I don't write because this program is very difficult for my format Thank You.<br><div class="gmail_quote"><div>El El mar, 16 de may. de 2017 a las 15:53, Alexandru Nedelcu <<a href="mailto:groups7@alexn.org">groups7@alexn.org</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p>Hello,</p>
<p>I have a small bundle I worked on for integrating <a href="https://www.gnu.org/software/emacs/" style="color:#3983c4" target="_blank">Emacs</a> with MailMate.</p>
<p>Project: <a href="https://github.com/alexandru/emacs.mmbundle" style="color:#3983c4" target="_blank">https://github.com/alexandru/emacs.mmbundle</a></p>
<p>It assumes the <a href="https://emacsformacosx.com/" style="color:#3983c4" target="_blank">Emacs for Mac OS X</a> distribution, but in case Emacs was installed using an alternative method (e.g. brew, Mac Ports, etc), then it's fine for as long as <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">emacs</code> and <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">emacsclient</code> binaries are found on this path:</p>
<pre style="background-color:#f7f7f7;border-radius:5px 5px 5px 5px;margin-left:15px;margin-right:15px;max-width:90vw;overflow-x:auto;padding:5px;color:black" bgcolor="#F7F7F7"><code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0" bgcolor="#F7F7F7"><span style="color:#996633">PATH</span><span style="color:#333333">=</span><span style="color:#996633">$HOME</span>/bin:~/Applications/Emacs.app/Contents/MacOS/bin:/Applications/Emacs.app/Contents/MacOS/bin:~/Applications/Emacs.app/Contents/MacOS:/Applications/Emacs.app/Contents/MacOS:/usr/local/bin:<span style="color:#996633">$PATH</span>
</code></pre>
<p>For reference, some implementation details ...</p>
<p>This was surprisingly tricky to develop, because the only reasonable way to use Emacs as an on-demand editor is through <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">emacsclient</code>, which needs an Emacs server to be active. Normally this is done by starting Emacs at boot with <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">--daemon</code> or by doing a <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">(server-start)</code> in the <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">emacs.el</code> config, or you can start the client with <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">emacsclient --alternate-editor=""</code>, which starts a daemon if one isn't available already.</p>
<p>However starting the daemon from within a MailMate-executed script doesn't work because it is missing a TTY. I managed to work around that by starting the daemon within a <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">script -q</code>. Found the trick on StackOverflow somewhere.</p>
<p>The other problem is that starting the daemon is too slow, might take 2-3 seconds, or even more, depending on how many plugins it has to load. So I was forced to display a notification by means of <code style="background-color:#f7f7f7;border-radius:3px;margin:0;padding:0 0.4em" bgcolor="#F7F7F7">osascript</code>, to let the user know that the editor is starting. But as long as a daemon is already active, opening a new Emacs window is instantaneous.</p>
<p>Cheers,</p>
</div>
--
<br>
Alex Nedelcu
<br>
<a href="https://alexn.org" target="_blank">alexn.org</a>
<br>
</div>
</div>
_______________________________________________<br>
mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com" target="_blank">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate" rel="noreferrer" target="_blank">https://lists.freron.com/listinfo/mailmate</a><br>
</blockquote></div></div>