aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/lisp/init-company.el5
-rw-r--r--.emacs.d/lisp/init-deft.el2
-rw-r--r--.emacs.d/lisp/init-evil.el17
-rw-r--r--.emacs.d/lisp/init-git.el2
-rw-r--r--.emacs.d/lisp/init-input-method.el12
-rw-r--r--.emacs.d/lisp/init-ivy.el5
-rw-r--r--.emacs.d/lisp/init-lang.el30
-rw-r--r--.emacs.d/lisp/init-markdown.el9
-rw-r--r--.emacs.d/lisp/init-misc.el22
-rw-r--r--.emacs.d/lisp/init-org.el26
-rw-r--r--.emacs.d/lisp/init-package.el47
-rw-r--r--.emacs.d/lisp/init-projectile.el4
12 files changed, 105 insertions, 76 deletions
diff --git a/.emacs.d/lisp/init-company.el b/.emacs.d/lisp/init-company.el
index c096e86..6fc8cbc 100644
--- a/.emacs.d/lisp/init-company.el
+++ b/.emacs.d/lisp/init-company.el
@@ -1,6 +1,5 @@
-(use-package company :ensure t :defer t)
-
-(add-hook 'after-init-hook 'global-company-mode)
+(when (gx/maybe-require-package 'company)
+ (add-hook 'after-init-hook 'global-company-mode))
(setq company-global-modes
'(emacs-lisp-mode go-mode ledger-mode sh-mode c++-mode))
diff --git a/.emacs.d/lisp/init-deft.el b/.emacs.d/lisp/init-deft.el
index 6cc18ea..23d288f 100644
--- a/.emacs.d/lisp/init-deft.el
+++ b/.emacs.d/lisp/init-deft.el
@@ -1,4 +1,4 @@
-(use-package deft :ensure t :defer t)
+(gx/maybe-require-package 'deft)
(setq deft-recursive t
deft-use-filter-string-for-filename t
deft-extensions '("org" "txt" "md" "tex")
diff --git a/.emacs.d/lisp/init-evil.el b/.emacs.d/lisp/init-evil.el
index d950f73..c41296b 100644
--- a/.emacs.d/lisp/init-evil.el
+++ b/.emacs.d/lisp/init-evil.el
@@ -1,11 +1,12 @@
-(use-package evil :ensure t :defer t)
+(when (gx/maybe-require-package 'evil)
+ (add-hook 'after-init-hook (lambda () (evil-mode 1))))
-(add-hook 'after-init-hook (lambda () (evil-mode 1)))
(setq evil-want-integration t
evil-want-C-u-scroll t
evil-wannt-fine-undo t
evil-want-keybinding nil
evil-disable-insert-state-bindings t)
+
(with-eval-after-load 'evil
(evil-set-leader 'normal ",")
(evil-set-undo-system 'undo-tree)
@@ -16,13 +17,13 @@
(kbd "gk") 'evil-previous-visual-line))
;; evil-collection
-(use-package evil-collection :ensure t :defer t)
-(with-eval-after-load 'evil
- (evil-collection-init))
+(when (gx/maybe-require-package 'evil-collection)
+ (with-eval-after-load 'evil
+ (evil-collection-init)))
;; evil-easymotion
-(use-package evil-easymotion :ensure t :defer t)
-(with-eval-after-load 'evil
- (evilem-default-keybindings "SPC"))
+(when (gx/maybe-require-package 'evil-easymotion)
+ (with-eval-after-load 'evil
+ (evilem-default-keybindings "SPC")))
(provide 'init-evil)
diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el
index c903636..f7e4246 100644
--- a/.emacs.d/lisp/init-git.el
+++ b/.emacs.d/lisp/init-git.el
@@ -1,4 +1,4 @@
-(use-package magit :ensure t :defer t)
+(gx/maybe-require-package 'magit)
(with-eval-after-load 'evil
(evil-define-key 'normal 'global
diff --git a/.emacs.d/lisp/init-input-method.el b/.emacs.d/lisp/init-input-method.el
index 157c632..d9390b2 100644
--- a/.emacs.d/lisp/init-input-method.el
+++ b/.emacs.d/lisp/init-input-method.el
@@ -1,10 +1,9 @@
(when *is-a-linux*
- (use-package fcitx :ensure t :defer t)
(setq fcitx-remote-command "fcitx5-remote")
- (fcitx-aggressive-setup))
+ (when (gx/maybe-require-package 'fcitx)
+ (add-hook 'after-init-hook 'fcitx-aggressive-setup)))
(when *is-a-mac*
- (use-package sis :ensure t :defer t)
(setq sis-external-ism "/usr/local/bin/macism")
(setq sis-english-source "com.apple.keylayout.ABC"
sis-other-source "com.apple.inputmethod.SCIM.ITABC")
@@ -14,7 +13,10 @@
(setq sis-do-get
(lambda () (start-process "get-input-source" nil
sis-external-ism)))
- (sis-global-respect-mode t)
- (sis-global-context-mode t))
+ (when (gx/maybe-require-package 'sis)
+ (add-hook 'after-init-hook
+ (lambda ()
+ (sis-global-respect-mode t)
+ (sis-global-context-mode t)))))
(provide 'init-input-method)
diff --git a/.emacs.d/lisp/init-ivy.el b/.emacs.d/lisp/init-ivy.el
index b1fb73a..52c92ff 100644
--- a/.emacs.d/lisp/init-ivy.el
+++ b/.emacs.d/lisp/init-ivy.el
@@ -1,6 +1,5 @@
-(use-package counsel :ensure t :defer t)
-
-(add-hook 'after-init-hook (lambda () (ivy-mode 1)))
+(when (gx/maybe-require-package 'counsel)
+ (add-hook 'after-init-hook (lambda () (ivy-mode 1))))
(with-eval-after-load 'evil
(evil-define-key 'normal ivy-mode-map
diff --git a/.emacs.d/lisp/init-lang.el b/.emacs.d/lisp/init-lang.el
index 341321a..4d56858 100644
--- a/.emacs.d/lisp/init-lang.el
+++ b/.emacs.d/lisp/init-lang.el
@@ -1,28 +1,28 @@
-(use-package ledger-mode :ensure t :defer t)
-(add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode))
+(when (gx/maybe-require-package 'ledger-mode)
+ (add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode)))
(with-eval-after-load 'ledger-mode
(setq ledger-default-date-format ledger-iso-date-format))
-(use-package go-mode :ensure t :defer t)
-(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
-(add-hook 'go-mode-hook (lambda () (setq tab-width 4)))
+(when (gx/maybe-require-package 'go-mode)
+ (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
+ (add-hook 'go-mode-hook (lambda () (setq tab-width 4))))
-(use-package go-dlv :ensure t :defer t)
+(gx/maybe-require-package 'go-dlv)
-(use-package eglot :ensure t :defer t)
-(add-hook 'go-mode-hook 'eglot-ensure)
+(when (gx/maybe-require-package 'eglot)
+ (add-hook 'go-mode-hook 'eglot-ensure))
-(use-package realgud :ensure t :defer t)
+(gx/maybe-require-package 'realgud)
-(use-package plantuml-mode :ensure t :defer t)
-(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
(setq plantuml-jar-path "~/.local/bin/plantuml.jar"
plantuml-default-exec-mode 'jar
org-plantuml-jar-path plantuml-jar-path
org-plantuml-default-exec-mode 'jar)
-(unless (file-readable-p plantuml-jar-path)
- (plantuml-download-jar))
-(with-eval-after-load 'org
- (add-to-list 'org-src-lang-modes '("plantuml" . plantuml)))
+(when (gx/maybe-require-package 'plantuml-mode)
+ (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
+ (unless (file-readable-p plantuml-jar-path)
+ (plantuml-download-jar))
+ (with-eval-after-load 'org
+ (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))))
(provide 'init-lang)
diff --git a/.emacs.d/lisp/init-markdown.el b/.emacs.d/lisp/init-markdown.el
index 94c718f..0c5ecc6 100644
--- a/.emacs.d/lisp/init-markdown.el
+++ b/.emacs.d/lisp/init-markdown.el
@@ -1,8 +1,7 @@
-(use-package markdown-mode :ensure t :defer t)
-
-(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
-(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
-(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
+(when (gx/maybe-require-package 'markdown-mode)
+ (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
+ (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
+ (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)))
(with-eval-after-load 'evil
(evil-define-key 'normal markdown-mode-map
diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el
index 56e8a2c..184626c 100644
--- a/.emacs.d/lisp/init-misc.el
+++ b/.emacs.d/lisp/init-misc.el
@@ -43,26 +43,26 @@
(show-paren-mode)
(fset 'yes-or-no-p 'y-or-n-p)))
-(use-package avy :ensure t :defer t)
-(use-package rg :ensure t :defer t)
-(use-package esup :ensure t :defer t)
+(gx/maybe-require-package 'avy)
+(gx/maybe-require-package 'rg)
+(gx/maybe-require-package 'esup)
;; appearance
-(use-package atom-one-dark-theme :ensure t :defer t)
+(gx/maybe-require-package 'atom-one-dark-theme)
(add-hook 'after-init-hook
(lambda ()
(load-theme 'atom-one-dark t)
(set-face-attribute 'default nil :height 130)))
-(use-package which-key :ensure t :defer t)
-(add-hook 'after-init-hook 'which-key-mode)
+(when (gx/maybe-require-package 'which-key)
+ (add-hook 'after-init-hook 'which-key-mode))
-(use-package undo-tree :ensure t :defer t)
-(add-hook 'after-init-hook 'global-undo-tree-mode)
+(when (gx/maybe-require-package 'undo-tree)
+ (add-hook 'after-init-hook 'global-undo-tree-mode))
-(use-package exec-path-from-shell :ensure t :defer t)
(setq exec-path-from-shell-arguments '("-l"))
-(when (memq window-system '(mac ns))
- (exec-path-from-shell-initialize))
+(when (gx/maybe-require-package 'exec-path-from-shell)
+ (when (memq window-system '(mac ns))
+ (exec-path-from-shell-initialize)))
(provide 'init-misc)
diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el
index e27a9fe..14ac3d8 100644
--- a/.emacs.d/lisp/init-org.el
+++ b/.emacs.d/lisp/init-org.el
@@ -1,4 +1,4 @@
-(use-package org-ql :ensure t :defer t)
+(gx/maybe-require-package 'org-ql)
(defvar gx/org-agenda-block--today-schedule
'(agenda "" ((org-agenda-span 1)
@@ -154,11 +154,11 @@
("pc" "C items" tags-todo "+PRIORITIES=\"C\"")))
;; evil
-(use-package evil-org :ensure t :defer t)
-(add-hook 'org-mode-hook 'evil-org-mode)
-(add-hook 'evil-org-mode-hook
- (lambda ()
- (setq evil-want-C-i-jump nil)))
+(when (gx/maybe-require-package 'evil-org)
+ (add-hook 'org-mode-hook 'evil-org-mode)
+ (add-hook 'evil-org-mode-hook
+ (lambda ()
+ (setq evil-want-C-i-jump nil))))
(with-eval-after-load 'evil
(evil-define-key 'motion org-agenda-mode-map
(kbd "q") (lambda ()
@@ -171,8 +171,8 @@
(evil-org-agenda-set-keys))
;; roam
-(use-package org-roam :ensure t :defer t)
-(add-hook 'org-mode-hook 'org-roam-db-autosync-mode)
+(when (gx/maybe-require-package 'org-roam)
+ (add-hook 'org-mode-hook 'org-roam-db-autosync-mode))
(setq org-roam-directory (file-truename "~/words"))
(setq org-roam-db-gc-threshold most-positive-fixnum)
(setq org-roam-dailies-directory "journals/")
@@ -195,21 +195,21 @@
"#+title: %<%Y>\n"))))
;; roam ui
-(use-package org-roam-ui :ensure t :defer t)
+(gx/maybe-require-package 'org-roam-ui)
(setq org-roam-ui-follow t
org-roam-ui-sync-theme t
org-roam-ui-update-on-save t
org-roam-ui-open-at-start t)
;; alert
-(use-package org-alert :ensure t :defer t)
-(autoload 'org-alert-enable "org-alert")
+(when (gx/maybe-require-package 'org-alert)
+ (autoload 'org-alert-enable "org-alert")
+ (when (daemonp)
+ (org-alert-enable)))
(when *is-a-linux*
(setq alert-default-style 'libnotify))
(when *is-a-mac*
(setq alert-default-style 'osx-notifier))
(setq org-alert-interval 60)
-(when (daemonp)
- (org-alert-enable))
(provide 'init-org)
diff --git a/.emacs.d/lisp/init-package.el b/.emacs.d/lisp/init-package.el
index 1501de4..dbd520e 100644
--- a/.emacs.d/lisp/init-package.el
+++ b/.emacs.d/lisp/init-package.el
@@ -2,17 +2,46 @@
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("mepla" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")))
-(package-initialize)
-(dolist (package '(use-package))
- (unless (package-installed-p package)
- (package-refresh-contents)
- (package-install package)))
-(require 'use-package)
-(setq use-package-always-ensure t
- use-package-always-defer t)
+(defun gx/require-package (package &optional min-version no-refresh)
+ "Install given PACKAGE, optionally requiring MIN-VERSION. If
+NO-REFRESH is non-nil, the available package lists will not be
+re-downloaded in order to locate PACKAGE.
+
+This function is copied from
+https://github.com/purcell/emacs.d/blob/master/lisp/init-elpa.el"
+ (or (package-installed-p package min-version)
+ (let* ((known (cdr (assoc package package-archive-contents)))
+ (best (car (sort known (lambda (a b)
+ (version-list-<= (package-desc-version b)
+ (package-desc-version a)))))))
+ (if (and best (version-list-<= min-version (package-desc-version best)))
+ (package-install best)
+ (if no-refresh
+ (error "No version of %s >= %S is available" package min-version)
+ (package-refresh-contents)
+ (require-package package min-version t)))
+ (package-installed-p package min-version))))
+
+(defun gx/maybe-require-package (package &optional min-version no-refresh)
+ "Try to install PACKAGE, and return non-nil if successful.
+In the event of failure, return nil and print a warning message.
+Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the
+available package lists will not be re-downloaded in order to
+locate PACKAGE.
+
+This function is copied from
+https://github.com/purcell/emacs.d/blob/master/lisp/init-elpa.el"
+ (condition-case err
+ (gx/require-package package min-version no-refresh)
+ (error
+ (message "Couldn't install optional package `%s': %S" package err)
+ nil)))
+
+(setq package-enable-at-startup nil)
+(package-initialize)
-(use-package auto-package-update)
+(gx/maybe-require-package 'auto-package-update)
(setq auto-package-update-delete-old-versions t
auto-package-update-hide-results t)
diff --git a/.emacs.d/lisp/init-projectile.el b/.emacs.d/lisp/init-projectile.el
index 6f305b6..a1bb2fe 100644
--- a/.emacs.d/lisp/init-projectile.el
+++ b/.emacs.d/lisp/init-projectile.el
@@ -1,8 +1,8 @@
-(use-package projectile :ensure t :defer t)
+(when (gx/maybe-require-package 'projectile)
+ (add-hook 'after-init-hook (lambda () (projectile-mode 1))))
(setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)
projectile-require-project-root nil)
-(add-hook 'after-init-hook (lambda () (projectile-mode 1)))
(with-eval-after-load 'evil
(evil-define-key 'normal projectile-mode-map