Make config use user-emacs-directory instead of hard-coded value

This commit is contained in:
Wojciech Kozlowski 2020-04-05 23:45:45 +02:00
parent 685ad488ca
commit d188301372
7 changed files with 30 additions and 23 deletions

View File

@ -45,7 +45,7 @@
Clone this repository into your home directory:
#+BEGIN_SRC
$ git clone https://github.com/Wojtek242/.emacs.d ~/.emacs.d
$ git clone https://github.com/Wojtek242/.emacs.d ~/.config/emacs
#+END_SRC
This configuration uses the [[https://github.com/adobe-fonts/source-code-pro][Source Code Pro]] font. If you do not have it

View File

@ -19,12 +19,12 @@ and removal.
Import the package:
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "~/.emacs.d/emodule")
(add-to-list 'load-path (concat (file-name-as-directory user-emacs-directory) "emodule"))
(require 'emodule)
#+END_SRC
Define one or more modules in the modules directory (by default
=~/.emacs.d/modules=). The module =MODULE=, is expected to be
=<user-emacs-directory>/modules=). The module =MODULE=, is expected to be
defined in a file called =MODULE.el= which will define the list of
required packages in ~emodule/MODULE-packages~ and any accompanying
initialisation in the function ~emodule/MODULE-init~.

View File

@ -55,7 +55,8 @@ may fix the problem. Note that subsequent attempts are only made
after attempting to install all other packages first."
:type 'integer)
(defcustom emodule/modules-dir "~/.emacs.d/modules/"
(defcustom emodule/modules-dir
(concat (file-name-as-directory user-emacs-directory) "modules")
"Directory in which module files are to be found."
:type 'string)
@ -183,7 +184,7 @@ dependency of one that is."
(let ((needed (cl-loop for p in pkgs
if (assq p package-alist)
;; `p' and its dependencies are needed.
append (cons p (package--get-deps p)))))
append (cons p (package--get-deps (list p))))))
(cl-loop for p in (mapcar #'car package-alist)
unless (memq p needed)
collect p)))
@ -301,7 +302,7 @@ this macro."
"Create a backup of the elpa directory in elpa.tar.xz."
(interactive)
(message "Backing up elpa...")
(let* ((default-directory "~/.emacs.d")
(let* ((default-directory user-emacs-directory)
(dir "elpa")
(archive (format "%s.tar.xz" dir)))
(emodule/unset-logs-read-only)
@ -328,7 +329,7 @@ this macro."
"Restore elpa directory state from backup."
(interactive)
(message "Restoring elpa...")
(let* ((default-directory "~/.emacs.d")
(let* ((default-directory user-emacs-directory)
(dir "elpa")
(dir-bkp (format "%s.bkp" dir))
(archive (format "%s.tar.xz" dir)))

View File

@ -15,7 +15,9 @@
;;
;;; Code:
(defconst init-buffer/banner-file "~/.emacs.d/init-buffer/blue-robot.png"
(defconst init-buffer/banner-file
(concat (file-name-as-directory user-emacs-directory)
"init-buffer/blue-robot.png")
"Location of the banner image to use.")
(defconst init-buffer/name "*GNU Emacs*"

22
init.el
View File

@ -17,6 +17,14 @@
(let ((gc-cons-threshold most-positive-fixnum))
;; --------------------------------------------------------------------------
;; Helper function to get correct configuration directory.
;; --------------------------------------------------------------------------
(defun emacs-dir (rel)
"Obtain full path to REL."
(concat (file-name-as-directory user-emacs-directory) rel))
;; --------------------------------------------------------------------------
;; Initialise and setup `package'.
;; --------------------------------------------------------------------------
@ -27,13 +35,13 @@
(package-initialize)
;; External .el files that are not available from MELPA.
(add-to-list 'load-path "~/.emacs.d/external/")
(add-to-list 'load-path (emacs-dir "external"))
;; --------------------------------------------------------------------------
;; Load `emodule'.
;; --------------------------------------------------------------------------
(add-to-list 'load-path "~/.emacs.d/emodule")
(add-to-list 'load-path (emacs-dir "emodule"))
(require 'emodule)
;; --------------------------------------------------------------------------
@ -66,8 +74,8 @@
;; Theme --------------------------------------------------------------------
;; Add the necessary paths.
(add-to-list 'load-path "~/.emacs.d/themes/")
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(add-to-list 'load-path (emacs-dir "themes"))
(add-to-list 'custom-theme-load-path (emacs-dir "themes"))
;; Load the dark theme by default.
(load-theme 'havoc-dark t) ;; Load personal theme
@ -75,7 +83,7 @@
;; Splash screen ------------------------------------------------------------
;; Add path.
(add-to-list 'load-path "~/.emacs.d/init-buffer")
(add-to-list 'load-path (emacs-dir "init-buffer"))
(require 'init-buffer)
;; Set the initial buffer.
@ -85,7 +93,7 @@
;; Change file in which custom variable changes are saved.
;; --------------------------------------------------------------------------
(setq-default custom-file "~/.emacs.d/custom.el")
(setq-default custom-file (emacs-dir "custom.el"))
;; *********************************************************************** ;;
@ -141,5 +149,3 @@
(provide 'init)
;;; init.el ends here
(put 'narrow-to-region 'disabled nil)
(put 'downcase-region 'disabled nil)

View File

@ -80,14 +80,15 @@
whitespace-line-column fill-column)
;; Backup settings.
(defvar backup-directory "~/.emacs.d/.backups")
(defvar backup-directory
(concat (file-name-as-directory user-emacs-directory) "backups"))
(if (not (file-exists-p backup-directory))
(make-directory backup-directory t))
(setq-default
;; Backup a file the first time it is saved.
make-backup-files t
;; Save backup files in ~/.emacs.d/.backups.
;; Save backup files in <user-emacs-directory>/.backups.
backup-directory-alist `((".*" . ,backup-directory))
;; Copy the current file into backup directory.
backup-by-copying t
@ -572,9 +573,6 @@
:config
(require 'smartparens-config)
(sp-with-modes '(c-mode c++-mode)
(sp-local-pair "<" ">"))
(smartparens-global-mode t)
(show-smartparens-global-mode t)

View File

@ -62,8 +62,8 @@
;; ------------------------------------------------------------------------
(setq
;; Hide special characters for italics/bold/underline.
org-hide-emphasis-markers t
;; Do not hide special characters for italics/bold/underline.
org-hide-emphasis-markers nil
;; Open org files unfolded
org-startup-folded nil
;; Catch edits in invisible areas (space after the ellipsis ...)