diff options
author | Yuchen Pei <id@ypei.org> | 2024-12-22 20:41:18 +1100 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2024-12-22 20:41:18 +1100 |
commit | 8b39b8fab7992f11666cae8f94f4b3b812349bda (patch) | |
tree | 2b74dbb27b25dcd9ba468e20454b9e6a250e0a71 | |
parent | c997f63695502f1160524b2e76ea7358ad341bb1 (diff) |
[emacs] A function to upload current pdf to a digital paper device
Uses dpt-rp1
-rw-r--r-- | emacs/.emacs.d/init/ycp-pdf.el | 1 | ||||
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-pdf-tools.el | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/emacs/.emacs.d/init/ycp-pdf.el b/emacs/.emacs.d/init/ycp-pdf.el index 95b73bd..9553f7a 100644 --- a/emacs/.emacs.d/init/ycp-pdf.el +++ b/emacs/.emacs.d/init/ycp-pdf.el @@ -55,6 +55,7 @@ "U" #'my-pdf-view-backward-node-lower-depth "." #'my-pdf-view-enlarge-a-bit "," #'my-pdf-view-shrink-a-bit + "Q" #'my-pdf-dptrp1-upload ) ) diff --git a/emacs/.emacs.d/lisp/my/my-pdf-tools.el b/emacs/.emacs.d/lisp/my/my-pdf-tools.el index 8fe884c..0d498eb 100644 --- a/emacs/.emacs.d/lisp/my/my-pdf-tools.el +++ b/emacs/.emacs.d/lisp/my/my-pdf-tools.el @@ -196,5 +196,20 @@ (defun my-pdf-view-enlarge-a-bit () (interactive) (pdf-view-enlarge 1.01)) (defun my-pdf-view-shrink-a-bit () (interactive) (pdf-view-enlarge .99)) +(defvar my-pdf-dptrp1-ip nil + "IP address of digital paper device for dpt-rp1 to connect to.") + +(defvar my-pdf-dptrp1-program "dptrp1" "The name of the dpt-rp1 program.") + +(defun my-pdf-dptrp1-upload (dest) + (interactive (list (read-string "[dptrp1] Upload to: " "Document/"))) + (let ((file (buffer-file-name))) + (with-temp-buffer + (if (= (call-process my-pdf-dptrp1-program nil (current-buffer) nil + "--addr" my-pdf-dptrp1-ip "upload" file dest) + 0) + (message "Uploaded %s to %s" file dest) + (message "Failed to upload %s to %s: %s" file dest (buffer-string)))))) + (provide 'my-pdf-tools) ;;; my-pdf-tools.el ends here |