;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; GNU Emacs EMACS_VERSION default settings for Vine Linux
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq emacs-build-system 
      (concat emacs-build-system ", modified for Vine Linux"))

(setq report-emacs-bug-address "Vine@vinelinux.org")

(defcustom emacs-ime (getenv "EMACS_IME")
  "A variable of default Input Method Editor"
  :type 'string)
(if (null emacs-ime)
    (setq emacs-ime "ibus-el"))

(defconst vine-default-major-version VINE_DEFAULT_MAJOR_VERSION "\
Major version number of this version of vine-default.
This variable equals the major version number of Vine Linux that is running.")

(defconst vine-default-minor-version 0 "\
Minor version number of this version of vine-default.
This variable is the system number for vine-default-major-version.")

(defconst vine-default-version (+ vine-default-major-version (/ (float vine-default-minor-version) 10)) "\
The version of vine-default.")

(defcustom vine-default t
  "A boolean for all Vine Linux default settings"
  :type 'boolean)
(if (equal (getenv "LOGNAME") "root") 
    (setq vine-default nil))

(defcustom vine-default-base t
  "A boolean for vine-default-base"
  :type 'boolean)

(defcustom vine-default-faces t
  "A boolean for vine-default-faces"
  :type 'boolean)

(defvar vine-default-setup-hook nil
  "List of functions to be called at vine-default-setup")

;; (defvar after-vine-default-setup-hook nil 
;;   "This hook is obsolete! Please do not use this hook. 
;;    List of functions to be called at the end of vine-default-setup")

(defun vine-default-setup ()
  "A function for setup to default configurations of Vine Linux"
  (when vine-default
    (message "Starting vine-default-setup ...")
    (when vine-default-base 
      (message "Loading vine-default-base ...")
      (require 'vine-default-base))
    (when vine-default-faces 
      (message "Loading vine-default-faces ...")
      (require 'vine-default-faces))
    (run-hooks 'vine-default-setup-hook)
    ;; (run-hooks 'after-vine-default-setup-hook); obsolete
    )
  )

(defun show-vine-default ()
  "A function to show current vine-default configurations"
  (interactive)
  (shell-command 
   "/usr/lib/emacsen-common/show-vine-default.sh EMACS_VERSION"))

(defun drop-vine-default-from-load-path (regex)
  "A function to drop a path matching to REGEX from load-path"
  (setq load-path
	(let (list)
	  (dolist (x (reverse load-path) list)
	    (unless (string-match regex x)
	      (setq list (cons x list))))
	  )
	)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; run functions from the /etc/emacs-EMACS_VERSION/site-start.d directory
;;; Files in this directory ending with ".el" are run on startup
(mapc 'load (directory-files "/etc/emacs-EMACS_VERSION/site-start.d" t "\\.el\\'"))

;;; load local configuration
(if (file-exists-p (expand-file-name "/etc/emacs/emacs23-local.el"))
    (load (expand-file-name "/etc/emacs/emacs23-local.el")))

;;; load vine-default configuration per user before vine-default-setup
(if (file-exists-p (expand-file-name "~/.emacs.d/emacs23-vine-default.el"))
    (load (expand-file-name "~/.emacs.d/emacs23-vine-default.el")))

;;; run vine-default-setup
(vine-default-setup)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Local Variables:
;; mode: emacs-lisp
;; End: