diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-25 14:37:40 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-25 14:37:40 -0500 |
| commit | a5555afaf09be4c023f49661d48de803b2586927 (patch) | |
| tree | 78625656fea7df312ed9a4467e2e899433e16998 /modules/org-capture-config.el | |
| parent | 80de20b443c7a3cbc9283bb64380539d80c61cf8 (diff) | |
re-organized org modules using use-package + maintenance work
- updated packages
- removed :after org-contrib references
- added ob-awk, sed, scheme, and shell backends
- make v play with mpv in elfeed search mode map
- added abbrevs
Diffstat (limited to 'modules/org-capture-config.el')
| -rw-r--r-- | modules/org-capture-config.el | 103 |
1 files changed, 53 insertions, 50 deletions
diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el index 4fa7af41..469abf52 100644 --- a/modules/org-capture-config.el +++ b/modules/org-capture-config.el @@ -11,14 +11,12 @@ ;;; Code: -(with-eval-after-load 'org +;; ---------------------- Org-Webpage-Clipper ---------------------- +;; Saves a copy of the page eww is visiting in the 'articles'-file for offline +;; reading. In other words, it's a "Poor Man's Pocket/Instapaper" - ;; ---------------------- Org-Webpage-Clipper ---------------------- - ;; Saves a copy of the page eww is visiting in the 'articles'-file for offline - ;; reading. In other words, it's a "Poor Man's Pocket/Instapaper" - - (defun cj/org-webpage-clipper () - "Capture a web page for later viewing in an org-file. +(defun cj/org-webpage-clipper () + "Capture a web page for later viewing in an org-file. Encodes all links and marks that may interfere with org mode display, then inserts the content into a file for later offline use. This is meant to be used in coordination with an org-capture-template. @@ -29,52 +27,57 @@ Example Template: (\"w\" \"Website\" plain (function cj/org-webpage-clipper) \"* %a\\nArticle Link: %L\\nCaptured On: %U\\n\\n\" :immediate-finish t) '@" - (interactive) - - ;; Ensure valid major mode before encoding - (cond - ((eq major-mode 'w3m-mode) - (org-w3m-copy-for-org-mode)) - ((eq major-mode 'eww-mode) - (org-eww-copy-for-org-mode)) - (t - (error "Not valid -- must be in w3m or eww mode"))) - - ;; Check for full path to the archive file. Create missing directories. - (unless (file-exists-p article-file) - (let ((dir (file-name-directory article-file))) - (unless (file-exists-p dir) - (make-directory dir)))) - - ;; Move to end of file and insert blank line for org-capture to add timestamp, etc. - (find-file article-file) - (goto-char (point-max)) - (insert "\n\n\n\n\n") - - ;; Insert the web content keeping our place. - (save-excursion (yank)) - - ;; Remove page info from kill ring. Also, fix the yank pointer. - (setq kill-ring (cdr kill-ring)) - (setq kill-ring-yank-pointer kill-ring) - - ;; Final repositioning. - (forward-line -1)) + (interactive) + + ;; Ensure valid major mode before encoding + (cond + ((eq major-mode 'w3m-mode) + (org-w3m-copy-for-org-mode)) + ((eq major-mode 'eww-mode) + (org-eww-copy-for-org-mode)) + (t + (error "Not valid -- must be in w3m or eww mode"))) + + ;; Check for full path to the archive file. Create missing directories. + (unless (file-exists-p article-file) + (let ((dir (file-name-directory article-file))) + (unless (file-exists-p dir) + (make-directory dir)))) + + ;; Move to end of file and insert blank line for org-capture to add timestamp, etc. + (find-file article-file) + (goto-char (point-max)) + (insert "\n\n\n\n\n") + + ;; Insert the web content keeping our place. + (save-excursion (yank)) + + ;; Remove page info from kill ring. Also, fix the yank pointer. + (setq kill-ring (cdr kill-ring)) + (setq kill-ring-yank-pointer kill-ring) + + ;; Final repositioning. + (forward-line -1)) ;;;; --------------------------------- Functions ------------------------------- - (defun org-capture-pdf-active-region () - "Capture the active region of the pdf-view buffer. +(defun cj/org-capture-pdf-active-region () + "Capture the active region of the pdf-view buffer. Intended to be called within an org capture template." - (let* ((pdf-buf-name (plist-get org-capture-plist :original-buffer)) - (pdf-buf (get-buffer pdf-buf-name))) - (if (buffer-live-p pdf-buf) - (with-current-buffer pdf-buf - (car (pdf-view-active-region-text))) - (user-error "Buffer %S not alive" pdf-buf-name)))) + (let* ((pdf-buf-name (plist-get org-capture-plist :original-buffer)) + (pdf-buf (get-buffer pdf-buf-name))) + (if (buffer-live-p pdf-buf) + (with-current-buffer pdf-buf + (car (pdf-view-active-region-text))) + (user-error "Buffer %S not alive" pdf-buf-name)))) ;;;; --------------------------- Org-Capture Templates ------------------------- +(use-package org-protocol + :ensure nil ;; built-in + :defer .5 + :after org + :config ;; ORG-CAPTURE TEMPLATES (setq org-protocol-default-template-key "L") (setq org-capture-templates @@ -90,9 +93,10 @@ Intended to be called within an org capture template." Source: [[%:link][%(buffer-name (org-capture-get :original-buffer))]] Captured On: %U" :prepend t) + ;; requires cj/org-capture-pdf-active-region function defined above ("P" "PDF Text" entry (file+headline inbox-file "Inbox") "* %? -#+BEGIN_QUOTE\n%(org-capture-pdf-active-region)\n#+END_QUOTE +#+BEGIN_QUOTE\n%(cj/org-capture-pdf-active-region)\n#+END_QUOTE Source:[[%L][%(buffer-name (org-capture-get :original-buffer))]] Captured On: %U" :prepend t) @@ -119,11 +123,10 @@ Captured On: %U" ("s" "Shopping List Entry" entry (file+headline inbox-file "Shopping List") "* %?") + ;; requires cj/org-web-clipper function defined above ("w" "Web Page Clipper" plain (function cj/org-webpage-clipper) - "* %a\nArticle Link: %L\nCaptured On: %U\n\n" :immediate-finish t))) - - ) ;; end with-eval-after-load 'org + "* %a\nArticle Link: %L\nCaptured On: %U\n\n" :immediate-finish t)))) ;; ---------------------------- Simple Task Capture ---------------------------- ;; the simplest way to capture a task. Also a simple way to write this function. |
