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
|
!init.el
|
||||||
!early-init.el
|
!early-init.el
|
||||||
!custom.el
|
!custom.el
|
||||||
@@ -9,5 +7,4 @@
|
|||||||
!lisp/**/
|
!lisp/**/
|
||||||
!lisp/**/*.el
|
!lisp/**/*.el
|
||||||
|
|
||||||
# 保留 .gitignore 本身
|
|
||||||
!.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
|
;; 使用F2打开init.el
|
||||||
(defun open-init-file()
|
(defun open-init-file()
|
||||||
"Open user's init.el file in ~/.emacs.d
|
"Open user's init.el file in ~/.emacs.d"
|
||||||
这是一段文档"
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file "~/.emacs.d/init.el"))
|
(find-file "~/.emacs.d/init.el"))
|
||||||
|
|
||||||
@@ -54,27 +53,30 @@
|
|||||||
(global-set-key (kbd "M-l") 'downcase-dwim)
|
(global-set-key (kbd "M-l") 'downcase-dwim)
|
||||||
|
|
||||||
;; jinx相关
|
;; jinx相关
|
||||||
(with-eval-after-load 'jinx
|
(defun my/jinx-smart-toggle ()
|
||||||
(defun my/jinx-smart-toggle ()
|
"Toggle jinx-mode smartly.
|
||||||
"Toggle jinx-mode smartly.
|
|
||||||
Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise toggle global-jinx-mode."
|
Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise toggle global-jinx-mode."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((local-on (bound-and-true-p jinx-mode))
|
(unless (featurep 'jinx)
|
||||||
(global-on (bound-and-true-p global-jinx-mode)))
|
(require 'jinx))
|
||||||
(cond
|
(let ((local-on (bound-and-true-p jinx-mode))
|
||||||
((and local-on (not global-on))
|
(global-on (bound-and-true-p global-jinx-mode)))
|
||||||
(message "disable jinx-mode in current buffer")
|
(cond
|
||||||
(jinx-mode -1))
|
((and local-on (not global-on))
|
||||||
(t
|
(message "disable jinx-mode in current buffer")
|
||||||
(if global-on
|
(jinx-mode -1))
|
||||||
(progn
|
(t
|
||||||
(message "disable global-jinx-mode")
|
(if global-on
|
||||||
(global-jinx-mode -1))
|
|
||||||
(progn
|
(progn
|
||||||
(message "enable global-jinx-mode")
|
(message "disable global-jinx-mode")
|
||||||
(global-jinx-mode 1))))))))
|
(global-jinx-mode -1))
|
||||||
|
(progn
|
||||||
|
(message "enable global-jinx-mode")
|
||||||
|
(global-jinx-mode 1)))))))
|
||||||
|
|
||||||
(global-set-key (kbd "C-c j j") 'my/jinx-smart-toggle)
|
(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编辑
|
;; pair编辑
|
||||||
(global-set-key (kbd "C-c p d") 'delete-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打开定义
|
;; 中键使用embark打开定义
|
||||||
(global-set-key (kbd "<mouse-2>") 'xref-find-definitions)
|
(global-set-key (kbd "<mouse-2>") 'xref-find-definitions)
|
||||||
|
|
||||||
;; 使用快速切换到scrath buffer
|
;; 使用快速切换到scratch buffer
|
||||||
(if *is-mac*
|
(if *is-mac*
|
||||||
(global-set-key (kbd "C-C <f12>") 'scratch-buffer)
|
(global-set-key (kbd "C-C <f12>") 'scratch-buffer)
|
||||||
(global-set-key (kbd "C-c <delete>") '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-c y") 'consult-yank-from-kill-ring) ;; 从kill ring中粘贴
|
||||||
(global-set-key (kbd "C-x r b") 'consult-bookmark) ;; 书签菜单,embark中有更多操作
|
(global-set-key (kbd "C-x r b") 'consult-bookmark) ;; 书签菜单,embark中有更多操作
|
||||||
(define-key minibuffer-local-map (kbd "C-c C-e") 'embark-export) ;; 把minibuffer结果在一个菜单中显示
|
(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*
|
(if *is-mac*
|
||||||
(progn
|
(progn
|
||||||
(global-set-key (kbd "C-c f l") 'consult-fd-global)
|
(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 l") 'consult-locate)
|
||||||
(global-set-key (kbd "C-c f m") 'consult-fd-global))
|
(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
|
;; avy
|
||||||
(global-set-key (kbd "C-M-;") 'avy-goto-char)
|
(global-set-key (kbd "C-M-;") 'avy-goto-char)
|
||||||
(global-set-key (kbd "C-M-'") 'ace-pinyin-jump-char)
|
(global-set-key (kbd "C-M-'") 'ace-pinyin-jump-char)
|
||||||
|
|||||||
@@ -130,15 +130,24 @@
|
|||||||
:config (setq jinx-languages "en_US")
|
:config (setq jinx-languages "en_US")
|
||||||
(add-to-list 'jinx-exclude-regexps '(t "\\cc"))
|
(add-to-list 'jinx-exclude-regexps '(t "\\cc"))
|
||||||
(with-eval-after-load 'jinx
|
(with-eval-after-load 'jinx
|
||||||
(dolist (range '((#x4E00 . #x9FFF)
|
(dolist (range '((#x4E00 . #x9FFF)
|
||||||
(#x3400 . #x4DBF)
|
(#x3400 . #x4DBF)
|
||||||
(#x3000 . #x303F)
|
(#x3000 . #x303F)
|
||||||
(#xFF00 . #xFFEF)
|
(#xFF00 . #xFFEF)
|
||||||
(#x20000 . #x2A6DF)))
|
(#x20000 . #x2A6DF)))
|
||||||
(let ((start (car range))
|
(let ((start (car range))
|
||||||
(end (cdr range)))
|
(end (cdr range)))
|
||||||
(dotimes (i (- end start))
|
(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
|
;; 安装emms
|
||||||
(use-package emms
|
(use-package emms
|
||||||
|
|||||||
Reference in New Issue
Block a user