(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(GeoMaestro-manual-URL "../eGM0.html")
 '(cscsd-CSOUNDRC "$SURMULOTDIR/csound/.csoundrc")
 '(cscsd-INCDIR "$SURMULOTDIR/csound/include")
 '(cscsd-MFDIR "$SURMULOTDIR/midi")
 '(cscsd-OPCODEDIR "$SURMULOTDIR/csound/plugins")
 '(cscsd-OPCODEDIR64 "$SURMULOTDIR/csound/plugins64")
 '(cscsd-RAWWAVE_PATH "$SURMULOTDIR/csound/samples")
 '(cscsd-SADIR "$SURMULOTDIR/csound/analysis")
 '(cscsd-SFDIR "$SURMULOTDIR/csound/rendered")
 '(cscsd-SSDIR "$SURMULOTDIR/csound/samples;$SURMULOTDIR/soundfonts;$SURMULOTDIR/csound/library/SourceMaterials")
 '(cscsd-csound-binary "$SURMULOTDIR/csound/bin/csound.exe")
 '(cscsd-csr-files (quote ("$SURMULOTDIR/emacs/site-lisp/stef-elisp/csound-x/somecode.csr")))
 '(cscsd-current-csr-file "$SURMULOTDIR/emacs/site-lisp/stef-elisp/csound-x/somecode.csr")
 '(cscsd-current-processing "csound to dac")
 '(cscsd-default-csd-directory "$SURMULOTDIR/csound/csd/")
 '(cscsd-libraries (quote (("Iain McCurdy's Realtime Examples" "$SURMULOTDIR/csound/library/CsoundRealTimeExamples") ("Choosen works" "$SURMULOTDIR/csound/library/examples"))))
 '(cscsd-orchestras-path (quote ("$SURMULOTDIR/csound/manual/examples")))
 '(cscsd-orchestras-recursive-path (quote ("$SURMULOTDIR/csound/csd" "$SURMULOTDIR/csound/include" "$SURMULOTDIR/csound/library")))
 '(cscsd-process-file (quote (("csound <CsOptions> csd" "$csound %s &") ("csound to wav" "$csound -dWo %s %s &") ("csound to dac" "$csound -dodac %s &") ("csound midi to dac" "$csound -dodac %s -TF %s &") ("csound to wav, then play" (lambda (csd-file output-file) (set-cscsd-post-csound-log-action (lambda nil (cscsd-play-audio (cscsd-audio-file-from-log)))) (cscsd-call-csound "$csound -dWo %s %s &" csd-file output-file))) ("csound to wav, then edit" (lambda (csd-file output-file) (set-cscsd-post-csound-log-action (lambda nil (cscsd-edit-audio (cscsd-audio-file-from-log)))) (cscsd-call-csound "$csound -dWo %s %s &" csd-file output-file))))))
 '(cscsd-shell-compile-sco "$csound -dWo %s %s %s &")
 '(cscsd-shell-edit-audio "\"$SURMULOTDIR/bin/wavesurfer\" -config default \"%s\" &")
 '(cscsd-shell-play-audio "\"$SURMULOTDIR/bin/wavesurfer\" -config default -play \"%s\" &")
 '(cscsd-shell-play-sco "$csound -dodac %s %s &")
 '(cscsd-temp-csd-file "$SURMULOTDIR/csound/csd/tmp.csd")
 '(cscsd-use-MMM t)
 '(csdoc-csoundAV-manual-directory "$SURMULOTDIR/csound/ManualCsoundAV")
 '(csdoc-examples-with-new-frame t)
 '(csdoc-html-directory "$SURMULOTDIR/csound/manual/")
 '(csdoc-html-entry-point "$SURMULOTDIR/csound/manual/indexframes.html")
 '(csdoc-squeak-opcode-library "$SURMULOTDIR/squeak/csound opcodes.cs")
 '(csdoc-winhelp-file "$SURMULOTDIR/csound/csound.hlp")
 '(cseel-elisp-pops-up t)
 '(csmid-midi-directory "$SURMULOTDIR/MIDI")
 '(csmid-midi-path (quote ("$SURMULOTDIR/MIDI")))
 '(csound-x-disable-smart-semicolon nil)
 '(csound-x-orc-fontlock t)
 '(csound-x-sco-fontlock t)
 '(csound-x-show-global-menu t)
 '(custom-buffer-style (quote links))
 '(custom-raised-buttons t)
 '(default-frame-alist (quote ((menu-bar-lines . 5) (top . 5) (left . 5) (width . 80) (height . 30) (background-color . "ivory1") (cursor-color . "black"))))
 '(desktop-base-file-name ".surmulot.desktop")
 '(desktop-save t)
 '(desktop-save-mode nil)
 '(embedded-elisp-repository "~/site-lisp/EEL")
 '(fill-column 100)
 '(inhibit-startup-screen t)
 '(initial-frame-alist (quote ((menu-bar-lines . 1) (top . 1) (left . 1) (width . 80) (height . 30))))
 '(kk-HTML-background-color "thistle")
 '(kk-HTML-background-picture "../../fond_papier.gif")
 '(kk-HTML-external-link "../GMfunctions.html")
 '(kk-HTML-external-link-label "back to GeoMaestro manual")
 '(kk-HTML-title "Library of KeyKit and GeoMaestro functions")
 '(kk-HTML-topics-links (quote (("GVARS" "../GMtips.html#GVARS") ("csound" "../GMcsound.html") ("RawData" "../GMtut11.html") ("closure" "../GMclosure.html") ("piste" "../GMtips.html#pistes") ("emacs" "../GMemacs.html") ("audio" "../GMinstall.html#audio") ("help" "../GMfunctions.html") ("event" "../GMstructures.html#events"))))
 '(kk-auto-newline t)
 '(kk-default-directory "$SURMULOTDIR/keykit/")
 '(kk-geomaestro-dvlp-items nil)
 '(kk-keypath (quote ("$SURMULOTDIR/keykit/contrib/GeoMaestro/lib/" "$SURMULOTDIR/keykit/contrib/GeoMaestro/userlib/" "$SURMULOTDIR/keykit/lib/" "$SURMULOTDIR/keykit/liblocal/" "$SURMULOTDIR/keykit/contrib/GeoMaestro/toys/")))
 '(kk-lowkey-executable "$SURMULOTDIR/keykit/bin/lowkey.exe")
 '(kk-tab-always-indent t t)
 '(kk-tcpip-key-command "$SURMULOTDIR/../start keykit.bat")
 '(kk-tcpip-key-start-directory "$SURMULOTDIR/../")
 '(kk-temp-code-filename "$SURMULOTDIR/tmp/bof.k")
 '(kk-temp-midifiles-rootname "$SURMULOTDIR/tmp/kktmp")
 '(max-lisp-eval-depth 500)
 '(mmm-submode-decoration-level 0)
 '(mouse-buffer-menu-mode-mult 1)
 '(mouse-drag-copy-region nil)
 '(occur-hook (quote (occur-rename-buffer)))
 '(org-confirm-elisp-link-function nil)
 '(org-confirm-shell-link-function nil)
 '(org-link-frame-setup (quote ((vm . vm-visit-folder-other-frame) (gnus . gnus-other-frame) (file . find-file-other-frame))))
 '(org-return-follows-link t)
 '(safe-local-variable-values (quote ((cscsd-current-processing . "csound to wav, then edit") (cscsd-current-processing . "csound to dac") (turn-on-eel-mode . t) (auto-recompile . t))))
 '(scomx-Cmask-binary "$SURMULOTDIR/bin/cmask")
 '(scomx-Cmask-support t)
 '(scomx-Cmask-tmp-file "$SURMULOTDIR/tmp/scomx-tmp")
 '(special-display-frame-alist (quote ((tool-bar-lines . 0) (height . 14) (width . 80) (unsplittable . t))))
 '(speedbar-frame-parameters (quote ((minibuffer) (width . 30) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t))))
 '(speedbar-track-mouse-flag nil)
 '(squeak-tcpip-default-image "$SURMULOTDIR/squeak/muO")
 '(squeak-tcpip-init-command "'Squeak connected (muO %s)' sformat: MuO version")
 '(squeak-tcpip-launch-command "$SURMULOTDIR/squeak/vm/squeak.exe")
 '(surman-is-daemon t)
 '(surmulot-squeak-widget-image "$SURMULOTDIR/squeak/widget.image")
 '(timcfg-midi-drumtest-file "$SURMULOTDIR/timidity/drumtest.mid")
 '(timcfg-midi-mix-file "$SURMULOTDIR/timidity/mix.mid")
 '(timcfg-midi-test-file "$SURMULOTDIR/timidity/test.mid")
 '(timcfg-sf2-editor "$SURMULOTDIR/soundfonts/viena/viena.exe")
 '(timcfg-timidity-executable-win "$SURMULOTDIR/timidity/timidity.bat"))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(custom-button ((((type x w32 mac) (class color)) (:background "khaki" :foreground "black" :box (:line-width 1 :style released-button)))))
 '(custom-button-face ((((type x w32 mac) (class color)) (:background "khaki" :foreground "black" :box (:line-width 1 :style released-button)))) t)
 '(custom-button-mouse ((((type x w32 ns) (class color)) (:background "khaki" :foreground "black" :box (:line-width 1 :color "goldenrod2" :style released-button)))))
 '(custom-button-pressed ((((type x w32 mac) (class color)) (:background "goldenrod2" :foreground "black" :box (:line-width 1 :style pressed-button)))))
 '(custom-button-pressed-face ((((type x w32 mac) (class color)) (:background "goldenrod2" :foreground "black" :box (:line-width 1 :style pressed-button)))) t)
 '(custom-documentation ((t (:weight bold))))
 '(custom-documentation-face ((t (:weight bold))) t)
 '(custom-group-tag ((t (:inherit variable-pitch :foreground "blueviolet" :underline unspecified :weight bold :height 1.2))))
 '(custom-group-tag-face ((t (:inherit variable-pitch :foreground "blueviolet" :underline unspecified :weight bold :height 1.2))) t)
 '(custom-state ((((class color) (background light)) (:foreground "red"))))
 '(custom-state-face ((((class color) (background light)) (:foreground "red"))) t)
 '(font-lock-builtin-face ((((class color) (background light)) (:foreground "orange red"))))
 '(font-lock-string-face ((((class color) (background light)) (:foreground "DeepSkyBlue4"))))
 '(fringe ((t (:background "lavender"))))
 '(header-line ((t (:inherit mode-line :background "gold" :foreground "grey20" :box nil))))
 '(highlight ((((class color) (background light)) (:background "gold"))))
 '(mmm-cleanup-submode-face ((t (:background "floral white"))))
 '(mmm-code-submode-face ((t (:background "floral white"))))
 '(mmm-default-submode-face ((t (:background "cornsilk1"))))
 '(mode-line ((((type x w32 mac) (class color)) (:background "dark slate blue" :foreground "green yellow" :box (:line-width -1 :style released-button)))))
 '(region ((t (:background "yellow green"))))
 '(show-paren-match ((((class color)) (:background "gold"))))
 '(show-paren-match-face ((((class color)) (:background "gold"))) t)
 '(show-paren-mismatch ((((class color)) (:foreground "white" :background "firebrick"))))
 '(show-paren-mismatch-face ((((class color)) (:foreground "white" :background "firebrick"))) t)
 '(speedbar-highlight-face ((((class color) (background light)) (:background "SlateGray1"))))
 '(widget-field ((((class grayscale color) (background light)) (:background "ghost white"))))
 '(widget-field-face ((((class grayscale color) (background light)) (:background "ghost white"))) t)
 '(widget-inactive ((((class grayscale color) (background light)) (:foreground "goldenrod2"))))
 '(widget-inactive-face ((((class grayscale color) (background light)) (:foreground "goldenrod2"))) t))


;;========================= directories and paths

; emacs being launched from above the root surmulot directory,
; default-directory is surmulot/emacs/
; from there we can retreive all other directories global names

; this very file is:
(setq user-init-file
      (expand-file-name "surmulot.emacs" default-directory))

(defvar surmulot-directory (expand-file-name ".." default-directory)
  "root directory for the surmulot distribution")      

(setenv "SURMULOTDIR" surmulot-directory) ; used by csound-x, see customizations above

;(add-to-list 'load-path (expand-file-name "emacs/site-lisp" surmulot-directory))
(cd (expand-file-name "emacs" surmulot-directory))
(normal-top-level-add-subdirs-to-load-path)


;;========================= misc. settings

(setq frame-title-format "Surmulot Emacs: %b")

(setq tool-bar-button-margin 2)

; auto-recompile
(require 'auto-recomp)

(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(show-paren-mode 1)
(global-font-lock-mode t)

(setq auto-mode-alist
      (cons '("\\.emacs$" . emacs-lisp-mode) auto-mode-alist))

;no ^M with DOS
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m)

;; supertab 
(autoload 'supertab-handle-tab "supertab")
(define-key emacs-lisp-mode-map "\t"
  'supertab-handle-tab )
(define-key lisp-interaction-mode-map "\t"
  'supertab-handle-tab )

(cua-mode)

;; a nice monospace font for Windows systems
(condition-case nil
    (when (eq system-type 'windows-nt)
      (set-default-font "Consolas 10")
      ;; "-outline-Consolas-normal-r-normal-normal-14-97-96-96-c-*-iso8859-1"
      (add-to-list' default-frame-alist '(font . "Consolas 10")))
  (error nil))

(add-to-list 'special-display-regexps "\\*Occur")

;;========================= F keys

; F1 displays help
(global-set-key [f1] 'info)

; F8 open query buffer:
(autoload 'qsheet-display-search-buffer "query-sheet" "open a search buffer in other-window" t)
(global-set-key [f8] 'qsheet-display-search-buffer)

; F5 kills current buffer:
(global-set-key [f5] 'kill-buffer)

; F6 do the same then remove its window or frame:
(global-set-key [f6]
                (lambda ()
                  (interactive)
                  (let ((w (selected-window))
                        (f (selected-frame)))
                    (when (kill-buffer (current-buffer))
		      (if (eq f (selected-frame))
			  (if (not (one-window-p))
			      (delete-window)
                            (delete-frame)))))))

; F7 imports a CSD from clipboard:
(global-set-key [f7] 'cscsd-import-from-clipboard)


;;========================= start up

(require 'surman)
(surman-start-daemon)

(load "stef-elisp")
(require 'surmulot) 
(surmulot-make-global-menu)


;;========================= welcome buffer

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(surmulot-display-welcome-buffer)


;;========================= desktop

(setq desktop-dirname ".")
(when (and desktop-save-mode
	   (file-exists-p (desktop-full-file-name)))
  (desktop-read))
