summaryrefslogtreecommitdiffhomepage
path: root/custom/jao-custom-eww.el
diff options
context:
space:
mode:
Diffstat (limited to 'custom/jao-custom-eww.el')
-rw-r--r--custom/jao-custom-eww.el35
1 files changed, 19 insertions, 16 deletions
diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el
index a3f4df9..1b766c9 100644
--- a/custom/jao-custom-eww.el
+++ b/custom/jao-custom-eww.el
@@ -116,16 +116,17 @@
;;; eww to org
(defun jao-eww-to-org (&optional dest)
- (interactive)
- (unless (org-region-active-p)
+ (interactive "P")
+ (unless (or (and (interactive-p) dest) (org-region-active-p))
(let ((shr-width 80)) (eww-readable)))
- (let* ((start (if (org-region-active-p) (region-beginning) (point-min)))
+ (let* ((dest (unless (interactive-p) dest))
+ (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 +184,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 +256,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)
@@ -279,5 +279,8 @@ It should be the title of the web page as returned by `rdrview'"
(advice-add 'shr-tag-img :around #'jao-shr-tag-img)
(advice-add 'shr-insert :around #'jao-shr-insert)
+;; (advice-remove 'shr-tag-img #'jao-shr-tag-img)
+;; (advice-remove 'shr-insert #'jao-shr-insert)
+
;;; .
(provide 'jao-custom-eww)