From 33b8a7c60839b2a83a5d0d2c3c85ca147c9a5f74 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 1 Sep 2025 12:52:06 -0500 Subject: wip webclipper and org-capture issues --- modules/org-capture-config.el | 30 +++++++++++++++++++++++++----- modules/org-roam-config.el | 22 +++++++++++++++++++++- todo.org | 28 ++++++++++++++++++++-------- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el index b035752b..55a12e2f 100644 --- a/modules/org-capture-config.el +++ b/modules/org-capture-config.el @@ -17,7 +17,6 @@ ;;; Code: - ;; ---------------------------- Org Webpage Clipper ---------------------------- ;; Allows saving a copy of the page eww is visiting for offline reading. ;; In other words, it's a "Pocket/Instapaper" that keeps the article in Emacs. @@ -110,13 +109,34 @@ Captured On: %U" (file+headline inbox-file "Shopping List") "* %?") ;; requires cj/org-web-clipper function defined above - ("w" "Web Page Clipper" entry - (file+headline inbox-file "To Read") - "* %a\nURL: %L\nCaptured On:%U\n%(cj/org-webpage-clipper)\n" - :prepend t :immediate-finish t) + ("w" "Web Page Clipper" plain + (function cj/org-roam-capture-webclip) + "" :immediate-finish t) )) ;; end setq ) ;; end use-package org-protocol +;; -------------------------- Org-Roam-Capture-Webclip ------------------------- + +(defun cj/org-roam-capture-webclip () + "Capture current webpage as an org-roam node with webclipped tag." + (let* ((url (plist-get org-store-link-plist :link)) + (title (or (plist-get org-store-link-plist :description) "")) + (body (cj/org-webpage-clipper))) + (org-roam-capture- :node (org-roam-node-create :title title) + :templates '(("w" "webclip" plain "%?" + :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" + "#+TITLE: ${title} +#+FILETAGS: webclipped +#+ROAM_KEY: ${url} +URL: ${url} +Captured On: %U + +${body}") + :unnarrowed t + :immediate-finish t)) + :props =(:url ,url + :body ,body)))) + ;; ---------------------------- Simple Task Capture ---------------------------- ;; the simplest way to capture a task. Also a simple way to write this function. diff --git a/modules/org-roam-config.el b/modules/org-roam-config.el index be0c0876..1f1524aa 100644 --- a/modules/org-roam-config.el +++ b/modules/org-roam-config.el @@ -23,6 +23,16 @@ '(("d" "default" plain "%?" :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+TITLE: ${title}\n") :unnarrowed t) + ("w" "webclip" plain "%?" + :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+TITLE: ${title} +#+FILETAGS: webclipped +#+ROAM_KEY: ${url} +URL: ${url} +Captured On: %U + +${body}") + :unnarrowed t + :immediate-finish t) ("v" "v2mom" plain (function (lambda () (concat roam-dir "templates/v2mom.org"))) :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+TITLE: ${title}\n") @@ -30,7 +40,7 @@ ("r" "recipe" plain (function (lambda () (concat roam-dir "templates/recipe.org"))) :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+TITLE: ${title} - #+CATEGORY: ${title}\n#+FILETAGS: Recipe\n#+STARTUP: showall") + #+CATEGORY: ${title}\n#+FILETAGS: Recipe\n#+STARTUP: showall") :unnarrowed t) ("p" "project" plain (function (lambda () (concat roam-dir "templates/project.org"))) @@ -49,6 +59,7 @@ ("C-c n r" . cj/org-roam-find-node-recipe) ("C-c n t" . cj/org-roam-find-node-topic) ("C-c n i" . org-roam-node-insert) + ("C-c n w" . cj/org-roam-find-node-webclip) :map org-mode-map ("C-M-i" . completion-at-point) :map org-roam-dailies-map @@ -140,6 +151,15 @@ created nodes are added to the agenda and follow a template defined by (interactive) (cj/org-roam-find-node "Project" "p" (concat roam-dir "templates/project.org"))) +(defun cj/org-roam-find-node-webclip () + "List nodes of type 'webclipped' in completing read for selection." + (interactive) + (org-roam-node-find + nil + nil + (cj/org-roam-filter-by-tag "webclipped") + nil)) + ;; ---------------------- Org Capture After Finalize Hook ---------------------- (defun cj/org-roam-add-node-to-agenda-files-finalize-hook () diff --git a/todo.org b/todo.org index 81b07032..a6ad3c00 100644 --- a/todo.org +++ b/todo.org @@ -1,4 +1,24 @@ * Emacs Open Work +** DOING [#A] Org Roam and Org Template Fixes +*** TODO [#B] Fix Emacs Org Roam Recipe Error +**** TODO Fix category alignment +**** TODO Fix added path to template file +**** TODO Fix having template outline in file +**** 2025-09-01 Mon @ 12:49:21 -0500 Fixed org-element issue +it's a bug in not loading org-element. Added this to my config + + ;; bug workaround for org-element--get-category: Invalid function: org-element-with-disabled-cache + ;; https://github.com/doomemacs/doomemacs/issues/7347 + (load-library "org-element.el") + +**** Problem Statement +C-c n i then type a recipe name. +org-element--get-category: Invalid function: org-element-with-disabled-cache +The file was created, but does not come to the front +The category value seems unaligned +*** TODO [#B] Add Org Capture Template for Vocabulary Words +*** DONE [#A] Add Org Templates Back to Emacs Repository! +CLOSED: [2025-09-01 Mon 12:51] ** TODO [#A] Delete whitespace from region is broken ** TODO [#A] Reconfigure ai-config.el *** DONE Toggle gptel's side window with t or @@ -61,14 +81,6 @@ https://github.com/jeremy-compostella/org-msg *** TODO [#A] Fix org-contacts functionality ** TODO [#A] file-config.el cj/xdg-open blocks further Emacs use Should change to non-blocking process -** TODO [#A] Org Roam and Org Template Fixes -*** TODO [#B] Fix Emacs Org Roam Recipe Error -C-c n i then type a recipe name. -org-element--get-category: Invalid function: org-element-with-disabled-cache -The file was created, but does not come to the front -The category value seems unaligned -*** TODO [#A] Add Org Templates Back to Emacs Repository! -*** TODO [#B] Add Org Capture Template for Vocabulary Words ** TODO [#B] Add all ert tests into separate directory Tests should be added to a separate directory rather than the end of each elisp file. Gather them together, move them there, and make it easy to run tests per module and workflow. -- cgit v1.2.3