HTML them READ org

1 Emacs

Emacs or EMACS (Editor MACroS) is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as “the extensible, customizable, self-documenting, real-time display editor”. Development of the first Emacs began in the mid-1970s, and work on its direct descendant, GNU Emacs, continues actively as of 2020.

2 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; -*-

;; Copy this file to ~/.doom.d/init.el or ~/.config/doom/init.el ('doom install'
;; will do this for you). The `doom!' block below controls what modules are
;; enabled and in what order they will be loaded. Remember to run 'doom refresh'
;; after modifying it.
;;
;; More information about these modules (and what flags they support) can be
;; found in modules/README.org.

(doom! :input
       chinese
       ;;japanese
       :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
       :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
       ;;fill-column       ; a `fill-column' indicator
       hl-todo           ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
       ;;hydra
       indent-guides     ; highlighted indent columns
       modeline          ; snazzy, Atom-inspired modeline, plus API
       nav-flash         ; blink the current line after jumping
       ;;neotree           ; a project drawer, like NERDTree for vim
       ophints           ; highlight the region an operation acts on
       (popup +defaults)   ; tame sudden yet inevitable temporary windows
       ;;pretty-code       ; replace bits of code with pretty symbols
       ;;tabs              ; an tab bar for Emacs
       treemacs          ; 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     ; visually switch windows
       workspaces        ; tab emulation, persistence & separate workspaces

       :editor
       ;;(evil +everywhere); come to the dark side, we have cookies
       file-templates    ; auto-snippets for empty files
       ;;god               ; run Emacs commands without modifier keys
       fold              ; (nigh) universal code folding
       ;;(format +onsave)  ; automated prettiness
       ;;lispy             ; vim for lisp, for people who dont 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             ; making dired pretty [functional]
       electric          ; smarter, keyword-based electric-indent
       ibuffer           ; interactive buffer management
       vc                ; version-control and Emacs, sitting in a tree

       :term
       ;;eshell            ; a consistent, cross-platform shell (WIP)
       ;;shell             ; a terminal REPL for Emacs
       ;;term              ; terminals in Emacs
       vterm             ; another terminals in Emacs

       :checkers
       syntax              ; tasing you for every semicolon you forget
       ;;spell             ; 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)
       ;;flycheck          ; tasing you for every semicolon you forget
       ;;flyspell          ; tasing you for misspelling mispelling
       ;;gist              ; interacting with github gists
       (lookup           ; helps you navigate your code and documentation
        +docsets)        ; ...or in Dash docsets locally
       lsp
       ;;macos             ; MacOS-specific commands
       magit             ; 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
       ;;terraform         ; infrastructure as code
       ;;tmux              ; an API for interacting with tmux
       ;;upload              ; map local to remote projects via ssh/ftp
       ;;wakatime

       :os
       (:if IS-MAC macos)  ; improve compatibility with macOS

       :lang
       ;;agda              ; types of types of types of types...
       ;;assembly          ; assembly for fun or debugging
       (cc
          +lsp)                              ; C/C++/Obj-C madness
       ;;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
       ;;erlang            ; an elegant language for a more civilized age
       ;;elixir            ; erlang done right
       ;;elm               ; care for a cup of TEA?
       emacs-lisp        ; drown in parentheses
       ess               ; emacs speaks statistics
       ;;faust             ; dsp, but you get to keep your soul
       ;;fsharp           ; ML stands for Microsoft's Language
       go                ; the hipster dialect
       json

       haskell ; a language that's lazier than I am
       ;;hy                ; readability of scheme w/ speed of python
       ;;idris             ;
       ;;(java +meghanada) ; the poster child for carpal tunnel syndrome
       ;;javascript        ; 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
       ;;lean
       ;;ledger            ; an accounting system in Emacs
       ;;lua               ; 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
        +dragndrop       ; drag & drop files/images into org buffers
        +hugo            ; use Emacs for hugo blogging
        +ipython         ; ipython/jupyter support for babel
        +pandoc          ; export-with-pandoc support
        +journal
        +roam
        ;;+helm-org
        ;+pomodoro        ; be fruitful with the tomato technique
        +present)        ; using org-mode for presentations
       ;;perl              ; write code no one else can comprehend
       ;;php               ; perl's insecure younger brother
       plantuml          ; diagrams for confusing people more
       ;;purescript        ; javascript, but functional
       (python
        +poetry
        +lsp
        +pyright)            ; beautiful is better than ugly
       ;;qt                ; the 'cutest' gui framework ever
       ;;racket            ; a DSL for DSL
       ;;ruby              ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
       rust              ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
       ;;scala             ; java, but good
       ;;scheme            ; a fully conniving family of lisps
       sh                ; she sells {ba,z,fi}sh shells on the C xor
       ;;solidity          ; do you need a blockchain? No.
       ;;swift             ; who asked for emoji variables?
       ;;terra             ; Earth and Moon in alignment for performance.
       ;;web               ; the tubes

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

       ;; Applications are complex and opinionated modules that transform Emacs
       ;; toward a specific purpose. They may have additional dependencies and
       ;; should be loaded late.
       :app
       ;;calendar
       ;;irc               ; how neckbeards socialize
       ;;(rss +org)        ; emacs as an RSS reader
       ;;twitter           ; twitter client https://twitter.com/vnought
       ;;(write            ; emacs for writers (fiction, notes, papers, etc.)
       ;; +wordnut         ; wordnet (wn) search
       ;; +langtool)       ; a proofreader (grammar/style check) for Emacs

       :config
       ;; For literate config users. This will tangle+compile a config.org
       ;; literate config in your `doom-private-dir' whenever it changes.
       literate

       ;; The default module sets reasonable defaults for Emacs. It also
       ;; provides a Spacemacs-inspired keybinding scheme and a smartparens
       ;; config. Use it as a reference for your own modules.
       ;;(default +smartparens)
         :private
         spacemacs-default
         my-org
         my-code
         )

3 package.el

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;;; packages.el -*- lexical-binding: t; -*-
(package! discover :recipe (:host github :repo "mickeynp/discover.el"))
(package! maple-iedit :recipe (:host github :repo "honmaple/emacs-maple-iedit"))
(package! scrollkeeper :recipe (:host github :repo "alphapapa/scrollkeeper.el"))
(package! awesome-tab :recipe (:host github :repo "manateelazycat/awesome-tab"))
(package! ob-session-async :recipe (:host github :repo "jackkamm/ob-session-async"))
(package! maple-explorer :recipe (:host github :repo "honmaple/emacs-maple-explorer"))
(package! sunrise-commander :recipe (:host github :repo "sunrise-commander/sunrise-commander"))
(package! awesome-pair :recipe (:host github :repo "manateelazycat/awesome-pair"))
(package! meow :recipe (:host github :repo "DogLooksGood/meow"))
;; (package! berrys-theme)

4 config.el

1
2
3
;;; config.el -*- lexical-binding: t; -*-
(load! "show-parentheses.el")
(load! "meow.el")
  • native compile
1
;;(setq comp-async-jobs-number 24)

5 use-package

5.1 helm-tramp

1
(package! helm-tramp)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
(use-package! helm-tramp
  :config
  (setq tramp-default-method "sshx")
  (setq make-backup-files nil)
  (setq create-lockfiles nil)
  (setq helm-tramp-custom-connections '(/sshx:gtrun@10.220.170.112:/home/gtrun
                                        /sshx:gtrun@10.220.170.112:/home/gtrun/.config/nixpkgs
                                        /sshx:test@10.220.170.134:/home/test/))
  (add-hook 'helm-tramp-pre-command-hook '(lambda () ;;(global-aggressive-indent-mode 0)
                     (projectile-mode 0)
                     ;;(editorconfig-mode 0)
             ))
  (add-hook 'helm-tramp-quit-hook '(lambda () ;;(global-aggressive-indent-mode 1)
                  (projectile-mode 1)
                  ;;(editorconfig-mode 1)
            ))
)
1
t

5.2 Pinyin

1
(package! pinyin-search)
1
(use-package! pinyin-search)

5.3 wakatime-mode

1
(package! wakatime-mode)
1
2
(use-package! wakatime-mode
:hook (after-init . global-wakatime-mode))

5.4 vlf

1
(package! vlf)
1
2
3
4
5
6
(use-package! vlf
  :config
  (require 'vlf-setup)
  (custom-set-variables
   '(vlf-application 'dont-ask))
)

5.5 maple-explorer

1
2
3
4
5
6
7
8
(use-package! maple-explorer
  :commands (maple-explorer-file maple-explorer-buffer maple-explorer-imenu maple-explorer-recentf)
  :config
  (setq maple-explorer-file-display-alist '((side . left) (slot . -1)))
  (add-hook 'maple-explorer-imenu-mode-hook
            (lambda() (setq cursor-type 'box
                            cursor-in-non-selected-windows t)))
)

5.6 imenu-list

1
(package! imenu-list)
1
2
3
4
5
6
7
(use-package! imenu-list
  :config
  (setq imenu-list-auto-resize t)
  (setq imenu-list-focus-after-activation t)
  (setq imenu-list-after-jump-hook nil)
  (add-hook 'menu-list-after-jump-hook #'recenter-top-bottom)
)

5.7 w3m

1
(package! w3m)
1
2
3
4
5
(use-package! w3m
  :commands (w3m)
  :config
  (setq w3m-use-tab-line nil)
)

5.8 ein

1
2
3
4
(package! ein :recipe (:host github
                       :repo "millejoh/emacs-ipython-notebook"
                       :files ("lisp/*.el")
                       :build (:not compile)))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(use-package! ein
  :config
  (setq ob-ein-languages
   (quote
    (("ein-python" . python)
     ("ein-R" . R)
     ("ein-r" . R)
     ("ein-rust" . rust)
     ("ein-haskell" . haskell)
     ("ein-julia" . julia))))
  )

(after! ein:ipynb-mode                  ;
  (poly-ein-mode 1)
  (hungry-delete-mode -1)
  )

5.9 undo-fu

1
2
(package! undo-fu)
(package! undo-fu-session)
 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
(use-package! undo-fu
  :after-call doom-switch-buffer after-find-file
  :init
  (after! undo-tree
    (global-undo-tree-mode -1))
  :config
  ;; Store more undo history to prevent loss of data
  (setq undo-limit 400000
        undo-strong-limit 3000000
        undo-outer-limit 3000000)

  (define-minor-mode undo-fu-mode
    "Enables `undo-fu' for the current session."
    :keymap (let ((map (make-sparse-keymap)))
              (define-key map [remap undo] #'undo-fu-only-undo)
              (define-key map [remap redo] #'undo-fu-only-redo)
              (define-key map (kbd "C-_")     #'undo-fu-only-undo)
              (define-key map (kbd "M-_")     #'undo-fu-only-redo)
              (define-key map (kbd "C-M-_")   #'undo-fu-only-redo-all)
              (define-key map (kbd "C-x r u") #'undo-fu-session-save)
              (define-key map (kbd "C-x r U") #'undo-fu-session-recover)
              map)
    :init-value nil
    :global t)

  (undo-fu-mode +1))

(use-package! undo-fu-session
  :hook (undo-fu-mode . global-undo-fu-session-mode)
  :preface
  (setq undo-fu-session-directory (concat doom-cache-dir "undo-fu-session/")
        undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'"))

  ;; HACK We avoid `:config' here because `use-package's `:after' complicates
  ;;      the load order of a package's `:config' block and makes it impossible
  ;;      for the user to override its settings with merely `after!' (or
  ;;      `eval-after-load'). See jwiegley/use-package#829.
  (after! undo-fu-session
    ;; HACK Use the faster zstd to compress undo files instead of gzip
    (when (executable-find "zstd")
      (defadvice! doom--undo-fu-session-use-zstd-a (filename)
        :filter-return #'undo-fu-session--make-file-name
        (if undo-fu-session-compression
            (concat (file-name-sans-extension filename) ".zst")
          filename)))))

(use-package! undo-tree
  :disabled
  ;; Branching & persistent undo
  :after-call doom-switch-buffer-hook after-find-file
  :config
  (setq undo-tree-visualizer-diff t
        undo-tree-auto-save-history t
        undo-tree-enable-undo-in-region t
        ;; Increase undo-limits by a factor of ten to avoid emacs prematurely
        ;; truncating the undo history and corrupting the tree. See
        ;; https://github.com/syl20bnr/spacemacs/issues/12110
        undo-limit 800000
        undo-strong-limit 12000000
        undo-outer-limit 120000000
        undo-tree-history-directory-alist
        `(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))

  ;; Compress undo-tree history files with zstd, if available. File size isn't
  ;; the (only) concern here: the file IO barrier is slow for Emacs to cross;
  ;; reading a tiny file and piping it in-memory through zstd is *slightly*
  ;; faster than Emacs reading the entire undo-tree file from the get go (on
  ;; SSDs). Whether or not that's true in practice, we still enjoy zstd's ~80%
  ;; file savings (these files add up over time and zstd is so incredibly fast).
  (when (executable-find "zstd")
    (defadvice! doom--undo-tree-make-history-save-file-name-a (file)
      :filter-return #'undo-tree-make-history-save-file-name
      (concat file ".zst")))

  ;; Strip text properties from undo-tree data to stave off bloat. File size
  ;; isn't the concern here; undo cache files bloat easily, which can cause
  ;; freezing, crashes, GC-induced stuttering or delays when opening files.
  (defadvice! doom--undo-tree-strip-text-properties-a (&rest _)
    :before #'undo-list-transfer-to-tree
    (dolist (item buffer-undo-list)
      (and (consp item)
           (stringp (car item))
           (setcar item (substring-no-properties (car item))))))

  ;; Undo-tree is too chatty about saving its history files. This doesn't
  ;; totally suppress it logging to *Messages*, it only stops it from appearing
  ;; in the echo-area.
  (advice-add #'undo-tree-save-history :around #'doom-shut-up-a)

  (global-undo-tree-mode +1))

5.10 vundo

1
(package! vundo :recipe (:host github :repo "casouri/vundo"))
1
(use-package! vundo)

5.11 color-rg

1
(package! color-rg :recipe (:host github :repo "manateelazycat/color-rg"))
1
2
3
4
5
6
7
8
(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))
  )

5.12 envrc

1
(package! envrc :recipe (:host github :repo "purcell/envrc"))
1
2
3
(use-package! envrc
:hook (after-init . envrc-global-mode)
)

5.13 snails

1
2
3
  (package! snails :recipe (:host github
                            :repo "manateelazycat/snails"
                            :files ("*.el")))
1
2
3
4
5
6
;; (use-package! snails
;;   :config
;;   (setq snails-show-with-frame nil)
;;   (define-key snails-mode-map [remap previous-line] #'snails-select-prev-item)
;;   (define-key snails-mode-map [remap next-line] #'snails-select-next-item)
;;   )

5.14 iscroll

1
2
(package! iscroll :recipe (:host github
                                 :repo "casouri/iscroll"))
1
2
3
4
(use-package! iscroll
  :config
  (add-hook! 'org-mode-hook 'iscroll-mode)
  )

5.15 helm-tramp

5.16 helm-rg

  • [2021-01-08 Fri 17:49] <- org-z
1
(package! helm-rg)
1
(use-package! helm-rg)

5.17 fd-dired

1
2
3
(package! fd-dired :recipe (:host github
                                 :repo "yqrashawn/fd-dired"))

1
(use-package! fd-dired)

5.18 find-dupes-dired

1
2
3
(package! find-dupes-dired :recipe (:host github
                                 :repo "ShuguangSun/find-dupes-dired"))

1
(use-package! find-dupes-dired)

6 autoload

6.1 +misc.el

6.1.1 timer

 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
;;; ~/.doom.d/autoload/misc.el -*- lexical-binding: t; -*-
(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")

;;;###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 "==========\n")
;       (insert (let () (comment-start)))
       (insert (format-time-string current-date-time-format (current-time)))
       )

(defvar current-date-time-format-inactive "[%Y-%m-%d %a %H:%M]"

  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")

;;;###autoload
(defun insert-current-date-time-inactive
 ()
  "insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
       (interactive)
       ;;(insert "==========\n")
;       (insert (let () (comment-start)))
       (insert (format-time-string current-date-time-format-inactive (current-time)))
       ;;(insert "\n")
       )

(defvar current-date-time-format-active "<%Y-%m-%d %a %H:%M>"

  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")

;;;###autoload
(defun insert-current-date-time-active
 ()
  "insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
       (interactive)
       ;;(insert "==========\n")
;       (insert (let () (comment-start)))
       (insert (format-time-string current-date-time-format-active (current-time)))
       ;;(insert "\n")
       )

6.2 +org-mode.el

6.2.1 alphapapa/unpackaged.el: A collection of useful Emacs Lisp code that isn’t substantial enough to be packaged

  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
;;; ~/.doom.d/autoload/+org-mode.el -*- lexical-binding: t; -*-
(defun unpackaged/org-element-descendant-of (type element)
  "Return non-nil if ELEMENT is a descendant of TYPE.
TYPE should be an element type, like `item' or `paragraph'.
ELEMENT should be a list like that returned by `org-element-context'."
  ;; MAYBE: Use `org-element-lineage'.
  (when-let* ((parent (org-element-property :parent element)))
    (or (eq type (car parent))
        (unpackaged/org-element-descendant-of type parent))))

;;;###autoload
(defun unpackaged/org-fix-blank-lines (&optional prefix)
  "Ensure that blank lines exist between headings and between headings and their contents.
With prefix, operate on whole buffer. Ensures that blank lines
exist after each headings's drawers."
  (interactive "P")
  (org-map-entries (lambda ()
                     (org-with-wide-buffer
                      ;; `org-map-entries' narrows the buffer, which prevents us from seeing
                      ;; newlines before the current heading, so we do this part widened.
                      (while (not (looking-back "\n\n" nil))
                        ;; Insert blank lines before heading.
                        (insert "\n")))
                     (let ((end (org-entry-end-position)))
                       ;; Insert blank lines before entry content
                       (forward-line)
                       (while (and (org-at-planning-p)
                                   (< (point) (point-max)))
                         ;; Skip planning lines
                         (forward-line))
                       (while (re-search-forward org-drawer-regexp end t)
                         ;; Skip drawers. You might think that `org-at-drawer-p' would suffice, but
                         ;; for some reason it doesn't work correctly when operating on hidden text.
                         ;; This works, taken from `org-agenda-get-some-entry-text'.
                         (re-search-forward "^[ \t]*:END:.*\n?" end t)
                         (goto-char (match-end 0)))
                       (unless (or (= (point) (point-max))
                                   (org-at-heading-p)
                                   (looking-at-p "\n"))
                         (insert "\n"))))
                   t (if prefix
                         nil
                       'tree)))


;;;###autoload
(defun unpackaged/org-return-dwim (&optional default)
  "A helpful replacement for `org-return'.  With prefix, call `org-return'.

On headings, move point to position after entry content.  In
lists, insert a new item or end the list, with checkbox if
appropriate.  In tables, insert a new row or end the table."
  ;; Inspired by John Kitchin: http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/
  (interactive "P")
  (if default
      (org-return)
    (cond
     ;; Act depending on context around point.

     ;; NOTE: I prefer RET to not follow links, but by uncommenting this block, links will be
     ;; followed.

     ;; ((eq 'link (car (org-element-context)))
     ;;  ;; Link: Open it.
     ;;  (org-open-at-point-global))

     ((org-at-heading-p)
      ;; Heading: Move to position after entry content.
      ;; NOTE: This is probably the most interesting feature of this function.
      (let ((heading-start (org-entry-beginning-position)))
        (goto-char (org-entry-end-position))
        (cond ((and (org-at-heading-p)
                    (= heading-start (org-entry-beginning-position)))
               ;; Entry ends on its heading; add newline after
               (end-of-line)
               (insert "\n\n"))
              (t
               ;; Entry ends after its heading; back up
               (forward-line -1)
               (end-of-line)
               (when (org-at-heading-p)
                 ;; At the same heading
                 (forward-line)
                 (insert "\n")
                 (forward-line -1))
               ;; FIXME: looking-back is supposed to be called with more arguments.
               (while (not (looking-back (rx (repeat 3 (seq (optional blank) "\n")))))
                 (insert "\n"))
               (forward-line -1)))))

     ((org-at-item-checkbox-p)
      ;; Checkbox: Insert new item with checkbox.
      (org-insert-todo-heading nil))

     ((org-in-item-p)
      ;; Plain list.  Yes, this gets a little complicated...
      (let ((context (org-element-context)))
        (if (or (eq 'plain-list (car context))  ; First item in list
                (and (eq 'item (car context))
                     (not (eq (org-element-property :contents-begin context)
                              (org-element-property :contents-end context))))
                (unpackaged/org-element-descendant-of 'item context))  ; Element in list item, e.g. a link
            ;; Non-empty item: Add new item.
            (org-insert-item)
          ;; Empty item: Close the list.
          ;; TODO: Do this with org functions rather than operating on the text. Can't seem to find the right function.
          (delete-region (line-beginning-position) (line-end-position))
          (insert "\n"))))

     ((when (fboundp 'org-inlinetask-in-task-p)
        (org-inlinetask-in-task-p))
      ;; Inline task: Don't insert a new heading.
      (org-return))

     ((org-at-table-p)
      (cond ((save-excursion
               (beginning-of-line)
               ;; See `org-table-next-field'.
               (cl-loop with end = (line-end-position)
                        for cell = (org-element-table-cell-parser)
                        always (equal (org-element-property :contents-begin cell)
                                      (org-element-property :contents-end cell))
                        while (re-search-forward "|" end t)))
             ;; Empty row: end the table.
             (delete-region (line-beginning-position) (line-end-position))
             (org-return))
            (t
             ;; Non-empty row: call `org-return'.
             (org-return))))
     (t
      ;; All other cases: call `org-return'.
      (org-return)))))

6.2.2 alphapapa/unpackaged.el: A collection of useful Emacs Lisp code that isn’t substantial enough to be packaged

1
2
3
4
5
6
7
8
;;;###autoload
(defun unpackaged/org-sort-multi ()
  "Call `org-sort' until \\[keyboard-quit] is pressed."
  (interactive)
  ;; Not sure if `with-local-quit' is necessary, but probably a good
  ;; idea in case of recursive edit.
  (with-local-quit
    (cl-loop while (call-interactively #'org-sort))))

7 Default Setting

7.1 Global Setting

 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
(setq user-full-name "GTrunSec"
      user-mail-address "gtrunsec@hardenedlinux.org")
;; (setq auth-sources '("~/.authinfo.gpg")
;;       auth-source-cache-expiry nil) ; default is 7200 (2h)

(setq-default history-length 1000)
(setq create-lockfiles nil)
(require 'org-protocol)

;; (setq browse-url-browser-function 'browse-url-Chrome)
;; https://emacs.stackexchange.com/questions/5603/how-to-quickly-copy-move-file-in-emacs-dired
(setq dired-dwim-target t)

(add-hook! 'dired-mode 'dired-async-mode)

(defun gtrun/truncate-lines-hook ()
  (setq-local truncate-lines nil)
  )

(add-hook! 'text-mode-hook 'gtrun/truncate-lines-hook)

(setenv "XAPIAN_CJK_NGRAM" "1")
(setenv "QT_DEBUG_PLUGINS" "1")
(fset 'yes-or-no-p 'y-or-n-p)

(setq plantuml-jar-path (expand-file-name "~/.myscript/plantuml"))

7.2 Better default Setting

1
2
3
4
5
(setq-default
 delete-by-moving-to-trash t                      ;; Delete files to trash
 window-combination-resize t                      ;; take new window space from all other windows (not just current)
 x-stretch-cursor t)                              ;; Stretch cursor to the glyph width

1
t

8 Completion

8.1 Ivy/counsel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  (use-package! counsel
    :hook
    (after-init . ivy-mode)
    (counsel-grep-post-action . better-jumper-set-jump)
    :diminish ivy-mode
    :config
    (setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)"
          counsel-describe-function-function #'helpful-callable
          ncounsel-describe-variable-function #'helpful-variable
          ;; Add smart-casing (-S) to default command arguments:
          counsel-rg-base-command "rg -S --no-heading --line-number --color never %s ."
          counsel-ag-base-command "ag -S --nocolor --nogroup %s"
          counsel-pt-base-command "pt -S --nocolor --nogroup -e %s"
          counsel-find-file-at-point t)
       )

     (use-package! ivy-rich
       :config
       (ivy-rich-mode 1)
       (setq ivy-format-function #'ivy-format-function-line))
     ;;[[https://github.com/gilbertw1/better-jumper][gilbertw1/better-jumper: A configurable jump list implementation for Emacs]]

8.2 company

 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
(after! company
  (setq company-idle-delay 0.5
        company-minimum-prefix-length 2
        company-transformers nil)
  (setq company-show-numbers t)
  (define-key company-active-map (kbd "C-n") 'company-select-next-or-abort)
  (define-key company-active-map (kbd "C-j") 'company-select-previous-or-abort)

  (defun ora-company-number ()
  "Forward to `company-complete-number'.
Unless the number is potentially part of the candidate.
In that case, insert the number."
  (interactive)
  (let* ((k (this-command-keys))
         (re (concat "^" company-prefix k)))
    (if (or (cl-find-if (lambda (s) (string-match re s))
                        company-candidates)
            (> (string-to-number k)
               (length company-candidates))
            (looking-back "[0-9]+\\.[0-9]*" (line-beginning-position)))
        (self-insert-command 1)
      (company-complete-number
       (if (equal k "0")
           10
         (string-to-number k))))))

(defun ora--company-good-prefix-p (orig-fn prefix)
  (unless (and (stringp prefix) (string-match-p "\\`[0-9]+\\'" prefix))
    (funcall orig-fn prefix)))
(advice-add 'company--good-prefix-p :around #'ora--company-good-prefix-p)

(let ((map company-active-map))
  (mapc (lambda (x) (define-key map (format "%d" x) 'ora-company-number))
        (number-sequence 0 9))
  (define-key map " " (lambda ()
                        (interactive)
                        (company-abort)
                        (self-insert-command 1)))
  (define-key map (kbd "<return>") nil)))

8.3 selectrum

1
2
;; (package! selectrum)
;; (package! selectrum-prescient)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
;; (use-package! selectrum
;;   :config
;;   (selectrum-mode +1)
;;   )
;; (use-package! selectrum-prescient
;;   :config
;;   ;; to make sorting and filtering more intelligent
;;   (selectrum-prescient-mode +1)
;;   ;; to save your command history on disk, so the sorting gets more
;;   ;; intelligent over time
;;   ;;(prescient-persist-mode +1)
;;   )

8.4 Customize completion-at-point

1
2
3
;; First try to indent the current line, and if the line
;; was already indented, then try `completion-at-point'
(setq tab-always-indent 'complete)

8.5 company-tabnine

1
(package! company-tabnine)
 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! company-tabnine
  :when (featurep! :completion company)
  :config
  (setq company-tabnine--disable-next-transform nil)
  (defun my-company--transform-candidates (func &rest args)
    (if (not company-tabnine--disable-next-transform)
        (apply func args)
      (setq company-tabnine--disable-next-transform nil)
      (car args)))

  (defun my-company-tabnine (func &rest args)
    (when (eq (car args) 'candidates)
      (setq company-tabnine--disable-next-transform t))
    (apply func args))

  (advice-add #'company--transform-candidates :around #'my-company--transform-candidates)
  (advice-add #'company-tabnine :around #'my-company-tabnine)
  ;; Trigger completion immediately.
  ;; (setq company-idle-delay 0)

  ;; Number the candidates (use M-1, M-2 etc to select completions).
  (setq company-show-numbers t)

  ;; Use the tab-and-go frontend.
  ;; Allows TAB to select and complete at the same time.
  (company-tng-configure-default)
  (setq company-frontends
        '(company-tng-frontend
          company-pseudo-tooltip-frontend
          company-echo-metadata-frontend))
  )

8.6 company-math

1
2
3
4
5
6
7
(use-package! company-math
  :config
  (defun my-latex-mode-setup ()
  (setq-local company-backends
              (append '((company-math-symbols-latex company-latex-commands))
                      company-backends)))
  )

8.7 company-backend

 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
(set-company-backend! '(julia-mode
                        org-mode)
  '(
    company-math-symbols-unicode
    company-files
    company-yasnippet
    :separate
    company-tabnine
    ))
;;  (set-company-backend! 'sh-mode nil) ; unsets backends for sh-mode
(set-company-backend! '(c-mode
                        c++-mode
                        ess-mode
                        haskell-mode
                        ;;emacs-lisp-mode
                        conf-mode
                        lisp-mode
                        sh-mode
                        php-mode
                        python-mode
                        go-mode
                        ruby-mode
                        rust-mode
                        js-mode
                        css-mode
                        web-mode
                        nix-mode
                        json-mode
                        )
  '(
    company-files
    company-yasnippet
    :separate
    company-tabnine
    ))

(setq +lsp-company-backends '(company-capf
                              company-files
                              company-yasnippet
                              :separate
                              company-tabnine
                              ))

8.8 Edition

8.8.1 maple-iedit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  (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 maple-iedit-mode-keymap
                ("C-n" . maple-iedit-match-next)
                ("C-m" . maple-iedit-match-previous)
                ("<down>" . maple-iedit-match-next)
                ("<up>" . maple-iedit-match-previous)
                ("C-," . maple-iedit-skip-and-match-next)
                ("C-." . maple-iedit-skip-and-match-previous)
                ("<right>" . maple-iedit-skip-and-match-next)
                ("<left>" . maple-iedit-skip-and-match-previous)
                )
    )

8.8.2 highlight

1
2
3
4
5
6
7
8
(use-package! highlight-indent-guides
:config
(setq highlight-indent-guides-method 'character)
(setq highlight-indent-guides-auto-enabled nil)
(set-face-background 'highlight-indent-guides-even-face "dimgray")
(set-face-foreground 'highlight-indent-guides-character-face "dimgray")
)

8.8.3 parentheses

 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
;;; -*- lexical-binding: t; -*-
;; we will call `blink-matching-open` ourselves...

(remove-hook 'post-self-insert-hook
             #'blink-paren-post-self-insert-function)
;; this still needs to be set for `blink-matching-open` to work
(setq blink-matching-paren 'show)

(let ((ov nil)) ; keep track of the overlay
  (advice-add
   #'show-paren-function
   :after
    (defun show-paren--off-screen+ (&rest _args)
      "Display matching line for off-screen paren."
      (when (overlayp ov)
        (delete-overlay ov))
      ;; check if it's appropriate to show match info,
      ;; see `blink-paren-post-self-insert-function'
      (when (and (overlay-buffer show-paren--overlay)
                 (not (or cursor-in-echo-area
                          executing-kbd-macro
                          noninteractive
                          (minibufferp)
                          this-command))
                 (and (not (bobp))
                      (memq (char-syntax (char-before)) '(?\) ?\$)))
                 (= 1 (logand 1 (- (point)
                                   (save-excursion
                                     (forward-char -1)
                                     (skip-syntax-backward "/\\")
                                     (point))))))
        ;; rebind `minibuffer-message' called by
        ;; `blink-matching-open' to handle the overlay display
        (cl-letf (((symbol-function #'minibuffer-message)
                   (lambda (msg &rest args)
                     (let ((msg (apply #'format-message msg args)))
                       (setq ov (display-line-overlay+
                                 (window-start) msg ))))))
          (blink-matching-open))))))

(defun display-line-overlay+ (pos str &optional face)
  "Display line at POS as STR with FACE.

FACE defaults to inheriting from default and highlight."
  (let ((ol (save-excursion
              (goto-char pos)
              (make-overlay (line-beginning-position)
                            (line-end-position)))))
    (overlay-put ol 'display str)
    (overlay-put ol 'face
                 (or face '(:inherit default :inherit highlight)))
    ol))

(setq show-paren-style 'paren
      show-paren-delay 0.03
      show-paren-highlight-openparen t
      show-paren-when-point-inside-paren nil
      show-paren-when-point-in-periphery t)
(show-paren-mode 1)

8.8.4 awesome-pair

1
(use-package! awesome-pair)

8.8.5 hungry-delete

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

8.8.6 format-all

1
(package! format-all :recipe (:host github :repo "lassik/emacs-format-all-the-code"))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
(use-package! format-all
  :config
  (dolist (hook (list
                 'js-mode-hook
                 'rust-mode-hook
                 'python-mode-hook
                 'java-mode-hook
                 'sh-mode-hook
                 'nix-mode-hook
                 'haskell-mode-hook
                 'emacs-lisp-mode-hook
                 ))
    (add-hook hook 'format-all-mode))
  (add-hook! 'format-all-mode-hook 'format-all-ensure-formatter)
  )
1
t

8.9 Bookmark

1
(package! bm)
  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
  (use-package! bm
    :demand t
    :init
    (setq bm-restore-repository-on-load t)
    :config

    (bind-keys
     :map bm-show-mode-map
     ("j" . next-line)
     ("k" . previous-line))

    (setq bm-cycle-all-buffers t
          bm-highlight-style 'bm-highlight-only-fringe
          bm-repository-size 1000)
    (setq-default bm-buffer-persistence t)

    (defun adq/bm-save ()
      "Save bookmarks to persistent repository."
      (interactive)
      (bm-buffer-save-all)
      (bm-repository-save))

    (advice-add 'bm-bookmark-add
                :after (lambda (&rest args)
                         (adq/bm-save)))
    (advice-add 'bm-bookmark-remove
                :after (lambda (&rest args)
                         (adq/bm-save)))
    (add-hook 'after-init-hook #'bm-repository-load)
    (add-hook 'find-file-hooks #'bm-buffer-restore)
    (add-hook 'after-rever-hook #'bm-buffer-restore)
    (add-hook 'kill-buffer-hook #'bm-buffer-save)
    (add-hook 'after-save-hook #'bm-buffer-save)
    (add-hook 'kill-emacs-hook
              (lambda ()
                (bm-buffer-save-all)
                (bm-repository-save)))

    (defun adq/bm-list-all-bookmarks ()
      "Generate a list of all bookmarks from all files."
      (let ((bookmarks '()))
        (cl-loop for entry in bm-repository
                 when (and (listp entry) (f-readable-p (car entry)))
                 do
                 (with-temp-buffer
                   (insert-file-contents-literally (car entry))
                   (cl-letf (((symbol-function 'bm-bookmark-add)
                              (lambda (&optional annotation time temporary)
                                (!cons (list (car entry)
                                             (point)
                                             (line-number-at-pos)
                                             (string-trim (thing-at-point 'line t)))
                                       bookmarks)))
                             ((symbol-function 'message)
                              (lambda (&rest _))))
                     (bm-buffer-restore-2 (cdr entry)))))
        bookmarks))

      (defun adq/helm-bm-all-format-bookmark (bookmark)
        "Format bookmark for display."
        (let ((file (f-filename (car bookmark)))
              (line (caddr bookmark))
              (contents (cadddr bookmark)))
          (cons
           (format "%s:%s: %s"
                   (propertize file 'face compilation-info-face)
                   (propertize (format "%d" line) 'face compilation-line-face)
                   contents)
           bookmark)))

      (defvar adq/helm-bm-all-source
        (helm-build-sync-source "Helm All Bookmarks"
          :candidates
          (lambda ()
            (mapcar #'adq/helm-bm-all-format-bookmark
                    (adq/bm-list-all-bookmarks)))
          :action
          '(("Switch to buffer" .
             (lambda (bookmark)
               (find-file (car bookmark))
               (goto-char (cadr bookmark))))))
        "Helm source with all the bookmarks.")

      (defun adq/helm-bm-list-all ()
        "List all bookmarks usin Helm."
        (interactive)
        (helm :sources 'adq/helm-bm-all-source
              :buffer "*helm bm all*"))

    (defhydra adq/hydra-bm nil
      "
  Bookmarks
  ^^^^------------------------------------------------
  _m_: Toggle      _l_: Bookmarks from Buffers
  _n_: Next        _a_: Bookmarks form All Files
  _p_: Previous    _L_: List
  "
      ("m" bm-toggle)
      ("n" bm-next)
      ("p" bm-previous)
      ("a" adq/helm-bm-list-all :exit t)
      ("l" helm-bm :exit t)
      ("L" bm-show-all :exit t))
    (bind-key "C-c m" #'adq/hydra-bm/body))

8.10 scroll

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; (use-package! fast-scroll
;; :config
;; (setq fast-scroll-throttle 0.5)
;; (add-hook 'fast-scroll-start-hook (lambda () (flycheck-mode -1)))
;; (add-hook 'fast-scroll-end-hook (lambda () (flycheck-mode 1)))
;; (fast-scroll-config)
;; (fast-scroll-mode 1)
;; )
(use-package! scrollkeeper)
(global-set-key [remap scroll-up-command] #'scrollkeeper-contents-up)
(global-set-key [remap scroll-down-command] #'scrollkeeper-contents-down)

8.11 templating

1
(package! yatemplate)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(use-package! yatemplate
  :after yasnippet
  :config
  ;; Define template directory
  (setq yatemplate-dir (concat doom-private-dir "modules/templates"))
  ;; Coupling with auto-insert
  (setq auto-insert-alist nil)
  (yatemplate-fill-alist)
  (add-hook 'find-file-hook 'auto-insert)
  )

8.12 ROCKTAKEY/grugru: Rotate text at point in Emacs.

9 org-mode

9.1 load basic config

1
2
3
(load! "setting")
(use-package! ox-hugo)
(use-package! ob-session-async)

9.2 Only modes or files seeting in org-mode

1
2
3
4
5
(define-derived-mode only-file-to-org-mode org-mode "Org + only mode"
  "Only modes for org file."
  (add-hook! org-tanglesync-watch-mode :local #'org-tanglesync-mode)
  )
(add-to-list 'auto-mode-alist '("README-[^z-a]*\\.org\\'" . only-file-to-org-mode))

9.3 Org Mode Map && After Org! settings

 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
(after! org
  (when IS-LINUX
    (setq org-id-locations-file (concat org-directory "/cache/.linux-orgids"))
    )

  (when IS-MAC
    (setq org-id-locations-file (concat org-directory "/cache/.mac-orgids"))
    )

  (setq org-clock-into-drawer t)
  (add-hook! 'org-mode-hook 'auto-revert-mode)
  (add-hook! 'dired-mode-hook 'org-download-enable)
  ;; (setq-hook! 'org-mode-hook fill-column 80)
  ;; (setq-hook! 'org-mode-hook org-superstar-mode 1)
  (setq org-directory "~/Documents/org-notes")
  (setq org-log-into-drawer t)
  (setq org-agenda-start-day "-1d")
  (setq org-agenda-span 2)
  (setq org-time-clocksum-format '(:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t))
  (setq org-archive-location (concat "%s_archive_" (format-time-string "%Y" (current-time)) "::"))
  ;; Removes clocked tasks with 0:00 duration
  (setq org-clock-out-remove-zero-time-clocks t)
  ;; Change task state to STARTED when clocking in
  (setq org-clock-in-switch-to-state "⚔ INPROCESS")
  (setq org-src-fontify-natively t
        org-src-preserve-indentation t
        org-src-tab-acts-natively t
        org-src-window-setup 'current-window)
  (setq org-agenda-time-leading-zero t)

  ;;Markdown
  (eval-after-load "org"
    '(require 'ox-md nil t))
  ;;https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html

  (defun org-show-two-levels ()
    (interactive)
    (org-content 2))

  (setq org-download-timestamp "%Y%m%d_%H%M%S")

  (add-hook! 'org-mode-hook 'org-show-two-levels)
  (add-hook! 'after-init-hook 'org-id-update-id-locations)

  (add-hook! 'unpackaged/org-return-dwim 'unpackaged/org-fix-blank-lines)
  (define-key org-mode-map (kbd "C-c ;") 'org-time-stamp-inactive)
  (define-key org-mode-map (kbd "RET") 'unpackaged/org-return-dwim)
  (setq org-plantuml-jar-path (expand-file-name "~/.myscript/plantuml"))
  )

9.4 org-starter

1
(package! org-starter)
 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
(use-package! org-starter
  :custom
  ;; Enable external configuration files loaded from org-starter-path
  (org-starter-load-config-files t)
  :config
  (org-starter-def "~/Documents/org-notes"
    :files
    ("posts/myself/love.org"         :key "l" :refile (:maxlevel . 5 ))
    ("posts/myself/qing.org"         :key "q" :refile (:maxlevel . 5 ))
    ("posts/myself/plan.org"         :key "p" :refile (:maxlevel . 5 ))
    )
  (org-starter-def "~/Documents/org-notes/braindump"
    :files
    ("myself-private/" :agenda t)
    ("myself-private/GTD/gtd.org"                      :key "g" :refile (:maxlevel . 5))
    ("myself-private/GTD/notes.org"                    :key "n" :refile (:maxlevel . 5 ))
    ("myself-private/GTD/myself.org"                    :key "m" :refile (:maxlevel . 5 ))
    ("myself-private/GTD/Habit.org"                     :key "h" :refile (:maxlevel . 5 ))
    ;;
    ("guangtao/" :agenda t)
    ("guangtao/learn_music.org"          :agenda t :key "M" :refile (:maxlevel . 5 ))
    ("guangtao/guangtao's_library.org"       :key "b" :refile (:maxlevel . 5 ))
    ("guangtao/guangtao's_feed.org"         :agenda t :key "f" :refile (:maxlevel . 5 ))
    ;;
    ("life/" :agenda t)
    ("life/life_goods.org"     :key "s" :refile (:maxlevel . 5 ))
    ("gaming/" :agenda t)
    ("journals/" :agenda t)
    ("hardware/" :agenda t)
    ("system/" :agenda t)
    ("deployment/" :agenda t)
    ("cs/" :agenda t)
    ("programming/" :agenda t)
    ("nix/" :agenda t)
    ("emacs/" :agenda t)
    ("security/" :agenda t)
    ("financial/" :agenda t)
    ("network/" :agenda t)
    ("data-science/" :agenda t)
    )
  (org-starter-def "~/.config/nixpkgs/dotfiles/doom-emacs/"
    :files
    ("config.org" :key "c" :refile (:maxlevel . 5))
    ("meow.org" :key "w" :refile (:maxlevel . 5))
    )
  (org-starter-def "~/.config/nixpkgs"
    :files
    ("README.org")
    ("global-readme.org")
    ("dotfiles/wallpaper/wallpaper.org" :agenda nil)
    )

  (defhydra gtrun/hydra-org-starter nil
    "
  Org-starter-files
  ^^^^------------------------------------------------
 _c_: config.org  _g_: gtd.org     _l_: love.org
 _n_: note        _h_: Habit.org    _w_: meow.org
 _m_: myself      _p_: Plan.org
 _b_: my-books    _f_: feed
 _s_: life-goods
  "

    ("c" org-starter-find-file:config)
    ("w" org-starter-find-file:meow)
    ("g" org-starter-find-file:gtd)
    ("s" org-starter-find-file:life_goods)
    ("n" org-starter-find-file:notes)
    ("f" org-starter-find-file:feed)
    ("m" org-starter-find-file:myself)
    ("l" org-starter-find-file:love)
    ("h" org-starter-find-file:Habit)
    ("p" org-starter-find-file:plan)
    ("b" org-starter-find-file:guangtao\'\s_library)
    )
  :commands org-starter-load-all-files-in-path
  :hook
  (after-init . org-starter-load-all-files-in-path)
  :bind
  (
   ("C-c e" . org-starter-select-file))
  ;; "C-c e" . org-starter-refile-by-key))
  )
1
org-starter-select-file

9.5 org-superstar

1
(package! org-superstar)
1
2
3
4
5
6
(use-package! org-superstar
  :hook
  (org-mode . org-superstar-mode)
  :config
  (setq org-superstar-headline-bullets-list '("☰" "☷" "☵" "☲"  "☳" "☴"  "☶"  "☱" ))
)

9.6 org-ql

1
2
3
(package! org-ql :recipe (:host github :repo "alphapapa/org-ql"
                         :files ("*.el")
                         ))
1
(use-package! org-ql)
1
(package! helm-org-rifle)
1
(use-package! helm-org-rifle)

9.7 org-book

1
(package! org-books :recipe (:host github :repo "lepisma/org-books"))
1
2
3
4
(use-package! org-books
  :config
  (setq org-books-file "~/Documents/org-notes/braindump/guangtao/guangtao's_library.org")
  )

9.8 org-z

  • [2021-01-08 Fri 17:49] -> helm-rg
  • [2021-01-08 Fri 17:49] -> org-ql
1
2
3
(package! org-z :recipe (:host github :repo "landakram/org-z"
                         :files ("*.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
(use-package! org-z
  :init
  (define-key org-mode-map (kbd "C-c C-;") 'org-z-insert-link)
  (require 'org-z-helm)
  ;;(require 'org-z-selectrum)
  :config
  (org-z-mode 1)
  (setq org-z-directories  '("~/Documents/org-notes/braindump"
                             "~/Documents/org-notes/braindump/guangtao"
                             "~/Documents/org-notes/braindump/journals"
                             "~/Documents/org-notes/braindump/cs"
                             "~/Documents/org-notes/braindump/network"
                             "~/Documents/org-notes/braindump/security"
                             "~/Documents/org-notes/braindump/life"
                             "~/Documents/org-notes/braindump/math"
                             "~/Documents/org-notes/braindump/math/my-mathematic-julia"
                             "~/Documents/org-notes/braindump/data-science"
                             "~/Documents/org-notes/braindump/deployment"
                             "~/Documents/org-notes/braindump/hardware"
                             "~/Documents/org-notes/braindump/system"
                             "~/Documents/org-notes/braindump/emacs"
                             "~/Documents/org-notes/braindump/gaming"
                             "~/Documents/org-notes/braindump/financial"
                             "~/Documents/org-notes/braindump/myself-private"
                             "~/Documents/org-notes/braindump/myself-private/GTD"
                             "~/Documents/org-notes/braindump/nix"
                             "~/Documents/org-notes/braindump/programming"
                             "~/.config/nixpkgs/dotfiles/doom-emacs"
                             ))

   )
1
t

9.9 GTD

9.9.1 agenda knowledge

  1. Org Mode - Organize Your Life In Plain Text!

    [2020-10-13 Tue 15:05] <- Org Edna

  1. Sexp Entries and the Fancy Diary Display

9.9.2 super-agenda

1
(package! org-super-agenda)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(use-package! org-super-agenda
  :config
  (add-hook! 'after-init-hook 'org-super-agenda-mode)
  (require 'org-habit)
  (setq
   org-agenda-skip-scheduled-if-done t
   org-agenda-skip-deadline-if-done t
   org-agenda-include-deadlines t
   org-agenda-include-diary nil
   org-agenda-block-separator nil
   org-agenda-compact-blocks t
   org-agenda-start-with-log-mode t)
  )

9.9.3 org-todo-keywords

 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
    (setq org-todo-keywords
     '((sequence
           "TODO(t)"  ; A task that needs doing & is ready to do
           "PROJ(p)"  ; An ongoing project that cannot be completed in one step
           "INPROCESS(s)"  ; A task that is in progress
           "⚑ WAITING(w)"  ; Something is holding up this task; or it is paused
           "|"
           "☟ NEXT(n)"
           "✰ IMPORTANT(i)"
           "DONE(d)"  ; Task successfully completed
           "✘ CANCELED(c@)") ; Task was cancelled, aborted or is no longer applicable
          (sequence
           "✍ NOTE(N)"
           "FIXME(f)"
           "☕ BREAK(b)"
           "❤ LOVE(l)"
           "REVIEW(r)"
           )) ; Task was completed
        org-todo-keyword-faces
        '(
          ("TODO" . (:foreground "#ff39a3" :weight bold))
          ("INPROCESS"  . "orangered")
          ("✘ CANCELED" . (:foreground "white" :background "#4d4d4d" :weight bold))
          ("⚑ WAITING" . "pink")
          ("☕ BREAK" . "gray")
          ("❤ LOVE" . (:foreground "VioletRed4"
                                   ;; :background "#7A586A"
                                   :weight bold))
          ("☟ NEXT" . (:foreground "DeepSkyBlue"
                                   ;; :background "#7A586A"
                                      :weight bold))
          ("✰ IMPORTANT" . (:foreground "greenyellow"
                                      ;; :background "#7A586A"
                                      :weight bold))
          ("DONE" . "#008080")
          ("FIXME" . "IndianRed")
          ))

9.9.4 agenda-custom-setting

 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
(require 'org-super-agenda)
(setq org-agenda-custom-commands
      '(("z" "GtruN Agenda"
         ((agenda "" ((org-agenda-span 2)
                      (org-agenda-start-day "-1d")
                      (org-super-agenda-groups
                       '((:name "Today List"
                                :time-grid t
                                :date today
                                :todo "⚔ INPROCESS"
                                :scheduled today
                                :order 1)))))
          (alltodo "" ((org-agenda-overriding-header "")
                       (org-super-agenda-groups
                        '((:name "Next to do"
                                 :priority>= "B"
                                 :order 2)
                          (:name "Important"
                                 :todo "✰ Important"
                                 :order 6)
                          (:name "Due Today"
                                 :deadline today
                                 :order 3)
                          (:name "Due Soon"
                                 :deadline future
                                 :order 8)
                          (:name "Overdue"
                                 :deadline past
                                 :order 20)
                          (:name "Issues"
                                 :tag "Issue"
                                 :order 12)
                          (:name "Projects"
                                 :tag "Project"
                                 :order 14)
                          (:name "Emacs"
                                 :tag "Emacs"
                                 :order 13)
                          (:name "Research"
                                 :tag "Research"
                                 :order 15)
                          (:name "To read"
                                 :tag ("BOOK" "READ")
                                 :order 30)
                          (:name "Waiting"
                                 :todo "⚑ WAITING"
                                 :order 18)
                          (:name "trivial"
                                 :priority<= "C"
                                 :todo ("SOMEDAY")
                                 :order 90)
                          (:discard (:tag ("Chore" "Routine" "Daily")))))))))

        ("b" . "BOOK")

        ("bb" "Search tags in todo, note, and archives"
         search "+{:book\\|books:}")

        ("bd" "BOOK TODO List"
         search "+{^\\*+\\s-+\\(⚔ INPROCESS\\|TODO\\|⚑ WAITING\\)\\s-} +{:book\\|books:}")

        ("d" "ALL DONE OF TASKS"
         search "+{^\\*+\\s-+\\(✔ DONE\\|✘ CANCELED\\)\\s-}")

        ("i" "ALL INPROCESS OF TASKS"
         search "+{^\\*+\\s-+\\(⚔ INPROCESS\\)\\s-}")

        ))

✰ IMPORTANT 9.9.5 Org Edna

[2020-10-13 Tue 15:05] -> Org Mode - Organize Your Life In Plain Text!

  • native-compiler-error
1
(package! org-edna :recipe (:build (:not compile)))
1
2
3
4
(use-package! org-edna
  :config
  (add-hook! 'after-init-hook 'org-edna-mode)
)

9.9.6 org-wild-notifier

1
(package! org-wild-notifier)
1
2
3
4
5
6
(use-package! org-wild-notifier
  :defer t
  :config
  (add-hook! 'after-init-hook 'org-wild-notifier-mode)
  (setq ;;org-wild-notifier-alert-time 15
        alert-default-style (if IS-MAC 'osx-notifier 'libnotify)))

TODO 9.9.7 takaxp/org-onit: Easy org-clock-in and org-clock-out

TODO 9.9.8 Trevoke/org-gtd.el: A package for using GTD using org-mode (beta)

9.10 Org-babel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
(after! ob-async
  (setq ob-async-no-async-languages-alist '("ipython" "ein-python"
                                            "ein-rust"
                                            "ein-julia"
                                            "ein-haskell"
                                            ))
  )

;;[[https://stackoverflow.com/questions/22668112/how-to-evaluate-all-code-blocks-when-exporting-in-emacs-org-mode][How to evaluate all code blocks when exporting in emacs org-mode - Stack Overflow]]
(setq org-confirm-babel-evaluate nil)
(setq org-export-use-babel nil)

(setq org-babel-C++-compiler 'clang++)
(setq org-babel-C-compiler 'clang)
1
gcc-9

9.11 org-publish

1
2
3
4
5
6
7
8
9
;;; setting.el -*- lexical-binding: t; -*-
(setq org-publish-project-alist
      '(
        ("init"
         :base-directory "~/.config/nixpkgs/dotfiles/doom-emacs"
         :publishing-function org-html-publish-to-html
         :publishing-directory "~/Documents/my-blog/public/custom"
         )
        ))

9.12 org-crypt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; 當被加密的部份要存入硬碟時,自動加密回去
  ;; 設定要加密的 tag 標籤為 secret
  (setq org-crypt-tag-matcher "secret")

  ;; 避免 secret 這個 tag 被子項目繼承 造成重複加密
  ;; (但是子項目還是會被加密喔)
  (setq org-tags-exclude-from-inheritance (quote ("secret")))

  ;; 用於加密的 GPG 金鑰
  ;; 可以設定任何 ID 或是設成 nil 來使用對稱式加密 (symmetric encryption)
  (setq org-crypt-key nil)

9.13 org-notdeft

1
(package! notdeft :recipe (:host github :repo "hasu/notdeft"))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(use-package! notdeft
  :config
  (setq notdeft-extension "org")
  ;;(setq notdeft-secondary-extensions '("md" "org" "scrbl"))
  (setq notdeft-xapian-program "/home/gtrun/.nix-profile/bin/notdeft-xapian")
  (when IS-MAC
    (setq notdeft-xapian-program "/Users/gtrun/.nix-profile/bin/notdeft-xapian")
    )
  (setq notdeft-directories '("~/Documents/org-notes/post/myself"
                              "~/Documents/org-notes/dailies"
                              "~/Documents/org-notes/post/traveling"
                              "~/Documents/org-notes/post/agenda"
                              "~/Documents/org-notes/post/game"
                              "~/Dropbox/project/my-learning-list"
                              "~/Documents/org-notes/GTD"
                              "~/Documents/org-notes/art"
                              "~/Documents/org-notes/braindump"
                              ))

  :bind (:map notdeft-mode-map
         ("C-q" . notdeft-quit)
         ("C-r" . notdeft-refresh)
         )
  )
  • build

cd ~/.emacs.d/.local/straight/repos/notdeft/xapian make

9.14 org-protocol

9.15 org-properties

1
(setq org-export-with-broken-links t)
1
t

9.16 org-timestramp

9.16.1 export

  • org-export-with-planning #+OPTIONS: p:t

9.17 org-roam

9.17.1 idea

  1. ✍ NOTE tilmanrassy/emacs-treeview: Abstract Emacs Lisp framework for tree navigation

    easy way to display org-ref with tree view instead of org-mode ?

9.17.2 org-roam

1
(unpin! org-roam)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
(use-package! org-roam
  :init
  (require 'org-roam-protocol)
  :config
  (setq org-roam-index-file "~/Documents/org-notes/braindump/pages/contents.org")
  ;;https://github.com/zaeph/.emacs.d/blob/0f4bf9a500ef6397b93c41cb51602bea9ab9a4c3/init.el#L3804
  ;; [[https://copingmechanism.com/2020/keeping-org-roam-daily-notes-in-a-separate-folder/][Keeping Org-roam Daily Notes in a separate folder – Coping Mechanism]]
  ;; (setq org-roam-dailies-capture-templates '(("d" "daily" plain (function org-roam-capture--get-point) ""
  ;;                                             :immediate-finish t
  ;;                                             :file-name "dailies/%<%Y-%m-%d>-${slug}"
  ;;                                             :head "#+TITLE: %<%Y-%m-%d>-${slug}\n#+created: %u\n#+last_modified: %U\n\n")))
  )

9.17.3 org-roam-server

1
;;(package! org-roam-server)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
;; (use-package! org-roam-server
;;   :config
;;   (setq org-roam-server-port 8081
;;         org-roam-server-export-inline-images t
;;         org-roam-server-authenticate nil
;;         org-roam-server-network-poll t
;;         org-roam-server-network-arrows nil
;;         org-roam-server-network-label-truncate t
;;         org-roam-server-network-label-truncate-length 60
;;         org-roam-server-network-label-wrap-length 20))

9.17.4 org-roam-bibtex

1
;;(package! org-roam-bibtex)
1
2
3
4
5
6
7
;; (use-package! org-roam-bibtex
;;   :config
;;   (add-hook 'org-mode-hook 'org-roam-bibtex-mode)
;;   :bind (:map org-roam-bibtex-mode-map
;;               ("C-c n a" . orb-note-actions)
;;               )
;;   )

9.17.5 org-nroam

1
(package! nroam :recipe (:host github :repo "NicolasPetton/nroam"))
1
2
3
4
(use-package! nroam
  :after org-roam
  :config
  (add-hook 'org-mode-hook #'nroam-setup-maybe))

9.17.6 org-ref

1
(package! org-ref)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(use-package! org-ref
  :config
  (defsubst dnd-unescape-uri (uri)
  (replace-regexp-in-string
   "%[A-Fa-f0-9][A-Fa-f0-9]"
   (lambda (arg)
     (let ((str (make-string 1 0)))
       (aset str 0 (string-to-number (substring arg 1) 16))
       str))
   uri t t))
  (setq org-ref-default-bibliography '("~/Documents/org-notes/braindump/bibliography/myBibliography.bib"))
  (setq bibtex-completion-bibliography "~/Documents/org-notes/braindump/bibliography/myBibliography.bib")
  )

9.17.7 org-templates

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
;; (defun org-roam-dailies-capture-today ()
;;   "Capture a note into the daily note for today."
;;   (interactive)
;;   (let ((org-roam-capture-templates org-roam-dailies-capture-templates)
;;         (org-roam-capture--info (list (cons 'time (current-time))))
;;         (org-roam-capture--context 'dailies))
;;     (org-roam--capture)))

;; (setq org-capture-templates '(("n" "Note" entry (function org-roam-dailies-capture-today)
;;                                  "* %?\n")))

9.18 org-journal

1
2
3
4
5
6
(use-package! org-journal
  :config
  (setq org-journal-dir "~/Documents/org-notes/braindump/journals")
  (setq org-journal-file-format "%Y_%m_%d.org")
  )

9.19 gkroam

1
;;(package! gkroam :recipe (:host github :repo "Kinneyzhang/gkroam"))
1
2
3
4
5
6
7
8
9
;; (use-package gkroam
;;   :hook (after-init . gkroam-mode)
;;   :init
;;   (setq gkroam-root-dir "~/Documents/org-notes/braindump")
;;   (setq gkroam-prettify-page-p t
;;         gkroam-show-brackets-p nil
;;         gkroam-use-default-filename t
;;         gkroam-window-margin 4)
;;   )

9.20 org-brain

1
(package! org-brain :recipe (:build (:not compile)))
1
2
3
4
5
6
7
8
(use-package! org-brain
  :config
  (setq org-brain-visualize-default-choices 'all
        org-brain-title-max-length 24
        org-brain-include-file-entries nil
        org-brain-file-entries-use-title nil)
  (setq org-brain-path "~/Documents/org-notes/braindump")
  )

9.21 ob-mermaid

1
(package! ob-mermaid)
1
2
3
4
(use-package! ob-mermaid
  :config
  (setq ob-mermaid-cli-path "~/.nix-profile/bin/mmdc")
  )

9.22 org-spacer

1
(package! org-spacer.el :recipe (:host github :repo "dustinlacewell/org-spacer.el"))
1
2
3
4
5
6
;; (use-package! org-spacer
;;   :config
;;   ;; (add-hook 'org-mode-hook
;;   ;;           (lambda () (add-hook 'before-save-hook
;;   ;;                                'org-spacer-enforce nil 'make-it-local)))
;;   )

9.23 org-density.el

1
(package! org-treeusage :recipe (:host github :repo "mtekman/org-treeusage.el"))
1
2
3
4
5
(use-package! org-treeusage
  :config
  (define-key org-mode-map (kbd "C-c d") 'org-treeusage-mode)
  )

9.24 org-format

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
;; (defun endless/export-audio-link (path desc format)
;;   "Export org audio links to hmtl."
;;   (cl-case format
;;     (html (format
;;        "<audio preload=\"auto\"> <source src=\"https://www.gtrun.org/music/%s\">%s</audio>"
;;        path (or desc "")))

;;     ;; README: hugo music file path
;;     (md (format
;;      "<audio class=\"wp-audio-shortcode\"  loop=\"1\"  preload=\"auto\" style=\"width: 100%%;\" controls> <source src=\"https://www.gtrun.org/music/%s\">%s</audio>"
;;      path (or desc "")))
;;     (latex (format "(HOW DO I EXPORT AUDIO TO LATEX? \"%s\")" path))))

;; (after! org
;;   (org-add-link-type "audio" #'ignore #'endless/export-audio-link)
;;   ;;(setq org-download-timestamp "%Y%m%d_%H%M%S")
;; )

9.24.2 ianxm/emacs-scrum: dynamic scrum report generation for org-mode buffers

1
2
3
4
(package! org-super-links :recipe (:host github
                       :repo "toshism/org-super-links"
                       :files ("*.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
(use-package! org-super-links
  :config
  (defun org-super-links-backlink-prefix-timestamp ()
  "Return the default prefix string for a backlink.
Inactive timestamp formatted according to `org-time-stamp-formats' and
a separator ' <- '."
  (let* ((time-format (substring (cdr org-time-stamp-formats) 1 -1))
	 (time-stamp (format-time-string time-format (current-time))))
    (format " - [%s] <- "
	    time-stamp)))

(defun org-super-links-link-prefix-timestamp ()
  "Return the default prefix string for a backlink.
Inactive timestamp formatted according to `org-time-stamp-formats' and
a separator ' -> '."
  (let* ((time-format (substring (cdr org-time-stamp-formats) 1 -1))
	 (time-stamp (format-time-string time-format (current-time))))
    (format " - [%s] -> "
	    time-stamp)))

(defun org-super-links-quick-insert-inline-link ()
  "Insert inline link regardless of variable `org-super-links-related-into-drawer' value."
  (interactive)
  ;; how to handle prefix here?
  (let ((org-super-links-related-into-drawer nil)
	(org-super-links-link-prefix 'org-super-links-link-prefix-timestamp))
    (org-super-links-link)))

(defun org-super-links-quick-insert-drawer-link ()
  "Insert link into drawer regardless of variable `org-super-links-related-into-drawer' value."
  (interactive)
  ;; how to handle prefix here?
  (let ((org-super-links-related-into-drawer (or org-super-links-related-into-drawer nil))
	(org-super-links-link-prefix 'org-super-links-backlink-prefix-timestamp))
    (org-super-links-link)))

(setq org-id-link-to-org-use-id
        'create-if-interactive-and-no-custom-id)

  (setq org-super-links-related-into-drawer nil
        org-super-links-backlink-into-drawer nil
        org-super-links-link-prefix 'org-super-links-link-prefix-timestamp)
  )

9.26 org-wiki

1
2
3
4
5
6
7
8
(package! wikinfo :recipe (:host github
                             :repo "progfolio/wikinfo"
                             ))

(package! wikinforg :recipe (:host github
                             :repo "progfolio/wikinforg"
                             ))

1
2
(use-package! wikinfo)
(use-package! wikinforg)

9.27 org-noter-plus

1
(package! org-noter-plus :recipe (:host github :repo "yuchen-lea/org-noter-plus"))
1
2
3
4
(use-package! org-noter-plus
  :config
  (setq org-noter-plus-image-dir "~/Documents/org-notes/braindump/.attach")
)

9.28 org-ipynb

1
(package! ox-ipynb :recipe (:host github :repo "jkitchin/ox-ipynb"))
1
(use-package! ox-ipynb)

9.29 org-html-theme

1
2
(package! org-html-themify :recipe (:host github :repo "DogLooksGood/org-html-themify"
                                    :files ("*.el" "*.js" "*.css")))
1
2
3
4
5
6
7
8
;; (use-package! org-html-themify
;;   :hook (org-mode . org-html-themify-mode)
;;   :custom
;;   (org-html-themify-themes
;;    '((dark . doom-one)
;;      (light . doom-one)))
;;   )

9.30 org-clones

  1. legalnonsense/org-clones: Prototype for method of cloning orgmore headers
1
2
3
4
(package! org-link-beautify :recipe (:host github
                             :repo "stardiviner/org-link-beautify"
                             ))

1
2
3
4
5
(use-package! org-link-beautify
  :config
  (add-hook! 'org-mode-hook 'org-link-beautify-mode)
  )

TODO 9.32 marcIhm/org-working-set: Manage a working-set of org-nodes

1
2
(package! org-working-set
)
1
(use-package! org-working-set)

9.33 mtekman/org-tanglesync.el: A package to pull external changes into an org-mode source block if that block is tangled to an external file

1
(package! org-tanglesync)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(use-package! org-tanglesync
  :config
  :hook (((prog-mode text-mode) . org-tanglesync-watch-mode))
  :custom
  (org-tanglesync-watch-files '("~/.config/nixpkgs/dotfiles/README-dotfiles.org"
                                "~/.config/nixpkgs/README-home-manager.org"
                                "~/.config/nixpkgs/nixos-flk/README-NixOS.org"
                                ))
  :config
  ;; (add-hook 'org-mode-hook (lambda ()
  ;;                            ;;……
  ;;                            (cond
  ;;                             ((equal (substring buffer-file-name -11) "-README.org")
  ;;                              (progn
  ;;                                (setq-local org-tanglesync-mode t)
  ;;                                ))
  ;;                              ))
  ;;                            )

  :bind
  (( "C-c M-i" . org-tanglesync-process-buffer-interactive)
   ( "C-c M-a" . org-tanglesync-process-buffer-automatic))
  )

TODO 9.34 casouri/valign: Pixel-perfect visual alignment for Org and Markdown tables.

TODO 9.35 lepisma/org-krita: Krita sketches in Org

9.36 alphapapa/org-graph-view: View Org buffers as a clickable, graphical mind-map

1
2
;; (package! org-graph-view :recipe (:host github :repo "alphapapa/org-graph-view"))

1
;;(use-package! org-graph-view)

9.37 the-humanities/org-mind-map: This is an emacs package that creates graphviz directed graphs.

1
(package! org-mind-map :recipe (:host github :repo "the-humanities/org-mind-map"))
1
2
3
4
5
6
(use-package! org-mind-map
  :init
  (require 'ox-org)
  :config
  (setq org-mind-map-engine "circo")
  )
1
t

9.38 org-parse

10 my-codes

10.1 Initialize packages

1
;;; modules/private/my-code/packages/packages.el -*- lexical-binding: t; -*-
1
;;; config..el -*- lexical-binding: t; -*-

10.2 Latex

1
(load! "my-latex")

10.2.1 auctex

10.2.2 chinese-latex

“./modules/private/my-code/my-latex.el” (after! latex (add-to-list ‘org-latex-classes ‘(“article” “\\documentclass[a4paper,11pt]{article} [NO-DEFAULT-PACKAGES] \\usepackage[utf8]{inputenc} \\usepackage[T1]{fontenc} \\usepackage{fixltx2e} \\usepackage{graphicx} \\usepackage{longtable} \\usepackage{float} \\usepackage{wrapfig} \\usepackage{rotating} \\usepackage[normalem]{ulem} \\usepackage{amsmath} \\usepackage{textcomp} \\usepackage{marvosym} \\usepackage{wasysym} \\usepackage{amssymb} \\usepackage{booktabs} \\usepackage[colorlinks,linkcolor=black,anchorcolor=black,citecolor=black]{hyperref} \\tolerance=1000 \\usepackage{listings} \\usepackage{xcolor} \\usepackage{fontspec} \\usepackage{xeCJK} \\setCJKmainfont{Weibei SC} \\setmainfont{Fantasque Sans Mono} \\lstset{ %行号 numbers=left, %背景框 framexleftmargin=10mm, frame=none, %背景色 %backgroundcolor=\\color[rgb]{1,1,0.76}, backgroundcolor=\\color[RGB]{245,245,244}, %样式 keywordstyle=\\bf\\color{blue}, identifierstyle=\\bf, numberstyle=\\color[RGB]{0,192,192}, commentstyle=\\it\\color[RGB]{0,96,96}, stringstyle=\\rmfamily\\slshape\\color[RGB]{128,0,0}, %显示空格 showstringspaces=false } " ("\\section{%s}” . “\\section*{%s}") ("\\subsection{%s}” . “\\subsection*{%s}") ("\\subsubsection{%s}” . “\\subsubsection*{%s}") ("\\paragraph{%s}” . “\\paragraph*{%s}") ("\\subparagraph{%s}” . “\\subparagraph*{%s}")))

  ;; {{ export org-mode in Chinese into PDF
  ;; @see <http://freizl.github.io/posts/tech/2012-04-06-export-orgmode-file-in-Chinese.html>
  ;; and you need install texlive-xetex on different platforms
  ;; To install texlive-xetex:
  ;;    \`sudo USE="cjk" emerge texlive-xetex\` on Gentoo Linux
  ;; }}
  ;;(setq org-latex-default-class "ctexart")
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
(setq org-src-fontify-natively t)
(setq org-latex-pdf-process
        '("xelatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "xelatex -interaction nonstopmode -output-directory %o %f"
          "xelatex -interaction nonstopmode -output-directory %o %f"
          "xelatex -interaction nonstopmode -output-directory %o %f"
          "rm -fr %b.out %b.log %b.tex auto"))

) #+endsrc

10.2.3 org-latex-instant-preview

1
(package! org-latex-impatient :recipe (:host github :repo "yangsheng6810/org-latex-impatient"))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(use-package org-latex-impatient
  ;;:hook (org-mode . org-latex-instant-preview-mode)
  :config
  (add-hook 'org-latex-impatient-mode-hook (lambda () (awesome-tab-mode -1)))

  (when IS-LINUX
    (setq org-latex-impatient-tex2svg-bin "/run/current-system/sw/bin/tex2svg")
    (setq org-latex-impatient-scale 10.0)
    )

  (when IS-MAC
    (setq org-latex-impatient-tex2svg-bin
          "~/.nix-profile/bin/tex2svg")
    (setq org-latex-impatient-scale 5.0)
    )
  )

10.3 Haskell

10.3.1 lsp-haskell

1
(package! lsp-haskell)
1
2
3
4
5
(use-package! lsp-haskell
  :config
  (add-hook 'haskell-mode-hook #'lsp)
  (add-hook 'haskell-literate-mode-hook #'lsp)
)

10.4 Ccls

1
2
3
4
(use-package! ccls
  :hook ((c-mode c++-mode objc-mode cuda-mode) .
         (lambda () (require 'ccls) (lsp)))
  )

10.5 Poly Mode

1
(unpin! polymode)
1
2
3
4
(use-package! polymode
:config
  (add-hook 'org-brain-visualize-mode-hook #'org-brain-polymode)
)

10.5.1 Poly Mode Markdown

1
(package! poly-markdown :recipe (:build (:not compile)))
1
2
3
4
(use-package! poly-markdown
  :config
  (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown-mode))
)

10.5.2 Poly 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
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
;;; poly-org.el --- Polymode for org-mode -*- lexical-binding: t -*-
;;
;; Author: Vitalie Spinu
;; Maintainer: Vitalie Spinu
;; Copyright (C) 2013-2020 Vitalie Spinu
;; Version: 0.2.2
;; Package-Requires: ((emacs "25") (polymode "0.2.2"))
;; URL: https://github.com/polymode/poly-org
;; Keywords: languages, multi-modes
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This file is *NOT* part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(require 'polymode)
(require 'org)
(require 'org-src)

(define-obsolete-variable-alias 'pm-host/org 'poly-org-hostmode "v0.2")
(define-obsolete-variable-alias 'pm-inner/org 'poly-org-innermode "v0.2")

(defun poly-org-mode-matcher ()
  (let ((case-fold-search t))
    (when (re-search-forward "#\\+begin_\\(src\\|example\\|export\\) +\\([^ \t\n]+\\)" (point-at-eol) t)
      (let ((lang (match-string-no-properties 2)))
        (or (cdr (assoc lang org-src-lang-modes))
            lang)))))

(defvar ess-local-process-name)
(defun poly-org-convey-src-block-params-to-inner-modes (_ this-buf)
  "Move src block parameters to innermode specific locals.
Used in :switch-buffer-functions slot."
  (cond
   ((derived-mode-p 'ess-mode)
    (with-current-buffer (pm-base-buffer)
      (let* ((params (nth 2 (org-babel-get-src-block-info t)))
             (session (cdr (assq :session params))))
        (when (and session (org-babel-comint-buffer-livep session))
          (let ((proc (buffer-local-value 'ess-local-process-name
                                          (get-buffer session))))
            (with-current-buffer this-buf
              (setq-local ess-local-process-name proc)))))))))

(define-hostmode poly-org-hostmode
  :mode 'org-mode
  :protect-syntax nil
  :protect-font-lock nil)

(define-auto-innermode poly-org-innermode
  :fallback-mode 'host
  :head-mode 'host
  :tail-mode 'host
  :head-matcher "^[ \t]*#\\+begin_\\(src\\|example\\|export\\) .*\n"
  :tail-matcher "^[ \t]*#\\+end_\\(src\\|example\\|export\\)"
  :mode-matcher #'poly-org-mode-matcher
  :head-adjust-face nil
  :switch-buffer-functions '(poly-org-convey-src-block-params-to-inner-modes)
  :body-indent-offset 'org-edit-src-content-indentation
  :indent-offset 'org-edit-src-content-indentation)

(define-polymode poly-org-mode
  :hostmode 'poly-org-hostmode
  :innermodes '(poly-org-innermode)
  (setq-local org-src-fontify-natively nil)
  (make-local-variable 'polymode-move-these-minor-modes-from-old-buffer)
  (push 'org-indent-mode polymode-move-these-minor-modes-from-old-buffer))

(provide 'poly-org)
;;; poly-org.el ends here
1
2
3
4
5
6
7
;; (package! poly-org :recipe (:host github
;;                             :repo "polymode/poly-org"
;;                             :build (:not compile)
;;                             ))
(package! poly-org   :recipe (:local-repo "./modules"
                              :build (:not compile))
)
1
2
(use-package! poly-org
  :commands poly-org-mode)

10.6 Elisp

TODO 10.6.1 doublep/eldev: Elisp Development Tool

TODO 10.6.2 emacs-elsa/Elsa: Emacs Lisp Static Analyzer

10.6.3 twlz0ne/elpl: Provides a simple interface to evaluating Emacs Lisp expressions but without contaminating current Emacs.

10.7 Scheme

1
;;(package! geiser)
1
2
3
4
;; (use-package! geiser
;;   :config
;;   (setq geiser-default-implementation 'racket)
;; )

10.8 Julia

10.8.1 julia-snail: An Emacs development environment for Julia

10.8.2 lsp-julia

  • pin “716e7d99a30b26012e5711fb2f33bea71a7bc5ab” to master

    1
    
    (package! lsp-julia :recipe (:host github :repo "non-Jedi/lsp-julia"))
    
1
2
3
4
5
6
(use-package! lsp-julia
  :config
  ;;(add-hook 'julia-mode-hook #'lsp)
  ;;(setq lsp-julia-default-environment "~/.julia/environments/v1.5")
  (setq lsp-folding-range-limit 100)
)

10.8.3 gcv/julia-snail: An Emacs development environment for Julia

1
2
3
4
(package! julia-snail :recipe (:host github
                                   :repo "gcv/julia-snail"
                                   :files ("*")
                                   ))
1
2
3
4
5
(use-package! julia-snail
  :config
  :requires vterm
  :hook (julia-mode . julia-snail-mode)
  )

10.9 Python

1
(package! lsp-pyright)
1
2
3
4
5
6
7
(setq flycheck-python-pylint-executable "pylint")
(use-package! lsp-pyright
  :config
  (setq lsp-clients-python-command "pyright")
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))

10.10 Nox

1
;;(package! nox :recipe (:host github :repo "manateelazycat/nox"))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
;; (use-package! nox
;;   :config
;;   (add-to-list 'nox-server-programs '(haskell-mode . ("ghcide" "--lsp")))
  ;; (dolist (hook (list
  ;;                'js-mode-hook
  ;;                'rust-mode-hook
  ;;                'python-mode-hook
  ;;                'ruby-mode-hook
  ;;                'java-mode-hook
  ;;                'sh-mode-hook
  ;;                'php-mode-hook
  ;;                'c-mode-common-hook
  ;;                'c-mode-hook
  ;;                'c++-mode-hook
  ;;                'haskell-mode-hook
  ;;                ))
  ;;   (add-hook hook '(lambda () (nox-ensure))))
  ;; )

10.11 Zeek Mode

1
(package! zeek-mode :recipe (:host github :repo "ynadji/zeek-mode"))
1
2
3
4
5
6
7
(use-package! zeek-mode
  :config
  (setq default-tab-width 4)
  (defun add-company-tabnine ()
    (add-to-list (make-local-variable 'company-backends) 'company-tabnine))
  (add-hook 'zeek-mode-hook #'add-company-tabnine)
  )

10.12 Nix Mode

1
2
3
4
(use-package! nix-mode
  :config
  (setq-hook! 'nix-mode-hook company-idle-delay t)
  )

10.13 Rust

1
2
3
4
5
6
(after! rust
  (seqpetq racer-cmd "racer")
  (add-hook 'rustic-mode-hook (lambda () (setq-local +lsp-company-backends '(company-capf
                                                                             company-tabnine))
                                ))
  )

10.14 separedit.el

1
(package! separedit :recipe (:host github :repo "twlz0ne/separedit.el"))
1
2
3
4
5
6
7
;;
(use-package! separedit
  :config
  (define-key prog-mode-map        (kbd "C-x '") #'separedit)
  (define-key minibuffer-local-map (kbd "C-x '") #'separedit)
  (define-key org-src-mode-map     (kbd "C-x '") #'separedit)
  )

11 Visual

11.1 Buffer

11.1.1 Parenthesis

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(use-package! rainbow-delimiters
  :config
  (custom-set-faces
   '(rainbow-delimiters-mismatched-face ((t (:foreground "white" :background "red" :weight bold))))
   '(rainbow-delimiters-unmatched-face ((t (:foreground "white" :background "red" :weight bold))))

   ;; show parents (in case of rainbow failing !)
   '(show-paren-match ((t (:foreground "white" :background "green" :weight bold))))
   '(show-paren-mismatch ((t (:foreground "white" :background "red" :weight bold)))))
  (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;; highlight brackets
  )

11.1.2 eysbrowse

1
(package! eyebrowse)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(use-package! eyebrowse
  :hook (after-init . eyebrowse-mode)
  :config
  (define-key eyebrowse-mode-map (kbd "M-1") 'eyebrowse-switch-to-window-config-1)
  (define-key eyebrowse-mode-map (kbd "M-2") 'eyebrowse-switch-to-window-config-2)
  (define-key eyebrowse-mode-map (kbd "M-3") 'eyebrowse-switch-to-window-config-3)
  (define-key eyebrowse-mode-map (kbd "M-4") 'eyebrowse-switch-to-window-config-4)
  (define-key eyebrowse-mode-map (kbd "M-5") 'eyebrowse-switch-to-window-config-5)
  (setq eyebrowse-new-workspace t)
)

11.2 window

11.2.1 awesome-tab

 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
(use-package! awesome-tab
  :config
  (awesome-tab-mode t)
  (setq awesome-tab-style 'slant)
  ;; winum users can use `winum-select-window-by-number' directly.
  (defun my-select-window-by-number (win-id)
    "Use `ace-window' to select the window by using window index.
WIN-ID : Window index."
    (let ((wnd (nth (- win-id 1) (aw-window-list))))
      (if wnd
          (aw-switch-to-window wnd)
        (message "No such window."))))

  (defun my-select-window ()
    (interactive)
    (let* ((event last-input-event)
           (key (make-vector 1 event))
           (key-desc (key-description key)))
      (my-select-window-by-number
       (string-to-number (car (nreverse (split-string key-desc "-")))))))

  (when (not (display-graphic-p))
    (setq frame-background-mode 'dark))
  (defun awesome-tab-buffer-groups ()
    "`awesome-tab-buffer-groups' control buffers' group rules.

Group awesome-tab with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
All buffer name start with * will group to \"Emacs\".
Other buffer group by `awesome-tab-get-group-name' with project name."
    (list
     (cond
      ((or (string-equal "*" (substring (buffer-name) 0 1))
           (memq major-mode '(magit-process-mode
                              magit-status-mode
                              magit-diff-mode
                              magit-log-mode
                              magit-file-mode
                              magit-blob-mode
                              magit-blame-mode
                              )))
       "Emacs")
      ((derived-mode-p 'eshell-mode)
       "EShell")
      ((derived-mode-p 'emacs-lisp-mode)
       "Elisp")
      ((derived-mode-p 'dired-mode)
       "Dired")
      ((memq major-mode '(org-mode org-agenda-mode diary-mode))
       "OrgMode")
      (t
       (awesome-tab-get-group-name (current-buffer))))))

  (defhydra awesome-fast-switch (:hint nil)
    "
 ^^^^Fast Move             ^^^^Tab                    ^^Search            ^^Misc
-^^^^--------------------+-^^^^---------------------+-^^----------------+-^^---------------------------
   ^_k_^   prev group    | _C-a_^^     select first | _b_ search buffer | _C-k_   kill buffer
 _h_   _l_  switch tab   | _C-e_^^     select last  | _g_ search group  | _C-S-k_ kill others in group
   ^_j_^   next group    | _C-j_^^     ace jump     | ^^                | ^^
 ^^0 ~ 9^^ select window | _C-h_/_C-l_ move current | ^^                | ^^
-^^^^--------------------+-^^^^---------------------+-^^----------------+-^^---------------------------
"
    ("h" awesome-tab-backward-tab)
    ("j" awesome-tab-forward-group)
    ("k" awesome-tab-backward-group)
    ("l" awesome-tab-forward-tab)
    ("0" my-select-window)
    ("1" my-select-window)
    ("2" my-select-window)
    ("3" my-select-window)
    ("4" my-select-window)
    ("5" my-select-window)
    ("6" my-select-window)
    ("7" my-select-window)
    ("8" my-select-window)
    ("9" my-select-window)
    ("C-a" awesome-tab-select-beg-tab)
    ("C-e" awesome-tab-select-end-tab)
    ("C-j" awesome-tab-ace-jump)
    ("C-h" awesome-tab-move-current-tab-to-left)
    ("C-l" awesome-tab-move-current-tab-to-right)
    ("b" ivy-switch-buffer)
    ("g" awesome-tab-counsel-switch-group)
    ("C-k" kill-current-buffer)
    ("C-S-k" awesome-tab-kill-other-buffers-in-current-group)
    ("q" nil "quit"))
  )
;; (setq awesome-tab-style "bar")
;; (setq awesome-tab-set-icons t)
;; (setq awesome-tab-set-bar t)
;; (setq awesome-tab-set-bar 'over)
;; (setq awesome-tab-set-modified-marker t)
;; (setq awesome-tab-set-close-button nil)
;; (setq awesome-tab-modified-marker "*")
(global-set-key (kbd "C-c j") 'awesome-tab-forward-tab)
(global-set-key (kbd "C-c k") 'awesome-tab-backward-tab)
(global-set-key (kbd "C-c o") 'awesome-tab-switch-group)

11.2.2 Dimming Unused Windows

1
(package! dimmer)
1
2
(use-package! dimmer
  :config (dimmer-mode))

11.2.3 beacon

1
(package! beacon)
1
2
3
4
(use-package! beacon
  :diminish
  :config (setq beacon-color "#666600")
  :hook   ((org-mode text-mode) . beacon-mode))

11.2.4 Flashing when something goes wrong —no blinking

1
(setq visible-bell 1)

11.2.5 golden-ratio

1
2
3
4
(use-package! golden-ratio
  :disabled
  :diminish golden-ratio-mode
  :init (golden-ratio-mode 1))

11.3 theme

11.3.1 vbuzin/berrys-theme: A light, clean and elegant Emacs theme

1
2
3
4
5
6
7
;; (use-package! berrys-theme
;;   :config
;;   (load-theme 'berrys t)

;;   :config ;; for good measure and clarity
;;   (setq-default cursor-type '(bar . 2))
;;   (setq-default line-spacing 2))

11.3.2 rougier/elegant-emacs: A very minimal but elegant emacs (I think)

11.4 writeroom or writegood

1
(package! writeroom-mode)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(use-package! writeroom-mode
  :hook
  (org-mode . writeroom-mode)
  (w3m-mode . writeroom-mode)
  :config
  (advice-add 'text-scale-adjust :after
              #'visual-fill-column-adjust)

  ;;https://github.com/joostkremers/writeroom-mode#fullscreen-effect
  (setq writeroom-fullscreen-effect 'maximized)
)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
;; (use-package! writegood-mode
;;   ;; Load this whenver I'm composing prose.
;;   ;;:hook (text-mode org-mode)
;;   ;; Don't show me the “Wg” marker in the mode line
;;   :diminish
;;   ;; Some additional weasel words.
;;   :config
;;   (--map (push it writegood-weasel-words)
;;          '("some" "simple" "simply" "easy" "often" "easily" "probably"
;;            "clearly"               ;; Is the premise undeniably true?
;;            "experience shows"      ;; Whose? What kind? How does it do so?
;;            "may have"              ;; It may also have not!
;;            "it turns out that")))  ;; How does it turn out so?
;;            ;; ↯ What is the evidence of highighted phrase? ↯

11.5 grip-mode

  1. seagle0128/grip-mode: Instant Github-flavored Markdown/Org preview using grip

11.6 windown manager

  1. nex3/perspective-el: Perspectives for Emacs.

11.7 alphapapa/burly.el: Save and restore frames and windows with their buffers in Emacs

11.8 ashton314/emacs-writer: An elegant Emacs setup optimized for non-technical writers

12 chinese

12.1 pinyinlib

 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
(use-package! pinyinlib
  :config
  (defun re-builder-extended-pattern (str)
    (let* ((len (length str)))
      (cond
       ;; do nothing
       ((<= (length str) 0))

       ;; If the first charater of input in ivy is ":",
       ;; remaining input is converted into Chinese pinyin regex.
       ((string= (substring str 0 1) ":")
        (setq str (pinyinlib-build-regexp-string (substring str 1 len) t)))

       ;; If the first charater of input in ivy is "/",
       ;; remaining input is converted to pattrn to search camel case word
       ((string= (substring str 0 1) "/")
        (let* ((rlt "")
               (i 0)
               (subs (substring str 1 len))
               c)
          (when (> len 2)
            (setq subs (upcase subs))
            (while (< i (length subs))
              (setq c (elt subs i))
              (setq rlt (concat rlt (cond
                                     ((and (< c ?a) (> c ?z) (< c ?A) (> c ?Z))
                                      (format "%c" c))
                                     (t
                                      (concat (if (= i 0) (format "[%c%c]" (+ c 32) c)
                                                (format "%c" c))
                                              "[a-z]+")))))
              (setq i (1+ i))))
          (setq str rlt))))
      (ivy--regex-plus str)))

  (eval-after-load 'ivy
    '(progn
       ;; better performance on everything (especially windows), ivy-0.10.0 required
       ;; @see https://github.com/abo-abo/swiper/issues/1218
       (setq ivy-dynamic-exhibit-delay-ms 250)

       ;; Press C-p and Enter to select current input as candidate
       ;; https://oremacs.com/2017/11/30/ivy-0.10.0/
       (setq ivy-use-selectable-prompt t)

       (setq ivy-re-builders-alist
             '((t . re-builder-extended-pattern)))
       ;; set actions when running C-x b
       ;; replace "frame" with window to open in new window
       (ivy-set-actions
        'ivy-switch-buffer-by-pinyin
        '(("j" switch-to-buffer-other-frame "other frame")
          ("k" kill-buffer "kill")
          ("r" ivy--rename-buffer-action "rename")))))
  (with-eval-after-load "swiper-isearch"
    (setq ivy-re-builders-alist
          '((t . re-builder-extended-pattern)
            (t . ivy-prescient-re-builder))))
  )

12.2 helm-pinyin

1
;; (package! helm-pinyin :recipe (:host github :repo "twlz0ne/helm-pinyin"))
1
2
3
4
;; (use-package! helm-pinyin
;;   :hook
;;   (after-init . turn-on-helm-pinyin)
;;   )

13 minor mode and major mode

13.1 rnkn/binder: Emacs global minor mode facilitating multi-file writing projects

13.2 jerrypnz/major-mode-hydra.el: Spacemacs-esque major mode leader key powered by Hydra

14 Writing

14.1 grammarly

1
2
3
;;(package! flycheck-grammarly :recipe (:host github :repo "jcs-elpa/flycheck-grammarly"))
(package! company-english-helper :recipe (:host github :repo "manateelazycat/company-english-helper"))
(package! emacs-powerthesaurus :recipe (:host github :repo "SavchenkoValeriy/emacs-powerthesaurus"))
1
2
(use-package! company-english-helper)
;;(use-package! flycheck-grammarly)

14.2 arnm/ob-mermaid: Generate mermaid diagrams within Emacs org-mode babel

TODO 14.3 zzkt/smog: Analyse the writing style, word use and readability of prose in Emacs.

**

TODO 14.4 rnkn/binder: Emacs global minor mode facilitating multi-file writing projects

15 unload packages & unpin packages

15.1 disbale-packages

1
2
3
(disable-packages! pyim)
(disable-packages! company-go)
(disable-packages! lsp-python-ms)

15.2 unpin packages

1
2
3
4
5
(unpin! doom-modeline)
(unpin! magit)
(unpin! nix-mode)
(unpin! org-journal)
(unpin! lsp-mode)

16 misc

16.1 emacs-music

16.1.1 SpringHan/netease-cloud-music.el: A netease music client for emacs.

17 set popup rules

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
;; (custom-set-faces
;;   '(awesome-tab-close-selected((t ( :foreground "DarkGray"))))
;;   )

(set-popup-rule! "^\\*org-graph-view" :side 'right :size 70 :quit nil :select t :ttl 0)

(set-popup-rule! "^\\*julia:main"
  :side 'right :size 0.3 :quit nil :select nil :ttl 0)

(set-popup-rule! "^\\*Ilist"
  :side 'right :size 35 :quit nil :select nil :ttl 0)

(after! org
  (set-popup-rule! "^\\*Org tags" :size 0.5))

(after! helm
  (set-popup-rule! "^\\*helm" :size 0.5))

(after! maple-explorer-imenu
(set-popup-rule! "^\\*maple-explorer-imenu"
  :side 'right :size 35 :quit nil :select nil :ttl 0)
)

18 Warning

1
(add-to-list 'warning-suppress-types '(yasnippet backquote-change))
yasnippet backquote-change
:warning

19 Linux & MacOS

1
2
3
4
5
6
(when IS-LINUX
  (load! "linux.el")
)
(when IS-MAC
  (load! "macos.el")
)

19.1 Linux only

 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
(add-hook! 'emacs-startup-hook 'doom-modeline-mode)
;;fix post hook only linux
(require 'savehist)
(setq-default cursor-type 'box)
(blink-cursor-mode -1)
(set-cursor-color "IndianRed3")
(setq bm-repository-file (f-join doom-private-dir "etc/bm-linux-data"))
(setq bookmark-default-file
      (concat doom-private-dir "etc/bookmark-linux-default.el"))


(setq python-shell-interpreter "python")
(setq eaf-python-command "python")

(bookmark-load bookmark-default-file t)

(setq org-roam-db-location "~/.emacs.d/.local/cache/org-roam.db")

(when (not window-system)
  (xterm-mouse-mode 1)
  )
(setq org-crypt-key "24945FE0DBD04F4C045025F96F92B3E8F942D425")

(set-face-attribute
 'default nil
 :font (font-spec :name "-PfEd-Fantasque Sans Mono-bold-italic-normal-*-*-*-*-*-m-0-iso10646-1"
                  :weight 'normal
                  :slant 'normal
                  :size 12.0))

(when (display-graphic-p)
  (dolist (charset '(kana han cjk-misc bopomofo))
    (set-fontset-font (frame-parameter nil 'font) charset
                      (font-spec :family "Weibei SC" :size 55)))
  )

(define-key org-mode-map (kbd "C-c l") 'grab-x-link)

;; (setq jupyter-runtime-directory "~/.local/share/jupyter/runtime")
(add-hook 'ob-async-pre-execute-src-block-hook
          '(lambda ()
             (setq inferior-julia-program-name "julia")))

19.1.1 eaf

1
2
3
4
5
6
(when IS-LINUX
  (package! eaf :recipe (:host github
                            :repo "manateelazycat/emacs-application-framework"
                            :files ("*")
                            :build (:not compile)))
  )
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(when (display-graphic-p)
  (use-package! eaf
    :if (eq system-type 'gnu/linux)
    :custom
    (eaf-find-alternate-file-in-dired t)
    :config
    (eaf-setq eaf-browser-default-zoom "2.0")

    (eaf-bind-key scroll_up "C-n" eaf-pdf-viewer-keybinding)
    (eaf-bind-key scroll_down "C-p" eaf-pdf-viewer-keybinding)

    (defun eaf-open-google ()
      "Open Google using EAF."
      (interactive)
      (eaf-open-browser "https://www.google.com")))
  )
1
2
3
(use-package! grab-x-link
  :if (eq system-type 'gnu/linux)
  )

19.2 My MacOS

 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
(setq bookmark-default-file
      (concat doom-private-dir "etc/bookmark-macos-default.el"))
(bookmark-load bookmark-default-file t)

(setq-default cursor-type 'box)
(blink-cursor-mode -1)
(set-cursor-color "yellow1")
(setq bm-repository-file (f-join doom-private-dir "etc/bm-macos-data"))
(setq insert-directory-program "/usr/local/bin/gls")

(setq org-roam-db-location "~/.emacs.d/.local/cache/org-roam-macos.db")

(define-key org-mode-map (kbd "C-c l") 'org-mac-grab-link)

(set-face-attribute
 'default nil
 :font (font-spec :name "-*-Fantasque Sans Mono-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1"
                  :weight 'normal
                  :slant 'normal
                  :size 25.0))
(dolist (charset '(kana han symbol cjk-misc bopomofo))
  (set-fontset-font
   (frame-parameter nil 'font)
   charset
   (font-spec :name "-*-STFangsong-normal-normal-normal-*-*-*-*-*-p-0-iso10646-1"
              :weight 'normal
              :slant 'normal
              :size 24.5)))

(setq ispell-program-name "~/.nix-profile/bin/ispell")

19.3 macos use packages

1
2
3
4
(when IS-MAC
  (package! cnfonts)
  (package! exec-path-from-shell)
)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
;;; my-macos.el -*- lexical-binding: t; -*-
(when IS-MAC
  (use-package! cnfonts)
  (use-package! exec-path-from-shell)
  (define-key! awesome-tab-mode-map
    "s-1" #'awesome-tab-select-visible-tab
    "s-2" #'awesome-tab-select-visible-tab
    "s-3" #'awesome-tab-select-visible-tab
    "s-4" #'awesome-tab-select-visible-tab
    "s-5" #'awesome-tab-select-visible-tab
    "s-6" #'awesome-tab-select-visible-tab
    "s-7" #'awesome-tab-select-visible-tab
    "s-8" #'awesome-tab-select-visible-tab
    "s-9" #'awesome-tab-select-visible-tab
    )
  )

20 Bugs

21 r0man/docopt.el: A Docopt implementation in Emacs Lisp.

22 Cache