.emacs-defs
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 25 Jul 2022 11:34:41 +0300
changeset 1755 e99278df97cb
parent 1717 3c60aeba5004
permissions -rw-r--r--
kill-do-not-save-duplicates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1284
0e25700290c4 Simplify expression.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1278
diff changeset
     1
;; -*- mode: emacs-lisp; coding: utf-8; fill-column: 78; no-byte-compile: t; -*-
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
1688
0bab53c47567 Moved startup profiler settings to init.el and simplified activation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1687
diff changeset
     3
(defvar my-profiler-enabled nil
1714
73cab0de25c6 Docs: my-profiler-enabled.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1689
diff changeset
     4
  "Switch for enabling startup profiling.
73cab0de25c6 Docs: my-profiler-enabled.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1689
diff changeset
     5
73cab0de25c6 Docs: my-profiler-enabled.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1689
diff changeset
     6
Put value to '~/.emacs.d/.emacs-pre' which isn't overridden on installation.")
1688
0bab53c47567 Moved startup profiler settings to init.el and simplified activation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1687
diff changeset
     7
1675
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
     8
(defvar my-lisp-usr-home-dir
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
  (expand-file-name "~/usr/share/emacs/site-lisp")
1675
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    10
  "There is a place for additional lisp packages installed via 'DIST=~/usr make install'.")
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
(defvar my-lisp-dir
1674
68a521583d8e Added suffix "/" to my-lisp-dir for next easy/safe concat operations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1672
diff changeset
    13
  (expand-file-name (concat user-emacs-directory "mylisp/"))
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  "Here live my lisp packages.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
(add-to-list 'load-path my-lisp-dir)
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
1717
3c60aeba5004 Moved definition of root for Org mode files to defs file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
    17
(defvar my-org-dir "~/my/gtd"
3c60aeba5004 Moved definition of root for Org mode files to defs file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
    18
  "Root directory for my Org files.")
3c60aeba5004 Moved definition of root for Org mode files to defs file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
    19
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
(defvar my-lisp-autoload (concat my-lisp-dir "loaddefs.el")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
  "Path to autoload for mode files.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
(defvar my-lisp-auth (concat user-emacs-directory ".emacs-auth")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
  "Path to auth info for Emacs.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
(defvar my-lisp-autogen (concat user-emacs-directory ".emacs-autogen")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
  "Path to automatically generated config file. It content depend on
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
  installation environment and it was overridden on install.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
(defvar my-lisp-pre (concat user-emacs-directory ".emacs-pre")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
  "Path to file with pre-settings. Intended for local modifications.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
(defvar my-lisp-dotemacs (concat user-emacs-directory ".emacs-my")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    30
  "Path to file with settings. Overwritten on install.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    31
(defvar my-lisp-post (concat user-emacs-directory ".emacs-post")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    32
  "Path to file with post-settings. Intended for local modifications.")
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
(setq custom-file (concat user-emacs-directory ".emacs-custom"))
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
(setq save-place-file (concat user-emacs-directory ".emacs-places"))
1285
8e2c4332223d Use newer recommended place for bookmarks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1284
diff changeset
    36
(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
(setq ido-save-directory-list-file (concat user-emacs-directory ".ido.last"))
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
1687
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    39
(setq
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    40
 package-archives
1689
96846689e388 Work with packages over HTTPS.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1688
diff changeset
    41
 '(("gnu" . "https://elpa.gnu.org/packages/")
1687
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    42
   ("melpa-stbl" . "https://stable.melpa.org/packages/")
1689
96846689e388 Work with packages over HTTPS.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1688
diff changeset
    43
   ("melpa" . "https://melpa.org/packages/"))
1687
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    44
 package-archive-priorities
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    45
 '(("gnu" . 10)
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    46
   ("melpa-stbl" . 5)
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    47
   ("melpa" . 0)) )
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    48
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    49
(setq
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    50
 package-selected-packages
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    51
 '(adoc-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    52
   apache-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    53
   dockerfile-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    54
   groovy-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    55
   markdown-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    56
   terraform-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    57
   web-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    58
   yaml-mode
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    59
   expand-region
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    60
   helm
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    61
   ))
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    62
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    63
(defun my-lisp--install-external-packages ()
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    64
  ;; (package-initialize)
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    65
  ;; Update `package-archive-contents'.
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    66
  (advice-add #'y-or-n-p :override (lambda (prompt) t))
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    67
  (package-refresh-contents)
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    68
  ;; (package-install 'yaml-mode)
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    69
  (package-install-selected-packages))
3f69332472cb Added Make target to preinstall packages from ELPA.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1675
diff changeset
    70
1675
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    71
(defun my-lisp--load-pre ()
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    72
  (mapc (lambda (f)
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    73
          (when (file-exists-p f)
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    74
            (load f nil nil t)))
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    75
        (list custom-file my-lisp-autogen my-lisp-auth my-lisp-pre my-lisp-autoload)))
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    76
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    77
(defun my-lisp--load-usr-home ()
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    78
  "Add hierarchy `my-lisp-usr-home-dir' to `load-path'."
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    79
  (when (file-directory-p my-lisp-usr-home-dir)
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    80
    (add-to-list 'load-path my-lisp-usr-home-dir)
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    81
    (let ((default-directory my-lisp-usr-home-dir))
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    82
      (normal-top-level-add-subdirs-to-load-path))))
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    83
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    84
(defun my-lisp--load-all ()
1672
e2d0fc84c6f5 Simplified Makefile byte compillation recipe by moving some logic from CLI to elisp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1670
diff changeset
    85
  "Load everything to help during byte compilation to spot errors
e2d0fc84c6f5 Simplified Makefile byte compillation recipe by moving some logic from CLI to elisp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1670
diff changeset
    86
better. Not for regular use but for the Makefile."
1675
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    87
  (my-lisp--load-usr-home)
08f7fd3c4d5b Load more files for byte compilation check. Switched to my-lisp-* prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1674
diff changeset
    88
  (my-lisp--load-pre))
1241
4f22d9fe2e5b Byte compile '.emacs-my' and 'my/*.el'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    89
1254
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    90
(defmacro my--eval-after-load (feature &rest forms)
1278
8e47e801be9d Remove qouting from 'my--eval-after-load' macro usage because that code doesn't evaluated.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1254
diff changeset
    91
  (declare (indent defun))
1254
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    92
  `(,(if (or (not (boundp 'byte-compile-current-file))
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    93
             (not byte-compile-current-file)
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    94
             (if (symbolp feature)
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    95
                 (require feature nil :no-error)
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    96
               (load feature :no-message :no-error)))
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    97
         'progn
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    98
       (message "my--eval-after-load: cannot find %s" feature)
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
    99
       'with-no-warnings)
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
   100
    (eval-after-load ',feature
1284
0e25700290c4 Simplify expression.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1278
diff changeset
   101
      '(funcall (lambda () ,@forms)))))
1254
19c7b3be9b3a Define special macro to avoid warning about "assignment to free variable".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1241
diff changeset
   102