#!/bin/sh

# I tried: `REP_LOAD_PATH=... exec ...' but solaris /bin/sh won't play along

REP_LOAD_PATH="/usr/local/share/sawfish/1.6.3/lisp"
export REP_LOAD_PATH

exec rep "$0" "$@"

!#

;; nokogiri-main.jl -- entry point
;;
;; Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
;;
;; This file is part of sawfish.
;;
;; sawfish is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; sawfish is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with sawfish; see the file COPYING.  If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

(structure ()

    (open rep
	  rep.system
	  rep.io.streams
	  rep.io.files
	  rep.regexp)
  (define socket-id nil)

  (when (getenv "SAWFISH_USER_LISP_DIR")
    (setq load-path
	  (append
	   (mapcar canonical-file-name
		   (string-split ":" (getenv "SAWFISH_USER_LISP_DIR")))
	   load-path)))

  ;; mapcar fails for compilation 
  (require 'sawfish.gtk.widget)
  (require 'sawfish.cfg.i18n)
  (require 'sawfish.cfg.shell)
  (require 'sawfish.cfg.group)

  (when (get-command-line-option "--help")
    (write standard-output "\
usage: sawfish-config [OPTIONS...]\n
where OPTIONS are any of:\n
  --group=GROUP-NAME
  --flatten
  --single-level
  --socket-id=WINDOW-ID\n")
    (throw 'quit 0))

  (let ((group (get-command-line-option "--group" t)))
    (when group
      (setq group (read-from-string group))
      (set-top-group (if (listp group) group `(root ,group)))))

  (when (get-command-line-option "--flatten")
    (setq *nokogiri-flatten-groups* t))

  (when (get-command-line-option "--single-level")
    (setq *nokogiri-single-level* t))

  (let ((id (get-command-line-option "--socket-id" t)))
    (when id
      (setq socket-id (string->number id))))

  (setq interrupt-mode 'exit)
  (i18n-init)
  (add-widget-prefix 'sawfish.cfg.widgets)
  (run-shell socket-id))


;; Local variables:
;; major-mode: lisp-mode
;; End:
