Table of Contents

HTML them READ org

1 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
;;; 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            ; tame sudden yet inevitable temporary windows
        +all             ; catch all popups that start with an asterix
        +defaults)       ; default popup rules
       ;;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

       :lang
       ;;agda              ; types of types of types of types...
       ;;assembly          ; assembly for fun or debugging
       cc                ; 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


       ;;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
        ;+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)            ; 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
         public/ihaskell ;;haskell
         public/inix ;;nix
         public/iein ;;ein
         public/ijulia ;;julia
         )

2 package.el

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(package! discover :recipe (:host github :repo "mickeynp/discover.el"))
(package! xah-fly-keys :recipe (:host github :repo "GTrunSec/xah-fly-keys"))
(package! maple-iedit :recipe (:host github :repo "honmaple/emacs-maple-iedit"))
(package! ctrlf :recipe (:host github :repo "raxod502/ctrlf"))
(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! berrys-theme)

2.0.1 jackkamm/undo-propose-el: Navigate the emacs undo history by staging undo’s in a temporary buffer

3 config.el

1
2
3
4
;;; config.el -*- lexical-binding: t; -*-

(load! "xah-fly.el")
(load! "show-parentheses.el")

4 use-package

4.1 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.113:/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)
            ))
)

4.2 Pinyin

1
(use-package! pinyin-search)

4.3 wakatime-mode

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

4.4 ctrlf

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

4.5 vlf

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

4.6 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)))
)

4.7 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)
)

4.8 w3m

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

4.9 ein

1
(use-package! ein)

4.10 undo

 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
(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 autoload

5.1 misc

5.1.1 time

 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
;;; ~/.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")
       )

5.1.2 default

1
;;; ~/.doom.d/autoload/+default.el -*- lexical-binding: t; -*-

6 default-setting

6.1 Global

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(setq user-full-name "GTrunSec"
      user-mail-address "gtrunsec@hardenedlinux.org")
(setq-default history-length 1000)
(setq create-lockfiles nil)
;; (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! 'xah-fly-command-mode-activate-hook 'xah-fly-save-buffer-if-file)

(add-hook! 'dired-mode 'dired-async-mode)
;;(add-hook! 'xah-fly-command-mode-activate-hook 'bookmark-save)
(defun gtrun/truncate-lines-hook ()
  (setq-local truncate-lines nil)
  )

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

(add-hook! 'sunrise-start-hook 'xah-fly-insert-mode-activate)

(setenv "XAPIAN_CJK_NGRAM" "1")

7 Completion

7.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]]

7.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
40
41
42
(use-package! company-lsp)
(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))
  )

7.3 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
(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))
  )

7.4 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
  (set-company-backend! '(nix-mode)
    '(:separate
      company-nixos-options
      company-tabnine
      company-files
      company-yasnippet
      ))


(set-company-backend! '(julia-mode)
  '(:separate company-lsp
              company-tabnine
              company-files
              company-yasnippet
              ))

;;  (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
                        lisp-mode
                        sh-mode
                        php-mode
                        python-mode
                        go-mode
                        ruby-mode
                        rust-mode
                        js-mode
                        css-mode
                        org-mode
                        web-mode
                        )
  '(:separate company-tabnine
              company-files
              company-yasnippet))

(setq +lsp-company-backend '(company-lsp :with company-tabnine :separate))

7.5 Edition

7.5.1 maple-iedit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  (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)
                ("C-," . maple-iedit-skip-and-match-next)
                ("C-." . maple-iedit-skip-and-match-previous)
                )
    )

7.5.2 highlight

1
2
3
4
5
6
7
(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")
)

7.5.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)

7.5.4 awesome-pair

1
(use-package! awesome-pair)

7.5.5 hungry-delete

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

7.6 Bookmark

  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))

7.7 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)

7.8 templating

 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 org-mode

8.1 Packages

1
2
3
4
5
6
(package! company-english-helper :recipe (:host github :repo "manateelazycat/company-english-helper"))
(package! org-books :recipe (:host github :repo "lepisma/org-books"))
(package! notdeft :recipe (:host github :repo "hasu/notdeft"))
(package! emacs-powerthesaurus :recipe (:host github :repo "SavchenkoValeriy/emacs-powerthesaurus"))
(package! org-spacer.el :recipe (:host github :repo "dustinlacewell/org-spacer.el"))
(package! org-treeusage :recipe (:host github :repo "mtekman/org-treeusage.el"))

