From 6203f490e8747977c0dfdb797cd46327fe7c63dd Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 19 Oct 2024 19:40:21 +0100 Subject: notes: capture org note from eww instead of tmp buffer --- custom/jao-custom-eww.el | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'custom/jao-custom-eww.el') diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el index a3f4df9..987040f 100644 --- a/custom/jao-custom-eww.el +++ b/custom/jao-custom-eww.el @@ -121,11 +121,11 @@ (let ((shr-width 80)) (eww-readable))) (let* ((start (if (org-region-active-p) (region-beginning) (point-min))) (end (if (org-region-active-p) (region-end) (point-max))) - (buff (or dest (generate-new-buffer "*eww-to-org*"))) (link (eww-current-url)) - (title (or (plist-get eww-data :title) ""))) + (title (plist-get eww-data :title)) + (buff (save-current-buffer (or dest (jao-org-notes-create title))))) (with-current-buffer buff - (insert "#+title: " title "\n#+link: " link "\n\n") + (insert "#+link: " link "\n\n") (org-mode)) (save-excursion (goto-char start) @@ -183,6 +183,15 @@ It should be the title of the web page as returned by `rdrview'" (if eww-rdrview-mode (eww-rdrview-mode -1) (eww-rdrview-mode 1)) (eww-reload)) +;;; auto-readable +(defvar jao-eww-auto-readable-urls + (regexp-opt '("guardian.co.uk" "theguardian.com" "github.com" "eldiario.es"))) + +(defun jao-eww-autoread () + (when (string-match-p jao-eww-auto-readable-urls (or (eww-current-url))) + (eww-readable))) + +(add-hook 'eww-after-render-hook #'jao-eww-autoread) ;;; package (use-package shr :custom ((shr-width nil) @@ -246,16 +255,6 @@ It should be the title of the web page as returned by `rdrview'" ("C-c C-w" . jao-eww-close) ("M-i" . eww-toggle-images)))) -;;; auto-readable -(defvar jao-eww-auto-readable-urls - (regexp-opt '("guardian.co.uk" "theguardian.com" "github.com" "eldiario.es"))) - -(defun jao-eww-autoread () - (when (string-match-p jao-eww-auto-readable-urls (or (eww-current-url))) - (eww-readable))) - -(add-hook 'eww-after-render-hook #'jao-eww-autoread) - ;;; fixes for shr image rendering (require 'shr) -- cgit v1.2.3