From ab937bf013b6f65dee4ca70c81fc62d4d52fb644 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 Jan 2016 02:04:27 -0500 Subject: [PATCH] init-packages.el -> bootstrap + remove init-org.el --- bootstrap.el | 81 ++++++++++++++++++++++++++++++++ init-org.el | 53 --------------------- init-packages.el | 84 --------------------------------- init.el | 119 ++++++++++++++++++++++++----------------------- 4 files changed, 142 insertions(+), 195 deletions(-) create mode 100644 bootstrap.el delete mode 100644 init-org.el delete mode 100644 init-packages.el diff --git a/bootstrap.el b/bootstrap.el new file mode 100644 index 000000000..066a36972 --- /dev/null +++ b/bootstrap.el @@ -0,0 +1,81 @@ +;;; bootstrap.el + +(defconst narf-emacs-dir user-emacs-directory) +(defconst narf-core-dir (concat narf-emacs-dir "core/")) +(defconst narf-modules-dir (concat narf-emacs-dir "modules/")) +(defconst narf-private-dir (concat narf-emacs-dir "private/")) +(defconst narf-packages-dir (concat narf-emacs-dir ".cask/" emacs-version "/elpa/")) +(defconst narf-script-dir (concat narf-emacs-dir "scripts/")) +(defconst narf-snippet-dirs (list (concat narf-private-dir "snippets/") + (concat narf-private-dir "templates/"))) +;; Hostname and emacs version-based elisp temp directories +(defconst narf-temp-dir + (format "%scache/%s/%s.%s/" + narf-private-dir (system-name) + emacs-major-version emacs-minor-version)) + +(defconst IS-MAC (eq system-type 'darwin)) +(defconst IS-LINUX (eq system-type 'gnu/linux)) +(defconst IS-WINDOWS (eq system-type 'windows-nt)) + +;; Global settings +(scroll-bar-mode -1) ; no scrollbar +(tool-bar-mode -1) ; no toolbar + +(setq-default + ;; stop package.el from being annoying. NARF relies entirely on Cask. + package--init-file-ensured t + package-enable-at-startup nil + gc-cons-threshold 4388608 + gc-cons-percentage 0.3) + +(eval-when-compile + ;; Make sure that cask is in the right place + (unless (eq 0 (call-process "which" nil nil nil "cask")) + (error "Cask could not be found")) + (let ((cask-dir (cond (IS-MAC "/usr/local/Cellar/cask/HEAD") + (t "~/.cask")))) + (unless (file-exists-p cask-dir) + (error "Cask folder not found")) + (add-to-list 'load-path cask-dir)) + + ;; Helper for traversing subdirectories recursively + (defun --subdirs (path &optional include-self) + (let ((result (if include-self (list path) (list))) + (paths (ignore-errors (directory-files path t "^[^.]" t)))) + (dolist (file paths) + (when (file-directory-p file) + (push file result))) + result))) + +;; Scan various folders to populate the load-paths +(setq custom-theme-load-path + (eval-when-compile + (append (--subdirs (concat narf-private-dir "themes/")) + custom-theme-load-path))) + +(setq load-path + (eval-when-compile + (require 'cask) + (cask-initialize) + (setq load-path (append (list narf-private-dir) + (--subdirs narf-core-dir t) + (--subdirs narf-modules-dir t) + (--subdirs narf-packages-dir) + load-path)))) + +(defun narf (packages) + "Bootstrap NARF emacs and initialize PACKAGES" + ;; prematurely optimize for faster startup + (let (file-name-handler-alist + (gc-cons-threshold 169715200)) + ;; Load local settings, if available + (when (file-exists-p "~/.emacs.local.el") + (load "~/.emacs.local.el")) + + (load-theme narf-theme t) + (setq narf-current-theme narf-theme) + + (mapc 'require packages))) + +;;; bootstrap.el ends here diff --git a/init-org.el b/init-org.el deleted file mode 100644 index 287dbf30b..000000000 --- a/init-org.el +++ /dev/null @@ -1,53 +0,0 @@ -;;; init-org.el --- inits Emacs for Org-mode and writing -;; -;; This orgfile is sourced instead of init.el for instances of Emacs dedicated for -;; writing fiction, papers, or simply org-mode. I prefer to keep this functionality -;; separate from stock Emacs. -;; -;;; - -(defconst EMACS-WRITE t) - -(defconst narf-theme 'narf-light) -(defconst narf-default-font (font-spec :family "Hack" :size 14)) -(defconst narf-writing-font (font-spec :family "Deja Sans" :size 14)) - -(defconst narf-packages - '(core ; core/core.el - - core-popup ; taming stray windows - core-ui ; draw me like one of your French editors - core-evil ; come to the dark side, we have cookies - core-editor ; filling the editor-shaped hole in the emacs OS - core-company ; for the lazy typist - core-yasnippet ; for the lazier typist - core-auto-insert ; for the laziest typist - core-flycheck ; remember that semicolon you forgot? - core-project ; whose project am I in? - core-vcs ; version control is a programmer's best friend - core-helm ; a search engine for life and love - core-eval ; run code, run. - core-workgroups ; cure Emacs alzheimers - - ;;; Environments - module-markdown - module-org - module-plantuml - - ;;; Specific custom functionality - ;; lib-plugin ; plugin dev for various programs - lib-tmux ; closing the rift between GUI & terminal - lib-demo ; let me demonstrate... - lib-writing ; yes, I write papers and fiction in emacs - ;; lib-crm ; emacs and org-mode based CRM - - ;;; Key bindings & ex commands - my-bindings - my-commands - )) - -(load (concat user-emacs-directory "init-packages.el")) - -(setq wg-session-file (expand-file-name "wg-org-default" narf-temp-dir)) -(cd org-directory) - diff --git a/init-packages.el b/init-packages.el deleted file mode 100644 index 420997e0a..000000000 --- a/init-packages.el +++ /dev/null @@ -1,84 +0,0 @@ -;;; init-packages.el - -(setq-default - ;; stop package.el from being annoying. NARF relies entirely on Cask. - package--init-file-ensured t - package-enable-at-startup nil - gc-cons-threshold 8388608 - gc-cons-percentage 0.3) - -(eval-and-compile - (defconst narf-emacs-dir user-emacs-directory) - (defconst narf-core-dir (concat narf-emacs-dir "core/")) - (defconst narf-modules-dir (concat narf-emacs-dir "modules/")) - (defconst narf-contrib-dir (concat narf-emacs-dir "contrib/")) - (defconst narf-private-dir (concat narf-emacs-dir "private/")) - (defconst narf-packages-dir (concat narf-emacs-dir ".cask/" emacs-version "/elpa/")) - - (defconst narf-script-dir (concat narf-emacs-dir "scripts/")) - (defconst narf-dropbox-dir "~/Dropbox/") - (defconst narf-snippet-dirs (list (concat narf-private-dir "snippets/") - (concat narf-private-dir "templates/"))) - (defconst narf-temp-dir - (format "%scache/%s/%s.%s/" - narf-private-dir (system-name) - emacs-major-version emacs-minor-version)) - - (defconst IS-MAC (eq system-type 'darwin)) - (defconst IS-LINUX (eq system-type 'gnu/linux)) - (defconst IS-WINDOWS (eq system-type 'windows-nt))) - -;;;;;;;;;;;;;;;; - -(eval-when-compile - (add-to-list 'load-path "/usr/local/Cellar/cask/HEAD") - (defun --subdirs (path) - (let ((result '()) - (paths (ignore-errors (directory-files path t "^[^.]" t)))) - (dolist (file paths) - (when (file-directory-p file) - (add-to-list 'result file))) - result))) - -;; Scan various folders to populate the load-dirs -(setq custom-theme-load-path - (eval-when-compile - (append (--subdirs (concat narf-private-dir "themes/")) - custom-theme-load-path))) - -(setq load-path - (eval-when-compile - (require 'cask) - (cask-initialize) - (setq load-path (append (list narf-core-dir narf-contrib-dir narf-modules-dir narf-private-dir) - (list (concat narf-core-dir "lib")) - (list (concat narf-modules-dir "lib")) - (--subdirs narf-contrib-dir) - (--subdirs narf-packages-dir) - load-path)))) - -;; Load local settings, if available -(when (file-exists-p "~/.emacs.local.el") - (load "~/.emacs.local.el")) - -;; prematurely optimize for faster startup -(let (file-name-handler-alist - (gc-cons-threshold 169715200)) - (scroll-bar-mode -1) ; no scrollbar - (tool-bar-mode -1) ; no toolbar - (load-theme narf-theme t) - (mapc 'require narf-packages)) - -(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate) - "Prevent annoying \"Active processes exist\" query when you quit Emacs." - (cl-flet ((process-list ())) ad-do-it)) - -(defun display-startup-echo-area-message () - (after! workgroups2 - (message "%sLoaded in %s" (narf/tab-display t t) (emacs-init-time)))) - -(require 'server) -(unless (server-running-p) - (server-start)) - -;;; init-packages.el ends here diff --git a/init.el b/init.el index 53d4f5992..4cdd98f56 100644 --- a/init.el +++ b/init.el @@ -40,71 +40,74 @@ ;; ;;; License: GPLv3 -(defconst EMACS-WRITE nil) +(defconst narf-theme 'narf-dark) +(defconst narf-default-font (font-spec :family "Terminus (TTF)" :size 12 :antialias nil)) +(defconst narf-big-font (font-spec :family "Inconsolata" :size 20)) -(defconst narf-theme 'narf-dark) -(defconst narf-default-font (font-spec :family "Terminus (TTF)" :size 12 :antialias nil)) -(defconst narf-writing-font (font-spec :family "Hack" :size 14)) -(defconst narf-big-font (font-spec :family "Inconsolata" :size 20)) +;; Write-mode settings +(defvar write-mode-theme 'narf-write) +(defvar write-mode-font (font-spec :family "Hack" :size 12)) +(defvar write-mode-dir "~/Dropbox/notes") +(defvar write-mode-biblio-dir "~/Dropbox/docs/biblio") -(defconst narf-packages - '(core ; core/core.el +;; +(load (concat user-emacs-directory "bootstrap.el")) +;; - ;;; The heart of NARF - core-popup ; taming stray windows - core-ui ; draw me like one of your French editors - core-evil ; come to the dark side, we have cookies - core-editor ; filling the editor-shaped hole in the emacs OS - core-company ; for the lazy typist - core-yasnippet ; for the lazier typist - core-auto-insert ; for the laziest typist - core-flycheck ; remember that semicolon you forgot? - core-project ; whose project am I in? - core-vcs ; version control is a programmer's best friend - core-helm ; a search engine for life and love - core-eval ; run code, run. - core-workgroups ; cure Emacs alzheimers + tab emulation +(narf '(core ; core/core.el - ;;; Environments - module-cc ; c/c++/obj-c madness - module-csharp ; unity, .NET, and mono shenanigans - module-data ; dbs 'n data formats - module-go ; the hipster dialect - module-java ; the poster child for carpal tunnel syndome - module-js ; all(hope(abandon(ye(who(enter(here)))))) - module-lisp ; drowning in parentheses - module-lua ; one-based indices? one-based indices. - module-markdown ; markdown - ;; module-org ; for fearless [organized] leader - module-php ; making php less painful to work with - module-plantuml ; to help show others how right I am - module-python ; beautiful is better than ugly - module-regex ; /^[^\s](meaning)[^\n]*/ - module-ruby ; <3 - module-rust ; Fe2O3; for gamedev and great good - module-sh ; she sells Z-shells by the C XOR - module-swift ; yay, emoji variables! - module-vim ; my mistress - module-web ; for the 2.0'er + ;; The heart of NARF + core-popup ; taming stray and sudden windows + core-ui ; draw me like one of your French editors + core-evil ; come to the dark side, we have cookies + core-editor ; filling the editor-shaped hole in the emacs OS + core-completion ; for the lazy typist + core-yasnippet ; for the lazier typist + core-file-templates ; for the laziest typist + core-flycheck ; code police; tazing you for every semicolon you forget + core-project ; whose project am I in? + core-vcs ; remember remember, that commit in November + core-helm ; a search engine for life and love + core-eval ; run code, run. + core-sessions ; cure Emacs alzheimers + tab emulation - ;;; Experimental - ;; module-crystal ; ruby at the speed of c - ;; module-eshell ; for inferior OSes *cough*windows - ;; module-nim ; look out Abraham - ;; module-pony ; Dear Princess Compiler + ;; Environments + module-apple ; Applescript, Swift, Launchbar, iOS + module-cc ; c/c++/obj-c madness + module-csharp ; unity, .NET, and mono shenanigans + module-go ; the hipster dialect + module-java ; the poster child for carpal tunnel syndome + module-js ; all(hope(abandon(ye(who(enter(here)))))) + module-lisp ; drowning in parentheses + module-lua ; one-based indices? one-based indices. + module-markdown ; markdown + module-php ; making php less painful to work with + module-plantuml ; to help show others how right I am + module-python ; beautiful is better than ugly + module-regex ; /^[^\s](meaning)[^\n]*/ + module-ruby ; <3 + module-rust ; Fe2O3; for gamedev and great good + module-sh ; she sells Z-shells by the C XOR + module-tmux ; closing the rift between GUI & terminal + module-web ; for the 2.0'er - ;;; Specific custom functionality - lib-plugin ; plugin dev for various programs - lib-tmux ; closing the rift between GUI & terminal - lib-demo ; let me demonstrate... - lib-writing ; yes, I write papers and fiction in emacs - ;; lib-crm ; emacs and org-mode based CRM + ;; Experimental + ;;module-crystal ; ruby at the speed of c + ;;module-eshell ; for inferior OSes *cough*windows + ;;module-nim ; look out Abraham + ;;module-pony ; Dear Princess Compiler - ;;; Key bindings & ex commands - my-bindings - my-commands - )) + ;; Organizational/Writing + module-org ; for fearless [and organized] leader + module-crm ; emacs and org-mode based CRM + module-write ; making Emacs fit for writing fiction, papers & notes -(load (concat user-emacs-directory "init-packages.el")) + ;; Extra Tools + module-demo ; let me demonstrate... + + ;; Key bindings & ex commands + my-bindings + my-commands + )) ;;; I think so Brain...