Config: add jinx spell check, org-download, and keybinding updates
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,7 +1,5 @@
|
||||
# 忽略所有文件
|
||||
*
|
||||
|
||||
# 保留特定配置文件
|
||||
!init.el
|
||||
!early-init.el
|
||||
!custom.el
|
||||
@@ -9,5 +7,4 @@
|
||||
!lisp/**/
|
||||
!lisp/**/*.el
|
||||
|
||||
# 保留 .gitignore 本身
|
||||
!.gitignore
|
||||
|
||||
80
lisp/init-jinx.el
Normal file
80
lisp/init-jinx.el
Normal file
@@ -0,0 +1,80 @@
|
||||
;;; init-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)))
|
||||
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 'init-jinx)
|
||||
;;; init-jinx.el ends here
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
;; 使用F2打开init.el
|
||||
(defun open-init-file()
|
||||
"Open user's init.el file in ~/.emacs.d
|
||||
这是一段文档"
|
||||
"Open user's init.el file in ~/.emacs.d"
|
||||
(interactive)
|
||||
(find-file "~/.emacs.d/init.el"))
|
||||
|
||||
@@ -54,11 +53,12 @@
|
||||
(global-set-key (kbd "M-l") 'downcase-dwim)
|
||||
|
||||
;; jinx相关
|
||||
(with-eval-after-load 'jinx
|
||||
(defun my/jinx-smart-toggle ()
|
||||
(defun my/jinx-smart-toggle ()
|
||||
"Toggle jinx-mode smartly.
|
||||
Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise toggle global-jinx-mode."
|
||||
(interactive)
|
||||
(unless (featurep 'jinx)
|
||||
(require 'jinx))
|
||||
(let ((local-on (bound-and-true-p jinx-mode))
|
||||
(global-on (bound-and-true-p global-jinx-mode)))
|
||||
(cond
|
||||
@@ -72,9 +72,11 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
(global-jinx-mode -1))
|
||||
(progn
|
||||
(message "enable global-jinx-mode")
|
||||
(global-jinx-mode 1))))))))
|
||||
(global-jinx-mode 1)))))))
|
||||
|
||||
(global-set-key (kbd "C-c j j") 'my/jinx-smart-toggle)
|
||||
(with-eval-after-load 'init-jinx
|
||||
(global-set-key (kbd "C-c f j") 'consult-jinx))
|
||||
|
||||
;; pair编辑
|
||||
(global-set-key (kbd "C-c p d") 'delete-pair)
|
||||
@@ -146,7 +148,7 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
;; 中键使用embark打开定义
|
||||
(global-set-key (kbd "<mouse-2>") 'xref-find-definitions)
|
||||
|
||||
;; 使用快速切换到scrath buffer
|
||||
;; 使用快速切换到scratch buffer
|
||||
(if *is-mac*
|
||||
(global-set-key (kbd "C-C <f12>") 'scratch-buffer)
|
||||
(global-set-key (kbd "C-c <delete>") 'scratch-buffer))
|
||||
@@ -194,6 +196,7 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
(global-set-key (kbd "C-c y") 'consult-yank-from-kill-ring) ;; 从kill ring中粘贴
|
||||
(global-set-key (kbd "C-x r b") 'consult-bookmark) ;; 书签菜单,embark中有更多操作
|
||||
(define-key minibuffer-local-map (kbd "C-c C-e") 'embark-export) ;; 把minibuffer结果在一个菜单中显示
|
||||
(global-set-key (kbd "C-c f e") 'consult-flycheck) ;; flycheck菜单
|
||||
(if *is-mac*
|
||||
(progn
|
||||
(global-set-key (kbd "C-c f l") 'consult-fd-global)
|
||||
@@ -201,6 +204,12 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
(global-set-key (kbd "C-c f l") 'consult-locate)
|
||||
(global-set-key (kbd "C-c f m") 'consult-fd-global))
|
||||
|
||||
;; flycheck
|
||||
(global-set-key (kbd "C-c f c") 'global-flycheck-mode)
|
||||
(with-eval-after-load 'flycheck
|
||||
(define-key flycheck-mode-map (kbd "M-{") 'flycheck-previous-error)
|
||||
(define-key flycheck-mode-map (kbd "M-}") 'flycheck-next-error))
|
||||
|
||||
;; avy
|
||||
(global-set-key (kbd "C-M-;") 'avy-goto-char)
|
||||
(global-set-key (kbd "C-M-'") 'ace-pinyin-jump-char)
|
||||
|
||||
@@ -138,7 +138,16 @@
|
||||
(let ((start (car range))
|
||||
(end (cdr range)))
|
||||
(dotimes (i (- end start))
|
||||
(modify-syntax-entry (+ start i) "_" jinx--syntax-table))))))
|
||||
(modify-syntax-entry (+ start i) "_" jinx--syntax-table)))))
|
||||
(require 'init-jinx))
|
||||
|
||||
;; flycheck
|
||||
(use-package flycheck
|
||||
:init
|
||||
(add-hook 'after-init-hook #'global-flycheck-mode))
|
||||
|
||||
;; consult-flycheck
|
||||
(use-package consult-flycheck)
|
||||
|
||||
;; 安装emms
|
||||
(use-package emms
|
||||
|
||||
Reference in New Issue
Block a user