In message <7KE5V1O@math.fu-berlin.de> Thomas Richter wrote:
>
> 	I gave up when I got an error about lock-directory being void
> 	while 'temacs -batch -l loadup.el' was working on startup.el.

This is because lisp/prim/startup.el wasn't allowing for the fact that the C
code might not have been compiled with support for locking.  Replace the
following two functions with the definition below.

	-- Jamie

(defun set-default-load-path ()
;  (send-string-to-terminal (format "\ninitial load path:\n %s" load-path))
;  (send-string-to-terminal (format "\ninitial exec path:\n %s\n" exec-path))
  ;;
  ;; Make sure there is a reasonable elisp library directory on the load path,
  ;; and a reasonable emacs utility directory on the exec-path, even if this
  ;; emacs was dumped with now-inappropriate defaults.  Look at the directory
  ;; from which this emacs image was run:
  ;;
  ;;   o  If it ends in .../src/, and ../lisp/ exists, then use that for the
  ;;      lisp library (likewise for /etc/ and /lock/).
  ;;   o  If there is a subdirectory of that dir called lisp/ (or etc/ or 
  ;;      lock/), then use that.
  ;;   o  If the emacs program that was run is itself a symlink, then chase
  ;;      the link and try again on the resultant directory.
  ;;
  ;; These heuristics fail if the emacs binary was copied from the main emacs
  ;; tree to some other directory, and links for the lisp directory were not
  ;; put in, but I can't think of a way around that.
  ;;
  (let ((lisp (find-default-load-path-internal "lisp"))
	(etc  (find-default-load-path-internal "etc"))
	(lock (and (boundp 'lock-directory)
		   (or lock-directory
		       (find-default-load-path-internal "lock")))))
    (if lisp
	(or (member lisp load-path)
	    (progn
	      ;; If the lisp dir isn't on the load-path, add it.
	      (setq load-path (append load-path (list lisp)))
	      ;; If the lisp dir wasn't on the load-path, then also add
	      ;; any direct subdirectories of the lisp directory to the
	      ;; load-path.
	      (let (;(files (directory-files lisp))
		    (files (directory-files lisp nil nil nil 'dirs-only))
		    file)
		(while files
		  (setq file (car files))
		  (if (and (not (member file '("." ".." "RCS")))
			   ;(file-directory-p
			    (setq file (expand-file-name file lisp))
			    ;)
			   (not (member file load-path)))
		      (setq load-path
			    (nconc load-path
				   (list (file-name-as-directory file)))))
		  (setq files (cdr files))))
	      )))
    (if etc
	(or (member etc exec-path)
	    (setq exec-path (append exec-path (list etc)))))
    (if (and (null exec-directory) etc)
	(setq exec-directory (file-name-as-directory etc)))
    (if (and (boundp 'Info-directory-list) (null Info-directory-list))
	(setq Info-directory-list
	      (list (expand-file-name "../info/" exec-directory))))
    (if (boundp 'lock-directory)
	(progn
	  (setq lock-directory lock)
	  (if (and lock-directory (null superlock-path))
	      (setq superlock-path
		    (concat lock-directory "!!!SuperLock!!!")))))
    (set-default-load-path-warning)))


(defun set-default-load-path-warning ()
  (if (and exec-directory load-path
	   (or (not (boundp 'lock-directory)) lock-directory))
      nil
    (save-excursion
      (set-buffer (get-buffer-create " *warning-tmp*"))
      (erase-buffer)
      (let ((fill-column 70)
	    warnings message guess)
	(if (and (boundp 'lock-directory) (null lock-directory))
	    (setq warnings (cons "lock-directory" warnings)))
	(if (null exec-directory)
	    (setq warnings (cons "exec-directory" warnings)))
	(if (null load-path)
	    (setq warnings (cons "load-path" warnings)))
	(cond ((cdr (cdr warnings))
	       (setq message (apply 'format "%s, %s, and %s" warnings)))
	      ((cdr warnings)
	       (setq message (apply 'format "%s and %s" warnings)))
	      (t (setq message (format "variable %s" (car warnings)))))
	(insert "couldn't find an obvious default for " message
		", and there were no defaults specified in paths.h when emacs "
		"was built.  Perhaps some directories don't exist, or the "
		"emacs executable, " execution-path " is in a strange place?")
	(setq guess (or exec-directory
			(car (reverse load-path))
			(and (string-match "/[^/]+$" execution-path)
			     (substring execution-path 0
					(match-beginning 0)))))
	(if (and guess (string-match "/\\(src\\|etc\\|lisp\\)/$" guess))
	    (setq guess (substring guess 0 (match-beginning 0))))
	(if (and guess (string-match "/$" guess))
	    (setq guess (substring guess 0 (match-beginning 0))))
	(if (and (boundp 'lock-directory) (null lock-directory))
	    (progn
	      (insert
	       "\n\nWithout lock-directory set, file locking won't work.  ")
	      (if guess
		  (insert
		   "Consider creating " guess "/lock/ as a directory or "
		   "symbolic link for use as the lock directory.  "))))

	(if (or (null exec-directory) (null load-path))
	    (insert
	     "\n\nWithout both exec-directory and load-path, emacs will "
	     "be very broken.  "))
	(if (and (null exec-directory) guess)
	    (insert
	     "Consider making a symbolic link from " guess
	     "/etc/ to wherever the appropriate emacs etc directory is"))
	(if (and (null load-path) guess)
	    (insert
	     (if exec-directory "Consider making a symbolic link " ", and ")
	     "from " guess
	     "/lisp/ to wherever the appropriate emacs lisp library is.  ")
	  (if (and (null exec-directory) guess) (insert ".")))
	(fill-region (point-min) (point-max))
	(goto-char (point-min))
	(insert "\nWARNING:\n")
	(send-string-to-terminal (buffer-string))
	(erase-buffer)
	t))))