Article View: gnu.emacs.bug
Article #98569Command line arguments: bug + style comments
From: Boaz Ben-Zvi
Date: Mon, 03 Jun 1991 18:50
Date: Mon, 03 Jun 1991 18:50
57 lines
3412 bytes
3412 bytes
Emacs 18.5[..7] : Bellow is a description of the bug, followed by some
comments about the style of the Emacs code that handles command line
arguments.
THE BUG:
In the *info* (File: emacs, Node: Command Switches) it says:
>> Note that the init file can get access to the command line argument
>> values as the elements of a list in the variable `command-line-args'.
>> (The arguments in the second table above will already have been
>> processed and will not be in the list.) The init file can override
>> the normal processing of the other arguments by setting this variable.
^^^^^^^^^^^^^^^^^^^^^
In startup.el:
(defun command-line ()
(let ((args (cdr command-line-args))
........... CHOP "-q" AND "-u" AWAY FROM args .......
(progn (load (if (eq system-type 'vax-vms)
"sys$login:.emacs"
(concat "~" init "/.emacs"))
t t t)
........... args NOT USED HERE ......................
(command-line-1 args)
.....))))
Thus, when command-line processes the arguments, it does not care about
the value of command-line-args that may have been set in the init-file !!!
An immediate solution is to muck with the variable 'args in the init-file
instead .... (at last, something good about dynamic binding).
STYLE COMMENTS:
Looking through the code that handles command line arguments (in emacs.c
and startup.el), I got the urge to grade it with an "F" !! (I have recently
been a TA in an MIT course that stresses issues of good design, programming,
etc. (6.170)).
All this "argument skipping" leads to ugly code and also puts silly
constraints on Emacs users (namely -- order of arguments). Why not just
call procedures (or set flags) as the arguments are scanned (e.g. in
init_cmdargs() ). Why is there a need to "chop off" those leading arguments
(e.g. "-batch"). (Same logic goes for startup.el).
The existing code may save few milliseconds over what I proposed, but
that happens only at start-up time !!
The reason I looked into this was that I wanted to add some of my options
to the command line (e.g. "emacs -foo"). I think that another clean way to
do that is by adding some '(foo . my-foo) to command-switch-alist (in my
init-file). This way is not mentioned in the *info* .
-- Boaz
========================================================
* Boaz Ben-Zvi (boaz@neutron.lcs.mit.edu) *
* MIT: NE43-526 Tel: (617) 253-6212 *
========================================================
Technical Details
Message-ID:
<1991Jun3.185028.10111@mintaka.lcs.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,cec74292dedcf127,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-06-03 11:50:28 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage From: boaz@CONCERTO.LCS.MIT.EDU (Boaz Ben-Zvi) Newsgroups: gnu.emacs.bug Subject: Command line arguments: bug + style comments Keywords: command-line Message-ID: <1991Jun3.185028.10111@mintaka.lcs.mit.edu> Date: 3 Jun 91 18:50:28 GMT Sender: daemon@tut.cis.ohio-state.edu Reply-To: boaz@lcs.mit.edu Distribution: gnu Organization: Laboratory for Computer Science, MIT Lines: 57 Approved: bug-gnu-emacs@prep.ai.mit.edu