diff options
-rw-r--r-- | custom/jao-custom-eww.el | 25 | ||||
-rw-r--r-- | lib/doc/jao-org-notes.el | 15 |
2 files changed, 20 insertions, 20 deletions
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) diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index bd82543..43b8c09 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -71,13 +71,13 @@ (and (string-match-p "^[^:]+ + :" m) "tags") "titles")) -(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd) +(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd initial) (let ((default-directory (expand-file-name (or cat "") jao-org-notes-dir))) (consult--read (consult--async-command #'jao-org-notes--rg-title-or-tags (consult--async-transform jao-org-notes--matches)) :prompt prompt - :initial (consult--async-split-initial "") + :initial (consult--async-split-initial (or initial "")) :add-history (concat (consult--async-split-initial (thing-at-point 'symbol))) :require-match (not no-req) :category 'jao-org-notes-lookup @@ -94,9 +94,10 @@ (cond ((file-exists-p (expand-file-name cat jao-org-notes-dir)) cat) ((yes-or-no-p "New category, create?") cat)))) -(defun jao-org-notes--insert-title () +(defun jao-org-notes--insert-title (&optional title) (let* ((cat (jao-org-notes--cat)) - (title (file-name-base (jao-org-notes--consult-rg "Title: " cat t))) + (note (jao-org-notes--consult-rg "Title: " cat t nil title)) + (title (file-name-base note)) (title (replace-regexp-in-string "^#" "" title))) (when (not (string-empty-p title)) (let* ((base (replace-regexp-in-string " +" "-" (downcase title))) @@ -160,16 +161,16 @@ (interactive) (consult-ripgrep (expand-file-name (or cat "") jao-org-notes-dir) initial)) -(defun jao-org-notes-create () +(defun jao-org-notes-create (&optional title) "Create a new note file, matching tags and titles with completion." (interactive) - (when (jao-org-notes--insert-title) + (when (jao-org-notes--insert-title title) (org-insert-time-stamp (current-time) t t "#+date: " "\n") (insert "#+tags: :" (mapconcat #'identity (jao-org-notes--read-tags) ":") ":\n")) (save-buffer) - (buffer-file-name)) + (current-buffer)) (defun jao-org-notes-backlinks () "Show a list of note files linking to the current one." |