;; 01-vars.el --- Various variables

;; Copyright (C) 2007 - 2020 Steve Youngs

;;     Author: Steve Youngs <steve@sxemacs.org>
;; Maintainer: Steve Youngs <steve@sxemacs.org>
;;    Created: <2007-12-02>
;; Time-stamp: <Thursday Apr  9, 2020 06:38:48 steve>
;;   Download: <https://downloads.sxemacs.org/SYinits/>
;;   HTMLised: <https://www.sxemacs.org/SYinits/01-vars.html>
;;   Git Repo: git clone https://git.sxemacs.org/syinit
;;   Keywords: init, compile

;; This file is part of SYinit

;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; 1. Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;;
;; 2. Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;;
;; 3. Neither the name of the author nor the names of any contributors
;;    may be used to endorse or promote products derived from this
;;    software without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

;;; Commentary:
;;
;;   This init file sets up a few miscelaneous variables and whatnot.
;;   If anything has to be loaded very early in the boot up I'll put
;;   it in here because this file is loaded first.
;;

;;; Credits:
;;
;;   The HTML version of this file was created with Hrvoje Niksic's
;;   htmlize.el which is part of the XEmacs "text-modes" package.
;;

;;; Todo:
;;
;;     

;;; Code:

;:*=======================
;:* Keep garbage collection out of my way.
;;
(setq gc-cons-threshold 50000000)


;:*=======================
;:* Set default font
(defvar sydeffaces
  '(default bold bold-italic italic)
  "List symbols for default fonts.")

(mapc
 #'(lambda (font)
     (remove-specifier (face-font font) 'global '(x default) nil))
 sydeffaces)

(progn
  (set-face-font 'default
                 (make-font-instance
                  "-xos4-terminus-medium-r-*-*-*-150-*-*-*-*-iso8859-*")
                 'global '(x default))
  (set-face-font 'bold
                 (make-font-instance
                  "-xos4-terminus-bold-r-*-*-*-150-*-*-*-*-iso8859-*")
                 'global '(x default))
  (set-face-font 'bold-italic
                 (make-font-instance
                  "-*-times-bold-i-*-*-*-140-*-*-*-*-iso8859-*")
                 'global '(x default))
  (set-face-font 'italic
                 (make-font-instance
                  "-*-times-medium-i-*-*-*-140-*-*-*-*-*-*")
                 'global '(x default)))

;:*=======================
;:* Lossage Messages
;; A lot of the time I'm running some very unstable code.  So I set
;; this quite high so I can catch all the help-lossage messages.
(setq view-lossage-message-count 1000)

;:*=======================
;:* SXEmacs has a sane filename for custom-file
(unless (featurep 'sxemacs)
  (setq custom-file
        (expand-file-name "custom-steve.el" user-init-directory))
  (load-file custom-file))

;:*=======================
;:* Set the default font
(set-face-property
 'default
 'face "-*-Terminus-medium-r-*-*-*-140-*-*-*-*-iso8859-*")

;:*=======================
;:* Stuff. Lots of stuff...

(setq-default
 buffers-menu-grouping-function
 'group-buffers-menu-by-mode-then-alphabetically
 buffers-menu-sort-function
 'sort-buffers-menu-by-mode-then-alphabetically
 buffers-menu-submenus-for-groups-p t
 case-fold-search t
 case-replace t
 get-frame-for-buffer-default-instance-limit nil
 mouse-yank-at-point t
 next-line-add-newlines nil
 overwrite-mode nil
 require-final-newline t
 teach-extended-commands-p t
 teach-extended-commands-timeout 5
 temp-buffer-show-function 'show-temp-buffer-in-current-frame
 zmacs-regions t)

(defvar gnus-directory (paths-construct-path 
                        (list (user-home-directory) "Gnus"))
  "Gnus directory.")
   
(defvar message-directory (paths-construct-path 
                           (list (user-home-directory) "Gnus"))
  "Gnus directory.")


;:*=======================
;:* Unicode shit
;(unless (fboundp 'ucs-to-char)
(when (featurep '(and mule mule-ucs-autoloads))
  ;; Order is important here
  (progn
    (require 'tae)
    (require 'un-define)
    (set-coding-priority-list '(utf-8))
    (set-coding-category-system 'utf-8 'utf-8))
  (and (coding-system-p (find-coding-system 'utf-8))
       (setq-default buffer-file-coding-system
                     (coding-system-name
                      (find-coding-system 'utf-8)))))

;:*=======================
;:* Fix #'run-at-time
;;  You get an `args-out-of-range' error if you try to set a #'run-at-time
;;  to go off in the past.  That's not as silly as it sounds, think of
;;  things you want to run once per day.  At some point the 'time' will be
;;  in the past for the current day.
(or (featurep 'timer-funcs)
    (require 'timer-funcs))

(defadvice run-at-time (before future-run-at-time first activate)
  "If TIME is in the past, set it for tomorrow."
  (when (stringp time)
    (let ((tspec (timer-parse-time time)))
      (if tspec
          (progn
            (setq time
                  (ceiling
                   (itimer-time-difference tspec (current-time))))
            (if (< time 0)
                (setq time (+ time 86400))))))))
   
;:*=======================
;:* Here because sometimes... order important it is
(require 'ffi-wand)

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
(message "variables initialiased")
Created with SXEmacs Valid XHTML 1.0 Transitional!
Copyright © 2020 Steve Youngs
Verbatim copying and distribution is permitted in any medium, providing this notice is preserved.
Last modified: Wed Apr 15 18:12:00 AEST 2020