dev: merge branch 'master' of github.com:doomemacs
This commit is contained in:
commit
25a4356ba1
15 changed files with 172 additions and 165 deletions
6
bin/doom
6
bin/doom
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env sh
|
||||
:; # -*- mode: emacs-lisp; lexical-binding: t -*-
|
||||
:; case "$EMACS" in *term*) EMACS=emacs ;; *) EMACS="${EMACS:-emacs}" ;; esac
|
||||
:; [ "$EMACS" = emacs ] && { type emacs >/dev/null 2>&1 || err=1; }
|
||||
:; [ -n "$err" ] && { echo "Error: failed to run Emacs with command '$EMACS'"; echo; echo "Are you sure Emacs is installed and in your \$PATH?"; exit 1; } >&2
|
||||
:; [ "x$EMACS" = xemacs ] && { type emacs >/dev/null 2>&1 || err=1; }
|
||||
:; [ "x$err" = x ] || { echo "Error: failed to run Emacs with command '$EMACS'"; echo; echo "Are you sure Emacs is installed and in your \$PATH?"; exit 1; } >&2
|
||||
:; emacs="$EMACS ${DEBUG:+--debug-init} -q --no-site-file --batch"
|
||||
:; export __DOOMPID="${__DOOMPID:-$$}"
|
||||
:; export __DOOMSTEP="${__DOOMSTEP:-0}"
|
||||
|
@ -10,7 +10,7 @@
|
|||
:; export __DOOMGPIPE=${__DOOMGPIPE:-$__DOOMPIPE}
|
||||
:; export __DOOMPIPE=; [ -t 0 ] || __DOOMPIPE="${__DOOMPIPE}0"; [ -t 1 ] || __DOOMPIPE="${__DOOMPIPE}1"
|
||||
:; $emacs --load "$0" -- "$@" || exit=$?
|
||||
:; [ "${exit:-0}" -eq 254 ] && { export TMPDIR="${TMPDIR:-${TEMP:-`$emacs -Q --eval '(princ (temporary-file-directory))' 2>/dev/null`}}"; sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" && true; exit="$?"; }
|
||||
:; [ "${exit:-0}" -eq 254 ] && { export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-`$emacs -Q --eval '(princ temporary-file-directory)' 2>/dev/null`}}}"; sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" && true; exit="$?"; }
|
||||
:; exit $exit
|
||||
|
||||
;; This magical mess of a shebang is necessary for any script that relies on
|
||||
|
|
|
@ -405,7 +405,16 @@ Defaults to the profile at `doom-profile-default'."
|
|||
(letf! ((defun module-loader (group name file &optional noerror)
|
||||
(doom-module-context-with (cons group name)
|
||||
`(let ((doom-module-context ,doom-module-context))
|
||||
(doom-load ,(abbreviate-file-name (file-name-sans-extension file))))))
|
||||
(doom-load
|
||||
,(pcase (cons group name)
|
||||
('(:core . nil)
|
||||
`(file-name-concat
|
||||
doom-core-dir ,(file-name-nondirectory (file-name-sans-extension file))))
|
||||
('(:user . nil)
|
||||
`(file-name-concat
|
||||
doom-user-dir ,(file-name-nondirectory (file-name-sans-extension file))))
|
||||
(_ (abbreviate-file-name (file-name-sans-extension file))))
|
||||
t))))
|
||||
(defun module-list-loader (modules file &optional noerror)
|
||||
(cl-loop for (cat . mod) in modules
|
||||
if (doom-module-locate-path cat mod file)
|
||||
|
|
|
@ -247,7 +247,12 @@ the command instead."
|
|||
(projectile-mode +1)
|
||||
;; HACK: See bbatsov/projectile@3c92d28c056c
|
||||
(remove-hook 'buffer-list-update-hook #'projectile-track-known-projects-find-file-hook)
|
||||
(add-hook 'doom-switch-buffer-hook #'projectile-track-known-projects-find-file-hook t)))
|
||||
(add-hook 'doom-switch-buffer-hook #'projectile-track-known-projects-find-file-hook t)
|
||||
(add-hook! 'dired-after-readin-hook
|
||||
(defun doom-project-track-known-project-h ()
|
||||
(when projectile-mode
|
||||
(setq projectile-project-root-cache (make-hash-table :test 'equal))
|
||||
(projectile-track-known-projects-find-file-hook))))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -590,8 +590,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
(put 'doom-theme 'previous-themes (or last-themes 'none))
|
||||
;; DEPRECATED Hook into `enable-theme-functions' when we target 29
|
||||
(doom-run-hooks 'doom-load-theme-hook)
|
||||
(setf (alist-get 'foreground-color default-frame-alist) (face-foreground 'default nil t)
|
||||
(alist-get 'background-color default-frame-alist) (face-background 'default nil t)))))))
|
||||
(when-let* ((fg (face-foreground 'default nil t))
|
||||
(bg (face-background 'default nil t)))
|
||||
(setf (alist-get 'foreground-color default-frame-alist) fg
|
||||
(alist-get 'background-color default-frame-alist) bg)))))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -198,13 +198,15 @@ Activate this advice with:
|
|||
-q or -Q, for example:
|
||||
|
||||
emacs -Q -l init.el -f doom-run-all-startup-hooks-h"
|
||||
(setq after-init-time (current-time))
|
||||
(setq after-init-time (current-time)
|
||||
doom-init-time (current-time))
|
||||
(let ((inhibit-startup-hooks nil))
|
||||
(doom-run-hooks 'after-init-hook
|
||||
'delayed-warnings-hook
|
||||
'emacs-startup-hook
|
||||
'tty-setup-hook
|
||||
'window-setup-hook)))
|
||||
'window-setup-hook
|
||||
'doom-after-init-hook)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -49,99 +49,74 @@
|
|||
|
||||
(defun doom--sandbox-run (&optional mode)
|
||||
"TODO"
|
||||
(doom--sandbox-launch
|
||||
(unless (eq mode 'doom) '("-Q"))
|
||||
(let ((forms
|
||||
(read (format "(progn\n%s\n)"
|
||||
(buffer-substring-no-properties
|
||||
(point-min)
|
||||
(point-max))))))
|
||||
(if (eq mode 'doom)
|
||||
forms
|
||||
`(progn
|
||||
;; doom variables
|
||||
(setq init-file-debug t
|
||||
doom-emacs-dir ,doom-emacs-dir
|
||||
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
|
||||
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
|
||||
(defun doom--write-to-etc-dir-a (fn &rest args)
|
||||
(let ((user-emacs-directory doom-data-dir))
|
||||
(apply fn args)))
|
||||
(advice-add #'locate-user-emacs-file :around #'doom--write-to-etc-dir-a)
|
||||
;; emacs essential variables
|
||||
(setq before-init-time (current-time)
|
||||
after-init-time nil
|
||||
init-file-debug init-file-debug
|
||||
noninteractive nil
|
||||
process-environment (get 'process-environment 'initial-value)
|
||||
exec-path (get 'exec-path 'initial-value)
|
||||
load-path ',load-path
|
||||
user-init-file load-file-name)
|
||||
;; package.el
|
||||
(setq package--init-file-ensured t
|
||||
package-user-dir ,package-user-dir
|
||||
package-archives ',package-archives)
|
||||
;; (add-hook 'kill-emacs-hook
|
||||
;; (lambda ()
|
||||
;; (delete-file user-init-file)
|
||||
;; (when (file-equal-p user-emacs-directory ,doom-sandbox-dir)
|
||||
;; (delete-directory user-emacs-directory 'recursive))))
|
||||
(with-eval-after-load 'undo-tree
|
||||
;; HACK `undo-tree' sometimes throws errors because
|
||||
;; `buffer-undo-tree' isn't correctly initialized.
|
||||
(setq-default buffer-undo-tree (make-undo-tree)))
|
||||
;; Then launch as much about Emacs as we can
|
||||
(defun --run-- () ,forms)
|
||||
,(pcase mode
|
||||
(`doom
|
||||
'(--run--))
|
||||
(`vanilla-doom+ ; Doom core + modules - private config
|
||||
`(progn
|
||||
(load-file ,(expand-file-name "doom.el" doom-core-dir))
|
||||
(setq doom-modules-dirs (list doom-modules-dir))
|
||||
(let ((doom-init-modules-p t))
|
||||
(doom-initialize)
|
||||
(doom-initialize-core-modules))
|
||||
(setq doom-modules ',doom-modules)
|
||||
(maphash (lambda (key plist)
|
||||
(doom-module-put
|
||||
(car key) (cdr key)
|
||||
:path (doom-module-locate-path (car key) (cdr key))))
|
||||
doom-modules)
|
||||
(--run--)
|
||||
(doom-run-hooks 'doom-before-modules-init-hook)
|
||||
(maphash (doom-module-loader doom-module-init-file) doom-modules)
|
||||
(doom-run-hooks 'doom-after-modules-init-hook)
|
||||
(doom-run-hooks 'doom-before-modules-config-hook)
|
||||
(maphash (doom-module-loader doom-module-config-file) doom-modules)
|
||||
(doom-run-hooks 'doom-after-modules-config-hook)))
|
||||
(`vanilla-doom ; only Doom core
|
||||
`(progn
|
||||
(load-file ,(expand-file-name "doom.el" doom-core-dir))
|
||||
(let ((doom-init-modules-p t))
|
||||
(doom-initialize)
|
||||
(doom-initialize-core-modules))
|
||||
(--run--)))
|
||||
(`vanilla ; nothing loaded
|
||||
`(progn
|
||||
(if (boundp 'comp-deferred-compilation)
|
||||
;; REVIEW Remove me after a month
|
||||
(setq comp-deferred-compilation nil
|
||||
comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||
comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||
comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))
|
||||
(letenv! (("DOOMDIR" (if (eq mode 'vanilla-doom+)
|
||||
(expand-file-name "___does_not_exist___" temporary-file-directory)
|
||||
doom-user-dir)))
|
||||
(doom--sandbox-launch
|
||||
(unless (memq mode '(doom vanilla-doom+)) '("-Q"))
|
||||
(let ((forms
|
||||
(read (format "(progn\n%s\n)"
|
||||
(buffer-substring-no-properties
|
||||
(point-min)
|
||||
(point-max))))))
|
||||
(if (memq mode '(doom vanilla-doom+))
|
||||
forms
|
||||
`(progn
|
||||
;; doom variables
|
||||
(setq init-file-debug t
|
||||
doom-log-level 2
|
||||
doom-emacs-dir ,doom-emacs-dir
|
||||
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
|
||||
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
|
||||
(define-advice locate-user-emacs-file (:around (fn &rest args) restrict-to-data-dir)
|
||||
(let ((user-emacs-directory doom-data-dir))
|
||||
(apply fn args)))
|
||||
;; emacs essential variables
|
||||
(setq before-init-time (current-time)
|
||||
after-init-time nil
|
||||
init-file-debug init-file-debug
|
||||
noninteractive nil
|
||||
process-environment (get 'process-environment 'initial-value)
|
||||
exec-path (get 'exec-path 'initial-value)
|
||||
load-path ',load-path
|
||||
user-init-file load-file-name)
|
||||
;; package.el
|
||||
(setq package--init-file-ensured t
|
||||
package-user-dir ,package-user-dir
|
||||
package-archives ',package-archives)
|
||||
(with-eval-after-load 'doom
|
||||
(run-hooks 'doom-before-init-hook))
|
||||
(with-eval-after-load 'undo-tree
|
||||
;; HACK `undo-tree' sometimes throws errors because
|
||||
;; `buffer-undo-tree' isn't correctly initialized.
|
||||
(setq-default buffer-undo-tree (make-undo-tree)))
|
||||
;; Then launch as much about Emacs as we can
|
||||
(defun --run-- () ,forms)
|
||||
,(pcase mode
|
||||
(`vanilla-doom ; only Doom core
|
||||
`(let ((doom-user-dir "/tmp/does/not/exist"))
|
||||
(require 'doom ,(expand-file-name "doom.el" doom-core-dir))
|
||||
(let ((doom-module-init-file "__does-not-exist__"))
|
||||
(require 'doom-start))
|
||||
(setq doom-modules (make-hash-table :test 'equal))
|
||||
(--run--)))
|
||||
(`vanilla ; nothing loaded
|
||||
`(progn
|
||||
(setq native-comp-deferred-compilation nil
|
||||
native-comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||
native-comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||
native-comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path)))
|
||||
(package-initialize t)
|
||||
(--run--))))
|
||||
;; Then rerun Emacs' startup hooks to simulate a fresh Emacs session,
|
||||
;; because they've already fired.
|
||||
(fset 'doom-run-hook #',(symbol-function #'doom-run-hook))
|
||||
(fset 'doom-run-hooks #',(symbol-function #'doom-run-hooks))
|
||||
(fset 'doom-run-all-startup-hooks-h #',(symbol-function #'doom-run-all-startup-hooks-h))
|
||||
(doom-run-all-startup-hooks-h))))))
|
||||
native-comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))
|
||||
(package-initialize t)
|
||||
(--run--))))
|
||||
(with-eval-after-load 'doom
|
||||
;; Then rerun Emacs' startup hooks to simulate a fresh Emacs session,
|
||||
;; because they've already fired.
|
||||
(fset 'doom-run-hook #',(symbol-function #'doom-run-hook))
|
||||
(fset 'doom-run-hooks #',(symbol-function #'doom-run-hooks))
|
||||
(fset 'doom-run-all-startup-hooks-h #',(symbol-function #'doom-run-all-startup-hooks-h))
|
||||
;; (doom-run-all-startup-hooks-h)
|
||||
(unless (default-toplevel-value 'mode-line-format)
|
||||
(setq-default mode-line-format (get 'mode-line-format 'initial-value))))))))))
|
||||
|
||||
(fset 'doom--run-vanilla-emacs (cmd! (doom--sandbox-run 'vanilla)))
|
||||
(fset 'doom--run-vanilla-doom (cmd! (doom--sandbox-run 'vanilla-doom)))
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
|
||||
(_ (doom-log "Spell checker not found. Either install `aspell', `hunspell' or `enchant'")))
|
||||
|
||||
(ispell-check-version))
|
||||
(if (executable-find ispell-program-name)
|
||||
(ispell-check-version)
|
||||
(warn "Can't find %s in your $PATH" ispell-program-name)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -61,8 +61,7 @@
|
|||
:before #'company-begin-backend
|
||||
(company-abort)))
|
||||
|
||||
(add-hook 'after-change-major-mode-hook #'+company-init-backends-h 'append)
|
||||
|
||||
(add-hook 'company-mode-hook #'+company-init-backends-h 'append)
|
||||
|
||||
;; NOTE Fix #1335: ensure `company-emulation-alist' is the first item of
|
||||
;; `emulation-mode-map-alists', thus higher priority than keymaps of
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(dired-git-info-mode 1)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +dired/dirvish-side-or-follow (&optional arg)
|
||||
(defun +dired/dirvish-side-and-follow (&optional arg)
|
||||
"Open `dirvish-side' then find the currently focused file.
|
||||
|
||||
If dirvish is already open, remotely jump to the file in Dirvish.
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
(add-to-list 'doom-debug-variables 'mu4e-debug)
|
||||
;; mu4e now uses `display-buffer-alist' so we need to add some rules of our own
|
||||
(set-popup-rule! "^\\*mu4e-\\(main\\|headers\\)\\*" :ignore t)
|
||||
(set-popup-rule! "^\\*mu4e-log\\*" :select nil)
|
||||
|
||||
;; Treat mu4e main menu buffer as real, so it can be switched to or fallen
|
||||
;; back to when killing other buffers.
|
||||
(add-hook 'mu4e-main-mode-hook #'doom-mark-buffer-as-real-h)
|
||||
|
||||
;; Ensures backward/forward compatibility for mu4e, which is prone to breaking
|
||||
;; updates, and also cannot be pinned, because it's bundled with mu (which you
|
||||
|
|
|
@ -10,7 +10,9 @@ This module adds rudimentary [[https://www.idris-lang.org/][Idris]] support to D
|
|||
*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]]
|
||||
|
||||
** Module flags
|
||||
/This module has no flags./
|
||||
- +lsp ::
|
||||
Enable LSP support for ~idris-mode~. Requires [[doom-module::tools lsp]] and
|
||||
[[https://github.com/idris-community/idris2-lsp][idris2-lsp]].
|
||||
|
||||
** Packages
|
||||
- [[doom-package:idris-mode]]
|
||||
|
@ -25,23 +27,38 @@ This module adds rudimentary [[https://www.idris-lang.org/][Idris]] support to D
|
|||
* TODO Installation
|
||||
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
||||
|
||||
For [[doom-module:+lsp]], [[https://github.com/idris-community/idris2-lsp][idris2-lsp]] is required.
|
||||
|
||||
#+begin_quote
|
||||
/No installation steps have been documented./ [[doom-contrib-module:][Document them?]]
|
||||
/No installation steps have been documented./ [[doom-contrib-module:][Document them?]]
|
||||
#+end_quote
|
||||
|
||||
* TODO Usage
|
||||
#+begin_quote
|
||||
/This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
||||
/This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
||||
#+end_quote
|
||||
|
||||
In addition to ~idris-mode~ goodness, adds frequently used functions under the
|
||||
[[kbd:][<localleader>]] key.
|
||||
In addition to ~idris-mode~ goodness, this module adds frequently used functions
|
||||
under the [[kbd:][<localleader>]] key.
|
||||
|
||||
* TODO Configuration
|
||||
#+begin_quote
|
||||
This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
|
||||
/This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
||||
#+end_quote
|
||||
|
||||
** Support for Idris 2
|
||||
While [[doom-package:idris-mode]] was designed for v1 of the IDE-Protocol of Idris,
|
||||
it tries to maintain compatibility with v2. However, not all the features have
|
||||
been realized, so expect a little jank.
|
||||
|
||||
To get this working, simply set [[var:idris-interpreter-path]] to the path of the
|
||||
=idris2= executable. E.g.
|
||||
#+begin_src emacs-lisp
|
||||
;;; add to $DOODMIR/config.el
|
||||
(after! idris-mode
|
||||
(setq idris-interpreter-path "idris2"))
|
||||
#+end_src
|
||||
|
||||
* Troubleshooting
|
||||
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
||||
|
||||
|
@ -50,5 +67,5 @@ In addition to ~idris-mode~ goodness, adds frequently used functions under the
|
|||
|
||||
* TODO Appendix
|
||||
#+begin_quote
|
||||
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
||||
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
||||
#+end_quote
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
;;; lang/idris/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(after! idris-mode
|
||||
(add-to-list 'completion-ignored-extensions ".ibc")
|
||||
(add-hook 'idris-mode-hook #'turn-on-idris-simple-indent)
|
||||
(when (modulep! +lsp)
|
||||
(add-hook 'idris-mode-hook #'lsp! 'append))
|
||||
(set-repl-handler! 'idris-mode 'idris-pop-to-repl)
|
||||
(set-popup-rule! "^\\*idris-\\(notes\\|holes\\|info\\)" :select nil :ttl nil)
|
||||
(set-repl-handler! 'idris-mode #'idris-pop-to-repl)
|
||||
(set-lookup-handlers! 'idris-mode
|
||||
:documentation #'idris-docs-at-point)
|
||||
(map! :localleader
|
||||
|
@ -18,3 +20,9 @@
|
|||
"m" #'idris-add-missing
|
||||
"p" #'idris-proof-search
|
||||
"h" #'idris-docs-at-point))
|
||||
|
||||
|
||||
(use-package! flycheck-idris
|
||||
:when (modulep! :checkers syntax)
|
||||
:when (not (modulep! :checkers syntax +flymake))
|
||||
:after idris-mode)
|
||||
|
|
|
@ -85,7 +85,7 @@ Can be a list of backends; accepts any value `company-backends' accepts.")
|
|||
:type-definition #'lsp-find-type-definition)
|
||||
|
||||
;; HACK: See emacs-lsp/lsp-mode#3577
|
||||
(unless (modulep! :lang terraform)
|
||||
(unless (modulep! :tools terraform)
|
||||
(setq lsp-client-packages (delete 'lsp-terraform lsp-client-packages)))
|
||||
|
||||
(defadvice! +lsp--respect-user-defined-checkers-a (fn &rest args)
|
||||
|
|
|
@ -63,6 +63,23 @@ be enabled. If any function returns non-nil, the mode will not be activated."
|
|||
(defun +indent-guides-in-childframe-p ()
|
||||
(frame-parameter nil 'parent-frame)))
|
||||
|
||||
;; HACK: The way `indent-bars-display-on-blank-lines' functions, it places
|
||||
;; text properties with a display property containing a newline, which
|
||||
;; confuses `move-to-column'. This breaks `next-line' and `evil-next-line'
|
||||
;; without this advice (See jdtsmith/indent-bars#22). Advising
|
||||
;; `line-move-to-column' isn't enough for `move-to-column' calls in various
|
||||
;; Evil operators (`evil-delete', `evil-change', etc).
|
||||
(defadvice! +indent-guides--prevent-passing-newline-a (fn col &rest args)
|
||||
:around #'move-to-column
|
||||
(if-let* ((indent-bars-mode)
|
||||
(indent-bars-display-on-blank-lines)
|
||||
(nlp (line-end-position))
|
||||
(dprop (get-text-property nlp 'display))
|
||||
((seq-contains-p dprop ?\n))
|
||||
((> col (- nlp (point)))))
|
||||
(goto-char nlp)
|
||||
(apply fn col args)))
|
||||
|
||||
;; HACK: `indent-bars-mode' interactions with some packages poorly, often
|
||||
;; flooding whole sections of the buffer with indent guides. This section is
|
||||
;; dedicated to fixing interop with those packages.
|
||||
|
|
|
@ -61,6 +61,10 @@ font.")
|
|||
(t))
|
||||
"A alist of ligatures to enable in specific modes.")
|
||||
|
||||
(defvar +ligatures-in-modes nil
|
||||
"List of major modes where ligatures should be enabled.")
|
||||
(make-obsolete-variable '+ligatures-in-modes "Use `ligature-ignored-major-modes' instead" "24.10.0")
|
||||
|
||||
(defvar +ligatures-prog-mode-list nil
|
||||
"A list of ligatures to enable in all `prog-mode' buffers.")
|
||||
(make-obsolete-variable '+ligatures-prog-mode-list "Use `+ligatures-alist' instead" "24.09.0")
|
||||
|
@ -72,15 +76,6 @@ font.")
|
|||
(defvar +ligatures-extra-alist '((t))
|
||||
"A map of major modes to symbol lists (for `prettify-symbols-alist').")
|
||||
|
||||
(defvar +ligatures-in-modes
|
||||
'(not special-mode comint-mode eshell-mode term-mode vterm-mode Info-mode
|
||||
elfeed-search-mode elfeed-show-mode)
|
||||
"List of major modes where ligatures should be enabled.
|
||||
|
||||
If t, enable it everywhere (except `fundamental-mode').
|
||||
If the first element is 'not, enable it in any mode besides what is listed.
|
||||
If nil, don't enable ligatures anywhere.")
|
||||
|
||||
(defvar +ligatures-extras-in-modes t
|
||||
"List of major modes where extra ligatures should be enabled.
|
||||
|
||||
|
@ -89,24 +84,10 @@ Extra ligatures are mode-specific substituions, defined in
|
|||
controls where these are enabled.
|
||||
|
||||
If t, enable it everywhere (except `fundamental-mode').
|
||||
If the first element is 'not, enable it in any mode besides what is listed.
|
||||
If the first element is not, enable it in any mode besides what is listed.
|
||||
If nil, don't enable these extra ligatures anywhere (though it's more
|
||||
efficient to remove the `+extra' flag from the :ui ligatures module instead).")
|
||||
|
||||
(defvar +ligatures--init-font-hook nil)
|
||||
|
||||
(defun +ligatures--correct-symbol-bounds (ligature-alist)
|
||||
"Prepend non-breaking spaces to a ligature.
|
||||
|
||||
This way `compose-region' (called by `prettify-symbols-mode') will use the
|
||||
correct width of the symbols instead of the width measured by `char-width'."
|
||||
(let ((len (length (car ligature-alist)))
|
||||
(acc (list (cdr ligature-alist))))
|
||||
(while (> len 1)
|
||||
(setq acc (cons #X00a0 (cons '(Br . Bl) acc))
|
||||
len (1- len)))
|
||||
(cons (car ligature-alist) acc)))
|
||||
|
||||
(defun +ligatures--enable-p (modes)
|
||||
"Return t if ligatures should be enabled in this buffer depending on MODES."
|
||||
(unless (eq major-mode 'fundamental-mode)
|
||||
|
@ -115,38 +96,24 @@ correct width of the symbols instead of the width measured by `char-width'."
|
|||
(not (apply #'derived-mode-p (cdr modes)))
|
||||
(apply #'derived-mode-p modes)))))
|
||||
|
||||
(defun +ligatures-init-buffer-h ()
|
||||
"Set up ligatures for the current buffer.
|
||||
(defun +ligatures-init-extra-symbols-h ()
|
||||
"Set up `prettify-symbols-mode' for the current buffer.
|
||||
|
||||
Extra ligatures are mode-specific substituions, defined in
|
||||
`+ligatures-extra-symbols', assigned with `set-ligatures!', and made possible
|
||||
with `prettify-symbols-mode'. This variable controls where these are enabled.
|
||||
See `+ligatures-extras-in-modes' to control what major modes this function can
|
||||
and cannot run in."
|
||||
(when after-init-time
|
||||
(let ((in-mode-p
|
||||
(+ligatures--enable-p +ligatures-in-modes))
|
||||
(in-mode-extras-p
|
||||
(and (modulep! +extra)
|
||||
(+ligatures--enable-p +ligatures-extras-in-modes))))
|
||||
(when in-mode-p
|
||||
;; If ligature-mode has been installed, there's no
|
||||
;; need to do anything, we activate global-ligature-mode
|
||||
;; later and handle all settings from `set-ligatures!' later.
|
||||
(unless (fboundp #'ligature-mode-turn-on)
|
||||
(run-hooks '+ligatures--init-font-hook)
|
||||
(setq +ligatures--init-font-hook nil)))
|
||||
(when in-mode-extras-p
|
||||
(prependq! prettify-symbols-alist
|
||||
(or (alist-get major-mode +ligatures-extra-alist)
|
||||
(cl-loop for (mode . symbols) in +ligatures-extra-alist
|
||||
if (derived-mode-p mode)
|
||||
return symbols))))
|
||||
(when (and (or in-mode-p in-mode-extras-p)
|
||||
prettify-symbols-alist)
|
||||
(when prettify-symbols-mode
|
||||
(prettify-symbols-mode -1))
|
||||
(prettify-symbols-mode +1)))))
|
||||
(when (and after-init-time (+ligatures--enable-p +ligatures-extras-in-modes))
|
||||
(prependq! prettify-symbols-alist
|
||||
(or (alist-get major-mode +ligatures-extra-alist)
|
||||
(cl-loop for (mode . symbols) in +ligatures-extra-alist
|
||||
if (derived-mode-p mode)
|
||||
return symbols)))
|
||||
(when prettify-symbols-alist
|
||||
(when prettify-symbols-mode
|
||||
(prettify-symbols-mode -1))
|
||||
(prettify-symbols-mode +1))))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -156,9 +123,8 @@ and cannot run in."
|
|||
;; When you get to the right edge, it goes back to how it normally prints
|
||||
(setq prettify-symbols-unprettify-at-point 'right-edge)
|
||||
|
||||
(add-hook! 'doom-init-ui-hook :append
|
||||
(defun +ligatures-init-h ()
|
||||
(add-hook 'after-change-major-mode-hook #'+ligatures-init-buffer-h)))
|
||||
(when (modulep! +extra)
|
||||
(add-hook 'after-change-major-mode-hook #'+ligatures-init-extra-symbols-h))
|
||||
|
||||
(cond
|
||||
;; The emacs-mac build of Emacs appears to have built-in support for ligatures,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue