From 0f8eb65fb807a125dd601cd6b3ee746e6c7b6020 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 6 Sep 2026 15:36:38 +0100 Subject: a slew of little fixes courtesy of the byte compiler --- lib/doc/jao-doc-view.el | 11 +++++--- lib/doc/jao-mac.el | 67 ++++++++++++++++++++++++++++++------------------ lib/doc/jao-org-focus.el | 2 +- lib/doc/jao-org-links.el | 5 +++- lib/doc/jao-org-notes.el | 4 +-- lib/doc/jao-pdf.el | 47 ++++++--------------------------- lib/doc/jao-words.el | 2 +- 7 files changed, 66 insertions(+), 72 deletions(-) (limited to 'lib/doc') diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el index 223984a..bb89f03 100644 --- a/lib/doc/jao-doc-view.el +++ b/lib/doc/jao-doc-view.el @@ -18,9 +18,15 @@ ;; Author: Jose Antonio Ortega Ruiz ;; Start date: Fri Feb 15, 2013 01:21 +(require 'browse-url) +(require 'thingatpt) (require 'doc-view) (require 'jao-pdf) +(declare-function pdf-view-image-size "pdf-view") +(declare-function pdf-view-goto-page "pdf-view") +(declare-function pdf-view-current-page "pdf-view") + ;;; Utilities (defmacro jao-doc-view--funcall (a b &rest args) @@ -39,8 +45,7 @@ ;;; imenu (defun jao-doc-view-enable-imenu (file-name goto-page) - (let ((ifun (lambda () (doc-view-imenu-index file-name goto-page))) - (doc-view-imenu-enabled t)) + (let ((ifun (lambda () (doc-view-imenu-index file-name goto-page)))) (doc-view-imenu-setup) (setq-local imenu-create-index-function ifun))) @@ -48,7 +53,7 @@ (defvar-local jao-doc-view--trail-back ()) (defvar-local jao-doc-view--trail-fwd ()) -(defun jao-doc-view--trail-push (dest-page) +(defun jao-doc-view--trail-push () (when-let* ((page (jao-doc-view-current-page))) (unless (eq (car jao-doc-view--trail-back) page) (push page jao-doc-view--trail-back)))) diff --git a/lib/doc/jao-mac.el b/lib/doc/jao-mac.el index 269e853..916a84d 100644 --- a/lib/doc/jao-mac.el +++ b/lib/doc/jao-mac.el @@ -18,6 +18,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +(require 'thingatpt) (require 'jao-shell) ;;; applescript @@ -51,7 +52,9 @@ "Invoke open after formatting thing with args, using `format'" (jao-shell-exec (format "open %s" (apply #'format thing args)))) -(defun jao-mac-open-in-skim (&optional file page height) +(declare-function 'doc-view-current-page "doc-view") + +(defun jao-mac-open-in-skim (&optional file page _height) (interactive) (let* ((file (if file (expand-file-name file) (buffer-file-name))) (page (or page (and (derived-mode-p 'doc-view-mode) @@ -60,7 +63,7 @@ ;; https://alvinalexander.com/macos/applescript-how-to-open-pdf-file-in-preview-go-to-page/ ;; This will work as long as Preview is the default app for the file at hand. -(defun jao-mac-open-in-preview (&optional file page height) +(defun jao-mac-open-in-preview (&optional file page _height) (interactive) (let ((file (if file (expand-file-name file) (buffer-file-name))) (page (or page (and (derived-mode-p 'doc-view-doc) @@ -88,6 +91,21 @@ (when (string-match ".*=\"\\([0-9]+\\)\" ." s) (string-to-number (match-string 1 s)))) ) +;;; dict + +(defvar jao-mac-dict-history nil) + +(defun jao-mac-dict (&optional word) + (interactive (list (thing-at-point 'word))) + (jao-mac-open "dict://%S" + (read-string (format "Look up (%s): " word) + nil + 'jao-mac-dict-history + (substring-no-properties word) + t))) + +;;(setq completion-auto-help nil) + ;;; Skim (defvar jao-skim--current-file-script (jao-mac-applescript-prepare @@ -204,29 +222,28 @@ ;;; DevonThink -(defun jao-devon-tell (&rest script-lines) - (apply #'jao-mac-tell-app "id DNtp" script-lines )) - -(defun jao-devon-find-url (file) - (jao-devon-tell - "repeat with db in databases" - (format "set res to lookup records with path %S in db" - (file-truename file)) - "if res /= {} then return the reference URL of (item 1 of res)" - "end repeat" - "return \"\"")) - -(defun jao-devon-show-search (s) - (jao-devon-tell (format "show search %S" s) "activate")) - -(defun jao-devon-open (file &optional page height) - (let ((url (jao-devon-find-url file))) - (if (string-empty-p (or url "")) - (let ((jao-pdf-open-in-emacs t)) - (jao-find-or-open file page height)) - (let* ((p (if page (format "?page=%s" (- page 1)) "")) - (u (format "%s%s" url p))) - (jao-mac-open "%s%s" url p))))) +;; (defun jao-devon-tell (&rest script-lines) +;; (apply #'jao-mac-tell-app "id DNtp" script-lines )) + +;; (defun jao-devon-find-url (file) +;; (jao-devon-tell +;; "repeat with db in databases" +;; (format "set res to lookup records with path %S in db" +;; (file-truename file)) +;; "if res /= {} then return the reference URL of (item 1 of res)" +;; "end repeat" +;; "return \"\"")) + +;; (defun jao-devon-show-search (s) +;; (jao-devon-tell (format "show search %S" s) "activate")) + +;; (defun jao-devon-open (file &optional page height) +;; (let ((url (jao-devon-find-url file))) +;; (if (string-empty-p (or url "")) +;; (let ((jao-pdf-open-in-emacs t)) +;; (jao-find-or-open file page height)) +;; (let ((p (if page (format "?page=%s" (- page 1)) ""))) +;; (jao-mac-open "%s%s" url p))))) (provide 'jao-mac) ;;; jao-mac.el ends here diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el index 2c0805d..a8d72be 100644 --- a/lib/doc/jao-org-focus.el +++ b/lib/doc/jao-org-focus.el @@ -77,7 +77,7 @@ When invoked on an indirect buffer, pops back to its base." (setq jao-org-focus--parent parent jao-org-focus--section title) (org-narrow-to-subtree) - (show-subtree) + (outline-show-subtree) (count-words (point-min) (point-max)))))) (defun jao-org-focus-redisplay () diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el index 8ccd06a..b38deb0 100644 --- a/lib/doc/jao-org-links.el +++ b/lib/doc/jao-org-links.el @@ -1,9 +1,12 @@ ;; -*- lexical-binding: t; -*- +(require 'org) +(require 'browse-url) (require 'jao-org-notes) (require 'jao-doc-view) (require 'jao-doc-session) (require 'jao-pdf) +(require 'jao-afio) (defvar jao-org--sink-dir "./") (defvar jao-org-open-pdf-fun #'jao-org--default-open) @@ -46,7 +49,7 @@ (defun jao-org-links--complete-doc (&optional arg) (let ((default-directory jao-org--sink-dir)) (let ((f (replace-regexp-in-string "^file:" "doc:" - (org-file-complete-link arg)))) + (org-link-complete-file arg)))) (if (jao-pdf-is-pdf-file f) (let ((page (read-from-minibuffer "Page: " ""))) (if (> (string-to-number page) 0) diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index 78ff76c..929ab66 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -76,7 +76,7 @@ (and (string-match-p "^[^:]+ + :" m) "tags") "titles")) -(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd initial) +(defun jao-org-notes--consult-rg (prompt &optional cat no-req initial) (let ((default-directory (expand-file-name (or cat "") jao-org-notes-dir))) (consult--read (consult--async-pipeline @@ -102,7 +102,7 @@ (defun jao-org-notes--insert-title (&optional title) (let* ((cat (jao-org-notes--cat)) - (note (jao-org-notes--consult-rg "Title: " cat t nil title)) + (note (jao-org-notes--consult-rg "Title: " cat t title)) (title (file-name-base note)) (title (replace-regexp-in-string "^#" "" title))) (when (not (string-empty-p title)) diff --git a/lib/doc/jao-pdf.el b/lib/doc/jao-pdf.el index 5d27048..0a1734f 100644 --- a/lib/doc/jao-pdf.el +++ b/lib/doc/jao-pdf.el @@ -1,6 +1,6 @@ ;;; jao-pdf.el --- utilities for pdf files -*- lexical-binding: t; -*- -;; Copyright (C) 2022, 2025 jao +;; Copyright (C) 2022, 2025, 2026 jao ;; Author: jao ;; Keywords: docs @@ -27,10 +27,13 @@ ;; - Interoperability with zathura. (require 'jao-doc-session) +(require 'jao-afio) +(require 'browse-url) ;;; PDF info (declare-function 'pdf-info-outline "pdf-info") +(defvar jao-pdf-org-dir nil) (defvar-local jao-pdf--outline nil) @@ -56,7 +59,7 @@ (setq-local jao-pdf--outline (doc-view--pdf-outline file-name))) (let ((page (or page (and (derived-mode-p 'doc-view-mode) (doc-view-current-page)) - (and (derived-mode-p 'pdf-view) (pdf-view-current-page)))) + (and (fboundp 'pdf-view-current-page) (pdf-view-current-page)))) (outline jao-pdf--outline) (cur-page 0) (cur-title (jao-pdf-title (or file-name buffer-file-name "title")))) @@ -91,21 +94,11 @@ (fn (file-name-nondirectory file)) (lnk (format "doc:%s::%s" fn page)) (desc (format "%s (p. %s)" (jao-pdf-section-title page file) no))) - (org-make-link-string lnk desc))) + (org-link-make-string lnk desc))) (defun jao-pdf-zathura-org-link (title) (jao-pdf--zathura-link (jao-pdf-zathura-file-info title))) -(defun jao-zathura-open (file page) - (let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file)))) - (if (string-blank-p id) - (progn - (when jao-xmonad-enabled (jao-x11-goto-ws 2)) - (jao-shell-exec (jao-pdf-zathura-open-cmd file page))) - (let* ((page (if page (format " && xdotool type %dg" page) "")) - (cmd (format "xdotool windowactivate %s%s" id page))) - (jao-shell-exec cmd t))))) - ;;; Mac (when (eq system-type 'darwin) @@ -115,7 +108,7 @@ (file (file-name-nondirectory (car fp))) (page (cadr fp)) (lnk (format "doc:%s::%s" file page))) - (org-make-link-string lnk title))) + (org-link-make-string lnk title))) (defun jao-pdf-insert-skim-org-link () (interactive) @@ -127,27 +120,11 @@ ;;; Open doc functions (defvar jao-pdf-open-in-emacs t) -(defun jao-find-or-open (file &optional page height) - (cond ((and jao-pdf-open-in-emacs window-system) - (let* ((buffs (buffer-list)) - (b (catch 'done - (while buffs - (when (string-equal (buffer-file-name (car buffs)) file) - (throw 'done (car buffs))) - (setq buffs (cdr buffs)))))) - (jao-afio-goto-docs) - (if b (pop-to-buffer b) (find-file file)) - (when page (jao-doc-view-goto-page page height)))) - (jao-river-enabled (jao-river-open-with-zathura file page)) - (jao-sway-enabled (jao-sway-open-with-zathura file page)) - ((eq system-type 'darwin) (jao-mac-open-in-skim file page)) - (t (jao-zathura-open file page)))) - (defun jao-open-doc (&optional file page height) (interactive) (when-let* ((file (or file (read-file-name "Document: " - (concat jao-org-dir "/doc/"))))) + (concat jao-pdf-org-dir "/doc/"))))) (funcall jao-open-doc-fun file page height))) (defun jao-select-pdf () @@ -155,14 +132,6 @@ (jao-buffer-same-mode '(pdf-view-mode doc-view-mode org-mode) #'jao-afio-goto-docs)) -(defun jao-open-with-zathura () - (interactive) - (when-let* ((f buffer-file-name)) - (let ((p (jao-doc-view-current-page))) - (cond (jao-river-enabled (jao-river-open-with-zathura f p)) - (jao-sway-enabled (jao-sway-open-with-zathura f p)) - (t (jao-zathura-open f p)))))) - ;;; doc:// links for browse-url (defun jao-open-doc-url (url &rest _) diff --git a/lib/doc/jao-words.el b/lib/doc/jao-words.el index 32baab8..328fecf 100644 --- a/lib/doc/jao-words.el +++ b/lib/doc/jao-words.el @@ -67,7 +67,7 @@ (org-mode) (indent-region (point-min) (point-max)) (goto-char 5) - (next-line 2) + (forward-line 2) (org-table-next-field) (org-table-sort-lines nil ?N))) (pop-to-buffer "*word-statistics*")) -- cgit v1.2.3