8.2 config Use-package

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(load! "setting")
(setq org-superstar-headline-bullets-list '("☰" "☷" "☵" "☲"  "☳" "☴"  "☶"  "☱" ))
(use-package! company-english-helper)
(use-package! ox-hugo)
(use-package! ob-session-async)
(use-package! ob-async)
(use-package! org-books
  :config
  (setq org-books-file "~/Documents/org-notes/GTD/my-books.org")
  )
;;(use-package emacs-powerthesaurus)

8.3 org-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
(setq org-clock-into-drawer t)
(add-hook! 'org-mode-hook 'auto-revert-mode)
;; (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)
(setq org-download-timestamp "%Y%m%d_%H%M%S")
;;Markdown
(eval-after-load "org"
  '(require 'ox-md nil t))

;;https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html

8.4 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
(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
                   ("GTD/gtd.org"                      :agenda t :key "g" :refile (:maxlevel . 5))
                   ("GTD/notes.org"                    :agenda t :key "n" :refile (:maxlevel .5 ))
                   ("GTD/myself.org"                   :agenda t :key "m" :refile (:maxlevel .5 ))
                   ("GTD/Habit.org"                    :agenda t :key "h" :refile (:maxlevel .5 ))
                   ("post/traveling/traveling.org" :key "t" :refile (:maxlevel .5 ))
                   ("post/myself/love.org"         :key "l" :refile (:maxlevel .5 ))
                   ("post/myself/qing.org"         :key "q" :refile (:maxlevel .5 ))
                   ("post/myself/plan.org"         :key "p" :refile (:maxlevel .5 ))
                   ("elfeed.org"         :key "e" :refile (:maxlevel .5 ))
                   ("GTD/my-books.org"             :agenda t :key "b" :refile (:maxlevel .5 ))
                   ("post/life-thing/life-things.org")
                   ("NSM-GTD/workflow.org"         :agenda t :required t)
                   ("NSM-GTD/NsmOrg.org"           :agenda t :required t)
                   ("art/learn-music.org"          :agenda t :key "M" :refile (:maxlevel .5 ))
                   )
  (org-starter-def "~/.config/nixpkgs/dotfiles/doom/"
                   :files
                   ("config.org" :key "i" :refile (:maxlevel . 5))
                   ;;("nix.org" :key "x" :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
  ^^^^------------------------------------------------
 _i_: config.org  _g_: gtd.org     _l_: love.org
 _n_: note        _t_: traveling    _h_: Habit.org
 _m_: myself      _q_: 情-qing      _p_: Plan.org
 _b_: my-books    _e_: elfeed       _M_: learn music

  "
      ("i" org-starter-find-file:config)
      ("g" org-starter-find-file:gtd)
      ("n" org-starter-find-file:notes)
      ("e" org-starter-find-file:elfeed)
      ("M" org-starter-find-file:learn-music)
      ("m" org-starter-find-file:myself)
      ("t" org-starter-find-file:traveling)
      ("q" org-starter-find-file:qing)
      ("l" org-starter-find-file:love)
      ("h" org-starter-find-file:Habit)
      ("p" org-starter-find-file:plan)
      ("b" org-starter-find-file:my-books)
)
: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))
 )

8.5 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)
  )

8.6 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)))

8.7 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-}")

        ))

8.8 elfeed

 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! elfeed
  :bind (:map elfeed-search-mode-map
          ("q" . bjm/elfeed-save-db-and-bury)
          ("Q" . bjm/elfeed-save-db-and-bury)
          ("m" . elfeed-toggle-star)
          )
  :config
(global-set-key (kbd "C-x w") 'elfeed)
(setf url-queue-timeout 30)
(setq elfeed-db-directory "~/Dropbox/shared/elfeeddb")
;;functions to support syncing .elfeed between machines
;;makes sure elfeed reads index from disk before launching
(defun bjm/elfeed-load-db-and-open ()
  "Wrapper to load the elfeed db from disk before opening"
  (interactive)
  (elfeed-db-load)
  (elfeed)
  (elfeed-search-update--force))

;;write to disk when quiting

(defun bjm/elfeed-save-db-and-bury ()
  "Wrapper to save the elfeed db to disk before burying buffer"
  (interactive)
  (elfeed-db-save)
  (quit-window))

(defun elfeed-mark-all-as-read ()
  (interactive)
  (mark-whole-buffer)
  (elfeed-search-untag-all-unread))



  )

(use-package! elfeed-goodies
  :config
  (elfeed-goodies/setup))

(use-package! elfeed-org
:config
(setq rmh-elfeed-org-files (list "~/Documents/org-notes/elfeed.org")))

