Using emacs in batch mode to dump a file with syntax highlighting? -



Using emacs in batch mode to dump a file with syntax highlighting? -

i'd utilize emacs in kind of batch mode render file syntax highlighting , exit. specifically, want dump fontified buffer ansi escape codes shows reasonably syntax-highlighted on terminal. there way this?

the ansi-lpr.el library seems kind of along lines of want, output isn't colorified. can't figure out how on final hurdle — there lot of modules digest ansi escape codes emacs text properties (e.g. ansi-color.el) haven't found reverse. if can point me does, think can piece rest.

alternatively, i've seen hacky approaches this answer (using script , capturing output) in experiments approach has seemed unlikely fruitful — tons of undesirable command sequences mixed in highlighted text.

the overarching motivation here utilize emacs in $lessopen pipe syntax highlighting when page files. in case you're going it, i've tried , "just page files in emacs" not acceptable me.

i'm glad announce new package, e2ansi, (hopefully) asked for.

the bundle provides command-line tool e2ansi-cat starts emacs in batch mode, opens files, syntax highlight them (using font-lock), , creates ansi-colored versions of syntax highlighted files.

you can integrate less setting next variables to, example:

export "lessopen=|emacs --batch -q -l ~/.emacs -l bin/e2ansi-cat %s" export "less=-r" export more=$less

the end result looks following:

you can vary colors , attributes bold, underline, , italics using suitable emacs theme.

the e2ansi bundle located @ https://github.com/lindydancer/e2ansi

personal note

i give thanks posting question, straight inspired me write e2ansi.

emacs syntax-highlighting

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -