用 config.org 文件来维护 doom emacs 配置。

GitHub Octicon View on GitHub

他人配置列表:

name&linkbrief
dot-doom/doom.org at master · zzamboni/dot-doom-
Sacha Chua's Emacs configuration-
daedreth/UncleDavesEmacs: My personal ~/.emacs.d-
PythonNut/quark-emacs: An incredible wonderland of code-
Mastering Emacs-
Doom Emacs Configuration-
GitHub - KaratasFurkan/.emacs.d: My literate Emacs configuration-
eggcaker/.doom.d: My private doom-emacs configurationsrime + pyim
https://www.gtrun.org/custom/config.html#org57b461c

Update Logs

[2021-05-30]

  1. add gcl/async-shell-command-silently

[2021-07-02]

  1. upgrade emacs27 to emacs28 native

Function declaration

mine

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;;;###autoload
(defun gcl/edit-zsh-configuration ()
  (interactive)
  (find-file "~/.zshrc"))

;;;###autoload
(defun gcl/use-eslint-from-node-modules ()
    "Set local eslint if available."
    (let* ((root (locate-dominating-file
                  (or (buffer-file-name) default-directory)
                  "node_modules"))
           (eslint (and root
                        (expand-file-name "node_modules/eslint/bin/eslint.js"
                                          root))))
      (when (and eslint (file-executable-p eslint))
        (setq-local flycheck-javascript-eslint-executable eslint))))

;;;###autoload
(defun gcl/goto-match-paren (arg)
  "Go to the matching if on (){}[], similar to vi style of % ."
  (interactive "p")
  (cond ((looking-at "[\[\(\{]") (evil-jump-item))
        ((looking-back "[\]\)\}]" 1) (evil-jump-item))
        ((looking-at "[\]\)\}]") (forward-char) (evil-jump-item))
        ((looking-back "[\[\(\{]" 1) (backward-char) (evil-jump-item))
        (t nil)))

