all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* access command line (arguments) from emacs --script
@ 2010-07-26 13:39 Terrence Brannon
  2010-07-26 20:11 ` David Kastrup
  0 siblings, 1 reply; 2+ messages in thread
From: Terrence Brannon @ 2010-07-26 13:39 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: access command line (arguments) from emacs --script
  2010-07-26 13:39 access command line (arguments) from emacs --script Terrence Brannon
@ 2010-07-26 20:11 ` David Kastrup
  0 siblings, 0 replies; 2+ messages in thread
From: David Kastrup @ 2010-07-26 20:11 UTC (permalink / raw)
  To: help-gnu-emacs

Terrence Brannon <metaperl@gmail.com> writes:

> 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'

(pop argv)

> (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'

The interpretation is up to you.  Argument processing is positioned
after emacs-script.el.

If argv is not yet available in your version of Emacs, you might have to
use command-line-args-left instead.

-- 
David Kastrup


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-26 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-26 13:39 access command line (arguments) from emacs --script Terrence Brannon
2010-07-26 20:11 ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.