Remove unused packages (EMMS, jinx, god-mode), simplify terminal setup with ido instead of vertico/orderless, and reorganize keybindings. Add new packages (debase, discomfort, git-timemachine, edit-indirect) and improve EXWM, dired, and theme configurations. Move restart-fcitx5 to kbd-func and update Linux PATH for Guix.
82 lines
3.0 KiB
EmacsLisp
82 lines
3.0 KiB
EmacsLisp
;;; consult-jinx.el --- Jinx configuration with consult-jinx -*- lexical-binding: t -*-
|
|
|
|
;;; Commentary:
|
|
;; Jinx spell-checker configuration with consult-jinx menu
|
|
|
|
;;; Code:
|
|
|
|
(require 'jinx)
|
|
(require 'consult)
|
|
|
|
(defvar consult-jinx--narrow
|
|
'((?m . "Misspelled"))
|
|
"Narrow keys for consult-jinx.")
|
|
|
|
(defface consult-jinx-line-number-prefix
|
|
'((t :inherit line-number))
|
|
"Face used for line numbers of misspellings from current line onwards.")
|
|
|
|
(defface consult-jinx-line-number-wrapped
|
|
'((t :inherit consult-jinx-line-number-prefix :inherit warning :weight normal))
|
|
"Face used for line numbers of misspellings before current line.")
|
|
|
|
(defun consult-jinx--candidates ()
|
|
"Return jinx misspellings as candidates list for consult."
|
|
(consult--forbid-minibuffer)
|
|
(unless jinx-mode
|
|
(user-error "Jinx mode not enabled in current buffer"))
|
|
(let* ((curr-line (line-number-at-pos (point)))
|
|
(overlays (jinx--force-overlays (point-min) (point-max) :check t))
|
|
default-cand candidates)
|
|
(unless overlays
|
|
(user-error "No misspellings"))
|
|
(let* ((line-width (length (number-to-string (line-number-at-pos (point-max)))))
|
|
(word-width (apply #'max (mapcar
|
|
(lambda (ov)
|
|
(- (overlay-end ov) (overlay-start ov)))
|
|
overlays))))
|
|
(dolist (ov overlays)
|
|
(let* ((start (overlay-start ov))
|
|
(end (overlay-end ov))
|
|
(line (line-number-at-pos start))
|
|
(word (buffer-substring-no-properties start end))
|
|
(line-str (propertize (format (format "%%%dd" line-width) line)
|
|
'face (if (< line curr-line)
|
|
'consult-jinx-line-number-wrapped
|
|
'consult-jinx-line-number-prefix))))
|
|
(push (propertize
|
|
(format (format "%%s %%-%ds" word-width)
|
|
line-str
|
|
(propertize word 'face 'error))
|
|
'consult--candidate (list (set-marker (make-marker) start) (cons 0 (- end start)))
|
|
'consult--type ?m)
|
|
candidates)
|
|
(when (and (not default-cand) (>= line curr-line))
|
|
(setq default-cand candidates)))))
|
|
(nreverse
|
|
(if default-cand
|
|
(let ((before (cdr default-cand)))
|
|
(setcdr default-cand nil)
|
|
(nconc before candidates))
|
|
candidates))))
|
|
|
|
;;;###autoload
|
|
(defun consult-jinx ()
|
|
"Jump to a jinx misspelled word."
|
|
(interactive)
|
|
(consult--read
|
|
(consult--with-increased-gc (consult-jinx--candidates))
|
|
:prompt "Jinx misspelling: "
|
|
:category 'consult-jinx-misspelling
|
|
:history t
|
|
:require-match t
|
|
:sort nil
|
|
:narrow (consult--type-narrow consult-jinx--narrow)
|
|
:group (consult--type-group consult-jinx--narrow)
|
|
:lookup #'consult--lookup-candidate
|
|
:state (consult--jump-state)))
|
|
|
|
(provide 'consult-jinx)
|
|
|
|
;;; consult-jinx.el ends here
|