This commit is contained in:
0
Emacs/20241210004247-emacs_moc.org
Normal file → Executable file
0
Emacs/20241210004247-emacs_moc.org
Normal file → Executable file
0
Emacs/20241210004329-org_roam.org
Normal file → Executable file
0
Emacs/20241210004329-org_roam.org
Normal file → Executable file
0
Emacs/20241210004453-gtd.org
Normal file → Executable file
0
Emacs/20241210004453-gtd.org
Normal file → Executable file
0
Emacs/20250218174735-emacs_stuff_keybindings.org
Normal file → Executable file
0
Emacs/20250218174735-emacs_stuff_keybindings.org
Normal file → Executable file
0
Emacs/20250326002128-emacs_stuff_elisp.org
Normal file → Executable file
0
Emacs/20250326002128-emacs_stuff_elisp.org
Normal file → Executable file
0
Emacs/20250329231658-emacs_stuff_magit.org
Normal file → Executable file
0
Emacs/20250329231658-emacs_stuff_magit.org
Normal file → Executable file
0
Emacs/20250420012258-emacs_stuff_evil.org
Normal file → Executable file
0
Emacs/20250420012258-emacs_stuff_evil.org
Normal file → Executable file
0
Emacs/20250806155335-emacs_stuff_org_publish.org
Normal file → Executable file
0
Emacs/20250806155335-emacs_stuff_org_publish.org
Normal file → Executable file
0
Emacs/20260401100130-emacs_org_noter.org
Normal file → Executable file
0
Emacs/20260401100130-emacs_org_noter.org
Normal file → Executable file
0
Emacs/20260401100839-emacs_calendar.org
Normal file → Executable file
0
Emacs/20260401100839-emacs_calendar.org
Normal file → Executable file
52
Emacs/20260407083539-emacs_config.org
Normal file → Executable file
52
Emacs/20260407083539-emacs_config.org
Normal file → Executable file
@@ -423,6 +423,58 @@
|
||||
(define-key org-mode-map (kbd "C-c m") #'org-insert-macro)
|
||||
#+end_src
|
||||
|
||||
* Insert Dailies into ~20260421100223-dailies.org~
|
||||
#+begin_src emacs-lisp
|
||||
;; ─── org-roam daily auto-linker ───────────────────────────────────────────
|
||||
|
||||
(defvar my/org-roam-last-capture-file nil
|
||||
"Stores the daily file path captured via org-roam-capture-new-node-hook.")
|
||||
|
||||
(defun my/org-roam-capture-store-file ()
|
||||
"Store file path when a new org-roam node is created."
|
||||
(when-let ((f (buffer-file-name)))
|
||||
(setq my/org-roam-last-capture-file f)))
|
||||
|
||||
(defun my/org-roam-daily-already-linked-p (index-file date-str)
|
||||
"Return t if DATE-STR already appears in INDEX-FILE."
|
||||
(when (file-exists-p index-file)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents index-file)
|
||||
(search-forward date-str nil t))))
|
||||
|
||||
(defun my/org-roam-daily-add-link (index-file date-str)
|
||||
"Append a heading linking DATE-STR daily into INDEX-FILE."
|
||||
(message " Adding link for %s..." date-str)
|
||||
(with-current-buffer (find-file-noselect index-file)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(unless (bolp) (insert "\n"))
|
||||
(insert (format "** [[file:daily/%s.org][%s]]\n" date-str date-str)))
|
||||
(save-buffer))
|
||||
(org-roam-db-update-file index-file))
|
||||
|
||||
(defun my/org-roam-daily-link-to-index ()
|
||||
"After capture, link today's daily into the index file."
|
||||
(let ((captured-file
|
||||
(or my/org-roam-last-capture-file
|
||||
(ignore-errors
|
||||
(plist-get org-capture-current-plist :original-file)))))
|
||||
(when (and captured-file
|
||||
(string-match-p (regexp-quote "daily") captured-file))
|
||||
(let* ((today-date (file-name-base captured-file))
|
||||
(index-file (expand-file-name
|
||||
"20260421100223-dailies.org"
|
||||
org-roam-directory)))
|
||||
(if (my/org-roam-daily-already-linked-p index-file today-date)
|
||||
(message " %s already linked, skipping." today-date)
|
||||
(my/org-roam-daily-add-link index-file today-date)))
|
||||
(setq my/org-roam-last-capture-file nil))))
|
||||
|
||||
(add-hook 'org-roam-capture-new-node-hook #'my/org-roam-capture-store-file)
|
||||
(add-hook 'org-capture-after-finalize-hook #'my/org-roam-daily-link-to-index)
|
||||
|
||||
#+end_src
|
||||
|
||||
* Old stuff:
|
||||
** org image inserter:
|
||||
#+begin_src emacs-lisp
|
||||
|
||||
Reference in New Issue
Block a user