;;;###autoload
(defun gcl/string-inflection-cycle-auto ()
  "switching by major-mode"
  (interactive)
  (cond
   ;; for emacs-lisp-mode
   ((eq major-mode 'emacs-lisp-mode)
    (string-inflection-all-cycle))
   ;; for python
   ((eq major-mode 'python-mode)
    (string-inflection-python-style-cycle))
   ;; for java
   ((eq major-mode 'java-mode)
    (string-inflection-java-style-cycle))
   (t
    ;; default
    (string-inflection-all-cycle))))

;; Current time and date
(defvar current-date-time-format "%a %b %d %H:%M:%S %Z %Y"
  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")

(defvar current-time-format "%H:%M"
  "Format of date to insert with `insert-current-time' func.
Note the weekly scope of the command's precision.")

;;;###autoload
(defun insert-current-date-time ()
  "insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
  (interactive)
  (insert (format-time-string current-date-time-format (current-time)))
  )

;;;###autoload
(defun insert-current-time ()
  "insert the current time (1-week scope) into the current buffer."
  (interactive)
  (insert (format-time-string current-time-format (current-time)))
  )

;;;###autoload
(defun my/capitalize-first-char (&optional string)
  "Capitalize only the first character of the input STRING."
  (when (and string (> (length string) 0))
    (let ((first-char (substring string nil 1))
          (rest-str   (substring string 1)))
      (concat (capitalize first-char) rest-str))))

;;;###autoload
(defun my/lowcase-first-char (&optional string)
  "Capitalize only the first character of the input STRING."
  (when (and string (> (length string) 0))
    (let ((first-char (substring string nil 1))
          (rest-str   (substring string 1)))
      (concat first-char rest-str))))

;;;###autoload
(defun gcl/async-shell-command-silently (command)
  "async shell command silently."
  (interactive)
  (let
      ((display-buffer-alist
        (list
         (cons
          "\\*Async Shell Command\\*.*"
          (cons #'display-buffer-no-window nil)))))
    (async-shell-command
     command)))

aj(AloisJanicek)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
;;;###autoload
(defun aj-fix-buffer-file-name-for-indirect-buffers-a (orig-fn &rest args)
  "Advice for functions expecting `buffer-file-name' to work."
  (let ((buffer-file-name buffer-file-truename))
    (cl-letf (((symbol-function 'buffer-file-name)
               (lambda (&optional buffer)
                 "Return value of `buffer-file-truename'."
                 (with-current-buffer (or buffer (current-buffer))
                   buffer-file-truename))))
      (apply orig-fn args))))

;;;###autoload
(defun aj-zeal-at-point-run-search-on-wsl-a (search)
  "Launch Windows Zeal from WSL emacs.
Use `call-process' instead of `start-process'.
Use in conjunction with
https://github.com/Konfekt/wsl-gui-bins/blob/master/zeal
"
  (call-process (executable-find "zeal") nil 0 nil search))

org-mode

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
;;;###autoload
(defun gcl/indent-org-block-automatically ()
  (interactive)
  (when (org-in-src-block-p)
   (org-edit-special)
   (indent-region (point-min) (point-max))
   (org-edit-src-exit)))

;;;###autoload
(defun aj-org-agenda-save-and-refresh-a (&rest _)
  "Save org files and refresh.
Only org files contributing to `org-agenda' are saved.
Refreshed are `org-agenda' org `org-ql-view', depending on
which one is currently active."
  (org-save-all-org-buffers)
  (if (string-match "Org QL" (buffer-name))
      (org-ql-view-refresh)
    (org-agenda-redo)))

;;;###autoload
(defun aj-org-roam-setup-dailies-file-h ()
  "Setup org-roam dailies file to my taste.
Initialy create id inside top-level \":PROPERTIES:\" drawer.
Finally save buffer.
"
  (let ((fname (or (buffer-file-name)
                   (buffer-file-name (buffer-base-buffer))))
        hstub)
    ;; Run this only when file is newly created (hasn't been saved yet)
    (unless (file-exists-p fname)
      (org-id-get-create)
      (save-buffer))

    (goto-char (point-max))
    (newline)
    ;; prompt for HH:MM if we are not in present day file
    (if (string-equal (format-time-string "%Y-%m-%d")
                      (file-name-sans-extension
                       (file-name-nondirectory
                        (or (buffer-file-name)
                            (buffer-file-name (buffer-base-buffer))))))
        (setq hstub (format-time-string "* %H:%M " (current-time)))
      (setq hstub (concat "* " (ivy-read
                                "Time of the day (HH:MM): "
                                nil)
                          " ")))
    (insert hstub)
    (evil-insert 0)))

quick-find

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

;;;###autoload
(defun dired-timesort (filename &optional wildcards)
  (let ((dired-listing-switches "-lhat"))
    (dired filename wildcards)))

;;;###autoload
(defmacro quick-find (key file &optional path find-args)
  `(bind-key
    ,key
    (cond
     ((stringp ,find-args)
      '(lambda (&optional arg)
         (interactive)
         (find-dired (expand-file-name ,file ,path) ,find-args)))
     ((and
       ;; (not (tramp-tramp-file-p (expand-file-name ,file ,path)))
       (or (file-directory-p (expand-file-name ,file ,path))
           (not (file-exists-p (expand-file-name ,file ,path)))))
      '(lambda (&optional arg)
         (interactive)
         (dired-timesort (expand-file-name ,file ,path))))
     (t
      '(lambda (&optional arg)
         (interactive)
         (find-file (expand-file-name ,file ,path)))))))

embrace

1
2
3
4
5
6
7
8
9
;;;###autoload
(defun gcl/embrace-prog-mode-hook ()
  (dolist (lst '((?` "`" . "`")))
    (embrace-add-pair (car lst) (cadr lst) (cddr lst))))

;;;###autoload
(defun gcl/embrace-org-mode-hook ()
  (dolist (lst '((?c "@@html:<font color=\"red\">" . "</font>@@")))
    (embrace-add-pair (car lst) (cadr lst) (cddr lst))))

Init.el

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
;;; init.el -*- lexical-binding: t; -*-

(doom! :input
       ;;chinese
       ;;japanese
       ;;layout            ; auie,ctsrnm is the superior home row

       :completion
       company           ; the ultimate code completion backend
       ;;helm              ; the *other* search engine for love and life
       ;;ido               ; the other *other* search engine...
       (ivy               ; a search engine for love and life
        +icons
        +prescient)

       :ui
       ;;deft              ; notational velocity for Emacs
       doom              ; what makes DOOM look the way it does
       doom-dashboard    ; a nifty splash screen for Emacs
       doom-quit         ; DOOM quit-message prompts when you quit Emacs
       (emoji +ascii +github)  ; 🙂
       fill-column       ; a `fill-column' indicator
       hl-todo           ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
       hydra
       ;;indent-guides     ; highlighted indent columns
       (ligatures         ; ligatures and symbols to make your code pretty again
        +extra)
       ;;minimap           ; show a map of the code on the side
       modeline          ; snazzy, Atom-inspired modeline, plus API
       nav-flash         ; blink cursor line after big motions
       ;;neotree           ; a project drawer, like NERDTree for vim
       ophints           ; highlight the region an operation acts on
       (popup +all +defaults)   ; tame sudden yet inevitable temporary windows
       ;;tabs              ; a tab bar for Emacs
       ;; (treemacs +lsp)          ; a project drawer, like neotree but cooler
       ;; unicode           ; extended unicode support for various languages
       vc-gutter         ; vcs diff in the fringe
       vi-tilde-fringe   ; fringe tildes to mark beyond EOB
       (window-select +numbers)     ; visually switch windows
       workspaces        ; tab emulation, persistence & separate workspaces
       ;;zen               ; distraction-free coding or writing

       :editor
       (evil +everywhere); come to the dark side, we have cookies
       file-templates    ; auto-snippets for empty files
       fold              ; (nigh) universal code folding
       (format +onsave)  ; automated prettiness
       ;;god               ; run Emacs commands without modifier keys
       ;;lispy             ; vim for lisp, for people who don't like vim
       multiple-cursors  ; editing in many places at once
       ;; objed             ; text object editing for the innocent
       ;;parinfer          ; turn lisp into python, sort of
       rotate-text       ; cycle region at point between text candidates
       snippets          ; my elves. They type so I don't have to
       word-wrap         ; soft wrapping with language-aware indent

       :emacs
       (dired +icons)             ; making dired pretty [functional]
       electric          ; smarter, keyword-based electric-indent
       (ibuffer +icons)         ; interactive buffer management
       ;; (undo +tree)              ; persistent, smarter undo for your inevitable mistakes
       vc                ; version-control and Emacs, sitting in a tree

       :term
       ;;eshell            ; the elisp shell that works everywhere
       ;;shell             ; simple shell REPL for Emacs
       ;;term              ; basic terminal emulator for Emacs
       vterm             ; the best terminal emulation in Emacs

       :checkers
       syntax              ; tasing you for every semicolon you forget
       ;; (:if (executable-find "aspell") spell +flyspell) ; tasing you for misspelling mispelling
       grammar           ; tasing grammar mistake every you make

       :tools
       ;;ansible
       ;;debugger          ; FIXME stepping through code, to help you add bugs
       ;;direnv
       ;;docker
       editorconfig      ; let someone else argue about tabs vs spaces
       ;;ein               ; tame Jupyter notebooks with emacs
       (eval +overlay)     ; run code, run (also, repls)
       ;;gist              ; interacting with github gists
       (lookup              ; navigate your code and its documentation
        +dictionary
        +docsets)
       (lsp +peek)
       (magit +forge)             ; a git porcelain for Emacs
       make              ; run make tasks from Emacs
       ;;pass              ; password manager for nerds
       ;; pdf               ; pdf enhancements
       ;;prodigy           ; FIXME managing external services & code builders
       rgb               ; creating color strings
       ;;taskrunner        ; taskrunner for all your projects
       ;;terraform         ; infrastructure as code
       ;;tmux              ; an API for interacting with tmux
       upload            ; map local to remote projects via ssh/ftp

       :os
       (:if IS-MAC macos)  ; improve compatibility with macOS
       tty               ; improve the terminal Emacs experience

       :lang
       ;;agda              ; types of types of types of types...
       ;;beancount         ; mind the GAAP
       (cc +lsp)                ; C > C++ == 1
       ;;clojure           ; java with a lisp
       ;;common-lisp       ; if you've seen one lisp, you've seen them all
       ;;coq               ; proofs-as-programs
       ;;crystal           ; ruby at the speed of c
       ;;csharp            ; unity, .NET, and mono shenanigans
       data              ; config/data formats
       (dart +flutter +lsp)   ; paint ui and not much else
       ;;elixir            ; erlang done right
       ;;elm               ; care for a cup of TEA?
       emacs-lisp        ; drown in parentheses
       ;;erlang            ; an elegant language for a more civilized age
       ;;ess               ; emacs speaks statistics
       ;;factor
       ;;faust             ; dsp, but you get to keep your soul
       ;;fsharp            ; ML stands for Microsoft's Language
       ;;fstar             ; (dependent) types and (monadic) effects and Z3
       ;;gdscript          ; the language you waited for
       (go +lsp)         ; the hipster dialect
       ;;(haskell +dante)  ; a language that's lazier than I am
       ;;hy                ; readability of scheme w/ speed of python
       ;;idris             ; a language you can depend on
       (json +lsp)              ; At least it ain't XML
       (java +meghanada +lsp) ; the poster child for carpal tunnel syndrome
       (javascript +lsp)        ; all(hope(abandon(ye(who(enter(here))))))
       ;;julia             ; a better, faster MATLAB
       ;;kotlin            ; a better, slicker Java(Script)
       (latex             ; writing papers in Emacs has never been so fun
        +latexmk
        +cdlatex
        +lsp
        +fold)
       ;;lean              ; for folks with too much to prove
       ;;ledger            ; be audit you can be
       (lua +lsp)               ; one-based indices? one-based indices
       markdown          ; writing docs for people to ignore
       ;;nim               ; python + lisp at the speed of c
       nix               ; I hereby declare "nix geht mehr!"
       ;;ocaml             ; an objective camel
       (org               ; organize your plain life in plain text
        +attach
        +babel
        +capture
        +dragndrop
        +hugo
        ;; +jupyter
        +export
        +pandoc
        +gnuplot
        +pretty
        +present
        +protocol
        +pomodoro
        +roam2
        +noter)
       (php +lsp)               ; perl's insecure younger brother
       plantuml          ; diagrams for confusing people more
       ;;purescript        ; javascript, but functional
       (python +lsp +pyright)            ; beautiful is better than ugly
       ;;qt                ; the 'cutest' gui framework ever
       ;;racket            ; a DSL for DSLs
       ;;raku              ; the artist formerly known as perl6
       rest              ; Emacs as a REST client
       ;;rst               ; ReST in peace
       (ruby +rails +lsp)     ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
       (rust +lsp)              ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
       ;;scala             ; java, but good
       (scheme +guile)   ; a fully conniving family of lisps
       (sh +lsp +powershell)                ; she sells {ba,z,fi}sh shells on the C xor
       ;;sml
       ;;solidity          ; do you need a blockchain? No.
       ;;swift             ; who asked for emoji variables?
       ;;terra             ; Earth and Moon in alignment for performance.
       (web +lsp)               ; the tubes
       (yaml +lsp)              ; JSON, but readable
       ;;zig               ; C, but simpler

       :email
       (mu4e +gmail +org)
       ;;notmuch
       ;;(wanderlust +gmail)

       :app
       calendar
       emms
       everywhere        ; *leave* Emacs!? You must be joking
       irc               ; how neckbeards socialize
       (rss +org)        ; emacs as an RSS reader
       ;;twitter           ; twitter client https://twitter.com/vnought

       :config
       literate
       (default +bindings +smartparens))

Theme Settings

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(setq doom-theme 'doom-vibrant)
;; (setq doom-theme 'spacemacs-light)
;;(setq doom-theme 'doom-nord-light)
;;(setq doom-theme 'doom-solarized-light)

;; (setq doom-font (font-spec :family "JetBrains Mono" :size 16))
(setq doom-font (font-spec :family "Fira Code" :size 16)
      doom-variable-pitch-font (font-spec :family "ETBembo" :size 32))
;; (setq doom-font (font-spec :family "Source Code Pro" :size 15))

;; set title
;; (setq frame-title-format
;;       '(""
;;         ;; (:eval
;;         ;;  (if (s-contains-p org-roam-directory (or buffer-file-name ""))
;;         ;;      (replace-regexp-in-string
;;         ;;       ".*/[0-9]*-?" "☰ "
;;         ;;       (subst-char-in-string ?_ ?  buffer-file-name))
;;         ;;    "%b"))
;;         (:eval
;;          (let ((project-name (projectile-project-name)))
;;            (unless (string= "-" project-name)
;;              (format (if (buffer-modified-p)  " ◉ %s" "  ●  %s") project-name))))))

Basic Settings

auto generate code into config.el, init.el, packages.el, …, and run `cp-config-org.sh`

to bakup some of my private things.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(doom-load-envvars-file "~/.doom.d/env" )

;; (defadvice! +literate-tangle-async-h ()
;;   "A very simplified version of `+literate-tangle-h', but async."
;;   :override #'+literate-tangle-h
;;   (let ((default-directory doom-private-dir))
;;     (gcl/async-shell-command-silently (format "emacs --batch --eval \"(progn \
;; (require 'org) (setq org-confirm-babel-evaluate nil) \
;; (org-babel-tangle-file \\\"%s\\\"))\" \
;; && /bin/bash ~/.gclrc/bin/rsync-doom-config"
;;                                               +literate-config-file))))

;; (cond (IS-MAC
;;        (setq mac-command-modifier 'meta
;;              mac-option-modifier 'alt
;;              mac-right-option-modifier 'alt)))

private:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

;; 启动全屏
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(add-hook 'org-mode-hook 'turn-on-auto-fill)

;; 个人信息配置
(setq user-full-name "Zhicheng Lee"
      user-mail-address "gccll.love@gmail.com"
      user-blog-url "https://www.cheng92.com"
      read-process-output-max (* 1024 1024)
      display-line-numbers-type t

      ;; exit no confirm
      confirm-kill-emacs nil

      ;; web, js, css
      css-indent-offset 2
      js2-basic-offset 2
      js-switch-indent-offset 2
      js-indent-level 2
      js2-mode-show-parse-errors nil
      js2-mode-show-strict-warnings nil
      web-mode-attr-indent-offset 2
      web-mode-code-indent-offset 2
      web-mode-css-indent-offset 2
      web-mode-markup-indent-offset 2
      web-mode-enable-current-element-highlight t
      web-mode-enable-current-column-highlight t

      ;; org
      org-roam-v2-ack t                 ; close v2 warning
      org-roam-directory "~/.gclrc/roam/"
      org-directory "~/.gclrc/org/"
      org-log-done 'time                        ; having the time a item is done sounds convenient
      org-list-allow-alphabetical t             ; have a. A. a) A) list bullets
      org-export-in-background t                ; run export processes in external emacs process
      org-catch-invisible-edits 'smart          ; try not to accidently do weird stuff in invisible regions
      org-fontify-done-headline t               ; 已完成的加上删除线

      ;; scroll behavior
      redisplay-dont-pause t
      scroll-margin 1
      scroll-step 1
      scroll-conservatively 10000
      scroll-preserve-screen-position 1

      ;; mouse wheel
      mouse-wheel-follow-mouse 't
      mouse-wheel-scroll-amount '(1 ((shift) . 1))

      vc-log-view-type nil

      ;; osx
      ;; browse-url-browser-function 'browse-url-default-macosx-browser
      )

(setq-default
 fill-column 80
 undo-limit 80000000
 delete-by-moving-to-trash t
 window-combination-resize t
 delete-trailing-lines t
 x-stretch-cursor t
 typescript-indent-level 2
 custom-file (expand-file-name ".custom.el" doom-private-dir))

(when (file-exists-p custom-file)
  (load custom-file))

Keybindings

Keybindings reference:

evil-bindings.el

editor/evil/config.el

Unbindings

To Unbind

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

(global-set-key (kbd "C-d") nil)        ; ns-print-buffer
(global-set-key (kbd "s-p") nil)        ; ns-print-buffer
(global-set-key (kbd "<f1>") nil)        ; ns-print-buffer
(global-set-key (kbd "<f2>") nil)        ; ns-print-buffer
(define-key evil-normal-state-map (kbd ",") nil)
(define-key evil-visual-state-map (kbd ",") nil)
;; (global-set-key (kbd ",") nil)
(map! "C-e" nil
      :n "C-t" nil)
;; (undefine-key! "SPC :" "SPC ~" "SPC ." "SPC X" "C-c C-r" ",")
;; (undefine-key! evil-normal-state-map ",")
(undefine-key! org-mode-map "C-c C-r")

F1~12(kbd)

1
2
3
4
5
6
7
8
9
(global-set-key (kbd "<f1>") 'gcl-everything/body)
(global-set-key (kbd "<f5>") 'deadgrep)
(global-set-key (kbd "<M-f5>") 'deadgrep-kill-all-buffers)
(global-set-key (kbd "<f8>") 'quickrun)
(global-set-key (kbd "<f12>") 'smerge-vc-next-conflict)
(global-set-key (kbd "<f11>") '+vc/smerge-hydra/body)
(global-set-key (kbd "C-t") '+vterm/toggle)
(global-set-key (kbd "C-S-t") '+vterm/here)
(global-set-key (kbd "C-d") 'kill-current-buffer)

Global

M(Option/Alt)

1
2
3
4
5
6
7
8
9
(map!
 ;; "M-1"          #'bm-toggle
 ;; "M-2"          #'bm-next
 ;; "M-@"          #'bm-previous
 "M--"          #'gcl/goto-match-paren
 "M-i"          #'parrot-rotate-next-word-at-point
 "M-TAB"        #'gcl-everything/body
 ;; "S-M-SPC"      #'counsel-osx-app
 )

C(Control)

1
2
3
4
5
6
7
(map!
 :niv   "C-e"   #'evil-end-of-line
 :niv   "C-="   #'er/expand-region

 "C-a"          #'crux-move-beginning-of-line
 "C-s"          #'+default/search-buffer
 )
C-c
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(map!
 ;; a -> applications, ...
 "C-c a"        #'org-agenda

 ;; b -> bookmark, buffer ...
 "C-c b l"      #'bm-show-all
 "C-c b s"      #'bm-buffer-save

 ;; i -> date, time, ...
 "C-c i d"      #'insert-current-date-time
 "C-c i t"      #'insert-current-time

 ;; f -> file, directory, ...
 "C-c f o"      #'crux-open-with

 ;; h -> help
 "C-c h d"      #'dash-at-point
 "C-c h D"      #'dash-at-point-with-docset

 ;; n -> network utils
 ;; "C-c n x"      #'xxx

 ;; s -> search/engine ...
 ;; "C-c s r"  ;; ...

 ;; s -> replace
 "C-c r r"      #'vr/replace
 "C-c r q"      #'vr/query-replace

 ;; u -> url, ...
 "C-c u u"      #'crux-view-url
 "C-c u o"      #'link-hint-open-link
 "C-c u c"      #'link-hint-copy-link
 "C-c u a"      #'link-hint-open-link-at-point
 "C-c u C"      #'link-hint-copy-link-at-point

 ;; y -> youdao, ...
 "C-c y y"      #'youdao-dictionary-search-at-point+

 "C-c C-r C-r"          #'verb-send-request-on-point-other-window-stay
 "C-c C-r C-s"          #'verb-send-request-on-point-other-window
 "C-c C-r C-f"          #'verb-send-request-on-point
 "C-c C-r C-m"          #'verb-send-request-on-point-no-window
 "C-c C-r C-k"          #'verb-kill-response-buffer-and-window
 "C-c C-r C-a"          #'verb-kill-all-response-buffers
 "C-c C-r C-u"          #'verb-export-request-on-point-curl
 "C-c C-r C-b"          #'verb-export-request-on-point-verb
 "C-c C-r C-w"          #'verb-export-request-on-point-eww
 "C-c C-r C-l"          #'verb-show-vars        ; 查看已存在的变量值列表
 "C-c C-r C-v"          #'verb-set-var

 )
C-x
1
2
3
4
5
(map!
 ;; "C-x p"        #'vmd-mode
 ;; "C-x d"        #'dash-at-point
 ;; "C-x D"        #'dash-at-point-with-docset
 )

s(Command)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(map!
 "s-<"          #'move-text-up
 "s->"          #'move-text-down
 ;; "s-'"          #'cycle-quotes
 "s-i"          #'gcl/string-inflection-cycle-auto
 ;; projector --- ---
 ;; "s-p b"      #'projector-switch-to-shell-buffer
 ;; "s-p B"      #'projector-run-shell-command-current-directory-background
 ;; "s-p c"      #'projector-run-shell-command-current-directory
 ;; "s-p d"      #'projector-run-default-shell-command
 ;; "s-p r"      #'projector-run-shell-command-project-root
 ;; "s-p R"      #'projector-rerun-buffer-process
 )

Evil

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(evil-define-minor-mode-key '(normal motion) 'evil-snipe-local-mode
  "s" #'avy-goto-char
  "S" #'avy-goto-char-2
  "w" #'avy-goto-word-1
  "W" #'avy-goto-word-0
  )

(evil-define-key '(normal motion visual) map
   "s" #'avy-goto-char
   "S" #'avy-goto-char-2
   "w" #'avy-goto-word-1
   "W" #'avy-goto-word-0
  )

(map!
 :n     "+"     #'evil-numbers/inc-at-pt
 :n     "-"     #'evil-numbers/dec-at-pt

 ;; g
 :n     "g["    #'beginning-of-defun
 :n     "g]"    #'end-of-defun
 :n     "gd"    #'xref-find-definitions
 :n     "gD"    #'xref-find-references
 :n     "gb"    #'xref-pop-marker-stack

 ;; z
 :n     "z-"    #'sp-splice-sexp
 :n     "z."    #'emmet-wrap-with-markup

 :n     "gi"    nil
 (:prefix ("gi" . "mine")
  :n    "f"     #'+org/attach-file-and-insert-link)

 :nv     ","     nil
 (:prefix ("," . "gccll")
  :nv    "`"     #'gcl-everything/body

  ;; embrace
  (:prefix ("e" . "embrace")
   :n    "a"    #'embrace-add
   :n    "c"    #'embrace-change
   :n    "d"    #'embrace-delete
   )

  )
 )

;; remap gs-> keybinding
(map! :after evil-easymotion
      :map evilem-map
      "c"       #'avy-goto-char
      "C"       #'avy-goto-char-2
      "w"       #'avy-goto-word-1
      "W"       #'avy-goto-word-0
      "ll"      #'avy-goto-line
      "lu"      #'avy-goto-line-above
      "ld"      #'avy-goto-line-below
      )

SPC

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(map!
 :leader
 :nv    "SPC"           #'execute-extended-command

 (:prefix ("a" . "Applications")
  :n    "e"     #'emms
  :n    "E"     #'emms-smart-browse
  )

 ;; b -> Buffer
 :n     "bf"            #'osx-lib-reveal-in-finder

 ;; f -> File
 :n     "fo"            #'crux-open-with
 :n     "fj"            #'dired-jump

 ;; d -> directory
 :n     "dd"            #'deft

 ;; d -> edit
 :n     "es"            #'sudo-edit

 ;; i -> Insert, Imenu
 :n     "ia"            #'+org/attach-file-and-insert-link
 :n     "im"            #'imenu-list
 :n     "iM"            #'lsp-ui-imenu

 ;; l -> load, ...
 :n     "lr"            #'ranger
 :n     "ld"            #'dired
 :n     "le"            #'=rss

 ;; r -> Run
 ;; :n     "rp"         #'projector-run-shell-command-project-root
 ;; :n     "rP"         #'projector-run-default-shell-command

 ;; s -> search ?
 (:map (scss-mode-map css-mode-map)
  :n     "si"            #'counsel-css
  )

 (:prefix ("v" . "View")
  :n    "e"            #'mu4e-alert-view-unread-mails
  )

 ;; / -> Search
 ;; :n     "/r"    #'deadgrep
 )

Org-mode

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(map! :map org-mode-map
      (:prefix "t"
       :n "t" #'org-todo
       :n "T" #'counsel-org-tag
       (:prefix ("c" . "checkbox")
        :n "c" #'org-toggle-checkbox
        :n "u" #'org-update-checkbox-count
        )
       (:prefix ("p" . "priority")
        :n "p" #'org-priority
        :n "u" #'org-priority-up
        :n "d" #'org-priority-down
        ))

      (:prefix "C-c"
       (:prefix ( "d" . "Do" )
        "f" #'gcl/indent-org-block-automatically
        )
       (:prefix ("e" . "Emoji")
        "e" #'all-the-icons-insert
        "a" #'all-the-icons-insert-faicon
        "f" #'all-the-icons-insert-fileicon
        "w" #'all-the-icons-insert-wicon
        "o" #'all-the-icons-insert-octicon
        "m" #'all-the-icons-insert-material
        "i" #'all-the-icons-insert-alltheicon
        )
       (:prefix ("c" . "Org Clock")
        "i" #'org-clock-in
        "o" #'org-clock-out
        "h" #'counsel-org-clock-history
        "g" #'counsel-org-clock-goto
        "c" #'counsel-org-clock-context
        "r" #'counsel-org-clock-rebuild-history
        )
       (:prefix ("i" . "Insert")
        "u" #'org-mac-chrome-insert-frontmost-url
        "c" #'copyright
        )

       ;; org-roam, C-c r <x>
       (:prefix ("C-r" . "Verb")
        "C-r"     #'verb-send-request-on-point-other-window-stay
        "C-s"     #'verb-send-request-on-point-other-window
        "C-f"     #'verb-send-request-on-point
        "C-m"     #'verb-send-request-on-point-no-window
        "C-k"     #'verb-kill-response-buffer-and-window
        "C-a"     #'verb-kill-all-response-buffers
        "C-u"     #'verb-export-request-on-point-curl
        "C-b"     #'verb-export-request-on-point-verb
        "C-w"     #'verb-export-request-on-point-eww
        "C-l"     #'verb-show-vars        ; 查看已存在的变量值列表
        )
       )
      )

Web-mode

QuickFind

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(quick-find "C-h C-x C-s" "~/.ssh/config")
(quick-find "C-h C-x C-z" "~/.zshrc")
(quick-find "C-h C-x C-d" "~/.gclrc/org/todo.org")
(quick-find "C-h C-x C-o" "~/.offlineimaprc")
(quick-find "C-h C-x C-m" "~/.mbsyncrc")

(map! :leader
      (:prefix ("-" . "open file")
       :desc "Edit agenda file"         "t" #'(lambda () (interactive) (find-file "~/.gclrc/org/todo.org"))
       :desc "Edit doom config.org"     "c" #'(lambda () (interactive) (find-file "~/.doom/config.org"))
       :desc "Edit mbsyncrc"            "d b" #'(lambda () (interactive) (find-file "~/.gclrc/mu4e/mbsyncrc"))
       :desc "Edit msmtprc"             "d s" #'(lambda () (interactive) (find-file "~/.msmtprc"))
       ))

Package Settings

Autoinsert

1
2
3
(use-package! autoinsert
  :hook
  (find-file . auto-insert))

Avy

1
2
3
4
5
6
(global-set-key (kbd "M-g f") 'avy-goto-line)
(global-set-key (kbd "M-g w") 'avy-goto-word-1)

(after! avy
  ;; home row priorities: 8 6 4 5 - - 1 2 3 7
  (setq avy-keys '(?n ?e ?i ?s ?t ?r ?i ?a)))

Bm, bookmark

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
(use-package! bm
  :bind
  ("M-1" . bm-toggle)
  ("M-2" . bm-next)
  ("M-@" . bm-previous)
  :custom
  (bm-cycle-all-buffers t)
  :config
  (add-hook 'after-init-hook 'bm-repository-load)
  (add-hook 'kill-buffer-hook #'bm-buffer-save)
  (add-hook 'kill-emacs-hook #'(lambda nil
                                 (bm-buffer-save-all)
                                 (bm-repository-save)))
  (add-hook 'after-save-hook #'bm-buffer-save)
  (add-hook 'find-file-hooks   #'bm-buffer-restore)
  (add-hook 'after-revert-hook #'bm-buffer-restore)
  (setq bm-repository-file "~/.doom.d/bm-repository")
  (setq-default bm-buffer-persistence t)
  )

Color-rg

1
2
3
4
5
6
7
(use-package! color-rg
  :commands (color-rg-search-input
             color-rg-search-symbol
             color-rg-search-input-in-project)
  :bind
  (:map isearch-mode-map
   ("M-s M-s" . isearch-toggle-color-rg)))

Company

1
2
3
4
(after! company
  (setq company-idle-delay 0.5
        company-minimum-prefix-length 2)
  (add-hook 'evil-normal-state-entry-hook #'company-abort)) ;; make aborting less annoying.

Counsel-osx-app

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(use-package! counsel-osx-app
  :bind* ("S-M-SPC" . counsel-osx-app)
  :commands counsel-osx-app
  :config
  (setq counsel-osx-app-location
        (list "/Applications"
              "/Applications/Misc"
              "/Applications/Utilities"
              (expand-file-name "~/Applications")
              (expand-file-name "~/.nix-profile/Applications")
              "/Applications/Xcode.app/Contents/Applications")))

Cycle-quotes

1
2
3
(use-package! cycle-quotes
  :bind
  ("s-'" . cycle-quotes))

Dash-at-point

1
2
3
4
(use-package! dash-at-point
  :bind
  (("C-x d" . dash-at-point)
   ("C-x D" . dash-at-point-with-docset)))

Deadgrep

正则搜索要在搜索的结果中,选中 regexp 来筛选。

按键绑定:

keyfunc
<f5>deadgrep
M-<f5>deadgrep-kill-all-buffers
RET查看结果
o在另一个窗口打开
n/p结果中上下移动
M-n/M-p文件头尾之间移动
g重新搜索
TAB展开/闭合结果
C-c C-k停止正在执行的搜索

Delsel

1
2
3
(use-package! delsel
  :config
  (delete-selection-mode t))

Dotenv-mode

1
2
(use-package! dotenv-mode
  :mode ("\\.env\\.?.*\\'" . dotenv-mode))

EAF

1
2
3
4
5
6
 ;; (use-package! eaf
 ;;  :commands (eaf-open-browser eaf-open find-file)
 ;;  :config
 ;;  (use-package! ctable)
 ;;  (use-package! deferred)
 ;;  (use-package! epc))

Elfeed

Keybindings

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(map! :map elfeed-search-mode-map
      :after elfeed-search
      [remap kill-this-buffer] "q"
      [remap kill-buffer] "q"
      :n doom-leader-key nil
      ;; :n "q" #'+rss/quit
      :n "e" #'elfeed-update
      :n "r" #'elfeed-search-untag-all-unread
      :n "u" #'elfeed-search-tag-all-unread
      :n "s" #'elfeed-search-live-filter
      :n "RET" #'elfeed-search-show-entry
      :n "p" #'elfeed-show-pdf
      :n "+" #'elfeed-search-tag-all
      :n "-" #'elfeed-search-untag-all
      :n "S" #'elfeed-search-set-filter
      :n "b" #'elfeed-search-browse-url
      :n "y" #'elfeed-search-yank)

(map! :map elfeed-show-mode-map
      :after elfeed-show
      [remap kill-this-buffer] "q"
      [remap kill-buffer] "q"
      :n doom-leader-key nil
      :nm "q" #'+rss/delete-pane
      :nm "o" #'ace-link-elfeed
      :nm "RET" #'org-ref-elfeed-add
      :nm "n" #'elfeed-show-next
      :nm "N" #'elfeed-show-prev
      :nm "p" #'elfeed-show-pdf
      :nm "+" #'elfeed-show-tag
      :nm "-" #'elfeed-show-untag
      :nm "s" #'elfeed-show-new-live-search
      :nm "y" #'elfeed-show-yank)

Usability enhancements

1
2
3
4
5
6
7
8
(after! elfeed-search
  (set-evil-initial-state! 'elfeed-search-mode 'normal))
(after! elfeed-show-mode
  (set-evil-initial-state! 'elfeed-show-mode   'normal))

(after! evil-snipe
  (push 'elfeed-show-mode   evil-snipe-disabled-modes)
  (push 'elfeed-search-mode evil-snipe-disabled-modes))

Visual enhancements

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
(after! elfeed

  ;; (elfeed-org)
  (use-package! elfeed-link)

  (setq elfeed-search-filter "@4-week-ago +unread"
        elfeed-search-print-entry-function '+rss/elfeed-search-print-entry
        elfeed-search-title-min-width 80
        elfeed-show-entry-switch #'pop-to-buffer
        elfeed-show-entry-delete #'+rss/delete-pane
        elfeed-show-refresh-function #'+rss/elfeed-show-refresh--better-style
        shr-max-image-proportion 0.6)

  (add-hook! 'elfeed-show-mode-hook (hide-mode-line-mode 1))
  (add-hook! 'elfeed-search-update-hook #'hide-mode-line-mode)

  (defface elfeed-show-title-face '((t (:weight ultrabold :slant italic :height 1.5)))
    "title face in elfeed show buffer"
    :group 'elfeed)
  (defface elfeed-show-author-face `((t (:weight light)))
    "title face in elfeed show buffer"
    :group 'elfeed)
  (set-face-attribute 'elfeed-search-title-face nil
                      :foreground 'nil
                      :weight 'light)

  (defadvice! +rss-elfeed-wrap-h-nicer ()
    "Enhances an elfeed entry's readability by wrapping it to a width of
`fill-column' and centering it with `visual-fill-column-mode'."
    :override #'+rss-elfeed-wrap-h
    (setq-local truncate-lines nil
                shr-width 120
                visual-fill-column-center-text t
                default-text-properties '(line-height 1.1))
    (let ((inhibit-read-only t)
          (inhibit-modification-hooks t))
      (visual-fill-column-mode)
      ;; (setq-local shr-current-font '(:family "Merriweather" :height 1.2))
      (set-buffer-modified-p nil)))

  (defun +rss/elfeed-search-print-entry (entry)
    "Print ENTRY to the buffer."
    (let* ((elfeed-goodies/tag-column-width 40)
           (elfeed-goodies/feed-source-column-width 30)
           (title (or (elfeed-meta entry :title) (elfeed-entry-title entry) ""))
           (title-faces (elfeed-search--faces (elfeed-entry-tags entry)))
           (feed (elfeed-entry-feed entry))
           (feed-title
            (when feed
              (or (elfeed-meta feed :title) (elfeed-feed-title feed))))
           (tags (mapcar #'symbol-name (elfeed-entry-tags entry)))
           (tags-str (concat (mapconcat 'identity tags ",")))
           (title-width (- (window-width) elfeed-goodies/feed-source-column-width
                           elfeed-goodies/tag-column-width 4))

           (tag-column (elfeed-format-column
                        tags-str (elfeed-clamp (length tags-str)
                                               elfeed-goodies/tag-column-width
                                               elfeed-goodies/tag-column-width)
                        :left))
           (feed-column (elfeed-format-column
                         feed-title (elfeed-clamp elfeed-goodies/feed-source-column-width
                                                  elfeed-goodies/feed-source-column-width
                                                  elfeed-goodies/feed-source-column-width)
                         :left)))

      (insert (propertize feed-column 'face 'elfeed-search-feed-face) " ")
      (insert (propertize tag-column 'face 'elfeed-search-tag-face) " ")
      (insert (propertize title 'face title-faces 'kbd-help title))
      (setq-local line-spacing 0.2)))

  (defun +rss/elfeed-show-refresh--better-style ()
    "Update the buffer to match the selected entry, using a mail-style."
    (interactive)
    (let* ((inhibit-read-only t)
           (title (elfeed-entry-title elfeed-show-entry))
           (date (seconds-to-time (elfeed-entry-date elfeed-show-entry)))
           (author (elfeed-meta elfeed-show-entry :author))
           (link (elfeed-entry-link elfeed-show-entry))
           (tags (elfeed-entry-tags elfeed-show-entry))
           (tagsstr (mapconcat #'symbol-name tags ", "))
           (nicedate (format-time-string "%a, %e %b %Y %T %Z" date))
           (content (elfeed-deref (elfeed-entry-content elfeed-show-entry)))
           (type (elfeed-entry-content-type elfeed-show-entry))
           (feed (elfeed-entry-feed elfeed-show-entry))
           (feed-title (elfeed-feed-title feed))
           (base (and feed (elfeed-compute-base (elfeed-feed-url feed)))))
      (erase-buffer)
      (insert "\n")
      (insert (format "%s\n\n" (propertize title 'face 'elfeed-show-title-face)))
      (insert (format "%s\t" (propertize feed-title 'face 'elfeed-search-feed-face)))
      (when (and author elfeed-show-entry-author)
        (insert (format "%s\n" (propertize author 'face 'elfeed-show-author-face))))
      (insert (format "%s\n\n" (propertize nicedate 'face 'elfeed-log-date-face)))
      (when tags
        (insert (format "%s\n"
                        (propertize tagsstr 'face 'elfeed-search-tag-face))))
      ;; (insert (propertize "Link: " 'face 'message-header-name))
      ;; (elfeed-insert-link link link)
      ;; (insert "\n")
      (cl-loop for enclosure in (elfeed-entry-enclosures elfeed-show-entry)
               do (insert (propertize "Enclosure: " 'face 'message-header-name))
               do (elfeed-insert-link (car enclosure))
               do (insert "\n"))
      (insert "\n")
      (if content
          (if (eq type 'html)
              (elfeed-insert-html content base)
            (insert content))
        (insert (propertize "(empty)\n" 'face 'italic)))
      (goto-char (point-min))))
  )

Emacs-everywhere

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
(use-package! emacs-everywhere
  :if (daemonp)
  :config
  (require 'spell-fu)
  (setq emacs-everywhere-major-mode-function #'org-mode
        emacs-everywhere-frame-name-format "Edit ∷ %s — %s")
  (defadvice! emacs-everywhere-raise-frame ()
    :after #'emacs-everywhere-set-frame-name
    (setq emacs-everywhere-frame-name (format emacs-everywhere-frame-name-format
                                (emacs-everywhere-app-class emacs-everywhere-current-app)
                                (truncate-string-to-width
                                 (emacs-everywhere-app-title emacs-everywhere-current-app)
                                 45 nil nil "…")))
    ;; need to wait till frame refresh happen before really set
    (run-with-timer 0.1 nil #'emacs-everywhere-raise-frame-1))
  (defun emacs-everywhere-raise-frame-1 ()
    (call-process "wmctrl" nil nil nil "-a" emacs-everywhere-frame-name)))

Embrace

1
2
(add-hook 'org-mode-hook 'gcl/embrace-org-mode-hook)
(add-hook 'prog-mode-hook 'gcl/embrace-prog-mode-hook)

Engine-mode

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

(use-package! engine-mode
  :config
  (engine/set-keymap-prefix (kbd "C-c s"))
  ;; (setq engine/browser-function 'eww-browse-url)
  (defengine amazon
    "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=%s"
    :keybinding "a")
  (defengine baidu "https://www.baidu.com/s?wd=%s"
    :keybinding "bb")
  (defengine baidu-image "https://image.baidu.com/search/index?tn=baiduimage&word=%s"
    :keybinding "bi")
  (defengine ctan
    "http://www.ctan.org/search/?x=1&PORTAL=on&phrase=%s"
    :docstring "Search the Comprehensive TeX Archive Network (ctan.org)"
    :keybinding "c")
  (defengine duckduckgo
    "https://duckduckgo.com/?q=%s"
    :keybinding "d")
  (defengine github
    "https://github.com/search?ref=simplesearch&q=%s"
    :keybinding "g")
  (defengine qwant
    "https://www.qwant.com/?q=%s"
    :docstring "什么都能搜到哦~~😍😍"
    :keybinding "q")
  (defengine rfcs
    "http://pretty-rfc.herokuapp.com/search?q=%s"
    :keybinding "r")
  (defengine stack-overflow
    "https://stackoverflow.com/search?q=%s"
    :keybinding "s")
  (defengine twitter
    "https://twitter.com/search?q=%s"
    :keybinding "t")
  (defengine wolfram-alpha
    "http://www.wolframalpha.com/input/?i=%s"
    :docstring "数学搜索引擎,公式,坐标图等。"
    :keybinding "w") ; 数学搜索引擎,公式,坐标图等
  (defengine youtube
    "http://www.youtube.com/results?aq=f&oq=&search_query=%s"
    :keybinding "y")

  (defengine google-images
    "http://www.google.com/images?hl=en&source=hp&biw=1440&bih=795&gbv=2&aq=f&aqi=&aql=&oq=&q=%s"
    :keybinding "/i")
  (defengine google-maps
    "http://maps.google.com/maps?q=%s"
    :docstring "Mappin' it up."
    :keybinding "/m")
  (defengine google
    "http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
    :keybinding "//")

  (engine-mode 1))

Emoji

Evil

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12

;; (defalias 'ex! 'evil-ex-define-cmd)

;; 快捷操作,通过 : 冒号进入 evil 命令模式
;; File operations
;; (ex! "cp"          #'+evil:copy-this-file)
;; (ex! "mv"          #'+evil:move-this-file)
;; (ex! "rm"          #'+evil:delete-this-file)

;; window 操作
(setq evil-split-window-below t
      evil-vsplit-window-right t)

Flycheck

使用项目本身的 eslint, node_modules/.bin/eslint

1
2
3
4
(use-package! flycheck
    :config
    (add-hook 'after-init-hook 'global-flycheck-mode)
    (add-hook 'flycheck-mode-hook 'gcl/use-eslint-from-node-modules))

(Ma)git

1
2
3
(use-package! git-gutter
  :config
  (global-git-gutter-mode 't))

Hungry-delete

1
2
3
4
(use-package! hungry-delete
  :config
  (add-hook! 'after-init-hook #'global-hungry-delete-mode)
  (global-hungry-delete-mode 1))

Hydra

scimax-hydra.el

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(map! :map dired-mode-map
      "<f2>"    #'gcl-dired/body
      :map ranger-mode-map
      "<f2>"    #'gcl-dired/body
      :map org-agenda-mode-map
      "<f2>"    #'gcl-agenda-view/body
      :map web-mode-map
      "<f2>"    #'hydra-web-mode/body
      )

(defhydra gcl-jump-hydra (:color blue :columns 3 :hint nil)
  "Jump -> Body"
  ("a" gcl-agenda-view/body "Org-Agenda")
  ("c" gcl-jump-char/body "Char Jump")
  ("l" gcl-jump-line/body "Line Jump")
  ("w" gcl-jump-word/body "Word Jump")

  )

(defhydra gcl-repl-hydra (:color blue :columns 3 :hint nil)
  "REPL "
  ("e" ielm " ELisp")
  ("h" httprepl " HTTP")
  ("j" jq-interactivly " JSON")
  ("l" +lua/open-repl " Lua")
  ("n" nodejs-repl " Node.js")
  ("p" +python/open-repl " Python")
  ("s" skewer-repl " Skewer")
  )



(defhydra gcl-everything (:color blue :columns 3 :hint nil)
  "🗯 做任何你想不到的事情~~~~ 👁👁👁👁👁👁👁👁👁
🌻"
  ("j" gcl-jump-hydra/body "Avy")
  ("r" gcl-repl-hydra/body "REPL")
  ("v" gcl-verb-hydra/body "Verb")
  )

Avy

Char:

1
2
3
4
5
6
7
8
9
(defhydra gcl-jump-char (:color blue :columns 3 :hint nil)
  "Jump By Char ->"
  ("c" avy-goto-char "Char")
  ("l" avy-goto-char-in-line "In line")
  ("t" avy-goto-char-timer "Timer")
  ("2" avy-goto-char-2 "Char2")
  ("a" avy-goto-char-2-above "Above")
  ("b" avy-goto-char-2-below "Below")
  )

Line:

1
2
3
4
5
6
7
(defhydra gcl-jump-line (:color blue :columns 3 :hint nil)
  "Jump To Line ->"
  ("u" avy-goto-line-above "Above")
  ("d" avy-goto-line-below "Below")
  ("s" avy-goto-line "Line Start")
  ("e" avy-goto-end-of-line "Line End")
  )

Word:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(defhydra gcl-jump-word (:color blue :columns 3 :hint nil)
  "Jump By Word ->"
  ("l" avy-jump-to-word-in-line "in line")
  ("w" avy-goto-word-1 "word1")
  ("0" avy-goto-word-0 "word0")
  ("a" avy-goto-word-0-above "above-0")
  ("A" avy-goto-word-1-above "above-1")
  ("b" avy-goto-word-0-below "below0")
  ("B" avy-goto-word-1-below "below1")
  ("o" avy-goto-word-or-subword-1 "word or subword")
  ("s" avy-subword-0 "subword-0")
  ("S" avy-subword-1 "subword-1")
  )

Dired

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(defhydra gcl-dired (:color blue :hint nil)
  "
Mark              Operate         Misc              Navigate
----              -------         ----              --------
_fd_: flag del    _C_: copy       _+_: mkdir        _<up>_: up directory
_f#_: autosave    _R_: rename     _o_: open other
_f~_: backups     _D_: delete
_f&_: garbage     _F_: open marks
_fe_: extension
----
_m_: mark         _T_: touch
_/_: directories  _M_: chmod
_@_: symlinks     _G_: chgrp
_O_: omitted      _O_: chown
----
_U_: unmark all   _A_: find regx
_t_: toggle marks _Q_: find/rep
"
    ;; marking
  ("t" dired-toggle-marks)
  ("m" dired-mark :exit nil)
  ("u" dired-unmark :exit nil)
  ("fd" dired-flag-file-deletion)
  ("f#" dired-flag-auto-save-files)
  ("f~" dired-flag-backup-files)
  ("f&" dired-flag-garbage-files)
  ("fe" dired-flag-extension)
  ("/" dired-mark-directories)
  ("@" dired-mark-symlinks)
  ("." dired-mark-extension)
  ("O" dired-mark-omitted)
  ("U" dired-unmark-all-marks)

  ("C" dired-do-copy)
  ("R" dired-do-rename)
  ("D" dired-do-delete :exit nil)
  ("F" dired-do-find-marked-files)
  ("!" dired-do-shell-command)
  ("&" dired-do-async-shell-command)

  ("T" dired-do-touch)
  ("M" dired-do-chmod)
  ("G" dired-do-chgrp)
  ("O" dired-do-chown)

  ("A" dired-do-find-regexp)
  ("Q" dired-do-find-regexp-and-replace)

  ("+" dired-create-directory)
  ("o" dired-find-file-other-window)

  ("<up>" dired-up-directory)
  )

Movement

1
2
3
4
5
(defhydra hydra-movement ()
  ("j" next-line "down" :column "Vertical")
  ("k" previous-line "up")
  ("l" forward-char "forward" :column "Horizontal")
  ("h" backward-char "back"))

Org-agenda

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(defun org-agenda-cts ()
  (and (eq major-mode 'org-agenda-mode)
       (let ((args (get-text-property
                    (min (1- (point-max)) (point))
                    'org-last-args)))
         (nth 2 args))))

(defhydra gcl-agenda-view (:color blue :columns 3 :hint none)
    "
_d_: ?d? day        _g_: time grid=?g?  _a_: arch-trees
_w_: ?w? week       _[_: inactive       _A_: arch-files
_t_: ?t? fortnight  _f_: follow=?f?     _r_: clock report=?r?
_m_: ?m? month      _e_: entry text=?e? _D_: include diary=?D?
_y_: ?y? year       _q_: quit           _L__l__c_: log = ?l?"
    ("SPC" org-agenda-reset-view)
  ("d" org-agenda-day-view (if (eq 'day (org-agenda-cts)) "[x]" "[ ]"))
  ("w" org-agenda-week-view (if (eq 'week (org-agenda-cts)) "[x]" "[ ]"))
  ("t" org-agenda-fortnight-view (if (eq 'fortnight (org-agenda-cts)) "[x]" "[ ]"))
  ("m" org-agenda-month-view (if (eq 'month (org-agenda-cts)) "[x]" "[ ]"))
  ("y" org-agenda-year-view (if (eq 'year (org-agenda-cts)) "[x]" "[ ]"))
  ("l" org-agenda-log-mode (format "% -3S" org-agenda-show-log))
  ("L" (org-agenda-log-mode '(4)))
  ("c" (org-agenda-log-mode 'clockcheck))
  ("f" org-agenda-follow-mode (format "% -3S" org-agenda-follow-mode))
  ("a" org-agenda-archives-mode)
  ("A" (org-agenda-archives-mode 'files))
  ("r" org-agenda-clockreport-mode (format "% -3S" org-agenda-clockreport-mode))
  ("e" org-agenda-entry-text-mode (format "% -3S" org-agenda-entry-text-mode))
  ("g" org-agenda-toggle-time-grid (format "% -3S" org-agenda-use-time-grid))
  ("D" org-agenda-toggle-diary (format "% -3S" org-agenda-include-diary))
  ("!" org-agenda-toggle-deadlines)
  ("[" (let ((org-agenda-include-inactive-timestamps t))
         (org-agenda-check-type t 'timeline 'agenda)
         (org-agenda-redo)
         (message "Display now includes inactive timestamps as well")))
  ("q" (message "Abort") :exit t)
  ("v" nil)
  )

Verb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
(defhydra gcl-verb-hydra (:colors yellow :columns 3 :hint nil)
  ("r" verb-send-request-on-point-other-window-stay "Send Focus")
  ("s" verb-send-request-on-point-other-window "Send Blur")
  ("f" verb-send-request-on-point "Fullscreen")
  ("m" verb-send-request-on-point-no-window "No Window")
  ("K" verb-kill-all-response-buffers "Kill All")

  ("vl" verb-show-vars "Show Vars")
  ("vl" verb-set-var "Set Var")
  ("vu" verb-unset-vars "Unset Vars")

  ("ec" verb-export-request-on-point-curl "Export Curl")
  ("ev" verb-export-request-on-point-verb "Export Verb")
  ("ew" verb-export-request-on-point-verb "Export EWW")
  )

Imenu

1
(global-set-key (kbd "C-'") 'imenu-list-smart-toggle)

JS Doc

1
2
3
4
5
6
7
8
9
(use-package! js-doc
  :bind (:map js2-mode-map
         ("C-c i" . js-doc-insert-function-doc)
         ("@" . js-doc-insert-tag))
  :config
  (setq js-doc-mail-address user-mail-address
       js-doc-author (format "%s<%s>" user-full-name js-doc-mail-address)
       js-doc-url user-blog-url
       js-doc-license "MIT"))

Leetcode

1
2
3
4
5
(after! leetcode
  (setq leetcode-prefer-language "javascript"
        leetcode-prefer-sql "mysql"
        leetcode-save-solutions t
        leetcode-directory "~/github/make-leetcode"))

Link-hint

1
2
3
4
5
6
7
;; (use-package! link-hint
;;   :config
;;   (setq
;;    browse-url-browser-function 'browse-url
;;    ;; browse-url-generic-args '("--target" "tab")
;;    )
;;   )

Lsp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(use-package! lsp-mode
  :hook ((web-mode . lsp)
         (rjsx-mode . lsp)
         (typescript-mode . lsp)
         ;; (vue-mode . lsp)
         (python-mode . lsp)
         (go-mode . lsp)
         (css-mode . lsp)
         (js2-mode . lsp)
         (bibtex-mode . lsp)
         (tex-mode . lsp)
         (latex-mode . lsp))
  :commands lsp
  :config
  (setq lsp-idle-delay 0.2
        lsp-enable-file-watchers nil))

(use-package! lsp-ui
  :commands lsp-ui-mode
  :config
  (setq lsp-headerline-breadcrumb-enable t ; 左上角显示文件路径
        lsp-lens-enable t                  ; 显示被引用次数
        )
  :bind (:map lsp-ui-mode-map
         ([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
         ([remap xref-find-references] . lsp-ui-peek-find-references)
         ([remap xref-pop-marker-stack] . lsp-ui-peek-jump-backward)
         ))

;; 关闭自动格式化,全局关闭
;; (setq +form-with-lsp nil)
;; 指定模式
;; (setq-hook! 'typescript-mode-hook +format-with-lsp nil)
;; (setq-hook! 'typescript-tsx-mode-hook +format-with-lsp nil)

open Lsp in org source block:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(cl-defmacro lsp-org-babel-enable (lang)
  "Support LANG in org source code block."
  (setq centaur-lsp 'lsp-mode)
  (cl-check-type lang stringp)
  (let* ((edit-pre (intern (format "org-babel-edit-prep:%s" lang)))
         (intern-pre (intern (format "lsp--%s" (symbol-name edit-pre)))))
    `(progn
       (defun ,intern-pre (info)
         (let ((file-name (->> info caddr (alist-get :file))))
           (unless file-name
             (setq file-name (make-temp-file "babel-lsp-")))
           (setq buffer-file-name file-name)
           (lsp-deferred)))
       (put ',intern-pre 'function-documentation
            (format "Enable lsp-mode in the buffer of org source block (%s)."
                    (upcase ,lang)))
       (if (fboundp ',edit-pre)
           (advice-add ',edit-pre :after ',intern-pre)
         (progn
           (defun ,edit-pre (info)
             (,intern-pre info))
           (put ',edit-pre 'function-documentation
                (format "Prepare local buffer environment for org source block (%s)."
                        (upcase ,lang))))))))
(defvar org-babel-lang-list
  '("go" "python" "ipython" "bash" "sh" "js" "typescript" "css"))
(dolist (lang org-babel-lang-list)
  (eval `(lsp-org-babel-enable ,lang)))

Markdown

Grip-mode

issue: Error (after-save-hook): Error running hook "grip-org-to-md" because: (void-variable vc-log-view-type)

1
2
3
4
5
;; (use-package! grip-mode
;;   :hook ((markdown-mode org-mode) . grip-mode)
;;   :config
;;   (setq grip-github-user "gcclll"
;;         grip-github-password "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"))

Pandoc-mode

1
2
3
4
5
(use-package! pandoc-mode
  :after (markdown-mode org-mode)
  :hook
  (markdown-mode org-mode)
  (pandoc-mode . pandoc-load-default-settings))

Vmd-mode

1
2
3
4
(use-package! vmd-mode
  :after markdown-mode
  :bind
  (:map markdown-mode-map ("C-x p" . vmd-mode)))

Maple-iedit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 (use-package! maple-iedit
    :commands (maple-iedit-match-all maple-iedit-match-next maple-iedit-match-previous)
    :config
    (delete-selection-mode t)
    (setq maple-iedit-ignore-case t)
    (defhydra maple/iedit ()
      ("n" maple-iedit-match-next "next")
      ("t" maple-iedit-skip-and-match-next "skip and next")
      ("T" maple-iedit-skip-and-match-previous "skip and previous")
      ("p" maple-iedit-match-previous "prev"))
    :bind (:map evil-visual-state-map
           ("n" . maple/iedit/body)
           ("C-n" . maple-iedit-match-next)
           ("C-p" . maple-iedit-match-previous)
           ("C-t" . map-iedit-skip-and-match-next)
           ("C-T" . map-iedit-skip-and-match-previous)))

Mu4e

README.org ->

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(add-to-list 'load-path "/usr/local/Cellar/mu/1.6.2/share/emacs/site-lisp/mu/mu4e")
(setq
 ;; sendmail-program "/usr/local/bin/msmtp"
 ;; sendmail-program "/usr/sbin/sendmail"
 send-mail-function #'sendmail-send-it
 ;; message-sendmail-f-is-evil t
 ;; message-sendmail-extra-arguments '("--read-envelope-from")
 message-send-mail-function #'message-send-mail-with-sendmail
 mu4e-view-auto-mark-as-read t
 ;; starttls-use-gnutls t
 ;; smtpmail-starttls-credentials '(("smtp.1and1.com" 587 nil nil))
 mu4e-get-mail-command "mbsync -a"
 ;; +mu4e-backend 'offlineimap
 mu4e-maildir "~/Mail"
 mu4e-html2text-command "/usr/local/bin/w3m -T text/html"
 )
(after! mu4e
  (set-email-account!
   "gmail" '((user-mail-address    . "gccll.love@gmail.com")
            (user-full-name       . "gccll.love")
            (smtpmail-smtp-user   . "gccll.love@gmail.com")
            (smtpmail-default-smtp-server   . "smtp.gmail.com")
            (smtpmail-smtp-server           . "smtp.gmail.com")
            (smtpmail-smtp-service          . 587)

            ;; Optional
            (mu4e-sent-folder     . "/gmail/sent")
            (mu4e-drafts-folder   . "/gmail/drafts")
            (mu4e-trash-folder    . "/gmail/trash")
            (mu4e-refile-folder   . "/gmail/all")
            (mu4e-get-mail-command    . "mbsync gmail")
            (mu4e-compose-signature   . "--\n World is yours, Yours is mine!")
            )
   )
  (set-email-account!
   "qq" '((user-mail-address    . "604522194@qq.com")
          (user-full-name       . "Li ZhiCheng")
          (smtpmail-smtp-user   . "604522194@qq.com")
          (smtpmail-default-smtp-server   . "smtp.qq.com")
          (smtpmail-smtp-server           . "smtp.qq.com")
          (smtpmail-smtp-service          . 587)

          ;; Optional
          (mu4e-sent-folder     . "/qq/sent")
          (mu4e-drafts-folder   . "/qq/drafts")
          (mu4e-trash-folder    . "/qq/trash")
          (mu4e-refile-folder   . "/qq/all")
          (mu4e-get-mail-command    . "mbsync qq")
          (mu4e-compose-signature   . "--\n Li ZhiCheng")
          )
   )
  (set-email-account!
   "sunlight" '((user-mail-address    . "simon.li@sunlight-tech.com")
                (user-full-name       . "Li ZhiCheng")
                (smtpmail-smtp-user   . "simon.li@sunlight-tech.com")
                (smtpmail-default-smtp-server   . "smtp.exmail.qq.com")
                (smtpmail-smtp-server           . "smtp.exmail.qq.com")
                (smtpmail-smtp-service          . 587)
                ;; Optional
                (mu4e-sent-folder     . "/sunlight/sent")
                (mu4e-drafts-folder   . "/sunlight/drafts")
                (mu4e-trash-folder    . "/sunlight/trash")
                (mu4e-refile-folder   . "/sunlight/all")
                (mu4e-get-mail-command    . "mbsync sunlight")
                (mu4e-compose-signature   . "
-----
[[http://qiniu.ii6g.com/img/20210811090513.png]]

李志诚   研发部

166 7554 1616

深圳市盛阳科技股份有限公司 | 智慧酒店服务平台运营商

www.sunlight-tech.com

地址 / 深圳市南山区科技南路16号深圳湾科技生态园11栋A座31层盛阳科技

电话 / 0755-26614499  传真 / 0755-26617699
")
                )
   t)
  )

Keybindings

keydesc
mark
?mark unread
Ddelete
uremove mark
Uremove all marks
xexecute
Rcompose reply at point
Enterread email at point
qquit
C-c C-csend email
C-c C-aadd attachment
C-c C-epreview
C-x mcompose mail

Mu4e-alert

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
(use-package! mu4e-alert
  :after mu4e
  :init
  (setq mu4e-alert-interesting-mail-query
    (concat
     "flag:unread maildir:/sunlight/inbox "
     "OR "
     "flag:unread maildir:/qq/inbox"
     ))
  (mu4e-alert-enable-mode-line-display)
  (defun gcl/refresh-mu4e-alert-mode-line ()
    (interactive)
    (mu4e~proc-kill)
    (mu4e-alert-enable-mode-line-display)
    )
  (run-with-timer 0 60 'gcl/refresh-mu4e-alert-mode-line)
  )

Net-utils

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(use-package! net-utils
  :bind
  (:map mode-specific-map
        :prefix-map net-utils-prefix-map ; C-c n x
        :prefix "n"
        ("p" . ping)
        ("i" . ifconfig)
        ("w" . iwconfig)
        ("n" . netstat)
        ("p" . ping)
        ("a" . arp)
        ("r" . route)
        ("h" . nslookup-host)
        ("d" . dig)
        ("s" . smbclient)
        ("t" . traceroute)))

(use-package! browse-at-remote
  :config
  (setq
   browse-at-remote-remote-type-domains '(("bitbucket.org" . "bitbucket")
                                          ("github.com" . "github")
                                          ("gitlab.com" . "gitlab")
                                          ("git.savannah.gnu.org" . "gnu")
                                          ("gist.github.com" . "gist")
                                          ("git.sr.ht" . "sourcehut")
                                          ("vs-ssh.visualstudio.com" . "ado")
                                          ("pagure.io" . "pagure")
                                          ("src.fedoraproject.org" . "pagure")
                                          ("code.aliyun.com" . "aliyun")
                                          )
))

Org-mode

Basic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
;; (org-hide-emphasis-markers t)
(setq org-list-demote-modify-bullet
      '(("+" . "-")
        ("-" . "+")
        ("*" . "+")
        ("1." . "a.")))


;; (use-package! org
;;   :hook (
;;          ;; (verb-mode . org-mode)
;;          (+org-pretty-mode . org-mode)))

(after! org
  (add-hook 'org-mode-hook (lambda () (visual-line-mode -1)))

  (org-babel-do-load-languages 'org-babel-load-languages
                             (append org-babel-load-languages
                              '((restclient . t)
                                (verb . t)
                                (deno . t))
                              ))

  (setq
   org-todo-keywords
   '((sequence "TODO(t)" "PROJECT(p)" "NEXT(n)" "WAIT(w)" "HOLD(h)" "IDEA(i)" "SOMEDAY(s)" "MAYBE(m)" "|" "DONE(d)" "CANCELLED(c)")
     (sequence "[ ](T)" "[-](S)" "[?](W)" "|" "[X](D)")
     ;; (sequence "|" "OKAY(o)" "YES(y)" "NO(x)")
     )
   org-todo-keyword-faces `(("NEXT" . ,(doom-color 'green))
                            ("TODO" . ,(doom-color 'yellow))
                            ("PROJECT" . ,(doom-color 'tan))
                            ("WAIT" . ,(doom-color 'teal))
                            ("HOLD" . ,(doom-color 'red))
                            ("IDEA" . ,(doom-color 'tomato))
                            ;; ("OKAY" . ,(doom-color 'cyan))
                            ;; ,(if (eq doom-theme 'doom-vibrant)
                                 ;; (cons "OKAY" (doom-color 'base7))
                               ;; (cons "OKAY" (doom-color 'base5)))
                            ;; ("YES" . ,(doom-color 'blue))
                            ("SOMEDAY" . ,(doom-color 'base7))
                            ("MAYBE" . ,(doom-color 'base5))
                            ("[ ]" . ,(doom-color 'green))
                            ("[-]" . ,(doom-color 'yellow))
                            ("[?]" . ,(doom-color 'red))
                            )
   ;; org-enforce-todo-dependencies nil ;; if t, it hides todo entries with todo children from agenda
   ;; org-enforce-todo-checkbox-dependencies nil
   org-provide-todo-statistics t
   org-pretty-entities t
   org-hierarchical-todo-statistics t

   ;; org-startup-with-inline-images t
   org-hide-emphasis-markers t
   ;; org-fontify-whole-heading-line nil
   org-src-fontify-natively t
   org-imenu-depth 9

   org-use-property-inheritance t

   org-log-done 'time
   org-log-redeadline 'time
   org-log-reschedule 'time
   org-log-into-drawer "LOGBOOK"
   ;; org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA"
   )
  )

counsel-org-clock

1
2
3
4
5
6
(use-package! counsel-org-clock
  :commands (counsel-org-clock-context
             counsel-org-clock-history
             counsel-org-clock-goto)
  :config
  (setq counsel-org-clock-history-limit 20))

engrave-faces-latex

1
2
(use-package! engrave-faces-latex
  :after ox-latex)

valign

1
2
3
4
5
(use-package! valign
  :custom
  (valign-fancy-bar t)
  :hook
  (org-mode . valign-mode))

Verb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
;; (setq verb-base-headers '(("User-Agent" . "my-user-agent")))

;; unused: b,d,f,g,j,k,m,n,o,p,r,t,u,v,w,x,y,z
(use-package! verb
  :after org
  :config
  (setq
   tempo-template-org-verb '("#+begin_src verb :wrap src ob-verb-response"
                             nil '> n p n
                             "#+end_src" >)
   verb-auto-kill-response-buffers t)
  )
1
get https://api.ipify.org/?format=json

Demos

org-clock

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(after! org-clock
  (advice-add #'org-clock-in :after (lambda (&rest _)
                                      "Save all opened org-mode files."
                                      (org-save-all-org-buffers)))
  (advice-add #'org-clock-out :after (lambda (&rest _)
                                       "Save all opened org-mode files."
                                       (org-save-all-org-buffers)))
  (advice-add #'org-clock-load :around #'doom-shut-up-a)
  (advice-add #'org-clock-report :after (lambda (&rest _)
                                          "Save all opened org-mode files."
                                          (org-save-all-org-buffers)))
  (advice-add #'org-clock-goto :after (lambda (&rest _)
                                        "Narrow view after switching."
                                        (interactive)
                                        (widen)
                                        (+org-narrow-and-show)))

  (doom-store-persist "custom" '(org-clock-out-time))
  (setq
   org-clock-clocked-in-display nil
   org-clock-history-length 50
   org-clock-in-resume t
   org-clock-out-remove-zero-time-clocks t
   org-clock-persist t
   org-clock-persist-query-resume nil
   org-clock-report-include-clocking-task t
   )
  )

org-chef

1
2
(use-package! org-chef
  :commands (org-chef-insert-recipe org-chef-get-recipe-from-url))

org-appear

1
2
3
4
5
6
7
(use-package! org-appear
  :hook (org-mode . org-appear-mode)
  :config
  (setq org-appear-autoemphasis t
        org-appear-autosubmarkers t
        org-appear-autolinks nil)
  )

org-fancy-priorities

1
2
3
4
5
6
(use-package! org-fancy-priorities
    :diminish
    :hook (org-mode . org-fancy-priorities-mode)
    :config
    (setq org-fancy-priorities-list
          '("🅰" "🅱" "🅲" "🅳" "🅴")))

org-fragtog

1
(add-hook 'org-mode-hook 'org-fragtog-mode)

ox-gfm

1
(use-package! ox-gfm :after org)

org-pandoc-import

1
(use-package! org-pandoc-import :after org)

org-ol-tree 目录树

1
2
3
4
5
6
7
(use-package! org-ol-tree
  :commands org-ol-tree)

(map! :map org-mode-map
    :after org
    :localleader
    :desc "Outline" "O" #'org-ol-tree)

org-pretty-capture

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
(defun org-capture-select-template-prettier (&optional keys)
  "Select a capture template, in a prettier way than default
Lisp programs can force the template by setting KEYS to a string."
  (let ((org-capture-templates
         (or (org-contextualize-keys
              (org-capture-upgrade-templates org-capture-templates)
              org-capture-templates-contexts)
             '(("t" "Task" entry (file+headline "" "Tasks")
                "* TODO %?\n  %u\n  %a")))))
    (if keys
        (or (assoc keys org-capture-templates)
            (error "No capture template referred to by \"%s\" keys" keys))
      (org-mks org-capture-templates
               "Select a capture template\n━━━━━━━━━━━━━━━━━━━━━━━━━"
               "Template key: "
               `(("q" ,(concat (all-the-icons-octicon "stop" :face 'all-the-icons-red :v-adjust 0.01) "\tAbort")))))))
(advice-add 'org-capture-select-template :override #'org-capture-select-template-prettier)

(defun org-mks-pretty (table title &optional prompt specials)
  "Select a member of an alist with multiple keys. Prettified.

TABLE is the alist which should contain entries where the car is a string.
There should be two types of entries.

1. prefix descriptions like (\"a\" \"Description\")
   This indicates that `a' is a prefix key for multi-letter selection, and
   that there are entries following with keys like \"ab\", \"ax\"…

2. Select-able members must have more than two elements, with the first
   being the string of keys that lead to selecting it, and the second a
   short description string of the item.

The command will then make a temporary buffer listing all entries
that can be selected with a single key, and all the single key
prefixes.  When you press the key for a single-letter entry, it is selected.
When you press a prefix key, the commands (and maybe further prefixes)
under this key will be shown and offered for selection.

TITLE will be placed over the selection in the temporary buffer,
PROMPT will be used when prompting for a key.  SPECIALS is an
alist with (\"key\" \"description\") entries.  When one of these
is selected, only the bare key is returned."
  (save-window-excursion
    (let ((inhibit-quit t)
          (buffer (org-switch-to-buffer-other-window "*Org Select*"))
          (prompt (or prompt "Select: "))
          case-fold-search
          current)
      (unwind-protect
          (catch 'exit
            (while t
              (setq-local evil-normal-state-cursor (list nil))
              (erase-buffer)
              (insert title "\n\n")
              (let ((des-keys nil)
                    (allowed-keys '("\C-g"))
                    (tab-alternatives '("\s" "\t" "\r"))
                    (cursor-type nil))
                ;; Populate allowed keys and descriptions keys
                ;; available with CURRENT selector.
                (let ((re (format "\\`%s\\(.\\)\\'"
                                  (if current (regexp-quote current) "")))
                      (prefix (if current (concat current " ") "")))
                  (dolist (entry table)
                    (pcase entry
                      ;; Description.
                      (`(,(and key (pred (string-match re))) ,desc)
                       (let ((k (match-string 1 key)))
                         (push k des-keys)
                         ;; Keys ending in tab, space or RET are equivalent.
                         (if (member k tab-alternatives)
                             (push "\t" allowed-keys)
                           (push k allowed-keys))
                         (insert (propertize prefix 'face 'font-lock-comment-face) (propertize k 'face 'bold) (propertize "›" 'face 'font-lock-comment-face) "  " desc "…" "\n")))
                      ;; Usable entry.
                      (`(,(and key (pred (string-match re))) ,desc . ,_)
                       (let ((k (match-string 1 key)))
                         (insert (propertize prefix 'face 'font-lock-comment-face) (propertize k 'face 'bold) "   " desc "\n")
                         (push k allowed-keys)))
                      (_ nil))))
                ;; Insert special entries, if any.
                (when specials
                  (insert "─────────────────────────\n")
                  (pcase-dolist (`(,key ,description) specials)
                    (insert (format "%s   %s\n" (propertize key 'face '(bold all-the-icons-red)) description))
                    (push key allowed-keys)))
                ;; Display UI and let user select an entry or
                ;; a sub-level prefix.
                (goto-char (point-min))
                (unless (pos-visible-in-window-p (point-max))
                  (org-fit-window-to-buffer))
                (let ((pressed (org--mks-read-key allowed-keys
                                                  prompt
                                                  (not (pos-visible-in-window-p (1- (point-max)))))))
                  (setq current (concat current pressed))
                  (cond
                   ((equal pressed "\C-g") (user-error "Abort"))
                   ;; Selection is a prefix: open a new menu.
                   ((member pressed des-keys))
                   ;; Selection matches an association: return it.
                   ((let ((entry (assoc current table)))
                      (and entry (throw 'exit entry))))
                   ;; Selection matches a special entry: return the
                   ;; selection prefix.
                   ((assoc current specials) (throw 'exit current))
                   (t (error "No entry available")))))))
        (when buffer (kill-buffer buffer))))))
(advice-add 'org-mks :override #'org-mks-pretty)

org-capture

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
(use-package! doct
  :commands (doct))

(after! org-capture

  (defun +doct-icon-declaration-to-icon (declaration)
    "Convert :icon declaration to icon"
    (let ((name (pop declaration))
          (set  (intern (concat "all-the-icons-" (plist-get declaration :set))))
          (face (intern (concat "all-the-icons-" (plist-get declaration :color))))
          (v-adjust (or (plist-get declaration :v-adjust) 0.01)))
      (apply set `(,name :face ,face :v-adjust ,v-adjust))))

  (defun +doct-iconify-capture-templates (groups)
    "Add declaration's :icon to each template group in GROUPS."
    (let ((templates (doct-flatten-lists-in groups)))
      (setq doct-templates (mapcar (lambda (template)
                                     (when-let* ((props (nthcdr (if (= (length template) 4) 2 5) template))
                                                 (spec (plist-get (plist-get props :doct) :icon)))
                                       (setf (nth 1 template) (concat (+doct-icon-declaration-to-icon spec)
                                                                      "\t"
                                                                      (nth 1 template))))
                                     template)
                                   templates))))

  (setq doct-after-conversion-functions '(+doct-iconify-capture-templates))

  (defvar +org-capture-recipies  "~/.gclrc/org/recipies.org")

  (defun set-org-capture-templates ()
    (setq org-capture-templates
          (doct `(("Personal todo" :keys "t"
                   :icon ("checklist" :set "octicon" :color "green")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Inbox"
                   :type entry
                   :template ("* TODO %?"
                              "%i %a")
                   )
                  ("Personal note" :keys "n"
                   :icon ("sticky-note-o" :set "faicon" :color "green")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Notes"
                   :type entry
                   :template ("* %?"
                              "%i %a"))
                  ("Emacs" :keys "e"
                   :icon ("emacs" :set "fileicon" :color "purple")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Emacs"
                   :type entry
                   :template ("* TODO %? :emacs:"
                              "%i %a"))
                  ("Email" :keys "E"
                   :icon ("envelope" :set "faicon" :color "blue")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Inbox"
                   :type entry
                   :template ("* TODO %^{type|reply to|contact} %\\3 %? ✉️"
                              "Send an email %^{urgancy|soon|ASAP|anon|at some point|eventually} to %^{recipiant}"
                              "about %^{topic}"
                              "%U %i %a"))
                  ("Web" :keys "w"
                   :icon ("web" :set "material" :color "yellow")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Web"
                   :type entry
                   :template ("* TODO %{desc}%? :%{i-type}:"
                              "%i %a")
                   :children (("Vue" :keys "v"
                               :icon ("vue" :set "fileicon" :color "green")
                               :desc ""
                               :headline "Vue"
                               :i-type "web:vue")
                              ("React" :keys "r"
                               :icon ("react" :set "alltheicon" :color "blue")
                               :desc ""
                               :headline "React"
                               :i-type "web:react"
                               )
                              ("JavaScript" :keys "j"
                               :icon ("javascript-shield" :set "alltheicon" :color "yellow")
                               :desc ""
                               :i-type "web:javascript"
                               )
                              ("HTML" :keys "h"
                               :icon ("html5" :set "alltheicon" :color "orange")
                               :desc ""
                               :i-type "web:html"
                               )
                              ("CSS" :keys "c"
                               :icon ("css3" :set "alltheicon" :color "blue")
                               :desc ""
                               :i-type "web:css"
                               ))
                   )
                  ("Interesting" :keys "i"
                   :icon ("eye" :set "faicon" :color "lcyan")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Interesting"
                   :type entry
                   :template ("* [ ] %{desc}%? :%{i-type}:"
                              "%i %a")
                   :children (("Webpage" :keys "w"
                               :icon ("globe" :set "faicon" :color "green")
                               :desc "%(org-cliplink-capture) "
                               :i-type "read:web"
                               )
                              ("Links" :keys "l"
                               :icon ("link" :set "octicon" :color "blue")
                               :desc "%(org-cliplink-capture) "
                               :i-type "link:web"
                               )
                              ("Article" :keys "a"
                               :icon ("file-text" :set "octicon" :color "yellow")
                               :desc ""
                               :i-type "read:reaserch"
                               )
                              ("\tRecipie" :keys "r"
                               :icon ("spoon" :set "faicon" :color "dorange")
                               :file +org-capture-recipies
                               :headline "Unsorted"
                               :template "%(org-chef-get-recipe-from-url)"
                               )
                              ("Information" :keys "i"
                               :icon ("info-circle" :set "faicon" :color "blue")
                               :desc ""
                               :i-type "read:info"
                               )
                              ("Idea" :keys "I"
                               :icon ("bubble_chart" :set "material" :color "silver")
                               :desc ""
                               :i-type "idea"
                               )))
                  ("Tasks" :keys "k"
                   :icon ("inbox" :set "octicon" :color "yellow")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Tasks"
                   :type entry
                   :template ("* TODO %? %^G%{extra}"
                              "%i %a")
                   :children (("General Task" :keys "k"
                               :icon ("inbox" :set "octicon" :color "yellow")
                               :extra ""
                               )
                              ("Task with deadline" :keys "d"
                               :icon ("timer" :set "material" :color "orange" :v-adjust -0.1)
                               :extra "\nDEADLINE: %^{Deadline:}t"
                               )
                              ("Scheduled Task" :keys "s"
                               :icon ("calendar" :set "octicon" :color "orange")
                               :extra "\nSCHEDULED: %^{Start time:}t"
                               )
                              ))
                  ("Project" :keys "p"
                   :icon ("repo" :set "octicon" :color "silver")
                   :prepend t
                   :type entry
                   :headline "Inbox"
                   :template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")
                   :file ""
                   :custom (:time-or-todo "")
                   :children (("Project-local todo" :keys "t"
                               :icon ("checklist" :set "octicon" :color "green")
                               :time-or-todo "TODO"
                               :file +org-capture-project-todo-file)
                              ("Project-local note" :keys "n"
                               :icon ("sticky-note" :set "faicon" :color "yellow")
                               :time-or-todo "%U"
                               :file +org-capture-project-notes-file)
                              ("Project-local changelog" :keys "c"
                               :icon ("list" :set "faicon" :color "blue")
                               :time-or-todo "%U"
                               :heading "Unreleased"
                               :file +org-capture-project-changelog-file))
                   )
                  ("\tCentralised project templates"
                   :icon ("ionic-project" :set "fileicon" :color "cyan")
                   :keys "o"
                   :type entry
                   :prepend t
                   :template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")
                   :children (("Project todo"
                               :keys "t"
                               :prepend nil
                               :time-or-todo "TODO"
                               :heading "Tasks"
                               :file +org-capture-central-project-todo-file)
                              ("Project note"
                               :keys "n"
                               :time-or-todo "%U"
                               :heading "Notes"
                               :file +org-capture-central-project-notes-file)
                              ("Project changelog"
                               :keys "c"
                               :time-or-todo "%U"
                               :heading "Unreleased"
                               :file +org-capture-central-project-changelog-file))
                   )))))

  (set-org-capture-templates)
  (unless (display-graphic-p)
    (add-hook 'server-after-make-frame-hook
              (defun org-capture-reinitialise-hook ()
                (when (display-graphic-p)
                  (set-org-capture-templates)
                  (remove-hook 'server-after-make-frame-hook
                               #'org-capture-reinitialise-hook))))))

org-capture bin

1
2
3
4
5
6
7
(setf (alist-get 'height +org-capture-frame-parameters) 15)
;; (alist-get 'name +org-capture-frame-parameters) "❖ Capture") ;; ATM hardcoded in other places, so changing breaks stuff
(setq +org-capture-fn
      (lambda ()
        (interactive)
        (set-window-parameter nil 'mode-line-format 'none)
        (org-capture)))

org-agenda

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(after! org-agenda
  (advice-add #'org-agenda-archive :after #'org-save-all-org-buffers)
  (advice-add #'org-agenda-archive-default :after #'org-save-all-org-buffers)
  (advice-add #'org-agenda-refile :after (lambda (&rest _)
                                           "Refresh view."
                                           (if (string-match "Org QL" (buffer-name))
                                               (org-ql-view-refresh)
                                             (org-agenda-redo))))
  (advice-add #'org-agenda-redo :around #'doom-shut-up-a)
  (advice-add #'org-agenda-set-effort :after #'org-save-all-org-buffers)
  (advice-add #'org-schedule :after (lambda (&rest _)
                                      (org-save-all-org-buffers)))
  (advice-add #'org-deadline :after (lambda (&rest _)
                                      (org-save-all-org-buffers)))
  (advice-add #'+org-change-title :after (lambda (&rest _)
                                           (org-save-all-org-buffers)))
  (advice-add #'org-cut-special :after #'org-save-all-org-buffers)
  (advice-add #'counsel-org-tag :after #'org-save-all-org-buffers)
  (advice-add #'org-agenda-todo :after #'aj-org-agenda-save-and-refresh-a)
  (advice-add #'org-todo :after (lambda (&rest _)
                                  (org-save-all-org-buffers)))
  (advice-add #'org-agenda-kill :after #'aj-org-agenda-save-and-refresh-a)

  (setq
      org-agenda-prefix-format '((agenda    . "  %-6t %6e ")
                                 (timeline  . "  %-6t %6e ")
                                 (todo      . "  %-6t %6e ")
                                 (tags      . "  %-6t %6e ")
                                 (search    . "%l")
                                 )
      org-agenda-tags-column 80
      org-agenda-skip-scheduled-if-done t
      org-agenda-skip-deadline-if-done t
      org-agenda-skip-timestamp-if-done t
      ;; org-agenda-todo-ignore-scheduled t
      ;; org-agenda-todo-ignore-deadlines t
      ;; org-agenda-todo-ignore-timestamp t
      ;; org-agenda-todo-ignore-with-date t
      org-agenda-start-on-weekday nil ; 从今天开始
      org-agenda-todo-list-sublevels t
      org-agenda-include-deadlines t
      org-agenda-log-mode-items '(closed clock state)
      org-agenda-block-separator nil
      org-agenda-compact-blocks t
      org-agenda-breadcrumbs-separator " ❱ "
      org-agenda-current-time-string "⏰ ┈┈┈┈┈┈┈┈┈┈┈ now"
      org-agenda-sorting-strategy
      '((agenda habit-down time-up effort-up priority-down category-keep)
        (todo   priority-up effort-up todo-state-up category-keep)
        (tags   priority-down category-keep)
        (search category-keep))
   )
  )

org-super-agenda

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(use-package! org-super-agenda
  :commands (org-super-agenda-mode))

(after! org-agenda
  (org-super-agenda-mode))

(setq
 org-agenda-custom-commands
 '(("o" "Overview"
    ((agenda "" ((org-agenda-span 'day)
                 (org-super-agenda-groups
                  '((:name "Today"
                     :time-grid t
                     :date today
                     :todo "TODAY"
                     :scheduled today
                     :order 1)))))
     (alltodo
      ""
      ((org-agenda-overriding-header "")
       (org-super-agenda-groups
        '((:name "Next(接下来)"         :todo "NEXT"        :order 1)
          (:name "Important(重要)"     :tag "Important"    :order 2    :priority "A")
          (:name "Due Today(今天完成)" :deadline today     :order 3)
          (:name "Due Soon(很快过期)"  :deadline future    :order 8)
          (:name "Overdue(过期)"      :deadline past      :order 9    :face error)
          (:name "Emacs"             :tag "Emacs"        :order 10)
          (:name "Vue"               :tag "Vue"          :order 15)
          (:name "React"             :tag "React"        :order 18)
          (:name "Assignments(作业)"  :tag "Assignment"   :order 20)
          (:name "Waiting(等待)"      :todo "WAITING"     :order 21)
          (:name "To read(阅读)"      :tag "Read"         :order 25)
          (:name "Issues(问题)"       :tag "Issue"        :order 30)
          (:name "Projects(项目)"     :tag "Project"      :order 40)
          (:name "Research(研究)"     :tag "Research"     :order 50)
          (:name "University(综合)"   :tag "uni"          :order 60)
          (:name "Trivial(不重要)"
           :priority<= "E"
           :tag ("Trivial" "Unimportant")
           :todo ("SOMEDAY" )
           :order 90)
          (:discard (:tag ("Chore" "Routine" "Daily")))))))))))

org-roam

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
;; (use-package! org-roam-lib
;; :after org-roam)

(use-package! org-roam
  :config
  (setq
   org-roam-file-extensions '("txt" "org")
   org-roam-capture-templates
   (quote
    (("d" "default" plain
      (function org-roam-capture--get-point)
      "%?" :file-name "%<%Y_%m%d>_${slug}"
      :head "#+TITLE: ${title}\n\n" :unnarrowed t)))
   )
  (org-roam-setup)
  :bind (("C-c r l" . org-roam-buffer-toggle)
         ("C-c r f" . org-roam-node-find)
         ("C-c r g" . org-roam-graph)
         ("C-c r i" . org-roam-node-insert)
         ("C-c r c" . org-roam-capture)
         ("C-c r j" . org-roam-dailies-capture-today)
         ))

org-preview-html

1
2
(use-package! org-preview-html
  :after org)

org-download

1
2
3
4
5
6
7
(use-package! org-download
  :after org
  :bind
  (:map org-mode-map
   (("s-Y" . org-download-screenshot)
    ("s-y" . org-download-yank)))
  )

mathpix.el

mathpix.el uses Mathpix’s API to convert clips into latex equations:

要收费~。

1
2
3
4
5
;; (use-package! mathpix.el
;;   :custom ((mathpix-app-id "app-id")
;;            (mathpix-app-key "app-key"))
;;   :bind
;;   ("C-x m" . mathpix-screenshot))

OSX

Keybindings:

Parrot

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(use-package! parrot
  :config
  (parrot-mode))

(setq parrot-rotate-dict
      '(
        (:rot ("alpha" "beta") :caps t :lower nil)
        ;; => rotations are "Alpha" "Beta"

        (:rot ("snek" "snake" "stawp"))
        ;; => rotations are "snek" "snake" "stawp"

        (:rot ("yes" "no") :caps t :upcase t)
        ;; => rotations are "yes" "no", "Yes" "No", "YES" "NO"

        (:rot ("&" "|"))
        ;; => rotations are "&" "|"
        ;; default dictionary starts here ('v')
        (:rot ("begin" "end") :caps t :upcase t)
        (:rot ("enable" "disable") :caps t :upcase t)
        (:rot ("enter" "exit") :caps t :upcase t)
        (:rot ("forward" "backward") :caps t :upcase t)
        (:rot ("front" "rear" "back") :caps t :upcase t)
        (:rot ("get" "set") :caps t :upcase t)
        (:rot ("high" "low") :caps t :upcase t)
        (:rot ("in" "out") :caps t :upcase t)
        (:rot ("left" "right") :caps t :upcase t)
        (:rot ("min" "max") :caps t :upcase t)
        (:rot ("on" "off") :caps t :upcase t)
        (:rot ("prev" "next"))
        (:rot ("start" "stop") :caps t :upcase t)
        (:rot ("true" "false") :caps t :upcase t)
        (:rot ("&&" "||"))
        (:rot ("==" "!="))
        (:rot ("===" "!=="))
        (:rot ("." "->"))
        (:rot ("if" "else" "elif"))
        (:rot ("ifdef" "ifndef"))
        ;; javascript
        (:rot ("var" "let" "const"))
        (:rot ("null" "undefined"))
        (:rot ("number" "object" "string" "symbol"))

        ;; c/...
        (:rot ("int8_t" "int16_t" "int32_t" "int64_t"))
        (:rot ("uint8_t" "uint16_t" "uint32_t" "uint64_t"))
        (:rot ("1" "2" "3" "4" "5" "6" "7" "8" "9" "10"))
        (:rot ("1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th" "9th" "10th"))

        ;; org
        (:rot ("DONE" "DOING" "WAITING" "PENDING"))
        (:rot ("increment", "decrement"))

        ))

PDF

Popper

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(use-package! popper
  :bind
  ("C-`" . popper-toggle-latest)
  ("C-~" . popper-cycle)
  ("C-s-`" . popper-kill-latest-popup)
  :custom
  (popper-reference-buffers
   '("*eshell*"
     "*vterm*"
     "*color-rg*"
     "Output\\*$"
     "*Process List*"
     "COMMIT_EDITMSG"
     embark-collect-mode
     deadgrep-mode
     grep-mode
     rg-mode
     rspec-compilation-mode
     inf-ruby-mode
     nodejs-repl-mode
     ts-comint-mode
     compilation-mode))
  :config
  (defun zero-point-thirty-seven () 0.37)
  (advice-add 'popper-determine-window-height :override #'zero-point-thirty-seven)
  :init
  (popper-mode)
  )

Projectile

ignore some directories.

1
2
3
4
(setq projectile-ignored-projects '("~/" "/tmp" "~/.emacs.d/.local/straight/repos/"))
(defun projectile-ignored-project-function (filepath)
  "Return t if FILEPATH is within any of `projectile-ignored-projects'"
  (or (mapcar (lambda (p) (s-starts-with-p p filepath)) projectile-ignored-projects)))

Projector

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
(use-package! projector
  :after
  (projectile vterm))

(map!
 (:prefix "s-p"
   "b"        #'projector-switch-to-shell-buffer
   "-"        #'projector-rerun-buffer-process

  (:prefix ("r" . "Run")
   "c"        #'projector-run-shell-command-current-directory-background
   "C"        #'projector-run-shell-command-current-directory
   "r"        #'projector-run-shell-command-project-root-background
   "R"        #'projector-run-shell-command-project-root
   )
  )
)

Ranger

1
2
3
(after! ranger
  :config
  (setq ranger-show-literal nil))

Restclient

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
(use-package! restclient
  :mode (("\\.rest\\'" . restclient-mode)
         ("\\.restclient\\'" . restclient-mode)))

(use-package! restclient-jq
  :after restclient)
(use-package! ob-restclient
  :after org restclient
  :init
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((restclient . t))))

Smartparen

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(sp-local-pair
 '(org-mode)
 "<<" ">>"
 :actions '(insert))

(use-package! smartparens
  :init
  (map! :map smartparens-mode-map
       "C-)" #'sp-forward-slurp-sexp
       "C-(" #'sp-forward-barf-sexp
       "C-{" #'sp-backward-slurp-sexp
       "C-}" #'sp-backward-barf-sexp
       ))

Server

卡死了…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
;; (use-package! server
;;  :unless (or noninteractive
;;              alternate-emacs)
;;  :no-require
;;  :config
;;  (unless (file-exists-p "/tmp/gcl-emacs")
;;    (make-directory "/tmp/gcl-emacs")
;;    (chmod "/tmp/gcl-emacs" 448))
;;  (setq server-socket-dir "/tmp/gcl-emacs")
;;  :hook (after-init . server-start))

Sudo-edit

1
2
(map!
 )

Treemacs

1
2
3
4
5
6
7
8
(after! treemacs
  (setq
   evil-treemacs-state-cursor 'box
   treemacs-project-follow-cleanup t
   treemacs-width 25
   )
  (treemacs-follow-mode +1)
  )

Themes

mixed-pitch

混合字体

1
2
3
4
5
6
(use-package! mixed-pitch
  :defer
  :config
  (setq mixed-pitch-variable-pitch-cursor nil)
  :hook
  (text-mode . mixed-pitch-mode))

Visual-regexp

1
2
3
4
5
(use-package! visual-regexp
  :commands (vr/select-replace vr/select-query-replace))

(use-package! visual-regexp-steriods
  :commands (vr/select-replace vr/select-query-replace))

Visual-fill-column

1
(use-package! visual-fill-column)

Which-key

Doom Emacs default configuration is too slow, let’s speed it up.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
(after! which-key
  (setq! which-key-idle-delay 0.1
         which-key-idle-secondary-delay 0.2))

;; dont display evilem-...
(setq which-key-allow-multiple-replacements t)
(after! which-key
  (pushnew!
   which-key-replacement-alist
   '(("" . "\\`+?evil[-:]?\\(?:a-\\)?\\(.*\\)") . (nil . "◂\\1"))
   '(("\\`g s" . "\\`evilem--?motion-\\(.*\\)") . (nil . "◃\\1"))
   ))

YASnippets

1
2
3
4
5
6
7
(setq yas-triggers-in-field t)

(use-package! doom-snippets             ; hlissner
  :after yasnippet)

(use-package! yasnippet-snippets        ; AndreaCrotti
  :after yasnippet)

Development Settings

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(add-to-list 'auto-mode-alist '("\\.js\\(x\\)?\\'" . rjsx-mode))
(add-to-list 'auto-mode-alist '("\\.vue\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[a-z]+rc$" . conf-mode))
(add-to-list 'auto-mode-alist '("\\.vim\\(rc\\)?\\'" . vimrc-mode))
(add-to-list 'auto-mode-alist '("[Mm]akefile" . makefile-gmake-mode))
(add-to-list 'auto-mode-alist '("\\.mak$" . makefile-gmake-mode))
(add-to-list 'auto-mode-alist '("\\.make$" . makefile-gmake-mode))
(add-to-list 'auto-mode-alist '("[._]bash.*" . shell-script-mode))

;; (add-to-list 'org-src-lang-modes '("deno" . typescript))

Web

Use `.prettierrc` file for prettier.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

(defun maybe-use-prettier ()
  "Enable prettier-js-mode if an rc file is located."
  (if (locate-dominating-file default-directory ".prettierrc")
      (prettier-js-mode +1)))
(add-hook 'typescript-mode-hook 'maybe-use-prettier)
(add-hook 'js2-mode-hook 'maybe-use-prettier)
(add-hook 'web-mode-hook 'maybe-use-prettier)
(add-hook 'rjsx-mode-hook 'maybe-use-prettier)

;; set docsets
(after! (:any js-mode js2-mode rjsx-mode web-mode typescript-mode)
  (set-docsets! '(js-mode js2-mode rjsx-mode web-mode typescript-mode)
    "JavaScript" "AngularJS" "Bootstrap_4" "jQuery" "NodeJS" "React" "VueJS" "TypeScript"))

jest

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
(use-package! jest
  :after js2-mode
  :config
  (advice-add #'jest--project-root :around (lambda (orig-fn &rest args)
                                             (if (string-match "exercism" (projectile-project-name))
                                                 (cl-letf (((symbol-function 'projectile-project-root)
                                                            (lambda (&rest _)
                                                              (file-name-directory buffer-file-name))))
                                                   (apply orig-fn args))
                                               (apply orig-fn args))))
  (setq jest-pdb-track nil)
  (add-hook 'jest-mode-hook (lambda ()
                              (evil-motion-state)
                              ))


  (set-popup-rule! "*jest\*"            :size 20            :side 'bottom :select t :quit t :modeline nil)
  )

react

1
2
(use-package! js-react-redux-yasnippets
  :after yasnippet)

deno

1
2
(use-package! ob-deno
  :after org)

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
(after! python
  (set-docsets! 'python-mode "Python_3")
  (set-popup-rule! "*Python*"     :size 16 :vslot -2 :side 'bottom :select t :quit t :ttl nil :modeline nil)
  )

(after! python-pytest
  (advice-add #'python-pytest--find-test-file
              :around
              (lambda (orig-fn &rest args)
                (if (string-match "exercism" (projectile-project-name))
                    (concat (file-name-sans-extension (buffer-file-name))
                            "_test.py")
                  (apply orig-fn args))))
  )

Java

My Packages

Email

1
(package! mu4e-alert)

Development

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(package! dotenv-mode)
(package! leetcode)
(package! ob-restclient)
;; FIX: jq-set-var not found
(package! restclient-jq :recipe
  (:host github
   :repo "pashky/restclient.el"
   :files ("restclient-jq.el")))
;; (package! ob-jq)
(package! ob-deno)
(package! deno-fmt)

WEB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
(package! instant-rename-tag
  :recipe (:host github
           :repo "manateelazycat/instant-rename-tag"))
(package! js-doc)
(package! js-react-redux-yasnippets)
(package! jest)
(package! phpactor)
(package! prettier-js)
(package! ob-typescript)
(package! web-beautify)
;; (package! ts-comint)
(package! dash-at-point
  :recipe (:host github
           :repo "waymondo/dash-at-point"))

F&D

File and directory management packages.

1
2
3
4
5
(package! crux)
(package! deft)
(package! autoinsert)
(package! ranger)
(package! sudo-edit)

Window

Window management packages.

1
2
(package! popper
  :recipe (:host github :repo "waymondo/popper") :disable t)

Funny

1
2
(package! selectric-mode
  :pin "1840de71f7414b7cd6ce425747c8e26a413233aa")

MacOS

1
2
3
4
5
6
7
8
(package! osx-lib)
(package! emacs-everywhere
  :recipe (:host github
           :repo "tecosaur/emacs-everywhere"))
(package! systemd
  :pin "b6ae63a236605b1c5e1069f7d3afe06ae32a7bae")
(package! counsel-osx-app)
(package! prodigy)

Markdown

Network

1
2
3
4
5
6
(package! counsel-tramp)
(package! net-utils)
(package! engine-mode)
;; (package! server)
(package! verb)
(package! httprepl)

Org

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(package! counsel-org-clock)
(package! doct
  :recipe (:host github :repo "progfolio/doct"))
;; hightlight latex export results
(package! engrave-faces
  :recipe (:host github :repo "tecosaur/engrave-faces"))

(package! org-appear)
(package! org-chef)
(package! org-fancy-priorities)
(package! org-fragtog)
(package! graphviz-dot-mode)
(package! org-pandoc-import :recipe
  (:host github
   :repo "tecosaur/org-pandoc-import"
   :files ("*.el" "filters" "preprocessors")))

(package! org-super-agenda)
(package! ox-gfm)
(package! org-ol-tree
  :recipe (:host github :repo "Townk/org-ol-tree"))
(package! org-sort-tasks
  :recipe (:host github :repo "felipelalli/org-sort-tasks"))
(package! org-preview-html :disable t)
(package! org-download)
(package! org-roam)
;; (package! mathpix.el
;;   :recipe ((:host github :repo "jethrokuan/mathpix.el")))
(package! lsp-latex)

PDF

Projectile

1
2
3
4
5
(package! bm)
(package! imenu-list)
(package! git-gutter)
(package! projector)
(package! yasnippet-snippets)

Search

1
2
3
4
5
6
7
(package! anzu)
(package! deadgrep)
(package! color-rg :recipe (:host github :repo "manateelazycat/color-rg"))
(package! visual-regexp)
(package! visual-regexp-steriods
  :recipe (:host github :repo "benma/visual-regexp-steroids.el"))
(package! youdao-dictionary)

Text Operation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(package! cycle-quotes)
(package! delsel)
(package! hungry-delete)
(package! move-text)
(package! pangu-spacing)
(package! pandoc-mode)
(package! parrot)
(package! string-inflection)
(package! maple-iedit
  :recipe (:host github
           :repo "honmaple/emacs-maple-iedit"))
(package! vmd-mode)
(package! vimrc-mode)

Themes&UI

1
2
3
(package! mixed-pitch)
(package! spacemacs-theme)
(package! visual-fill-column)

EAF

1
2
3
4
5
6
7
8
;; (when (package! eaf :recipe (:host github
;;                              :repo "manateelazycat/emacs-application-framework"
;;                              :files ("*.el" "*.py" "app" "core")
;;                              :build (:not compile)))

;;   (package! ctable :recipe (:host github :repo "kiwanami/emacs-ctable"))
;;   (package! deferred :recipe (:host github :repo "kiwanami/emacs-deferred"))
;;   (package! epc :recipe (:host github :repo "kiwanami/emacs-epc")))

Disabled

1
(disable-packages! bookmark tide eldoc valign grip-mode)

Practices

C-c C-v t:

Signature (org-babel-tangle &optional ARG TARGET-FILE LANG-RE)

Documentation Write code blocks to source-specific files.

Evil-mode

常用的按键练习 1️⃣ 2️⃣ 3️⃣ 🏃‍♂️ 。

可以重写的键值,用处不大:

g _, g ^, g a, g A, g e/E, g i/I, g J, g l/L, g m, g n/N

g o/O, g u/U, g v/V, g y/Y

g [x]

  1. 函数头尾跳转

    g [, beginning-of-defun

    g ], end-of-defun

  2. 注释前后一行

    g c -> [n] j/k, nc-comment-operator, [n] 可以输入数字来说明将要被注释的行数

  3. 查找并打开文件

    g f, +lookup/file, 支持链接

    g F, evil-find-file-at-point-with-line, 打开文件并跳到对应的行

    如: ~/github/tmp/test/a.js:10 按下 g f/F 后会直接在当前窗口内打开该

    文件并且跳转到第 10 行。

  4. 跳到标题位置

    g h, org-up-element, 当前的标题处

    g H, org-top, 当前的一级标题处, 比如在这里按会跳到 Practices

    g j, org-forward-element, 下一个同级元素(标题,段,行,等)

    g k, org-backward-element, 上一个同级元素(标题,段,行,等)

  5. imenu

    g O, imenu

  6. 粘贴替换

    g p, /alt-paste , 选中状态,按下后将粘贴板上的内容替换选中的内容

  7. 填充文本

    g w/W, evil-fill

    g q, fill-and-move, 将持中内容变成一行?

    g Q, org-fill-paragraph

    实用案例,如:

    test1 test2 test3
    test4 test5 test6
    test7 test8 test9
    

    选中上面的 test1-9 按下 g q 后变成:

    test1 test2 test3 test4 test5 test6 test7 test8 test9
    

    这对文本格式化挺有用的。

  8. 执行代码

    g r, +eval:region, 执行选中区域代码

    g R, +eval/buffer, 执行整个 Buffer

  9. 切换工作区

    g t/T, +workspace:switch-next/previous 切换工作区

  10. 交换,需要先选中

    g x/X, evil-exchange

    如: aaa - bbb

    -> 选中 aaa -> gx -> 选中 bbb -> gx

    结果: bbb - aaa

g s, 搜索定位

通过按下组合键之后,根据显示的字符来将光标定位到输入的字符位置。

  1. 所有窗口

    gs -> SPC, closure

  2. 块,前半部分

    gs -> [[, backward-section-begin, 定位当前位置前半部分块首

    gs -> [], backward-section-end, 定位当前位置前半部分块尾

  3. 块,后半部分

    gs -> ][, forward-section-begin, 定位当前位置后半部分块首

    gs -> ]], forward-section-end, 定位当前位置后半部分块尾

  4. search

    gs -> #, search-word-backward

    gs -> *, search-word-forward

  5. 非空行

    gs -> -, previous-line-first-non-blank, 向前

    gs -> +, next-line-first-non-blank, 向后

  6. avy

    gs -> /,, avy-goto-char-timer

    gs -> l, avy-goto-char-0, 零字符搜索

    gs -> s, avy-goto-char-2, 两个字符搜索

  7. 单词开始和结束

    gs -> b/B, backward-word|WORD-begin, 向后

    gs -> [g] e/E, backward-word|WORD-end, 向后

    gs -> w/W, forward-word|WORD-begin, 向前

  8. 查找字符

    gs -> f, find-char, 向前

    gs -> F, find-char-backward, 向后

    gs -> t, find-char-to

    gs -> T, find-char-to-backward

  9. 可视行, 即忽略折叠的行

    gs -> gj, next-visual-line

    gs -> gk, previous-visual-line

  10. 上下行

    gs -> j, next-line

    gs -> k, previous-line

Embrace(,e)

practices place…

embrach-add(,ea)

embrach-change(,ec)

embrach-delete(,ed)

Emms

Development

Deno

1
2
const arr = [1,2,3]
console.log(arr);
1
2
3
4
  const response = await fetch(`https://httpbin.org/get?user=${Deno.env.get("USER")}`);
  const json = await response.json();

  console.log(json.args);