summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/eos/jao-mac.el51
1 files changed, 28 insertions, 23 deletions
diff --git a/lib/eos/jao-mac.el b/lib/eos/jao-mac.el
index ae13c0f..2312c6c 100644
--- a/lib/eos/jao-mac.el
+++ b/lib/eos/jao-mac.el
@@ -48,21 +48,32 @@
;;; open
+;;;###autoload
(defun jao-mac-open (thing &rest args)
"Invoke open after formatting thing with args, using `format'"
(jao-shell-exec (format "open %s" (apply #'format thing args))))
-(declare-function 'doc-view-current-page "doc-view")
+;;; notifications
-(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)
- (doc-view-current-page)))))
- (jao-mac-open "skim://%s%s" file (if page (format "#page=%s" page) ""))))
+(defun jao-mac-notify (title subtitle msg)
+ (jao-mac-run-applescript*
+ (format "display notification %S with title %S subtitle %S"
+ msg title subtitle)))
+
+(defun jao-mac-app-badge (app)
+ "A very hacky, yet efficient, way of getting and apps badge."
+ (let* ((c (format "lsappinfo info -app %S -only StatusLabel" app))
+ (s (shell-command-to-string c)))
+ (when (string-match ".*=\"\\([0-9]+\\)\" ." s)
+ (string-to-number (match-string 1 s)))) )
+
+;;; Preview
+
+(declare-function 'doc-view-current-page "doc-view")
;; 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.
+;;;###autoload
(defun jao-mac-open-in-preview (&optional file page _height)
(interactive)
(let ((file (if file (expand-file-name file) (buffer-file-name)))
@@ -77,21 +88,8 @@
(format "keystroke %s" (or page 1))
"delay 0.1\rkeystroke return\rend tell")))
-;;; notifications
-
-(defun jao-mac-notify (title subtitle msg)
- (jao-mac-run-applescript*
- (format "display notification %S with title %S subtitle %S"
- msg title subtitle)))
-(defun jao-mac-app-badge (app)
- "A very hacky, yet efficient, way of getting and apps badge."
- (let* ((c (format "lsappinfo info -app %S -only StatusLabel" app))
- (s (shell-command-to-string c)))
- (when (string-match ".*=\"\\([0-9]+\\)\" ." s)
- (string-to-number (match-string 1 s)))) )
-
-;;; dict
+;;; Dict
(defvar jao-mac-dict-history nil)
@@ -104,8 +102,6 @@
(substring-no-properties word)
t)))
-;;(setq completion-auto-help nil)
-
;;; Skim
(defvar jao-skim--current-file-script
(jao-mac-applescript-prepare
@@ -141,6 +137,7 @@
(defun jao-skim-page-text ()
(jao-mac-run-applescript jao-skim--current-page-text))
+;;;###autoload
(defun jao-skim-view-page-text ()
(interactive)
(when-let* ((ps (jao-skim-current-doc))
@@ -161,6 +158,14 @@
(org-link-make-string lnk title)))
;;;###autoload
+(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)
+ (doc-view-current-page)))))
+ (jao-mac-open "skim://%s%s" file (if page (format "#page=%s" page) ""))))
+
+;;;###autoload
(defun jao-pdf-insert-skim-org-link ()
(interactive)
(if-let* ((title (read-string "Title: "))