From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Terrence Brannon Newsgroups: gmane.emacs.help Subject: access command line (arguments) from emacs --script Date: Mon, 26 Jul 2010 06:39:54 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291857167 1172 80.91.229.12 (9 Dec 2010 01:12:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 01:12:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 02:12:43 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQV3p-0006cA-AG for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 02:12:42 +0100 Original-Received: from localhost ([127.0.0.1]:33795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQV3n-0002fT-HM for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 20:12:39 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!j8g2000yqd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-NNTP-Posting-Host: 208.55.254.110 Original-X-Trace: posting.google.com 1280151594 12924 127.0.0.1 (26 Jul 2010 13:39:54 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 26 Jul 2010 13:39:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j8g2000yqd.googlegroups.com; posting-host=208.55.254.110; posting-account=GDJYuQoAAACvR3VU3OOyv8hdViWomHUu User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:180070 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76358 Archived-At: 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.