Aligning comments in Emacs

When I drag and drop an image into Emacs, I want the attached file to end up in ./img/YYYY/. This is how I tried configuring it in my setup (I use Doom Emacs):

Lisp function

1
2
3
4
5
6
7
8
;; Align comments in marked region
;; Via https://stackoverflow.com/a/20278032
(defun jab/align-comments (beginning end)
  "Align comments within marked region."
  (interactive "*r")
  (let (indent-tabs-mode align-to-tab-stop)
    (align-regexp beginning end (concat "\\(\\s-*\\)"
                                        (regexp-quote comment-start)))))

Example before aligning comments

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(setq org-roam-capture-templates
  '(("d" "default" plain "%?"
    :target (file+head "%<%Y%m%d>-${slug}.org"
                       "#+title: ${title}\n#+index: \n#+setupfile: ~/org/_SETUP/EXPORT\n#+setupfile: ~/org/_SETUP/org-roam-publish-fancy.setup")
    :unnarrowed t)
    ("p" ;; Key
     "project" ;; Description
     plain ;; Type
     (file "~/org/roam/templates/ProjectTemplate.org")       ;; Template
    :target (file "%<%Y%m%d>-${slug}.org")
    :unnarrowed t)))

Example after calling the new function

After calling jab/align-comments

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(setq org-roam-capture-templates
  '(("d" "default" plain "%?"
    :target (file+head "%<%Y%m%d>-${slug}.org"
                       "#+title: ${title}\n#+index: \n#+setupfile: ~/org/_SETUP/EXPORT\n#+setupfile: ~/org/_SETUP/org-roam-publish-fancy.setup")
    :unnarrowed t)
    ("p"                                               ;; Key
     "project"                                         ;; Description
     plain                                             ;; Type
     (file "~/org/roam/templates/ProjectTemplate.org") ;; Template
    :target (file "%<%Y%m%d>-${slug}.org")             ;; Target
    :unnarrowed t)))