Move all configs to "~/.emacs.d/my".
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 28 Jan 2015 00:45:31 +0200
changeset 1199 dff272add01e
parent 1198 81709141a539
child 1200 a8fcda9c0aab
Move all configs to "~/.emacs.d/my".
.emacs
.emacs-my
.emacs-obsolete
Makefile
--- a/.emacs	Tue Jan 27 22:53:39 2015 +0200
+++ b/.emacs	Wed Jan 28 00:45:31 2015 +0200
@@ -9,61 +9,45 @@
 ;; ======================================================================
 ;; Load path.
 
-(defun my-find-subdirs (dir)
-  (if (file-directory-p dir)
-      (cons dir (apply 'append (mapcar 'my-find-subdirs (directory-files dir t "^[^.]")) ) )
-    ))
-(defun my-add-subdirs-to-load-path (dir)
-  (mapc
-   (lambda (d)
-     (add-to-list 'load-path d t)
-     (message "Load-path updated with: %s" d)
-     )
-   (my-find-subdirs dir)) )
 
-(defvar my-usr-el-dir
+(defvar my-usr-lisp-dir
   (expand-file-name "~/usr/share/emacs/site-lisp")
   "Here live additional lisp packages.")
-(my-add-subdirs-to-load-path my-usr-el-dir)
+(when (file-directory-p my-usr-lisp-dir)
+  (add-to-list 'load-path my-usr-lisp-dir)
+  (let ((default-directory my-usr-lisp-dir))
+    (normal-top-level-add-subdirs-to-load-path)))
+
+(unless (boundp 'user-emacs-directory)
+  (setq user-emacs-directory "~/.emacs.d/"))
 
 (defvar my-lisp-dir
-  (expand-file-name (concat user-emacs-directory "my-lisp"))
+  (expand-file-name (concat user-emacs-directory "my/"))
   "Here live my lisp packages.")
-(my-add-subdirs-to-load-path my-lisp-dir)
-
-(defvar my-autoload (concat my-lisp-dir "/autoload-my.el")
-  "Path to autoload for mode files.")
-(defvar my-auth (expand-file-name "~/.emacs-auth")
-  "Path to auth info for Emacs.")
-(defvar dot-emacs-autogen (expand-file-name "~/.emacs-autogen")
-  "Path to automatically generated config file. It content depend on
-  installation environment and it was overridden on install.")
-(defvar dot-emacs-pre (expand-file-name "~/.emacs-pre")
-  "Path to file with pre-loaded custom settings.")
-(defvar dot-emacs-post (expand-file-name "~/.emacs-post")
-  "Path to file with post-loaded custom settings.")
+(add-to-list 'load-path my-lisp-dir)
 
-
-(if (file-exists-p dot-emacs-autogen)
-    (load dot-emacs-autogen))
-
-(if (file-exists-p my-auth)
-    (load my-auth))
-
-;; pre-load custom settings
-(if (file-exists-p dot-emacs-pre)
-    (load dot-emacs-pre))
-
-(if (file-exists-p my-autoload)
-    (load my-autoload))
-
-(setq custom-file "~/.emacs-custom.el")
+(setq custom-file (concat my-lisp-dir ".emacs-custom"))
 (if (file-exists-p custom-file)
     (load custom-file))
 
-;; load main customization
-(load "~/.emacs-my")
+(defvar my-lisp-autoload (concat my-lisp-dir "loaddefs.el")
+  "Path to autoload for mode files.")
+(defvar my-lisp-auth (concat my-lisp-dir ".emacs-auth")
+  "Path to auth info for Emacs.")
+(defvar my-lisp-autogen (concat my-lisp-dir ".emacs-autogen")
+  "Path to automatically generated config file. It content depend on
+  installation environment and it was overridden on install.")
+(defvar my-lisp-pre (concat my-lisp-dir ".emacs-pre")
+  "Path to file with pre-settings. Intended for local modifications.")
+(defvar my-lisp-dotemacs (concat my-lisp-dir ".emacs-my")
+  "Path to file with settings. Overwritten on install.")
+(defvar my-lisp-post (concat my-lisp-dir ".emacs-post")
+  "Path to file with post-settings. Intended for local modifications.")
 
-;; post-load custom settings
-(if (file-exists-p dot-emacs-post)
-    (load dot-emacs-post))
+(setq save-place-file (concat my-lisp-dir ".emacs-places"))
+
+(mapc
+ (lambda (fname)
+   (if (file-exists-p fname)
+       (load fname)))
+ (list custom-file my-lisp-autogen my-lisp-auth my-lisp-pre my-lisp-autoload my-lisp-dotemacs my-lisp-post))
--- a/.emacs-my	Tue Jan 27 22:53:39 2015 +0200
+++ b/.emacs-my	Wed Jan 28 00:45:31 2015 +0200
@@ -2971,8 +2971,11 @@
   (setq desktop-base-file-name ".emacs.desktop-cygwin")
   (setq desktop-base-lock-name ".emacs.desktop-cygwin.lock")
   )
+(setq desktop-dirname my-lisp-dir)
 
 (when (>= emacs-major-version 22)
+  (require 'desktop)
+  (add-to-list 'desktop-path desktop-dirname)
   (setq desktop-restore-frames nil)
   (desktop-save-mode 1)
   (setq
--- a/.emacs-obsolete	Tue Jan 27 22:53:39 2015 +0200
+++ b/.emacs-obsolete	Wed Jan 28 00:45:31 2015 +0200
@@ -42,3 +42,20 @@
         ;; Place dir at end to appear at the start of completion-ignored-extensions.
         "CVS/" ".hg/" ".svn/" ".git/" ".bzr/"
         ) )
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun my-find-subdirs (dir)
+  (if (file-directory-p dir)
+      (cons dir (apply 'append (mapcar 'my-find-subdirs (directory-files dir t "^[^.]")) ) )
+    ))
+(defun my-add-subdirs-to-load-path (dir)
+  (mapc
+   (lambda (d)
+     (add-to-list 'load-path d t)
+     (message "Load-path updated with: %s" d)
+     )
+   (my-find-subdirs dir)) )
+
+(my-add-subdirs-to-load-path my-usr-lisp-dir)
+(my-add-subdirs-to-load-path my-lisp-dir)
--- a/Makefile	Tue Jan 27 22:53:39 2015 +0200
+++ b/Makefile	Wed Jan 28 00:45:31 2015 +0200
@@ -41,6 +41,12 @@
 endif
 
 ################################################################
+# Installation directories.
+
+emacsdir := $(HOME)/.emacs.d
+mylispdir := $(emacsdir)/my
+
+################################################################
 # Build tool definition/switches.
 
 EMACS = emacs
@@ -73,34 +79,53 @@
 ################################################################
 # Install/uninstall targets.
 
+.PHONY: upgrade
+upgrade:
+	\
+if [ ! -d $(mylispdir) ]; then \
+  if [ -d $(emacsdir)/my-lisp ]; then \
+    rm -f $(emacsdir)/autoload-my.el; \
+    mv $(emacsdir)/my-lisp $(mylispdir); \
+  else \
+    mkdir -p $(mylispdir); \
+  fi; \
+  mv ~/.emacs-my $(mylispdir)/.emacs || true; \
+  mv ~/.emacs-custom.el $(mylispdir)/.emacs-custom || true; \
+  mv ~/.emacs-pre $(mylispdir) || true; \
+  mv ~/.emacs-post $(mylispdir) || true; \
+  mv ~/.emacs-places $(mylispdir) || true; \
+  mv ~/.emacs.desktop $(mylispdir) || true; \
+  rm -f ~/.emacs-autogen; \
+fi
+
 .PHONY: install-all
 install-all: install
-	cp .emacs-pre $(HOME)/.emacs-pre
-	cp .emacs-post $(HOME)/.emacs-post
+	cp .emacs-pre $(mylispdir)/.emacs-pre
+	cp .emacs-post $(mylispdir)/.emacs-post
 
 .PHONY: install
-install: .emacs .emacs-my .emacs-pre .emacs-post $(EL_FILES)
+install:
+	mkdir -p $(mylispdir)
+	find $(mylispdir) -type f -name '*.el' -delete
 	for file in .emacs-pre .emacs-post; do \
-		[ -f $(HOME)/$$file ] || cp $$file $(HOME)/$$file; \
+		[ -f $(mylispdir)/$$file ] || cp $$file $(mylispdir)/$$file; \
 	done
 	cp .emacs $(HOME)/.emacs
-	cp .emacs-my $(HOME)/.emacs-my
+	cp .emacs-my $(mylispdir)/.emacs-my
 	mkdir -p $(HOME)/.gnus/scores
 	cp all.SCORE $(HOME)/.gnus/scores
-	rm -f -r $(HOME)/.emacs.d/my-lisp
-	mkdir -p $(HOME)/.emacs.d/my-lisp
 	for file in $(EL_FILES); do \
-		cp -f $$file $(HOME)/.emacs.d/my-lisp; \
+		cp -f $$file $(mylispdir); \
 	done
-	$(EMACS) -Q --batch \
-		--eval='(let ( (generated-autoload-file "~/.emacs.d/my-lisp/autoload-my.el") ) (update-directory-autoloads "~/.emacs.d/my-lisp") )'
-	./.emacs-autogen.sh $(HOME)/.emacs-autogen
+	$(EMACS) -Q --batch --eval='(let ((generated-autoload-file "$(mylispdir)/loaddefs.el")) (update-directory-autoloads "$(mylispdir)"))'
+	./.emacs-autogen.sh $(mylispdir)/.emacs-autogen
 	cp -r srecode/ $(HOME)/.emacs.d/
 
 .PHONY: uninstall
 uninstall:
-	rm -f $(HOME)/.emacs $(HOME)/.emacs-my $(HOME)/.emacs-autogen
-	rm -f -r $(HOME)/.emacs.d/my-lisp $(HOME)/.emacs.d/srecode
+	rm -f $(HOME)/.emacs $(mylispdir)/.emacs-my $(mylispdir)/.emacs-autogen
+	find $(mylispdir) -type f -name '*.el' -delete
+	rm -f -r $(emacsdir)/srecode
 
 .PHONY: tar
 tar: