Skip to main content
5 votes
Accepted

Obtaining a backtrace on batch invocation of Emacs?

Is there a more idiomatic method for displaying backtraces for errors in batch mode? Nope, that's pretty much it. You can save a few characters by calling toggle-debug-on-error instead: emacs -...
npostavs's user avatar
  • 9,253
5 votes

Export an org-mode file as a PDF via command line?

I'm using self-compiled emacs 27.0.9x on Linux and macOS. To generate my presentations, I use org-mode. emacs -Q \ --batch "(require 'ox-beamer)" \ <input>.org -f org-beamer-export-to-pdf ...
Pedro A. Aranda's user avatar
4 votes
Accepted

How to use emacs packages in emacs lisp scripting

You have to tell Emacs where to find the s library: (add-to-list 'load-path "/path/to/s/") Or if you put s in the same directory: (add-to-list 'load-path ".")
clemera's user avatar
  • 3,476
4 votes
Accepted

Export all org-tables from batch mode

You can use org-table-map-tables for iterating over the tables of an Org file. Example for the Shell command: emacs --batch table.org --eval '(org-table-map-tables (quote org-table-export))' You ...
Tobias's user avatar
  • 33.7k
4 votes

Batch mode, read NUL-delimited list of file names from stdin

As NickD analyzed, read-from-minibuffer reads one line at a time, and considers either CR or LF to end a line and doesn't distinguish between them. And I can't find another way to read from standard-...
Gilles 'SO- stop being evil''s user avatar
3 votes

Batch mode, read NUL-delimited list of file names from stdin

Assuming I'm reading the code correctly, the keymap argument is ineffective when -batch is used. What happens is that read-from-minibuffer gets called and it, in turn, calls read_minibuf (Line 1318 in ...
NickD's user avatar
  • 33.6k
3 votes

How to run elisp checking utilities from the command line?

See the function batch-byte-compile which implements the last of your asks. It is invoked as emacs --batch -f batch-byte-compile *.el to compile all the *.el files in the current directory. If you ...
NickD's user avatar
  • 33.6k
3 votes

Make Emacs Line-Oriented

According to @NickD’s answer, to make Emacs line-oriented just like Vim’s ex mode, use: $ emacs -batch \ > -eval "(while t \ > (write-char ?\\n) \ > (...
shynur's user avatar
  • 5,890
3 votes
Accepted

Make Emacs Line-Oriented

emacs -batch can do that: echo '(progn (find-file "123.txt") (replace-string "2" "0") (save-buffer))' | emacs -batch --eval "(call-interactively #'eval-expression)&...
NickD's user avatar
  • 33.6k
3 votes

How to use emacs packages in emacs lisp scripting

--batch doesn't process your init file, so it has no idea where your personal libraries are. Instead of (require 's) (which, as per clemera's answer, means you need to set load-path), you could simply ...
phils's user avatar
  • 53.1k
3 votes
Accepted

Using org in emacs batch mode

I presume you have access to org-latex-classes when you start up Emacs for interactive use, so something in your init file is loading it. You can check which library defines org-latex-classes with C-...
Dan's user avatar
  • 33.4k
3 votes
Accepted

script to Ediff two files in running gui Emacs?

I use this to diff from bash. --eval is what I think you are looking for. If you are not using emacsclient you can adjust the first portion accordingly. ediff () { if [ -d $1 ]; then ...
eflanigan00's user avatar
2 votes
Accepted

Running flyspell on Latex files in batch-mode

I presume that the question mentioned flyspell specifically because it knows about TeX syntax and is good at ignoring math, TeX commands, etc. Although aspell can also do this (more on that below), I ...
Jason Blevins's user avatar
1 vote
Accepted

"unspecified-fg/bg" in "batch mode" when querying foreground/background colors

Emacs won't initialize the window system when launched by -batch: When Emacs is started up, it performs the following operations: If not running in batch mode, it initializes the window system that ....
shynur's user avatar
  • 5,890
1 vote
Accepted

How can I get the output of a batch emacs run to a custom path?

You will need to use a different function if you want to control where the export output goes. org-html-export-to-html uses the name of the Org mode file and saves it in the same directory with the ...
NickD's user avatar
  • 33.6k
1 vote
Accepted

Specifying a subdirectory in the argument of :tangle: effect only non-interactively

[These are my original comments made into an answer -- but note that there is a mysterious mode change that is so far unexplained.] I cannot reproduce the problem: interactively tangling the file ...
NickD's user avatar
  • 33.6k
1 vote

Trying to update emacs from the command line, but add-hook won't fire

The documentation gives the answer. Don't run this hook directly. It is meant to be run as part of package--update-downloads-in-progress. As a rule, -- in the name is an indication that it's a ...
naugiedoggie's user avatar
1 vote

Emacs org export shell script from txt file

Type -*- mode:org -*- at the top of file
user29606's user avatar
1 vote
Accepted

Can I use emacs to execute elisp files witout opening emacs?

You can use the --script flag to run an elisp file as a script: #!/usr/bin/emacs --script <-- Insert your elisp program here --> See the manual page on Initial Options for more details.
Tyler's user avatar
  • 22.8k
1 vote

How can I export an org file to PDF in batch mode and have source code blocks executed?

As you found out, the problem is that --batch prevents Emacs from loading your init file. You can work around that by using something like emacs --batch -l ~/.emacs ... or emacs --batch -l ~/....
Stefan's user avatar
  • 26.7k
1 vote

indentation (with multiline comments) in batch processing

Should just be a matter of setting the comment offset to always choose the current indentation: (defun myindent () "Format the whole buffer." (c-set-style "stroustrup") ;; `c' is for comment....
npostavs's user avatar
  • 9,253
1 vote
Accepted

Readline emulation in batch mode

I ended up writing my own readline thing with the help of @ack006. It consists of a shell script enabling raw mode and sending one character at a time to an Emacs in batch mode which interprets the ...
wasamasa's user avatar
  • 22.4k

Only top scored, non community-wiki answers of a minimum length are eligible