8.9 Org-babel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
(defun my-org-confirm-babel-evaluate (lang _body)
  "Return t if LANG is in whitelist."
  (not (or (string= lang "ditaa")
           (string= lang "dot")
           (string= lang "R")
           (string= lang "julia")
           (string= lang "C++")
           (string= lang "C")
           (string= lang "ein-R")
           (string= lang "python")
           (string= lang "ein-julia")
           (string= lang "ein-python")
           (string= lang "plantuml"))))

(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)

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

8.10 org publish

 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
  (setq org-publish-project-alist
        '(("nsm"
           :base-directory "~/Documents/org-notes/NSM-GTD"
           :with-author "GTrunSec"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           :exclude "README.org"
           )
          ("my-learning"
           :base-directory "~/Documents/org-publish"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           :exclude "README.org"
           )
          ("init"
           :base-directory "~/.config/nixpkgs/dotfiles/doom"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           )
          ("jupyter-math"
           :base-directory "~/Dropbox/Drop-project/my-mathematic-env/math"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           )
          ("art"
           :base-directory "~/Documents/org-notes/art"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           )
          ("course"
           :base-directory "~/Documents/org-notes/course"
           :publishing-function org-html-publish-to-html
           :publishing-directory "~/Documents/my-blog/public/custom"
           )
          ))

8.11 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)

8.12 org-notdeft

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
(use-package! notdeft
  :config
  (setq notdeft-extension "org")
  ;;(setq notdeft-secondary-extensions '("md" "org" "scrbl"))
  (setq notdeft-directories '("~/Documents/org-notes/post/myself"
                              "~/Documents/org-notes/post/life-thing"
                              "~/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"
                              ))

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

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

8.13 org-protocal

8.14 ob-mermaid

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

8.15 org-spacer

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)))
  )

8.16 org-density.el

1
2
3
4
(use-package! org-treeusage
  :config
  (define-key org-mode-map (kbd "C-c d") 'org-treeusage-mode)
  )

8.17 org-format

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
(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)
)

9 my-codes

9.1 packages

1
2
(package! lsp-julia :recipe (:host github :repo "non-Jedi/lsp-julia"))
(package! nox :recipe (:host github :repo "manateelazycat/nox"))

9.2 lsp

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


