Link: Emacs

Text search and completion

Full text search for both English and Chinese

[2023-09-03 Sun] Use helm-org-rifle to search text with preview pane Use M-x counsel-ripgrep or M-x consult-org-roam-search to search full text in orgmode/orgroam directory Note that the search is conflicted with ivy

Auto completion

Use ivy package to enhance autocompletion (conflit with ripgrep)

File explorer function when find files

Use counsel pacakge to counsel-find-files, after finding a file, press M-o to show more options such as open in other window, delete, etc

Use consult-org-roam with M-x consult-org-roam-backlinks to scan through each backlinks

Use org-roam-backlink-collections with M-x org-roam-backlink-collections-add-all to add all backlinks (read only) in current note. Alternatively, use ~mode to preview without actual adding it.

Package management

Refresh package source

If it shows “xx package not found” for a package available on MELPA, use M-x package-refresh-contents to refresh


Auto switch light/dark mode

Source: Did some minor changes since the original code is in doom emacs.

     (defun y/auto-update-theme ()
  "depending on time use different theme"
  ;; morning to afternoon: nord-light
  ;; night: monokai-machine
  (let* ((hour (nth 2 (decode-time (current-time))))
         (theme (cond ((<= 6 hour 18)   'doom-nord-light)
                      (t               'doom-monokai-machine))))
    (when (not (equal custom-enabled-themes theme))
      (load-theme theme t))
    ;; run that function again next hour
    (run-at-time (format "%02d:%02d" (+ hour 1) 0) nil 'y/auto-update-theme)))

Clock table

Use :tstart ”<-30d>” :tend “<now>” to indicate date range, e.g.

#+BEGIN: clocktable :maxlevel 9 :scope agenda :tstart ”<-30d>” :tend “<now>” :step semimonth :hidefiles t :emphasize t :compact t :properties (“Effort”)

Custom key binding

To customize key bindings for exising commands, define it directly with “SPC” won’t work. Instead, check out which keymap it belongs to. E.g. kill-this-buffer is part of doom-leader-map, and then define it by map!.

;; Bind SPC b k to 'kill-this-buffer'
(map! :map doom-leader-map
      "b k" #'kill-this-buffer)

Turn off evil mode in selected buffer mode

(evil-set-initial-state 'dired-mode 'emacs)