[gnu.emacs] Settable command line arguments

lrs@ai.mit.edu (Lynn Slater) (08/02/89)

The following changes to startup.el allow hooks to define new command line
arguments without rebuilding emacs.  Example:

 emacs -batch -l dbiogen -data DBIO.eld -verify -status -describe -autogen DBIO

The load of dbiogen defines hooks that recognizes all those successive
arguments which would not be otherwise recognized.

To define a hook, load code such as the following:
  (setq command-line-hooks (cons 'do-object-data command-line-hooks))
  (defun do-object-data ()
    (if (string= argi "-data")
	(let ((datafile (car command-line-args-left)))
	  (setq command-line-args-left (cdr command-line-args-left))
	  (object-data datafile)
	  )))


I regret that I cannot construct meaningful diffs of startup.el.

			     -*- Changes: -*-

;; Add the following near ths top of startup.el
(defvar command-line-hooks nil    ;; lrs 7/31/89
  " A list of functions to call to process every unrecognized entry on the
command line.  Each function should access the dynamically bound variables
argi (the current argument) and command-line-args-left (the remaining
arguments) . The function should return non-nil only if it recognizes and
processes argi. In this case, the function may consume successive arguments by
trimming command-line-args-left (via setq).")

;; Replace the last condition in command-line-1 at the bottom of startup.el
		(t
		 ;; We have almost exhausted our options. See if the
		 ;; user has made any other command-line options available
		 (let ((hooks command-line-hooks);; lrs 7/31/89
		       (did-hook nil))
		   (while (and hooks (not (and (funcall (car hooks))
					       (setq did-hook t))))
		     (setq hooks (cdr hooks)))
		   (if (not did-hook)
		       ;; Ok, give up and presume that the argument is a file name
		       (find-file (expand-file-name argi dir))
		     (or (zerop line)
			 (goto-line line))
		     (setq line 0))))

-- Good hacking. -- Lynn
===============================================================
Lynn Slater -- {sun, ames, pacbell}!indetech!lrs or lrs@indetech.uucp
42075 Lawrence Place, Fremont Ca 94538
Office (415) 438-2048; Home (415) 796-4149; Fax (415) 438-2034
===============================================================