.emacs-defs
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 02 Jan 2021 01:28:36 +0200
changeset 1672 e2d0fc84c6f5
parent 1670 c3a11a672d0d
child 1674 68a521583d8e
permissions -rw-r--r--
Simplified Makefile byte compillation recipe by moving some logic from CLI to elisp.

;; -*- mode: emacs-lisp; coding: utf-8; fill-column: 78; no-byte-compile: t; -*-

(defvar my-usr-lisp-dir
  (expand-file-name "~/usr/share/emacs/site-lisp")
  "Here live additional lisp packages.")

(defvar my-lisp-dir
  (expand-file-name (concat user-emacs-directory "mylisp"))
  "Here live my lisp packages.")
(add-to-list 'load-path my-lisp-dir)

(defvar my-lisp-autoload (concat my-lisp-dir "loaddefs.el")
  "Path to autoload for mode files.")
(defvar my-lisp-auth (concat user-emacs-directory ".emacs-auth")
  "Path to auth info for Emacs.")
(defvar my-lisp-autogen (concat user-emacs-directory ".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 user-emacs-directory ".emacs-pre")
  "Path to file with pre-settings. Intended for local modifications.")
(defvar my-lisp-dotemacs (concat user-emacs-directory ".emacs-my")
  "Path to file with settings. Overwritten on install.")
(defvar my-lisp-post (concat user-emacs-directory ".emacs-post")
  "Path to file with post-settings. Intended for local modifications.")

(setq custom-file (concat user-emacs-directory ".emacs-custom"))
(setq save-place-file (concat user-emacs-directory ".emacs-places"))
(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
(setq ido-save-directory-list-file (concat user-emacs-directory ".ido.last"))

(defun my-load--load-all ()
  "Load everything to help during byte compilation to spot errors
better. Not for regular use but for the Makefile."
  (if (file-exists-p my-lisp-pre)
      (load my-lisp-pre)
    (load ".emacs-pre"))
  (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))))

(defmacro my--eval-after-load (feature &rest forms)
  (declare (indent defun))
  `(,(if (or (not (boundp 'byte-compile-current-file))
             (not byte-compile-current-file)
             (if (symbolp feature)
                 (require feature nil :no-error)
               (load feature :no-message :no-error)))
         'progn
       (message "my--eval-after-load: cannot find %s" feature)
       'with-no-warnings)
    (eval-after-load ',feature
      '(funcall (lambda () ,@forms)))))