e2ansi
e2ansi copied to clipboard
Emacsclient use-case how?
Hi,
I think a very common use case would be to use "emacs -daemon" and "emacsclient" together with this to avoid the startup time of emacs. Could you clarify how to do this? "emacsclient" only offers an eval parameter.
Cheers
Hi!
I have been thinking about using emacs in deamon mode, but at this point in time it's only an idea. Before this becomes reality there are several technical issues that needs to be solved first. One, which you have already pointed out, is how to "wrap" emacsclient in a suitable script (without this makes it slower). Another problem is how to handle the case when several files should be converted at once.
Meanwhile, I would suggest optimizing your own startup code -- I have noticed that Emacs actually start surprisingly fast when no or a small init file is used.
I apologize that I can't give you a better answer. Anyway, I'm glad for your feedback (especially since I have had close to none concerning e2ansi so far).
Sincerely, Anders Lindgren
On Fri, Feb 13, 2015 at 5:12 PM, hura [email protected] wrote:
Hi,
I think a very common use case would be to use "emacs -daemon" and "emacsclient" together with this to avoid the startup time of emacs. Could you clarify how to do this? "emacsclient" only offers an eval parameter.
Cheers
— Reply to this email directly or view it on GitHub https://github.com/Lindydancer/e2ansi/issues/2.
I think use case number two is usually a use case where startup time isn't crucial.
Why does this not work:
emacsclient -e '(find-file "main.tex") (e2ansi-print-buffer)'
For many reasons...
To start with, in elisp you can't simply pack expressions on top of each
other. You have to use progn
or some other construct that group
expressions together, like:
emacsclient -e '(progn (find-file "main.tex") (e2ansi-print-buffer))'
However, the main problem with this is that it's the running interactive
Emacs that performs the work. This mean that the end result ends up in the
message area of that Emacs, not to standard output of the emacsclient
program. I haven't investigated if it's even possible to print something to
the output stream of emacslient
. If this isn't the case, then we would
have to write to some kind of script that starts emacsclient
, tell it to
write the result to a temporary file and print the content to standard
output (and do this faster than starting a new Emacs).
Another problem with this is that it uses the users normal Emacs to do the processing, and this is typically not a good thing. It would be better to start an Emacs dedicated to e2ansi.
-- Anders
On Fri, Feb 13, 2015 at 6:10 PM, hura [email protected] wrote:
I think use case number two is usually a use case where startup time isn't crucial.
Why does this not work:
emacsclient -e '(find-file "main.tex") (e2ansi-print-buffer)'
— Reply to this email directly or view it on GitHub https://github.com/Lindydancer/e2ansi/issues/2#issuecomment-74288753.
Thanks for the explanation! This really helped. (For a background: I'm switching to emacs from 10+ years of VIM).
I got this working pretty well:
function ehl {
tempf="$(mktemp emacs-ansi-hl-stdout-$USER.XXXXXXXX --tmpdir)"
emacsclient -e "(progn (find-file \"$1\") (e2ansi-write-file \"$tempf\"))" 2>&1 >/dev/null
cat $tempf
\rm $tempf
}
Figured I'd leave it here in case somebody else also wants to use this. It's really really fast. (TODO: Cleanup/delete buffer(s)).
Hi,
Good that you got it working! It's a good start, however, there are lots of
things left to do like using a dedicated Emacs, using a different port than
the normal (if that even is possible), automatically spawning an Emacs if
one isn't running, ensure that it works when piping to less
(in which
case less starts the input filter with -
as file name). etc.
Also, I need to pick a good language to write the wrapper script in, which is naturally available both on UNIX and Windows.
-- Anders
On Fri, Feb 13, 2015 at 10:59 PM, hura [email protected] wrote:
Thanks for the explanation! This really helped. (For a background: I'm switching to emacs from 10+ years of VIM).
I got this working pretty well:
function ehl { tempf="$(mktemp emacs-ansi-hl-stdout-$USER.XXXXXXXX --tmpdir)" emacsclient -e "(progn (find-file "$1") (e2ansi-write-file "$tempf"))" 2>&1 >/dev/null cat $tempf \rm $tempf }
Figured I'd leave it here in case somebody else also wants to use this. It's really really fast. (TODO: Cleanup/delete buffer(s)).
— Reply to this email directly or view it on GitHub https://github.com/Lindydancer/e2ansi/issues/2#issuecomment-74334563.