Group with-eval-after-load emacs instead of unless noninteractive

This commit is contained in:
Gerard Vermeulen 2022-02-27 16:58:24 +01:00
parent 781427c182
commit 93489d05a9

View File

@ -167,6 +167,8 @@ the ~custom-file~ as [[info:emacs#Saving Customizations][saving customizations (
'(epg-pinentry-mode 'loopback)
'(global-hl-line-mode t)
'(global-hl-line-sticky-flag t)
'(history-delete-duplicates t)
'(history-length 500)
'(indent-tabs-mode nil)
'(inhibit-startup-buffer-menu t)
'(inhibit-startup-screen t)
@ -286,6 +288,7 @@ background.
#+caption: Improve the visibility of faces in =faces.el=.
#+name: lst:tweak-faces-faces-after
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun tweak-region-face-background-color ()
(when (featurep 'gtk)
(set-face-attribute
@ -294,17 +297,18 @@ background.
'(("white" . "LightGoldenrod2")
("black" . "blue3")))))))
(tweak-region-face-background-color)
(tweak-region-face-background-color))
#+end_src
#+caption[Improve the visibility of faces in =org-faces.el=]:
#+caption: Improve the visibility of faces in =org-faces.el=.
#+name: lst:tweak-org-faces-before
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
;; Shadow the definition in org-faces.el:
(defface org-block
;; https://emacs.stackexchange.com/questions/9600/
;; how-can-i-override-a-pre-defined-face-for-light-and-dark-backgrounds
;; https://emacs.stackexchange.com/a/9604 answers:
;; How to override a defined face for light and dark backgrounds?
`((((background dark))
:inherit (fixed-pitch)
,@(and (>= emacs-major-version 27) '(:extend t))
@ -321,13 +325,14 @@ background.
When `org-fontify-quote-and-verse-blocks' is not nil, text inside
verse and quote blocks are fontified using the `org-verse' and
`org-quote' faces, which inherit from `org-block'.")
`org-quote' faces, which inherit from `org-block'."))
#+end_src
#+caption[Improve the visibility of faces in =sh-script.el=]:
#+caption: Improve the visibility of faces in =sh-script.el=.
#+name: lst:tweak-sh-script-faces-before
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
;; Shadow the definition in sh-script.el:
(defface sh-heredoc
'((((class color) (background dark))
@ -336,7 +341,7 @@ background.
(:foreground "magenta"))
(t
(:weight bold)))
"My face to show a here-document.")
"My face to show a here-document."))
#+end_src
** [[info:emacs#Dired][Dired: directory editor as file manager (info)]]
@ -559,6 +564,7 @@ users from shooting themselves in the feet. Listing
#+caption: Configure the =disabled-command-function=.
#+name: lst:configure-disabled-command-function
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(setq disabled-command-function
(defun my-enable-this-command (&rest _args)
"Called when a disabled command is executed.
@ -567,7 +573,7 @@ users from shooting themselves in the feet. Listing
(message "You typed %s. %s was disabled until now."
(key-description (this-command-keys)) this-command)
(sit-for 0)
(call-interactively this-command)))
(call-interactively this-command))))
#+end_src
* [[info:emacs#Emacs Server][Using Emacs as a server (info)]]
@ -703,23 +709,21 @@ file.
#+caption: Enable =savehist-mode= and =vertico-mode=.
#+name: lst:enable-vertico-mode
#+begin_src emacs-lisp
(unless noninteractive
(when (fboundp 'savehist-mode)
(savehist-mode +1)
(custom-set-variables
'(history-delete-duplicates t)
'(history-length 500)
'(savehist-additional-variables
'(eww-history
kill-ring
regexp-search-string
search-ring
search-string)))
(savehist-mode +1)
search-string))))
(when (fboundp 'vertico-mode)
(vertico-mode +1))
(with-eval-after-load 'vertico
(define-key vertico-map (kbd "RET") #'vertico-directory-enter)
(define-key vertico-map (kbd "DEL") #'vertico-directory-delete-char)
(define-key vertico-map (kbd "M-DEL") #'vertico-directory-delete-word)))
(define-key vertico-map (kbd "M-DEL") #'vertico-directory-delete-word))
#+end_src
#+attr_latex: :booktabs yes :float table
@ -760,7 +764,6 @@ Listing [[lst:configure-orderless]] enables =orderless=.
#+caption: Configure =orderless=.
#+name: lst:configure-orderless
#+begin_src emacs-lisp
(unless noninteractive
(when (fboundp 'orderless-filter)
(custom-set-variables
;; https://github.com/purcell/emacs.d/issues/778
@ -770,7 +773,7 @@ Listing [[lst:configure-orderless]] enables =orderless=.
'((file (styles partial-completion)))))
(add-hook 'minibuffer-setup-hook
(defun my-on-minibuffer-setup-hook()
(setq-default completion-styles '(substring orderless))))))
(setq-default completion-styles '(substring orderless)))))
#+end_src
** [[info:embark#Top][Embark (info)]]
@ -787,12 +790,11 @@ minibuffer help after a prefix key.
#+caption: Configure =embark=.
#+name: lst:configure-embark
#+begin_src emacs-lisp
(unless noninteractive
(when (cl-every #'fboundp '(embark-act embark-bindings embark-dwim))
(global-set-key (kbd "C-,") #'embark-act)
(global-set-key (kbd "C-:") #'embark-dwim)
(global-set-key (kbd "C-h B") #'embark-bindings)
(setq prefix-help-command #'embark-prefix-help-command)))
(setq prefix-help-command #'embark-prefix-help-command))
#+end_src
** [[info:marginalia#Top][Marginalia (info)]]
@ -806,9 +808,8 @@ Listing [[lst:enable-marginalia-mode]] enables =marginalia-mode=.
#+caption: Enable =marginalia-mode=.
#+name: lst:enable-marginalia-mode
#+begin_src emacs-lisp
(unless noninteractive
(when (fboundp 'marginalia-mode)
(marginalia-mode +1)))
(marginalia-mode +1))
#+end_src
** [[info:consult#Top][Consult (info)]]
@ -870,7 +871,6 @@ Listing [[lst:configure-consult]] configures =consult=.
#+caption: Configure =consult=.
#+name: lst:configure-consult
#+begin_src emacs-lisp
(unless noninteractive
(when (fboundp 'consult-apropos)
(custom-set-variables
'(consult-project-root-function #'vc-root-dir))
@ -904,7 +904,7 @@ Listing [[lst:configure-consult]] configures =consult=.
(global-set-key (kbd "<help> a") #'consult-apropos)
;; Tweak functions
(advice-add 'completing-read-multiple
:override #'consult-completing-read-multiple)))
:override #'consult-completing-read-multiple))
#+end_src
** [[https://company-mode.github.io/][Company: a modular complete anything framework for Emacs]]
@ -918,7 +918,6 @@ Listing [[lst:configure-company]] configures =company=.
#+caption: Configure =company=.
#+name: lst:configure-company
#+begin_src emacs-lisp
(unless noninteractive
(when (fboundp 'company-mode)
(custom-set-variables
;; https://github.com/purcell/emacs.d/issues/778
@ -931,7 +930,7 @@ Listing [[lst:configure-company]] configures =company=.
python-mode-hook
ielm-mode-hook
sly-mrepl-mode-hook))
(add-hook hook #'company-mode))))
(add-hook hook #'company-mode)))
#+end_src
** [[https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00802.html][Minibuffer history completion]]
@ -947,6 +946,7 @@ previous input in the minibuffer. Listing
#+caption: Enable =minibuffer-history-completion=.
#+name: lst:enable-minibuffer-history-completion
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun minibuffer-setup-history-completions ()
(unless (or minibuffer-completion-table minibuffer-completion-predicate)
(setq-local minibuffer-completion-table
@ -970,7 +970,7 @@ previous input in the minibuffer. Listing
(symbol-value minibuffer-history-variable)
nil))
(define-key minibuffer-local-map (kbd "C-<tab>") #'minibuffer-complete-history)
(define-key minibuffer-local-map (kbd "C-<tab>") #'minibuffer-complete-history))
#+end_src
* [[info:emacs#Search][Search and replace (info)]]
@ -984,8 +984,8 @@ previous input in the minibuffer. Listing
:END:
[[https://github.com/Wilfred/deadgrep#readme][Deadgrep]] uses [[https://github.com/BurntSushi/ripgrep#readme][ripgrep]] for superfast text searching in the default directory or
the current [[https://en.wikipedia.org/wiki/Version_control][VCS]] directory tree. Listing [[lst:configure-deadgrep]] binds the
=deadgrep= function to {{{kbd(M-s d)}}}.
the current [[https://en.wikipedia.org/wiki/Version_control][VCS]] directory tree. Listing [[lst:configure-deadgrep]] binds =deadgrep=
to {{{kbd(M-s d)}}} and =deadgrep-edit-mode= to {{{kbd(C-c C-w)}}}.
#+caption[Configure =deadgrep=]:
#+caption: Configure =deadgrep=.
@ -993,6 +993,8 @@ the current [[https://en.wikipedia.org/wiki/Version_control][VCS]] directory tre
#+begin_src emacs-lisp
(when (autoload 'deadgrep "deadgrep" nil t)
(define-key search-map (kbd "d") #'deadgrep))
(with-eval-after-load 'deadgrep
(define-key deadgrep-mode-map (kbd "C-c C-w") #'deadgrep-edit-mode))
#+end_src
* Reading
@ -1042,17 +1044,17 @@ rebuild the =epdfinfo= executable that serves the [[https://en.wikipedia.org/wik
#+caption: Enable =pdf-tools=.
#+name: lst:enable-pdf-tools
#+begin_src emacs-lisp
(when (fboundp 'pdf-loader-install)
;; `pdf-loader-install' is the lazy equivalent of `pdf-tools-install':
;; see the README file.
(when (fboundp 'pdf-loader-install)
(pdf-loader-install))
(pdf-loader-install)
(with-eval-after-load 'pdf-view
(custom-set-variables
'(pdf-view-display-size 'fit-page))
(when (fboundp 'pdf-view-restore-mode)
(add-hook 'pdf-view-mode-hook #'pdf-view-restore-mode)))
(add-hook 'pdf-view-mode-hook #'pdf-view-restore-mode))))
#+end_src
* Writing
@ -1206,15 +1208,14 @@ advising to override ~TeX-brace-count-line~ with ~my-TeX-brace-count-line~.
#+caption: Activate =Org=.
#+name: lst:activate-org
#+begin_src emacs-lisp
;; Inspect:
;; function with "C-h f"
;; symbols with "C-h o"
;; variables with "C-h v"
(when (cl-every #'fboundp '(org-agenda
org-capture
org-store-link
org-store-link-global))
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c C-l") #'org-insert-link-global)
(global-set-key (kbd "C-c C-l") #'org-insert-link-global))
#+end_src
*** Org customization
@ -1517,8 +1518,10 @@ compatibility with [[https://github.com/jkitchin/org-ref][org-ref]]. Listing [[
from the definition of =docview-org-link= and =doi-org-link= types to define an
=pdfview-org-link= type for use with [[https://github.com/vedang/pdf-tools][pdf-tools]]. Finally, listing
[[lst:emacs-lisp-setup-patch-ol-info]] patches the function =org-info-export= and
the constant ~org-info-other-documents~, to export the =info-org-link= types in
this document to =html= and LaTeX correctly.
listing [[lst:emacs-lisp-setup-buffer-local-ol-info]] sets the constants
~org-info-emacs-documents~ and ~org-info-other-documents~ as buffer local
variables in order to export the =info-org-link= types in this document to
=html= and LaTeX correctly.
#+caption[Define =org-link= types for backwards compatibility with =org-ref=]:
#+caption: Define =org-link= types for backwards compatibility with =org-ref=.
@ -1632,8 +1635,14 @@ this document to =html= and LaTeX correctly.
(`texinfo
(let ((title (or desc "")))
(format "@ref{%s,%s,,%s,}" node title manual)))
(_ nil))))
(_ nil)))))
#+end_src
#+caption[Patch buffer local =ol-info=]:
#+caption: Patch buffer local =ol-info=.
#+name: lst:emacs-lisp-setup-buffer-local-ol-info
#+begin_src emacs-lisp :exports code :silent :tangle no
(with-eval-after-load 'ol-info
(make-variable-buffer-local 'org-info-emacs-documents)
(setq org-info-emacs-documents (delete "org" org-info-emacs-documents))
(make-variable-buffer-local 'org-info-other-documents)
@ -1645,10 +1654,8 @@ this document to =html= and LaTeX correctly.
("orderless" . "https://github.com/oantolin/orderless")
("sly" . "https://joaotavora.github.io/sly/")
("vertico" . "https://github.com/minad/vertico"))
org-info-other-documents
:test #'equal)))
org-info-other-documents :test #'equal)))
#+end_src
*** [[https://tecosaur.github.io/emacs-config/#translate-capital-keywords][Translate capital keywords (old) to lower case (new)]]
:PROPERTIES:
:CUSTOM_ID: sec:convert-upper-to-lower-case-keywords
@ -2087,7 +2094,7 @@ exporting from Org-mode to LaTeX.
#+caption: Define buffer local =-ox-latex= variables.
#+header: :var title-page=lst/title-page
#+name: lst:ox-latex-emacs-lisp-setup
#+begin_src emacs-lisp :results silent
#+begin_src emacs-lisp :results silent :tangle no
(when (require 'ox-latex nil 'noerror)
;; https://emacs.stackexchange.com/questions/47347/
;; customizing-org-latex-title-command-to-edit-title-page
@ -2879,7 +2886,7 @@ library. It is a requirement of several packages in this Emacs setup ([[https:/
#+caption: Enable =iedit=.
#+name: lst:enable-iedit
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
(require 'iedit nil 'noerror))
#+end_src
@ -2892,12 +2899,11 @@ library. It is a requirement of several packages in this Emacs setup ([[https:/
#+caption: Configure =ws-butler=.
#+name: lst:configure-ws-butler
#+begin_src emacs-lisp
(unless noninteractive
(when (require 'ws-butler nil 'noerror)
(custom-set-variables
'(ws-butler-keep-whitespace-before-point nil))
(add-hook 'prog-mode-hook #'ws-butler-mode)
(add-hook 'text-mode-hook #'ws-butler-mode)))
(add-hook 'text-mode-hook #'ws-butler-mode))
#+end_src
** [[https://countvajhula.com/2021/09/25/the-animated-guide-to-symex/][Structural editing]]
@ -2944,7 +2950,7 @@ contrary to for instance [[https://github.com/Fanael/rainbow-delimiters#readme][
#+caption: Configure =smartparens=.
#+name: lst:configure-smartparens
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
;; To disables pairing of the quote character for lisp modes,
;; require smartparens-config instead of smartparens.
(when (require 'smartparens-config nil 'noerror)
@ -3098,7 +3104,7 @@ of the default face on all frames.
#+caption: Configure =face-attributes=.
#+name: lst:configure-face-attributes
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
;; Set face attributes.
(cond
((eq system-type 'darwin)
@ -3119,7 +3125,7 @@ of the default face on all frames.
#+caption: Implement =my-set-default-face-height=.
#+name: lst:my-set-default-face-height
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
(defun my-set-default-face-height ()
"Set the default face height in all current and future frames.
@ -3139,7 +3145,7 @@ of the default face on all frames.
#+caption: Implement =my-invert-default-face=.
#+name: lst:my-invert-default-face
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
(defun my-invert-default-face ()
"Invert the default face."
(interactive)
@ -3182,7 +3188,7 @@ and names in buffers for debugging.
#+caption: Implement =my-pulse-one-line=.
#+name: lst:my-pulse-one-line
#+begin_src emacs-lisp
(unless noninteractive
(with-eval-after-load 'emacs
;; https://karthinks.com/software/batteries-included-with-emacs/
;; https://www.reddit.com/r/emacs/comments/jwhr6g/batteries_included_with_emacs/
(defun my-pulse-one-line (&rest _)