Questions tagged [script]
The script tag has no summary.
30 questions
1
vote
4
answers
126
views
Detect if emacs is running as a script
How can I detect whether emacs is being invoked as a standalone script?
I'm looking for the emacs equivalent of pythons __name__ == __main__ test:
if __name__ == __main__:
# running this file a ...
0
votes
2
answers
136
views
How can a regex replace that computes the replacement in a function using back references be converted to a CLI batch version processing line by line?
An example of this is a script to output the contents of .zsh_history file in the manner of the history command, so an emacs script would be invoked by a command line like display.sh.el < ~/....
0
votes
2
answers
517
views
How can I use a file of Elisp code as a script?
I have written a code:
;;; calculator.el --- Calculator
;;; Commentary:
;;; Code:
(let ((operand1 (read-number "Enter the first number: "))
(operand2 (read-number "Enter the ...
0
votes
1
answer
49
views
set the correct major mode for script files based on interpreter
I want to make a function that will set the correct major mode based on the interpreter used for a script.
I don't want to include extensions in my scripts (because that can be annoying if making cli ...
1
vote
1
answer
75
views
How to build a script that queries an org-table?
I have a list of more than 80 search engines to perform keyword searches. They are listed in an org-table like this:
#+name: keyword-search
|---------------+--------------------------------------------...
0
votes
1
answer
125
views
Emacs 28.1: Bash Shell Script Indenting does not recognize if [....];then
Since upgrade to Emacs 28.1, I have noted an annoy change in shell-script mode auto-formatting.
I would like to recover the old behavior
Before, if I entered
if [ "$x" = "" ];then
...
1
vote
3
answers
214
views
Using Emacs to find and copy relevant database records
I have reduced a large text file to a 1.9GB size that Microsoft Access can handle, but only as a linked file. To permit full Access operations - to import the relevant data into Access - I need to ...
1
vote
1
answer
63
views
Why does the same code called first by bash and then by emacs not behave the same way?
I have this LaTeX code:
%% test.tex
\begin{wrapfig}
\includegraphics[width=1cm]{fig1.eps}\end{wrapfig}
\includegraphics[width=1cm]{fig2.eps}
I have a script called fix-files-ext.sh that fixes the ...
0
votes
1
answer
791
views
How to comment out multiple or all files in a directory?
I frequently use commands like paredit-comment-dwim, comment-dwim, and comment-region. I am also aware these commands can have a compound effect with the mark command.
But, I would like to comment ...
3
votes
1
answer
246
views
How to run elisp checking utilities from the command line?
There are a number of emacs-lisp checking utilities - for example:
checkdoc.
package-lint.
relint.
byte-code-compilation.
Are there existing ways to quickly run this on an entire project without ...
0
votes
0
answers
645
views
How to run shell scripts at startup of Emacs/EXWM?
I have configurations I would generally run on the startup of DWM. Now, I would like to do the same with EXWM/Emacs.
Is there any Elispian way to do it?
EDIT: arrived in conjunction with @lawlist
OBS: ...
3
votes
2
answers
330
views
Emacs script to indent files from the command line
I am trying to create an Emacs script that indents HTML files from the command line. This is what I have so far:
#!/usr/bin/env -S emacs --script
(require 'web-mode)
(indent-region (point-min) (point-...
1
vote
1
answer
290
views
How can I run a subprocess with emacs --script
I'm trying to write a script using emacs --script and in it I am using start-process, because I want to use set-process-filter.
The following does nothing if run as a script:
#!/usr/bin/env -S emacs -...
2
votes
1
answer
1k
views
Print shell-command output to STDOUT?
Is there an equivalent of C's system(char*) or Python's os.system(string) for emacs --script?
I want to use Emacs for shell-scripting purposes. However, I cannot find a function that allows running an ...
0
votes
0
answers
108
views
A script to run emacs in cmd
Good day,
I created the following script in order to run emacs 27.1 in cmd without gui:
$ cd \Users\xxxxxx\emacs-27.1-x86_64\bin
$ emacs-27.1.exe -nw %1
An elementary script which I named demacs. ...
4
votes
3
answers
494
views
How to add a new input method for Syriac script in Emacs?
I want to write an article in English mingled with Syriac script in emacs, when I hit list-input-methods the script is not shown, or at least I couldn't identify this language in the displayed list. ...
0
votes
0
answers
108
views
How can I provide the first-error and next-error initial positions as region selection in order to save to the kill-ring?
I am running a make command. I'd like to capture the first error and output it to a file.
How can I select as a region from the beginning of first-error position to the position right before the next-...
2
votes
1
answer
129
views
emacsclient's "--script" option alternatives
To run an elisp file hello.el with emacs in cli, do simply
$ emacs --script hello.el
However, a naive try for emacsclient fails, as --script is not an option of emacsclient.
$ emacsclient --script
...
2
votes
3
answers
556
views
Slurp standard-input into a buffer
How do I read the entire contents of stdin into an Emacs buffer in #! /usr/bin/env emacs --script mode? Stdin may not be a regular file.
2
votes
1
answer
52
views
Is --script a valid emacs switch?
When I execute
emacs --batch --script=/home/jim/test.el --no-site-file --file=testing
I get:
Cannot open load file: no such file or directory, /home/jim/--script=/home/jim/test.el
While emacs --help ...
1
vote
1
answer
74
views
visit buffer without setting mode in script
I'm trying to write a small program to indent lisp files using lisp-mode so I can get Emacs-compatible indentation even when using a different program.
Here's my first attempt to write a program to ...
1
vote
2
answers
856
views
How to use emacs packages in emacs lisp scripting
I have the following emacs script from here
#!/usr/local/bin/emacs --script
;;; rcat --- cat
;;; Commentary:
;;; cat function in elisp
;;; Code:
;;-*- mode: emacs-lisp;-*-
(defun process (string)
...
0
votes
1
answer
394
views
How to apply org-ctrl-c-ctrl-c-hook from command line?
This problem is so convoluted that maybe I should call it a puzzle...
On the Unix shell command line, I can convert TSV (tab-separated-values) input to org-mode table format with this perl one-liner:
...
0
votes
1
answer
256
views
How to make web-mode handle HTML inside <script> element?
I have elements that contain various things. Some contain HTML; web-mode does not realize that so it messes up the indentation. Some contain CSS; same issue.
My first preference is, can I somehow ...
2
votes
1
answer
2k
views
Can I call a python script from emacs?
I have a simple python script:
$ cat ~/simple.py
import os
import sys
def write_greeting(inpath):
outpath = os.path.splitext(inpath)[0] + '.txt'
with open(outpath, 'w') as f:
f.write('...
-1
votes
1
answer
111
views
why is save-buffer asking for a chmod?
All of sudden, XEmacs 21.4.22 starts asking whether it should chmod a+x $f everytime I try to save a buffer that is in Shell-script mode.
Switching it to fundamental-mode stops that behaviour.
...
5
votes
3
answers
175
views
How can I detect if an elisp script is piped?
I want to be able to tell whether stdout is a pipe in an elisp script. This would allow to distinguish between:
$ emacs --script foo.el
and
$ emacs --script foo.el | cat
Is this possible in Emacs ...
5
votes
2
answers
405
views
How can I script an emacs recording session?
Recording a GIF screencast of Emacs details a few ways we can record screencasts of Emacs sessions (e.g. to demonstrate features), but I'm really bad at not screwing things up :-)
Is there a way to ...
1
vote
1
answer
50
views
Can I use find to pass a list to emacs commands?
I'm trying to modify a script I got from an old question of mine.
I have many .org files under many subdirectories of ~/foo. I want to quickly run htmlize on each .org file. I have some elisp code
$ ...
8
votes
2
answers
2k
views
Print process output line by line
Read process output line by line gives some partial ideas about how to deal with sub-process output in an intelligent manner, but no example and no working solution. I have a couple of examples, one ...