diff options
-rw-r--r-- | custom/jao-custom-browse.el | 2 | ||||
-rw-r--r-- | custom/jao-custom-eww.el | 4 | ||||
-rw-r--r-- | custom/jao-custom-gnus.el | 1 | ||||
-rw-r--r-- | custom/jao-custom-org.el | 12 | ||||
-rw-r--r-- | init.el | 87 | ||||
-rw-r--r-- | lib/doc/jao-doc-session.el | 2 | ||||
-rw-r--r-- | lib/doc/jao-org-focus.el | 104 |
7 files changed, 167 insertions, 45 deletions
diff --git a/custom/jao-custom-browse.el b/custom/jao-custom-browse.el index ba47df7..0f4ae65 100644 --- a/custom/jao-custom-browse.el +++ b/custom/jao-custom-browse.el @@ -149,7 +149,7 @@ "t.com" "linkedin.com" "bigml.com" "slack.com" "zoom.us")) (defvar jao-browse--external-regexp - (format "https?://.*%s\\(/.*\\)?" + (format "https?://\\(.+\\.\\)*%s\\(/.*\\)?" (regexp-opt jao-browse-external-domains))) (defun jao-wget--regexp () diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el index a6fb342..221f442 100644 --- a/custom/jao-custom-eww.el +++ b/custom/jao-custom-eww.el @@ -245,8 +245,8 @@ (prog1 (apply fn args) (when (and p (> (point) p)) (jao-shr--kill-nl p))))) -(advice-add 'shr-tag-img :around #'jao-shr-tag-img) -(advice-add 'shr-insert :around #'jao-shr-insert) +;; (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) diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index dc729ce..bc39f5b 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -523,6 +523,7 @@ (setq gnus-single-article-buffer nil) (setq gnus-article-update-lapsed-header 60) (setq gnus-article-update-date-headers 60) +(setq gnus-article-truncate-lines t) (with-eval-after-load "gnus-art" (setq gnus-visible-headers diff --git a/custom/jao-custom-org.el b/custom/jao-custom-org.el index 9b8c4eb..01f324e 100644 --- a/custom/jao-custom-org.el +++ b/custom/jao-custom-org.el @@ -313,6 +313,14 @@ :hook ((org-agenda-finalize . org-modern-agenda))) +;;; jao-org-focus +(use-package jao-org-focus + :after org + :config + (with-eval-after-load "jao-custom-completion" + (jao-consult-add-buffer-source 'jao-org-focus-consult-buffer-source)) + :bind ((:map org-mode-map (("C-M-o" . jao-org-focus))))) + ;;; Keybindings (define-key mode-specific-map [?a] 'org-agenda) (define-key org-mode-map "\C-cv" 'jao-org-copy-link-at-point) @@ -321,7 +329,9 @@ (define-key org-mode-map "\C-cE" 'jao-insert-eww-link) (define-key org-mode-map "\C-cW" 'jao-insert-eww-link) (define-key org-mode-map "\C-c'" 'org-edit-src-code) -(define-key org-mode-map "\C-cO" 'outline-hide-other) +(define-key org-mode-map (kbd "C-c O") 'org-toggle-narrow-to-subtree) +(define-key org-mode-map (kbd "C-x C-n") 'org-next-link) +(define-key org-mode-map (kbd "C-x C-p") 'org-previous-link) (global-set-key "\C-cr" 'org-capture) (global-set-key "\C-c\C-l" 'org-store-link) ;; (global-set-key "\C-cL" 'org-insert-link-global) @@ -1800,43 +1800,52 @@ (jao-d-l (progn - (defun jao-open-firefox () (interactive) (jao-mac-open "-a Firefox")) - (defun jao-open-nnw () (interactive) (jao-mac-open "-a NetNewsWire")) - (defun jao-open-telegram () (interactive) (jao-mac-open "-a Telegram")) - (global-set-key (kbd "s-f") #'jao-open-firefox) - (global-set-key (kbd "s-n") #'jao-open-nnw) - (global-set-key (kbd "s-t") #'jao-open-telegram) - - (transient-define-prefix jao-transient-utils () - "Global operations." - [["Notes" - ("nn" "create new note" jao-org-notes-create) - ("no" "open note" jao-org-notes-open) - ("nt" "open note by tags" jao-org-notes-consult-tags) - ("ng" "ripgrep notes" jao-org-notes-consult-ripgrep)] - ["Documents" - ("d" "go to doc" jao-select-pdf) - ("o" "open doc" jao-open-doc) - ("c" "view cache" doc-view-dired-cache)] - ["External" - ("xn" "browse NNW article" jao-nnw-browse-current-article) - ("xs" "browse safary article" jao-safari-browse-current) - ("xk" "open skim doc" jao-skim-open-current-doc) - ("xe" "choose an emoji" ns-do-show-character-palette)] - ["Blog" - ("bn" "create post" jao-org-static-blog-create-new-post) - ("bd" "create draft" jao-org-static-blog-create-new-draft) - ("be" "edit draft" jao-org-static-blog-edit-draft)] - ["Afio" - ("g" "mail" jao-afio-goto-mail) - ("z" "docs" jao-afio-goto-docs) - ("w" "wwww" jao-afio-goto-www) - ("f" "main" jao-afio-goto-main)] - ["Utilities" - ("s" "ssh" jao-ssh) - ("l" "packages" jao-list-packages) - ("p" "passwords" password-store-menu) - ("F" "copy buffer file name" copy-buffer-file-name-as-kill)]])) + (defun jao-open-firefox () (interactive) (jao-mac-open "-a Firefox")) + (defun jao-open-nnw () (interactive) (jao-mac-open "-a NetNewsWire")) + (defun jao-open-safari () (interactive) (jao-mac-open "-a Safari")) + (defun jao-open-telegram () (interactive) (jao-mac-open "-a Telegram")) + (global-set-key (kbd "s-f") #'jao-open-safari) + ;; (global-set-key (kbd "s-n") #'jao-open-nnw) + (global-set-key (kbd "s-t") #'jao-open-telegram) + + (defun jao-safari-internal-browse () + (interactive) + (when-let ((url (jao-safari-current-url))) + (jao-browse-url-browse url))) + + (transient-define-prefix jao-transient-utils () + "Global operations." + [["Notes" + ("nn" "create new note" jao-org-notes-create) + ("no" "open note" jao-org-notes-open) + ("nt" "open note by tags" jao-org-notes-consult-tags) + ("ng" "ripgrep notes" jao-org-notes-consult-ripgrep)] + ["Documents" + ("d" "go to doc" jao-select-pdf) + ("o" "open doc" jao-open-doc) + ("c" "view cache" doc-view-dired-cache)] + ["External" + ("xn" "browse NNW article" jao-nnw-browse-current-article) + ("xs" "browse safary article" jao-safari-internal-browse) + ("xk" "open skim doc" jao-skim-open-current-doc) + ("xe" "choose an emoji" ns-do-show-character-palette)] + ["Blog" + ("bn" "create post" jao-org-static-blog-create-new-post) + ("bd" "create draft" jao-org-static-blog-create-new-draft) + ("be" "edit draft" jao-org-static-blog-edit-draft)] + ["Afio" + ("g" "mail" jao-afio-goto-mail) + ("z" "docs" jao-afio-goto-docs) + ("w" "wwww" jao-afio-goto-www) + ("f" "main" jao-afio-goto-main)] + ["Network" + ("s" "ssh" jao-ssh) + ("r" "r2e" jao-r2e)] + ["Utilities" + ("m" "mpc" jao-transient-media) + ("l" "packages" jao-list-packages) + ("p" "passwords" password-store-menu) + ("F" "copy buffer file name" copy-buffer-file-name-as-kill)]])) (transient-define-prefix jao-transient-utils () "Global operations." @@ -1903,9 +1912,7 @@ (global-set-key "\C-xr\M-w" #'kill-rectangle-save) (global-set-key "\C-c\C-z" #'comment-or-uncomment-region) (global-set-key "\C-z" #'comment-or-uncomment-region) - (jao-when-darwin - (global-set-key (kbd "M-`") 'other-frame) - (global-set-key (kbd "s-e") 'jao-firefox-open))) + (jao-when-darwin (global-set-key (kbd "M-`") 'other-frame))) (jao-global-keybindings) diff --git a/lib/doc/jao-doc-session.el b/lib/doc/jao-doc-session.el index d2076c1..df7e994 100644 --- a/lib/doc/jao-doc-session.el +++ b/lib/doc/jao-doc-session.el @@ -25,7 +25,7 @@ (defun jao-doc-session () (multisession-value jao-doc--session)) (defvar-local jao-doc-session-is-doc nil - "Setting this variable as t in a buffer will mark it as belonging to a session. + "Locally marks a buffer as belonging to a session. See also `jao-doc-session-mark'.") diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el new file mode 100644 index 0000000..ac33df9 --- /dev/null +++ b/lib/doc/jao-org-focus.el @@ -0,0 +1,104 @@ +;;; jao-org-focus.el --- focusing on org subtrees -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Jose Antonio Ortega Ruiz + +;; Author: Jose Antonio Ortega Ruiz <mail@jao.io> +;; Keywords: docs + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Miscellanous utilities for working with org files + +(require 'org) + +;;; focus on subtree +(defvar-local jao-org-focus--parent nil) +(defvar-local jao-org-focus--section nil) + +(defun jao-org-focus () + "Pop creatingly to an indirect buffer focused on the encloing subtree. + +When invoked on an indirect buffer, pops back to its base." + (interactive) + (if-let* ((b (get-buffer (or jao-org-focus--parent "")))) + (pop-to-buffer b) + (when-let* ((elem (org-element-at-point)) + (header (if (eq 'headline (org-element-type elem)) + elem + (org-previous-visible-heading 1) + (org-element-at-point))) + (title (org-element-property :title header)) + (parent (buffer-name)) + (bname (format "%s [%s]" title parent))) + (if-let* ((b (get-buffer bname))) + (pop-to-buffer b) + (clone-indirect-buffer bname t) + (setq jao-org-focus--parent parent + jao-org-focus--section title) + (org-narrow-to-subtree) + (show-subtree))))) + +(defun jao-org-focus-redisplay () + "Redisplay a focused buffer. + +Useful when its parent has been reorganised and the narrowing is out of +sync." + (interactive) + (when-let* ((title jao-org-focus--section)) + (widen) + (goto-char (point-min)) + (when (re-search-forward (format "\\*+ %s" title) nil t) + (org-narrow-to-subtree) + (beginning-of-line)))) + +(defun jao-org-focus-redisplay-children () + "Find focused children and redisplay them." + (interactive) + (dolist (b (jao-org-focus-list)) + (with-current-buffer b (jao-org-focus-redisplay)))) + +(defun jao-org-focus-list (&optional any-parent) + "List of buffers that are focusing on a subtree of this one or its parent." + (let ((n (or jao-org-focus--parent (buffer-name)))) + (seq-filter (lambda (b) + (let ((p (buffer-local-value 'jao-org-focus--parent b))) + (and p (or any-parent (string= n p))))) + (buffer-list)))) + +(defvar jao-org-focus--focused-history nil) + +(defun jao-org-focus-switch (arg) + "Read with completion a focused child and pop to it. + +With arg, offer to switch to all children, regardless of their parent." + (interactive "P") + (let ((fl (mapcar 'buffer-name (jao-org-focus-list arg)))) + (unless fl (error "No focused children")) + (pop-to-buffer + (completing-read "Focused child: " fl + nil t nil 'jao-org-focus--focused-history)))) + +(defvar jao-org-focus-consult-buffer-source + `(:name "Focus buffers" + :category jao-org-focus-buffers + :action switch-to-buffer + :hidden t + :narrow ,(cons ?o "focus") + :history jao-org-focus--focused-history + :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t))))) + +(provide 'jao-org-focus) +;;; jao-org.el ends here |