Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Completely refactored emacs-setup, setting load-path, and requiring f…

…iles.

Removed variable: `emacs-setup-pre-sexp`
  • Loading branch information...
commit dde70ed38894bbdd4ba9119ca70ab6c570f7964d 1 parent 46231ad
Brian Zwahr authored
Showing with 29 additions and 80 deletions.
  1. +21 −34 emacs-setup-require.el
  2. +8 −46 emacs-setup.el
View
55 emacs-setup-require.el
@@ -16,6 +16,17 @@
"Emacs setup layout customizations."
:group 'emacs-setup)
+(defcustom emacs-setup-require-base-dir "~/.emacs.d"
+ "Base directory where you keep your .el files to be loaded."
+ :group 'emacs-setup-require
+ :type '(file :must-match t))
+
+(defcustom emacs-setup-require-ignore-dirs '(".svn" ".git")
+ "Sub-directories of emacs-setup-base-elisp-dir to ignore when loading
+(i.e. .svn, .git, etc.)."
+ :group 'emacs-setup-require
+ :type '(repeat :tag "Sub-directory name: " (string)))
+
(defcustom emacs-setup-load-path-list nil
"This is a list of directory paths to add to the Emacs `load-path'."
:group 'emacs-setup-require
@@ -47,43 +58,19 @@ require statement is called."
:type 'file)
;;; *********
-;;; VARIABLES
-;;; *********
-
-(defvar emacs-setup-ring nil
- "Ring for `emacs-setup'.")
-
-;;; *********
;;; FUNCTIONS
;;; *********
-(defun emacs-setup-load-recursive-el-directories (base-dir ignore-dirs)
- "Recursively add all directories under BASE-DIR to the `load-path'.
-Argument BASE-DIR Base directory to add.
-Argument IGNORE-DIRS Directories to ignore (e.g. .git, .svn, etc)."
- (let ((el-dirs-list (list base-dir))
- (current-directory-list (directory-files-and-attributes base-dir t))
- (ignore-dirs (append ignore-dirs (list "." ".."))))
- (while current-directory-list
- (cond
- ;; check whether filename is that of a directory
- ((eq t (car (cdr (car current-directory-list))))
- (unless (member
- (file-name-nondirectory (car (car current-directory-list)))
- ignore-dirs)
- (setq el-dirs-list
- (cons (car (car current-directory-list)) el-dirs-list))
- (setq el-dirs-list
- (append
- (emacs-setup-load-recursive-el-directories
- (car (car current-directory-list)) ignore-dirs)
- el-dirs-list)))))
- (setq current-directory-list (cdr current-directory-list)))
- (dolist (el-dir el-dirs-list)
- (let ((dir-to-load (file-name-as-directory el-dir)))
- (unless (member dir-to-load load-path)
- (setq load-path (cons dir-to-load load-path)))))
- el-dirs-list))
+(defun emacs-setup-require-set-paths ()
+ "Set up the load-path and PATH."
+ (add-to-list 'load-path emacs-setup-require-base-dir)
+ (let ((default-directory emacs-setup-require-base-dir))
+ (normal-top-level-add-subdirs-to-load-path))
+ (add-to-list 'load-path emacs-setup-load-path-list)
+ (setenv "PATH" (mapconcat 'concat
+ (append emacs-setup-env-path-list
+ (list (getenv "PATH")))
+ ":")))
(defun emacs-setup-load-package-el ()
"Return the appropriate package.el."
View
54 emacs-setup.el
@@ -84,32 +84,15 @@
;;; **************
;;; CUSTOMIZATIONS
;;; **************
-
(defgroup emacs-setup nil
"Easy emacs setup."
:group 'environment)
-(defcustom emacs-setup-elisp-base-dir "~/.emacs.d"
- "Base directory where you keep your .el files to be loaded."
- :group 'emacs-setup
- :type '(file :must-match t))
-
-(defcustom emacs-setup-elisp-ignore-dirs '(".svn" ".git")
- "Sub-directories of emacs-setup-base-elisp-dir to ignore when loading
-(i.e. .svn, .git, etc.)."
- :group 'emacs-setup
- :type '(repeat :tag "Sub-directory name: " (string)))
-
(defcustom emacs-setup-base-sexp nil
"List of function names to run during base setup."
:group 'emacs-setup
:type '(repeat :tag "S-expression: " (sexp)))
-(defcustom emacs-setup-pre-sexp nil
- "List of function names to call before setup is run."
- :group 'emacs-setup
- :type '(repeat :tag "S-expression: " (sexp)))
-
(defcustom emacs-setup-post-sexp nil
"List of function names to call after setup has loaded."
:group 'emacs-setup
@@ -118,44 +101,23 @@
;;; *********
;;; FUNCTIONS
;;; *********
-(defun emacs-setup-base (&optional frame)
- "Performs initial setup. The frame argument is there for
-after-make-frame-hook."
- (interactive)
- (let ((dir (file-name-directory
- (find-lisp-object-file-name 'emacs-setup-base 'function))))
- (add-to-list 'load-path dir)
- (require 'emacs-setup-require)
- (require 'emacs-setup-keys))
- (emacs-setup-load-recursive-el-directories
- emacs-setup-elisp-base-dir
- emacs-setup-elisp-ignore-dirs)
- (dolist (dir emacs-setup-load-path-list)
- (add-to-list 'load-path dir))
- (let ((env-path (getenv "PATH")))
- (dolist (dir emacs-setup-env-path-list)
- (setq env-path (concat dir ":" env-path)))
- (setenv "PATH" env-path))
- (dolist (sexp emacs-setup-base-sexp)
- (eval sexp)))
-
(defun emacs-setup ()
(interactive)
- (let (errorp)
- (dolist (sexp emacs-setup-pre-sexp)
- (eval sexp))
- (setq errorp (emacs-setup-require-packages))
- (dolist (sexp emacs-setup-post-sexp)
- (eval sexp))
+ (add-to-list 'load-path (file-name-directory
+ (find-lisp-object-file-name 'emacs-setup 'function)))
+ (require 'emacs-setup-require)
+ (require 'emacs-setup-keys)
+ (emacs-setup-require-set-paths)
+ (mapc 'eval emacs-setup-base-sexp)
+ (let ((errorp (emacs-setup-require-packages)))
+ (mapc 'eval emacs-setup-post-sexp)
(emacs-setup-bind-keys)
(if errorp
(message "Setup complete, with errors. Check the *Messages* buffer.")
(message "Setup complete. Emacs is ready to go!"))))
(defadvice custom-set-variables (after my-advice-custom-setup)
- (emacs-setup-base)
(emacs-setup))
-
(ad-activate 'custom-set-variables)
(provide 'emacs-setup)
Please sign in to comment.
Something went wrong with that request. Please try again.