Skip to content

Commit

Permalink
Major: Organize personal settings
Browse files Browse the repository at this point in the history
- Create a var `user-personal-directory`
- Rename `setup-disables` to `setup-var-overrides`
- Load `setup-var-overrides` before the very first `load`/`require`
- Add `personal/setup-var-overrides-EXAMPLE.el`
- Remove useless functions `prepend-path` and `append-path`; use plain
  old `add-to-list` instead. Advantage of `add-to-list` is that it does
  not allow duplicate elements.
  • Loading branch information
kaushalmodi committed Jun 16, 2015
1 parent 120fefc commit a0403eb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 29 deletions.
37 changes: 20 additions & 17 deletions init.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; Time-stamp: <2015-06-10 17:29:44 kmodi>
;; Time-stamp: <2015-06-16 16:58:29 kmodi>
;; Author: Kaushal Modi

;; Record the start time
Expand All @@ -7,15 +7,19 @@
;; (setq debug-on-message "Making tags")

;; Global variables
(setq user-home-directory (concat (getenv "HOME") "/")) ; must end with /
(setq user-emacs-directory (concat user-home-directory ".emacs.d/")) ; must end with /
(setq emacs-version-short (replace-regexp-in-string
"\\([0-9]+\\)\\.\\([0-9]+\\).*"
"\\1_\\2" emacs-version)) ; 25.0.50.1 -> 25_0
(setq org-directory (concat user-home-directory "org/")) ; must end with /
(setq setup-packages-file (locate-user-emacs-file "setup-packages.el"))
(setq custom-file (locate-user-emacs-file
(concat "custom_" emacs-version-short ".el")))
(setq user-home-directory (concat (getenv "HOME") "/")) ; must end with /
(setq user-emacs-directory (concat user-home-directory ".emacs.d/")) ; must end with /
(setq emacs-version-short (replace-regexp-in-string
"\\([0-9]+\\)\\.\\([0-9]+\\).*"
"\\1_\\2" emacs-version)) ; 25.0.50.1 -> 25_0
(setq org-directory (concat user-home-directory "org/")) ; must end with /
(setq setup-packages-file (locate-user-emacs-file "setup-packages.el"))
(setq custom-file (locate-user-emacs-file
(concat "custom_" emacs-version-short ".el")))
(setq user-personal-directory (let ((dir (concat user-emacs-directory
"personal/")))
(make-directory dir :parents)
dir))

;; A list of packages to ensure are installed at launch
(setq my-packages
Expand Down Expand Up @@ -139,6 +143,10 @@
(require 'cl)
(require 'cl-lib)

;; Place `setup-var-overrides.el' with `(provide 'setup-var-overrides)' in
;; `user-personal-directory'
(require 'setup-var-overrides nil :noerror)

(load custom-file :noerror :nomessage) ; Load the emacs `M-x customize` generated file

(load setup-packages-file nil :nomessage) ; Load the packages
Expand All @@ -149,12 +157,6 @@
;; I call this function in setup-packages.el and so am keeping the
;; commented out version here so that package.el does not add it again.

;; Optional file containing `setq' statements to disable loading of selected
;; packages. Format to be used: (setq disable-pkg-PKGNAME t)
;; Example: (setq disable-pkg-pdf-tools t)
;; Place `setup-disables.el' with `(provide 'setup-disables)' in `setup-files/'
(require 'setup-disables nil :noerror)

;; Start `benchmark-init' as soon as possible
(require 'benchmark-init)

Expand Down Expand Up @@ -281,9 +283,10 @@
(require 'setup-calc)
(require 'setup-image)

;; Place `setup-work.el' with `(provide 'setup-work)' in `user-personal-directory'
(require 'setup-work nil :noerror)

;; Place `setup-personal.el' with `(provide 'setup-personal)' in `setup-files/'
;; Place `setup-personal.el' with `(provide 'setup-personal)' in `user-personal-directory'
(require 'setup-personal nil :noerror)

;; Load certain setup files after a 1 second idle time after emacs has loaded.
Expand Down
22 changes: 22 additions & 0 deletions personal/setup-var-overrides-EXAMPLE.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
;; Time-stamp: <2015-06-16 17:11:37 kmodi>

;; Variable overrides

;; This file can be used to override variables using `setq' forms.
;; An example use is to disable loading of selected packages.
;; Format to be used: (setq disable-pkg-PKGNAME t)
;; Example: (setq disable-pkg-pdf-tools t) ; Disable loading of `pdf-tools'
;; Note that all packages CANNOT be disabled in this manner.

;; (setq user-personal-directory "~/.emacs.d/personal/")

;; (setq disable-pkg-pdf-tools t)
;; (setq disable-pkg-yasnippet t)
;; (setq disable-pkg-ivy t)
;; (setq disable-pkg-shackle t)
;; (setq disable-pkg-fci t)
;; (setq disable-pkg-hl-anything t)


;; Below line *has to be uncommented* for the setup in this file to be effective
;; (provide 'setup-var-overrides)
2 changes: 1 addition & 1 deletion setup-files/setup-latex.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"AucTeX install directory.")

(when (file-exists-p auctex-install-dir)
(prepend-path auctex-install-dir)
(add-to-list 'load-path auctex-install-dir)
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

Expand Down
16 changes: 5 additions & 11 deletions setup-packages.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; Time-stamp: <2015-05-28 11:09:46 kmodi>
;; Time-stamp: <2015-06-16 16:34:44 kmodi>

;; Package management
;; Loading of packages at startup
Expand All @@ -14,17 +14,11 @@
(require 'package)

(when (version<= "25.0" emacs-version)
(setq package-menu-async t) ; If non-nil, do activities asynchronously, like refreshing menu
)
(setq package-menu-async t)) ; If non-nil, do activities asynchronously, like refreshing menu

(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))

(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))

(prepend-path (concat user-emacs-directory "elisp/"))
(prepend-path (concat user-emacs-directory "setup-files/"))
(add-to-list 'load-path (concat user-emacs-directory "elisp/"))
(add-to-list 'load-path (concat user-emacs-directory "setup-files/"))
(add-to-list 'load-path user-personal-directory)

;; Create the package install directory if it doesn't exist
(setq package-user-dir (concat user-emacs-directory "elpa_"
Expand Down

0 comments on commit a0403eb

Please sign in to comment.