(use-package! lsp-mode
  :config
  (add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection '("rnix-lsp"))
                    :major-modes '(nix-mode)
                    :server-id 'nix))
 ;; Support LSP in Org Babel with header argument `:file'.
  ;; https://github.com/emacs-lsp/lsp-mode/issues/377
  (defvar org-babel-lsp-explicit-lang-list
    '("java")
    "Org Mode Babel languages which need explicitly specify header argument :file.")
  (cl-defmacro lsp-org-babel-enbale (lang)
    "Support LANG in org source code block."
    ;; (cl-check-type lang symbolp)
    (let* ((edit-pre (intern (format "org-babel-edit-prep:%s" lang)))
           (intern-pre (intern (format "lsp--%s" (symbol-name edit-pre)))))
      `(progn
         (defun ,intern-pre (info)
           (let ((lsp-file (or (->> info caddr (alist-get :file))
                               buffer-file-name
                               (unless (member ,lang org-babel-lsp-explicit-lang-list)
                                 (concat (org-babel-temp-file (format "lsp-%s-" ,lang))
                                         (cdr (assoc ,lang org-babel-tangle-lang-exts)))))))
             (setq-local buffer-file-name lsp-file)
             (setq-local lsp-buffer-uri (lsp--path-to-uri lsp-file))
             (lsp)))
         (if (fboundp ',edit-pre)
             (advice-add ',edit-pre :after ',intern-pre)
           (progn
             (defun ,edit-pre (info)
               (,intern-pre info))
             (put ',edit-pre 'function-documentation
                  (format "Add LSP info to Org source block dedicated buffer (%s)."
                          (upcase ,lang))))))))

  (defvar org-babel-lsp-lang-list
    '("shell"
      "python"
      "ein"
      ;; "ruby"
      "js" "css"
      ;; "C" "C++"

      "rust" "go" "java"))

  (dolist (lang org-babel-lsp-lang-list)
    (eval `(lsp-org-babel-enbale ,lang))))

9.3 Latex

9.3.1 auctex

9.3.2 chinese-latex

 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
(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"))
)

9.3.3 cdominik/cdlatex: Fast input methods to enter LaTeX environments and math with GNU Emacs

9.4 haskell

1
2
3
4
5
6
(use-package! lsp-haskell
  :config
  (setq lsp-haskell-process-path-hie "ghcide")
  (setq lsp-haskell-process-args-hie '())
  (add-hook 'haskell-mode-hook #'lsp)
)

9.5 ccls

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

9.6 Poly

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

9.7 Scheme

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

9.8 julia

9.8.1 julia-snail: An Emacs development environment for Julia

9.8.2 lsp-julia

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(use-package! lsp-julia
  :init
  ;; (setq lsp-julia--self-path "~/.julia/packages")
  (setq lsp-julia-default-environment "~/.julia/environments/v1.3")
  :config
  (add-hook 'julia-mode-hook #'lsp)
  (setq lsp-folding-range-limit 100)
  ;;(setq lsp-julia-package-dir nil)

)

9.9 python

1
(setq flycheck-python-pylint-executable "pylint")

9.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 Visual

10.1 Buffer

10.1.1 Parenthesis

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
(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
  )

10.1.2 eysbrowse

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(use-package! eyebrowse
  :config
  (progn
    (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)
    (eyebrowse-mode t)
    (setq eyebrowse-new-workspace t)))

10.2 window

10.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
98
99
(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)

10.2.2 Dimming Unused Windows

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

10.2.3 beacon

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

10.2.4 Flashing when something goes wrong —no blinking

1
(setq visible-bell 1)

10.2.5 golden-ratio

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

10.3 theme

10.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))

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

10.4 writegood

1
2
3
4
5
6
7
8
(use-package! writeroom-mode
  :hook
  (org-mode . writeroom-mode)
  (w3m-mode . writeroom-mode)
  :config
  (advice-add 'text-scale-adjust :after
              #'visual-fill-column-adjust)
)
 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? ↯

10.5 grip-mode

11 chinese

11.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
60
(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 minor mode and major mode

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

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

13 Writing

13.1 grammarly

1
;;(package! flycheck-grammarly :recipe (:host github :repo "jcs-elpa/flycheck-grammarly"))
1
;;(use-package! flycheck-grammarly)

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

14 load & unload

14.1 disbale-package

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

15 set face

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; (custom-set-faces
;;   '(awesome-tab-close-selected((t ( :foreground "DarkGray"))))
;;   )

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

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

16 Linux & Macsos

1
2
(load! "./modules/my-linux.el")
(load! "./modules/my-macos.el")

16.1 Linux

 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
(use-package! my-linux
  :load-path "./modules"
  :if (eq system-type 'gnu/linux)
  :config
  ;;(add-hook! 'emacs-startup-hook 'doom-modeline-mode)
  (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"))

  (bookmark-load bookmark-default-file t)
  (add-hook 'nix-mode-hook #'lsp)

  (setq lsp-python-ms-executable  "~/.nix-profile/bin/mspyls")
  (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 notdeft-xapian-program "/home/gtrun/src/notdeft/xapian/notdeft-xapian")
  ;; (setq jupyter-runtime-directory "~/.local/share/jupyter/runtime")
(add-hook 'ob-async-pre-execute-src-block-hook
        '(lambda ()
           (setq inferior-julia-program-name "~/.nix-profile/bin/julia")))


(use-package! grab-x-link
  :if (eq system-type 'gnu/linux)
  )
(when (display-graphic-p)
  (use-package! eaf
    :if (eq system-type 'gnu/linux)
    :load-path "~/.myscript/eaf"
    :custom
    (eaf-find-alternate-file-in-dired t)
    :config
    (add-hook! 'eaf-mode-hook 'xah-fly-keys-off)

    (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")))
  )

(use-package! snails
  :if (eq system-type 'gnu/linux)
  :load-path "~/.myscript/snails"
  :config
  (define-key snails-mode-map [remap next-line] #'snails-select-next-item)
  (add-hook 'snails-mode-hook #'xah-fly-insert-mode-activate))
)
1
(provide 'my-linux)

16.2 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(use-package! my-macos
:load-path "./modules"
:if (memq window-system '(mac ns))
:config
 (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")
(define-key org-mode-map (kbd "C-c l") 'org-mac-grab-link)
;;(eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))

(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 "/usr/local/bin/ispell")

;; (setq lsp-python-ms-executable
;;       "~/src/python-language-server/output/bin/Release/osx-x64/publish/Microsoft.Python.LanguageServer")

(setq notdeft-xapian-program "/Users/gtrun/src/notdeft/xapian/notdeft-xapian")

(add-hook 'ob-async-pre-execute-src-block-hook
        '(lambda ()
           (setq inferior-julia-program-name "~/.nix-profile/bin/julia")))


;;(add-hook! 'emacs-startup-hook 'doom-modeline-mode)
)

16.2.1 macos-setting

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
(use-package! cnfonts)

(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
  )
(provide 'my-macos)

17 Cache