lindydancer / e2ansi Goto Github PK
View Code? Open in Web Editor NEWSyntax highlighting for `less`, powered by Emacs
Syntax highlighting for `less`, powered by Emacs
I'm using e2ansi as a filter for less. When I try to page a very large file, nothing seems to happen. But if I hit ^C, I get output that looks like this:
File goreham.log is large (10.6M), really open? (y or n)
So I believe that e2ansi is hanging because emacs is prompting for user input. I'm launching emacs with a --batch
option, so I'd have thought that prompts for user input would be turned off, but apparently not. I'd argue that, if possible, Emacs variables should be twiddled so that prompts of this kind are disabled, and that the answer to this particular question ("open large file?") should be "yes".
I'm using e2ansi on this file. It is not the largest file, but this error pops up:
$ e2ansi-cat hydrogen.cc
Args out of range: #<buffer hydrogen.cc>, 22542, 495376
$ emacs --version
GNU Emacs 24.3.93.1
Note, due to how Emacs parses options, some options passed to e2ansi-cat is parsed by Emacs. Most notably, passing the option --help to e2ansi-cat displays help for Emacs itself.
You can fix this, via the -- argument to Emacs.
There's a good overview in this article:
http://www.lunaryorn.com/2014/08/12/emacs-script-pitfalls.html#processing-command-line-arguments
With everything combined, you end up with this:
#!/bin/sh
":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
(message "Hello: %S" argv)
(kill-emacs 0)
Where the -- means Emacs doesn't try to interpret the options it recognises, and the explicit kill-emacs ensures that Emacs doesn't try to visit any remaining arguments as files (you can also set argv to nil, but it's cleaner to exit rather than letting Emacs continue to do things).
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
I have e2ansi working with eg Elisp files, but not Markdown. I get this error:
$ /usr/bin/emacs --batch -l markdown-mode -l solarized-theme -l e2ansi-cat --theme solarized-dark src/seq.el/README.md
Wrong type argument: symbolp, (font-lock-function-name-face)
The same command (without the -l markdown-mode
, and passing my init.el
instead of the .md
file) correctly produces syntax-highlighted Elisp output.
The only place I find font-lock-function-name-face
in the e2ansi directory is in file e2ansi-list.el
. I can't understand why that would be eval'ed at all.
BTW, in case you're wondering, -l e2ansi-cat
works because I have ~/.emacs.d/elpa/e2ansi-xxxxx/bin
in my EMACSLOADPATH
environment variable. You might want to add something about that to your doco. Or not. It's pretty nerdy :-)
$ emacs --version
GNU Emacs 24.5.1
Hi:
I just moved to emacs 27 and the e2ansy-cat doesn't work at all. When I try it in the old emacs it works perfectly, but not in the newer (future release) of emacs.
Any suggestion?
The README could do with a section titled "How to Install".
To be able to match emacs buffer exactly, it would be good to support exporting the buffer with it's background color.
This could be optional/off-by-default, since users may not want this.
Hi
I've successfully been able to use e2ansi
with less
using a manual pipe but not with the input preprocessor indicated by LESSOPEN. This works:
emacs --batch -l ~/.emacs -l bin/e2ansi-cat foo | less -R
but this
export LESSOPEN="|emacs --batch -l ~/.emacs -l bin/e2ansi-cat %s"
less -R foo
gives the error:
Symbol's value as variable is void: special-mode-map
Any idea what can be happening?
I'm using emacs
version 24.5.1, less
version 530 and the contents of ~/.emacs
is
(add-to-list 'load-path "~/.emacs.d/e2ansi/")
(add-to-list 'load-path "~/.emacs.d/face-explorer/")
Thank you!
Hi:
I have a different emacs path in my system so I need to update e2ansi-cat header everytime I download it:
Could you consider to use:
#!/usr/bin/env emacs
?
Thanks in advance,
Ergus
The e2ansi-cat program seems to produce no useful output when the input data comes from stdin. For instance,
emacs --batch -Q -l ~/.emacs -l bin/e2ansi-cat /etc/passwd
works fine for me, but
cat /etc/passwd |emacs --batch -Q -l ~/.emacs -l bin/e2ansi-cat /dev/stdin
produces no output. In situations where you know the input is stdin, you could save it to a temporary file, but this is problematic for streaming data and such. Is there a way to make it so that it can handle stdin directly?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.