summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-completion.el5
-rw-r--r--custom/jao-custom-eww.el35
-rw-r--r--custom/jao-custom-exwm.el5
-rw-r--r--custom/jao-custom-gnus.el110
-rw-r--r--custom/jao-custom-notmuch.el13
5 files changed, 122 insertions, 46 deletions
diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el
index 9524e23..490fd65 100644
--- a/custom/jao-custom-completion.el
+++ b/custom/jao-custom-completion.el
@@ -87,7 +87,7 @@
(funcall fun lines)
(move-overlay vertico--candidates-ov (point-min) (point-min))
(overlay-put vertico--candidates-ov 'after-string (apply #'concat lines))
- (vertico--resize-window (length lines))))
+ (vertico--resize)))
(advice-add 'vertico--display-candidates :around #'jao-vertico--display))
@@ -126,8 +126,7 @@
("M-g e" . consult-error)
("M-s m" . consult-multi-occur)
("M-y" . consult-yank-pop)
- ("C-s" . isearch-forward)
- ("<help> a" . consult-apropos))
+ ("C-s" . isearch-forward))
:custom ((consult-preview-key (kbd "`")))
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)
diff --git a/custom/jao-custom-exwm.el b/custom/jao-custom-exwm.el
index e5c67f8..3cb3fc9 100644
--- a/custom/jao-custom-exwm.el
+++ b/custom/jao-custom-exwm.el
@@ -194,7 +194,9 @@
(defun jao-exwm-switch-to-next-x ()
(interactive)
- (let ((bfs (seq-filter (lambda (b) (buffer-local-value 'exwm-class-name b))
+ (let ((bfs (seq-filter (lambda (b)
+ (with-current-buffer b
+ (derived-mode-p 'exwm-mode)))
(buffer-list (window-frame)))))
(when (car bfs) (switch-to-buffer (car (reverse bfs))))))
@@ -530,6 +532,7 @@
([f9] . jao-bright-show)))
;; (customize-set-variable 'exwm-input-global-keys exwm-input-global-keys)
+(exwm-wm-mode)
;;; .
(provide 'jao-custom-exwm)
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el
index 0d75b43..ce77285 100644
--- a/custom/jao-custom-gnus.el
+++ b/custom/jao-custom-gnus.el
@@ -114,7 +114,7 @@
(cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-recoll)
(qstring string)
- _query
+ query
&optional groups)
(let* ((subdir (slot-value engine 'remove-prefix))
(sep (slot-value engine 'separator))
@@ -128,8 +128,18 @@
(mapconcat (lambda (d) (format "dir:%s" d))
gdirs " OR ")
")")))
- (q (concat "mime:message " dirsq " (" qstring ")")))
- ;; (message "query is: %s" q)
+ (qstring (if (string-prefix-p "id:" qstring)
+ (replace-regexp-in-string "<\\|>" "\"" qstring)
+ qstring))
+ (qstring (if (cdr (assoc 'thread query))
+ (concat qstring " OR "
+ (replace-regexp-in-string "id:\"" "ref:\""
+ qstring))
+ qstring))
+ (qstring (replace-regexp-in-string " or " " OR " qstring))
+ (qstring (replace-regexp-in-string " and " " AND " qstring))
+ (q (format "mime:message %s (%s)" dirsq qstring)))
+ ;; (message "query is: %s -- %S" q query)
`("-b" "-t" "-q" ,q))))
;; (add-to-list 'gnus-parameters '("^nnselect:.*" (nnselect-rescan . t)))
@@ -202,8 +212,10 @@
(when jao-gnus-use-nnml
(add-to-list
'gnus-secondary-select-methods
- `(nnml "" (gnus-search-engine gnus-search-recoll
- (remove-prefix ,(jao-gnus-dir "Mail/"))))))
+ ;; `(nnml "" (gnus-search-engine gnus-search-recoll
+ ;; (remove-prefix ,(jao-gnus-dir "Mail/"))))
+ `(nnml "" (gnus-search-engine gnus-search-notmuch
+ (remove-prefix "/home/jao/var/mail/gnus")))))
(when jao-gnus-use-nnml
(dolist (p jao-gnus-nnml-group-params)
@@ -437,20 +449,49 @@
(use-package org-capture
:config
(add-to-list 'org-capture-templates
+ '("x" "arXiv" entry (file "notes/physics/arxiv.org")
+ "* %(jao-gnus-subject)\n\n %i\n\n %(jao-gnus-org-url)"
+ :immediate-finish t)
+ t)
+ (add-to-list 'org-capture-templates
'("X" "arXiv" entry (file "notes/physics/arxiv.org")
- "* %:subject\n %i" :immediate-finish t)
+ "* %(jao-gnus-subject)\n\n%(jao-gnus-org-paragraph \"%i\")"
+ :immediate-finish t)
t)
(org-capture-upgrade-templates org-capture-templates))
+(defvar jao-gnus-org-url nil)
+(defun jao-gnus-org-url () jao-gnus-org-url)
+(defun jao-gnus-org-paragraph (x)
+ (with-temp-buffer
+ (insert " " (string-trim (or x "")) "\n ")
+ (goto-char 0)
+ (fill-paragraph)
+ (goto-char (point-max))
+ (open-rectangle 0 (point))
+ (concat (buffer-string) "\n " (or jao-gnus-org-url ""))))
+(defvar jao-gnus-subject nil)
+(defun jao-gnus-subject () jao-gnus-subject)
+
(defun jao-gnus-arXiv-capture ()
(interactive)
+ (unless (derived-mode-p '(gnus-summary-mode)) (gnus-article-show-summary))
+ (setq jao-gnus-subject (gnus-summary-article-subject))
(gnus-summary-select-article-buffer)
(gnus-article-goto-part 0)
- (forward-paragraph)
- (setq-local transient-mark-mode 'lambda)
- (set-mark (point))
- (goto-char (point-max))
- (org-capture nil "X"))
+ (let ((transient-mark-mode t))
+ (set-mark (point))
+ (forward-paragraph)
+ (or (and (save-excursion
+ (when (re-search-forward "^Link" nil t)
+ (beginning-of-line)
+ (setq jao-gnus-org-url (org-eww-url-below-point))))
+ (org-capture nil "X"))
+ (and (save-excursion
+ (when (re-search-forward "^URL: " nil t)
+ (setq jao-gnus-org-url (thing-at-point-url-at-point))))
+ (org-capture nil "x"))))
+ (gnus-article-show-summary))
;;; article
;;;; config, headers
@@ -530,12 +571,21 @@
(save-excursion
(goto-char (point-min))
(when (or (search-forward-regexp "^Via: h" nil t)
- (search-forward-regexp "^URL: h" nil t)
+ (search-forward-regexp "^URL:[\n ]h" nil t)
(and (search-forward-regexp "^Link$" nil t)
(not (beginning-of-line))))
- (if external
- (jao-browse-with-external-browser)
- (browse-url (jao-url-around-point))))))
+ (cond (external (jao-browse-with-external-browser))
+ ((featurep 'jao-custom-eww) (eww (jao-url-around-point)))
+ (t (browse-url (jao-url-around-point)))))))
+
+(defun jao-gnus-from-eww (keep-eww-buffer)
+ (interactive "P")
+ (unless keep-eww-buffer (jao-eww-close))
+ (jao-afio-goto-mail)
+ (gnus-article-show-summary))
+
+(with-eval-after-load 'eww
+ (define-key eww-mode-map (kbd "h") #'jao-gnus-from-eww))
(defun jao-gnus-open-enclosure ()
(interactive)
@@ -543,7 +593,7 @@
(gnus-summary-select-article-buffer)
(save-excursion
(goto-char (point-min))
- (let ((offset (or (and (search-forward-regexp "^Enclosure: " nil t) 2)
+ (let ((offset (or (and (search-forward-regexp "^Enclosure: ?" nil t) 2)
(and (search-forward-regexp "^Enclosure$" nil t) -2))))
(when offset (forward-char offset))
(if-let ((url (jao-url-around-point)))
@@ -576,7 +626,16 @@
(gnus-demon-scan-news)
(jao-gnus--notify)))
-(gnus-demon-add-handler 'jao-gnus--scan 5 1)
+(defun jao-gnus-add-demon ()
+ (interactive)
+ (gnus-demon-add-handler 'jao-gnus--scan 5 1))
+
+(jao-gnus-add-demon)
+(gnus-demon-init)
+
+;; this is, in theory, not needed; but at some point in the way to emacs
+;; version 31 this idle timers have ceased to work after a sleep/awake cycle
+(add-to-list 'jao-sleep-awake-functions #'jao-gnus-add-demon)
;;; add-ons
;;;; notifications
@@ -587,13 +646,14 @@
(seq-difference '("feeds.trove")))))
`(("nnml:bigml\\.inbox" "B" jao-themes-f00)
("nnml:bigml\\.alba" "A" jao-themes-f00)
+ ("nnml:bigml\\.ryou" "R" jao-themes-f00)
("nnml:bigml\\.bugs" "b" jao-themes-error)
("nnml:bigml\\.support" "S" default)
+ ("nnml:bigml\\.[^aibsr]" "W" jao-themes-dimm)
("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01)
- ("nnml:bigml\\.[^aibs]" "W" jao-themes-dimm)
("nnml:jao.hacking" "H" jao-themes-dimm)
- ("nnml:jao.write" "W" jao-themes-error)
- ("nnml:jao.[^isthw]" "J" jao-themes-dimm)
+ ("nnml:jao.write" "W" jao-themes-warning)
+ ("nnml:jao.[^ithw]" "J" jao-themes-dimm)
(,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
("feeds\\.e" "E" jao-themes-dimm)
("nnml:local" "l" jao-themes-dimm)
@@ -643,6 +703,7 @@
(jao-gnus--notify)))
(add-hook 'gnus-summary-exit-hook #'jao-gnus--on-summary-exit)
+(add-hook 'gnus-exit-group-hook #'jao-gnus--notify)
;;;; open mail file in gnus
(defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server)
@@ -717,6 +778,15 @@
(with-eval-after-load "consult-recoll"
(add-to-list 'consult-recoll-open-fns
'("message/rfc822" . jao-gnus-goto-file))))
+;;;; notmuch
+(use-package jao-notmuch-gnus
+ :demand t)
+
+(jao-load-path "consult-notmuch")
+
+(use-package consult-notmuch
+ :bind (:map gnus-group-mode-map ("S" . #'jao-gnus-consult-notmuch)))
+
;;; keyboard shortcuts
(define-key gnus-article-mode-map "i" 'jao-gnus-show-images)
(define-key gnus-summary-mode-map "i" 'jao-gnus-show-images)
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el
index 3919897..42d9e12 100644
--- a/custom/jao-custom-notmuch.el
+++ b/custom/jao-custom-notmuch.el
@@ -588,12 +588,13 @@
;;; arXiv
(use-package org-capture
:config
- (add-to-list 'org-capture-templates
- '("X" "arXiv" entry (file "notes/physics/arxiv.org")
- "* %(jao-org-notmuch-last-subject)\n %i"
- :immediate-finish t)
- t)
- (org-capture-upgrade-templates org-capture-templates))
+ (when jao-notmuch-enabled
+ (add-to-list 'org-capture-templates
+ '("X" "arXiv" entry (file "notes/physics/arxiv.org")
+ "* %(jao-org-notmuch-last-subject)\n %i"
+ :immediate-finish t)
+ t)
+ (org-capture-upgrade-templates org-capture-templates)))
(defun jao-notmuch-arXiv-capture ()
(interactive)