diff options
Diffstat (limited to 'custom')
-rw-r--r-- | custom/jao-custom-blog.el | 2 | ||||
-rw-r--r-- | custom/jao-custom-completion.el | 17 | ||||
-rw-r--r-- | custom/jao-custom-email.el | 6 | ||||
-rw-r--r-- | custom/jao-custom-eww.el | 15 | ||||
-rw-r--r-- | custom/jao-custom-exwm.el | 29 | ||||
-rw-r--r-- | custom/jao-custom-gnus.el | 51 | ||||
-rw-r--r-- | custom/jao-custom-notmuch.el | 12 | ||||
-rw-r--r-- | custom/jao-custom-org.el | 2 | ||||
-rw-r--r-- | custom/jao-custom-w3m.el | 2 |
9 files changed, 77 insertions, 59 deletions
diff --git a/custom/jao-custom-blog.el b/custom/jao-custom-blog.el index 4b74601..a11c5c0 100644 --- a/custom/jao-custom-blog.el +++ b/custom/jao-custom-blog.el @@ -171,7 +171,7 @@ (to (expand-file-name (file-name-nondirectory from) org-static-blog-posts-directory))) (rename-file from to) - (when-let* ((b (get-buffer from))) + (when-let ((b (get-buffer from))) (kill-buffer b)) (find-file to) (jao-org-static-blog-update-date) diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el index cdffcdc..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 "`"))) @@ -175,9 +174,9 @@ (defvar jao-consult-narrow nil) (defun jao-consult-initial-narrow () - (when-let* ((c (cond ((eq this-command #'consult-buffer) - (cdr (assoc (jao-afio-frame-name) jao-consult-narrow))) - ((eq this-command #'consult-mode-command) ?m)))) + (when-let (c (cond ((eq this-command #'consult-buffer) + (cdr (assoc (jao-afio-frame-name) jao-consult-narrow))) + ((eq this-command #'consult-mode-command) ?m))) (setq unread-command-events (append unread-command-events `(,c 32))))) (add-hook 'minibuffer-setup-hook #'jao-consult-initial-narrow) @@ -290,7 +289,7 @@ (defun jao-embark-targets--w3m-anchor () (when (not (region-active-p)) - (when-let* ((url (or (jao-url-around-point) + (when-let ((url (or (jao-url-around-point) (thing-at-point 'url) (and (derived-mode-p 'w3m-mode) (or (w3m-anchor) w3m-current-url)) @@ -396,12 +395,12 @@ (with-eval-after-load "notmuch" (defun jao-link-hint--notmuch-next-part (&optional bound) - (when-let* ((p (next-single-property-change (point) :notmuch-part nil bound))) + (when-let (p (next-single-property-change (point) :notmuch-part nil bound)) (and (< p (or bound (point-max))) p))) (defun jao-link-hint--notmuch-part-p () (and (get-text-property (point) :notmuch-part) - (when-let* ((b (button-at (point)))) (button-label b)))) + (when-let (b (button-at (point))) (button-label b)))) (link-hint-define-type 'notmuch-part :next #'jao-link-hint--notmuch-next-part diff --git a/custom/jao-custom-email.el b/custom/jao-custom-email.el index dd898ad..a3d1a92 100644 --- a/custom/jao-custom-email.el +++ b/custom/jao-custom-email.el @@ -69,8 +69,8 @@ (defun jao-message-insert-bcc () (when jao-notmuch-enabled (let ((f (or (message-fetch-field "From") ""))) - (when-let* ((b (seq-some (lambda (x) (when (string-match-p (car x) f) (cdr x))) - jao-message--bcc-alist))) + (when-let (b (seq-some (lambda (x) (when (string-match-p (car x) f) (cdr x))) + jao-message--bcc-alist)) (insert "Bcc: " b "\n"))))) ;; (when jao-notmuch-enabled @@ -170,7 +170,7 @@ (save-excursion (save-restriction (message-narrow-to-headers) - (when-let* ((to (message-fetch-field "To"))) + (when-let ((to (message-fetch-field "To"))) (when (string-match-p jao-mails-regexp to) (unless (y-or-n-p "Message is addressed to yourself. Continue?") (error "Message not sent"))))))) diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el index 726f682..1b766c9 100644 --- a/custom/jao-custom-eww.el +++ b/custom/jao-custom-eww.el @@ -32,7 +32,7 @@ ;;; opening URLs (defun jao-eww-copy-link () (interactive) - (when-let* ((lnk (or (car (eww-links-at-point)) (eww-current-url)))) + (when-let (lnk (or (car (eww-links-at-point)) (eww-current-url))) (message "%s" lnk) (kill-new lnk))) @@ -83,7 +83,7 @@ ;;; images (defun jao-eww-next-image () (interactive nil eww-mode) - (when-let* ((p (text-property-search-forward 'image-displayer nil nil t))) + (when-let (p (text-property-search-forward 'image-displayer nil nil t)) (goto-char (prop-match-beginning p)))) ;;; close page and reopen @@ -91,7 +91,7 @@ (defun jao-eww-close () (interactive nil eww-mode) - (when-let* ((current (eww-current-url))) + (when-let (current (eww-current-url)) (add-to-list 'jao-eww--closed-urls current)) (let ((nxt (car (jao-eww-session-invisible-buffers)))) (kill-current-buffer) @@ -116,10 +116,11 @@ ;;; 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))) (link (eww-current-url)) (title (plist-get eww-data :title)) @@ -220,7 +221,7 @@ It should be the title of the web page as returned by `rdrview'" (with-eval-after-load "org" (require 'ol-eww nil t)) (defun jao-eww-buffer-name () - (when-let* ((s (or (plist-get eww-data :title) + (when-let ((s (or (plist-get eww-data :title) (plist-get eww-data :url)))) (when (not (string-blank-p s)) (format "%s" s)))) (setq eww-auto-rename-buffer #'jao-eww-buffer-name) diff --git a/custom/jao-custom-exwm.el b/custom/jao-custom-exwm.el index 2135935..3cb3fc9 100644 --- a/custom/jao-custom-exwm.el +++ b/custom/jao-custom-exwm.el @@ -185,7 +185,7 @@ (when cln (if (jao-exwm--check-name cln) (current-buffer) - (when-let* ((b (jao-exwm-find-class-buffer cln))) + (when-let ((b (jao-exwm-find-class-buffer cln))) (pop-to-buffer b))))) (defun jao-exwm-switch-to-next-class () @@ -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)))))) @@ -341,21 +343,21 @@ (defun jao-exwm-zathura-goto-org (&optional arg) (interactive "P") - (when-let* ((info (jao-zathura--file-info (current-buffer))) - (file (jao-org-find-for-pdf (car info)))) - (let ((newp (not (file-exists-p file)))) - (when (or arg newp) (org-store-link nil t)) - (find-file-other-window file) - (when newp - (jao-org-insert-doc-skeleton) - (org-insert-link))))) + (when-let ((info (jao-zathura--file-info (current-buffer)))) + (when-let ((file (jao-org-find-for-pdf (car info)))) + (let ((newp (not (file-exists-p file)))) + (when (or arg newp) (org-store-link nil t)) + (find-file-other-window file) + (when newp + (jao-org-insert-doc-skeleton) + (org-insert-link)))))) (defun jao-exwm-zathura-goto-org* () (interactive) (jao-exwm-zathura-goto-org t)) (defun jao-exwm-org-store-zathura-link () - (when-let* ((info (jao-zathura--file-info (current-buffer)))) + (when-let ((info (jao-zathura--file-info (current-buffer)))) (let* ((file-name (car info)) (page (cadr info)) (desc (jao-pdf-section-title page file-name))) @@ -385,7 +387,7 @@ (interactive) (if jao-browse-doc-use-emacs-p (jao-org-goto-pdf) - (when-let* ((pdf (jao-exwm-org-to-pdf-file))) + (when-let (pdf (jao-exwm-org-to-pdf-file)) (jao-zathura-open-doc pdf)))) (with-eval-after-load "org" @@ -422,7 +424,7 @@ (defun jao-exwm-kill-firefox-url () (interactive) - (when-let* ((b (jao-exwm-find-class-buffer "Firefox"))) + (when-let (b (jao-exwm-find-class-buffer "Firefox")) (let ((cb (current-buffer))) (switch-to-buffer b) (jao-exwm--send-str "yy") @@ -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 c56599e..ce77285 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -212,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) @@ -447,13 +449,19 @@ (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\n(jao-gnus-org-paragraph \"%i\")" + "* %(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 ") @@ -462,22 +470,27 @@ (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-subject (gnus-summary-article-subject)) + (setq jao-gnus-subject (gnus-summary-article-subject)) (gnus-summary-select-article-buffer) (gnus-article-goto-part 0) - (setq-local transient-mark-mode 'lambda) - (set-mark (point)) - (forward-paragraph) - (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") - (set-mark (point)) + (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 @@ -558,7 +571,7 @@ (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)))) (cond (external (jao-browse-with-external-browser)) @@ -580,10 +593,10 @@ (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))) + (if-let ((url (jao-url-around-point))) (jao-mpc-add-or-play-url url) (error "No enclosure found")))))) @@ -633,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-warning) - ("nnml:jao.[^isthw]" "J" jao-themes-dimm) + ("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) @@ -689,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) diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index 7b1540f..42d9e12 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -60,7 +60,7 @@ (defun jao-notmuch-tree-widen-search () (interactive) - (when-let* ((query (notmuch-tree-get-query))) + (when-let ((query (notmuch-tree-get-query))) (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto))) (notmuch-tree-close-message-window) (notmuch-tree (string-replace jao-notmuch--newa "" query))))) @@ -73,7 +73,7 @@ searches)) (defun jao-notmuch-hello--insert-searches (searches title) - (when-let* ((searches (notmuch-hello-query-counts searches))) + (when-let (searches (notmuch-hello-query-counts searches)) (let* ((cnt (when title (seq-reduce (lambda (c q) (+ c (or (plist-get q :count) 0))) @@ -348,7 +348,7 @@ (if (not (search-forward "Enclosure:" nil t)) (user-error "No enclosure in message body") (re-search-forward "https?://" nil t) - (if-let* ((url (thing-at-point-url-at-point))) + (if-let (url (thing-at-point-url-at-point)) (progn (message "%s %s ..." (if add "Adding" "Playing") url) (unless add (jao-mpc-clear)) @@ -363,7 +363,7 @@ "quant-ph updates on arXiv.org: "))) (defun jao-mail-clean-address (args) - (when-let* ((address (car args))) + (when-let ((address (car args))) (list (thread-last (replace-regexp-in-string jao-mail-clean-rx "" address) (replace-regexp-in-string " " ", "))))) @@ -430,8 +430,8 @@ (defun jao-notmuch-browse-url (ext) (interactive "P") - (when-let* ((url (or (jao-notmuch--via-url) - (car (last (jao-notmuch-message-urls)))))) + (when-let (url (or (jao-notmuch--via-url) + (car (last (jao-notmuch-message-urls))))) (funcall (if ext browse-url-secondary-browser-function #'browse-url) url))) diff --git a/custom/jao-custom-org.el b/custom/jao-custom-org.el index 1b15e72..4d2e622 100644 --- a/custom/jao-custom-org.el +++ b/custom/jao-custom-org.el @@ -254,7 +254,7 @@ (defun jao-insert-eww-link () "Look for last eww buffer and insert an org link to it." (interactive) - (when-let* ((b (car (jao-eww-session-eww-buffers)))) + (when-let (b (car (jao-eww-session-eww-buffers))) (let ((lnk (with-current-buffer b (format "[[%s][%s]]" (eww-current-url) diff --git a/custom/jao-custom-w3m.el b/custom/jao-custom-w3m.el index 57d0c4a..43b9e2d 100644 --- a/custom/jao-custom-w3m.el +++ b/custom/jao-custom-w3m.el @@ -6,7 +6,7 @@ (fn `(lambda (b) (with-current-buffer b (string= ,url (w3m-canonicalize-url w3m-current-url)))))) - (when-let* ((b (seq-find fn (w3m-list-buffers)))) + (when-let (b (seq-find fn (w3m-list-buffers))) (pop-to-buffer b)))) (defun jao-w3m-browse-url (url &rest r) |