help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

access command line (arguments) from emacs --script


From: Terrence Brannon
Subject: access command line (arguments) from emacs --script
Date: Wed, 08 Dec 2010 15:21:00 -0000
User-agent: G2/1.0

Hello, I am interested in accessing the arguments passed to an emacs
script.

I am interested in either:
(a) accessing what would be $1 to a shell program, in other words

./emacs-script.el 'here is dollar one... how does emacs get it'

(b) accessing an argument specified as an argument either in long or
short format:

./emacs-script.el --argument 'here is the argument .. how to get with
emacs'

I have written my entire program below. I just need to know how to get
command line arguments.

#!/bin/env emacs --script

(open-file "edan.el")
(search-forward "(provide 'edan)")
(move-beginning-of-line)
(open-line 2)

;;; option a
;;; prepend-edan.el `script-to-generate-text`
(insert $ARGV[0])

;;; option b
;;; prepend-edan.el --text `script-to-generate-text`
(insert $ARG['text'])

By the way, I found the manual (
http://www.gnu.org/software/emacs/elisp/html_node/Command_002dLine-Arguments.html
) to be confusing. Why is the handler function for the command-switch-
alist only passed the name of the option? How does it get the value of
the option?

Why is command-line args a list? How are you supposed to access the
arguments by name if this is just a list of the arguments.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]