This page looks best with JavaScript enabled

emacs-config

 ·  ☕ 4 min read  ·  ✍️ LifeIsFile

Here is my personal emacs config that maybe usefull for reference

  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
;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(consult-notes vertico org-roam-ui markdown-mode consult org-roam)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))


(add-to-list  'load-path "~/reps/md-roam")
(require 'md-roam)
(setq org-roam-file-extensions '("org" "md")) ; enable Org-roam for a markdown extension
(md-roam-mode 1) ; md-roam-mode needs to be active before org-roam-db-sync
(setq md-roam-file-extension "md")

(global-set-key (kbd "C-c <left>")  'windmove-left)
(global-set-key (kbd "C-c <right>") 'windmove-right)
(global-set-key (kbd "C-c <up>")    'windmove-up)
(global-set-key (kbd "C-c <down>")  'windmove-down)
(global-set-key (kbd "C-c d")  'delete-window)

(require 'use-package)
(use-package org-roam
  :ensure t
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/org-roam")
  (org-roam-completion-everywhere t)
  (org-roam-node-display-template
    (concat "${title:*} "
              (propertize "${tags:80}" 'face 'org-tag)))
  (org-roam-capture-templates
   '(
     ("d" "default" plain "%?"
      :if-new (file+head "%<%Y-%m-%d-%H:%M:%S>-${slug}.org" "#+title: ${title}\n#+filetags:%^{org-roam-tags}\n#+date: %U\n")
      :unnarrowed t)

     ("m" "Markdown" plain "" :target
        (file+head "%<%Y-%m-%dT%H%M%S>-${slug}.md"
"---\ntitle: ${title}\ndescription:\nimage:\nid: %<%Y-%m-%dT%H%M%S>\ncategory: %^{org-roam-tags}\nroam-date: %U\n---\n")
    :unnarrowed t)

     ("b" "Books" plain "\n* Source\n\nAuthor: %^{Author}\n\nTitle: ${title}\n\nYear: %^{Year}\n\n* Summary\n\n"
      :if-new (file+head "%<%Y-%m-%d-%H:%M:%S>-${slug}.org" "#+title: ${title}\n#+date: %U\n#+filetags: :Books: :%^{Book type}:\n")
      :unnarrowed t)
     ))
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
	 ("C-c n c" . org-roam-capture)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point)
         :map org-roam-dailies-map
         ("Y" . org-roam-dailies-capture-yesterday)
         ("T" . org-roam-dailies-capture-tomorrow))
  :bind-keymap
  ("C-c n d" . org-roam-dailies-map)
  :config
  (require 'org-roam-dailies) ;; Ensure the keymap is available
  (org-roam-db-autosync-mode))


;; Make the colors and text less eye-strainy
(load-theme 'tango-dark t)
(set-face-attribute 'default nil :height 200)

;; I mindlessly press ESC, so stop me from wreaking havoc
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)

(when (fboundp 'windmove-default-keybindings)
  (windmove-default-keybindings))

(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)

(defun bms/org-roam-rg-search ()
  "Search org-roam directory using consult-ripgrep. With live-preview."
  (interactive)
  (let ((consult-ripgrep-args "rg --null --type md --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --line-number --with-filename ."))  
    (consult-ripgrep "~/org-roam")))
  
  (global-set-key (kbd "C-c rr") 'bms/org-roam-rg-search)

(defun jmb/counsel-rg-roam ()
 "Do counsel-ag on the org roam directory"
 (interactive)
 (counsel-rg nil "~/org-roam"))
(global-set-key (kbd "C-c tt") 'jmb/counsel-rg-roam)

(setq resize-mini-windows 'grow-only)
(setq max-mini-window-height 10)

(fido-vertical-mode 1)
;;(icomplete-vertical-mode 1)


(defun delete-file-and-buffer ()
  "Kill the current buffer and deletes the file it is visiting."
  (interactive)
  (let ((filename (buffer-file-name)))
    (if filename
        (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
            (progn
              (delete-file filename)
              (message "Deleted file %s." filename)
              (kill-buffer)))
      (message "Not a file visiting buffer!"))))

(global-set-key (kbd "C-c rf") 'delete-file-and-buffer)

;; Prevent open files in second window (split screen)
(setq ns-pop-up-frames nil)


(setq consult-notes-file-dir-sources
      '(("Org"             ?o "~/org-roam/")))


(defun consult-ripgrep-one-file ()
    "Call `consult-ripgrep' for the current buffer (a single file)."
    (interactive)
    (let ((consult-project-root-function (lambda () 
					   "~/org-roam/"))
          (consult-ripgrep-args
           (concat "rg "
                   "--null "
                   "--line-buffered "
                   "--color=never "
                   "--line-number "
                   "--smart-case "
                   "--no-heading "
                   "--max-columns=1000 "
                   "--max-columns-preview "
                   "--search-zip "
                   "--with-filename "
		   "--path-separator=/ "
		   "."
                   )))
      (consult-ripgrep)))
	  

Alex Babochkin
REPORTED BY
LifeIsFile
CTO, DevOps, Backend developer