From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Check and install/update necessary packages when calling them in emacs.
Date: Tue, 30 Mar 2021 20:59:26 +0800 [thread overview]
Message-ID: <CAGP6POKQH5wi1++9s+ZV02QYJ=Vp4MD5WF2ncu64yCZ5PA5DhA@mail.gmail.com> (raw)
Currently, I use the following settings for my `.emacs.d/init.el`:
;;; begin
$ egrep -v '^[ ]*;' .emacs.d/init.el|sed -re '/^$/d'
(setq auth-sources
'((:source "~/.emacs.d/epg/news.rusnet.ru.gpg")))
(setq url-user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88
Safari/537.36")
(when (version<= "26.0.50" emacs-version )
(global-display-line-numbers-mode))
(require 'package)
(setq package-archives '(("gnu" .
"https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("melpa" .
"https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
("org" .
"https://mirrors.tuna.tsinghua.edu.cn/elpa/org/")))
(package-initialize)
(eval-when-compile
(add-to-list 'load-path "~/Public/repo/github.com/jwiegley/use-package.git")
(require 'use-package))
(require 'bind-key) ;; if you use any :bind variant
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(use-package auto-package-update
:config
(setq auto-package-update-delete-old-versions t)
(setq auto-package-update-hide-results t)
(auto-package-update-maybe))
(defun my-package-install-refresh-contents (&rest args)
(package-refresh-contents)
(advice-remove 'package-install 'my-package-install-refresh-contents))
(advice-add 'package-install :before 'my-package-install-refresh-contents)
(defvar prelude-packages
'(
dash flycheck posframe
s ein
smartparens
valign
)
"A list of packages to ensure are installed at launch.")
(defun prelude-packages-installed-p ()
"Check if all packages in `prelude-packages' are installed."
(cl-every #'package-installed-p prelude-packages))
(defun prelude-require-package (package)
"Install PACKAGE unless already installed."
(unless (memq package prelude-packages)
(add-to-list 'prelude-packages package))
(unless (package-installed-p package)
(package-install package)))
(defun prelude-require-packages (packages)
"Ensure PACKAGES are installed.
Missing packages are installed automatically."
(mapc #'prelude-require-package packages))
(defun prelude-install-packages ()
"Install all packages listed in `prelude-packages'."
(unless (prelude-packages-installed-p)
(message "%s" "Emacs Prelude is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
(prelude-require-packages prelude-packages)))
(prelude-install-packages)
(use-package smartparens-config
:ensure smartparens
:config (progn (show-smartparens-global-mode t))
:config (progn (smartparens-global-strict-mode t)))
(setq sp-navigate-close-if-unbalanced t)
(add-to-list 'load-path "~/Public/repo/code.orgmode.org/bzg/org-mode.git/lisp")
(add-to-list 'load-path
"~/Public/repo/code.orgmode.org/bzg/org-mode.git/contrib/lisp" t)
(require 'org)
(add-hook 'org-mode-hook #'valign-mode)
(add-hook 'text-mode-hook #'auto-fill-mode)
(setq-default fill-column 80)
(add-hook 'prog-mode-hook #'auto-fill-mode)
(use-package rime
:bind
(:map rime-mode-map
("C-`" . 'rime-send-keybinding))
:custom
(default-input-method "rime")
(rime-share-data-dir "~/.local/share/fcitx5/rime")
(rime-show-candidate 'posframe))
(custom-set-variables
'(package-selected-packages '(dash rime use-package)))
(custom-set-faces
'(default ((t (:family "DejaVuSansMono Nerd Font Mono" :foundry
"PfEd" :slant normal :weight normal :height 151 :width normal)))))
;;; end
But I want to have some functions similar to lazy loading, that is,
the corresponding installation/update process will be activated only
when the corresponding software package is actually called in Emacs.
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
reply other threads:[~2021-03-30 12:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGP6POKQH5wi1++9s+ZV02QYJ=Vp4MD5WF2ncu64yCZ5PA5DhA@mail.gmail.com' \
--to=hongyi.zhao@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.