From 6b2df99faf632f722d2325ef4338327f377c0fe0 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Thu, 3 Mar 2022 15:10:16 -0800 Subject: [PATCH] Adding my hot-new Ironsworn package to my loader --- ha-aux-apps.org | 11 +++++++++++ ha-org-clipboard.org | 42 +++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/ha-aux-apps.org b/ha-aux-apps.org index 975ca87..102ff63 100644 --- a/ha-aux-apps.org +++ b/ha-aux-apps.org @@ -58,8 +58,19 @@ Been working on a project for getting Emacs helping as a /Dungeon Master's Assis (use-package rpgdm :straight (:local-repo "~/other/rpgdm") :commands (rpgdm-mode rpgdm-tables-load) + :init (setq rpgdm-base (expand-file-name "~/other/rpgdm")) :config (ha-leader "t D" '("rpg dm" . rpgdm-mode)))) #+END_SRC +And my new Ironsworn project: + +#+BEGIN_SRC emacs-lisp + (when (f-directory? "~/other/emacs-ironsworn") + (use-package rpgdm-ironsworn + :after rpgdm + :straight (:local-repo "~/other/emacs-ironsworn") + :init + (setq rpgdm-ironsworn-project (expand-file-name "~/other/emacs-ironsworn")))) +#+END_SRC * Technical Artifacts :noexport: Let's =provide= a name so we can =require= this file: diff --git a/ha-org-clipboard.org b/ha-org-clipboard.org index f0b36e8..c90379d 100644 --- a/ha-org-clipboard.org +++ b/ha-org-clipboard.org @@ -43,27 +43,27 @@ either :html or :text, and the second is the clipboard contents." Let's define the clipboard for a Mac. The challenge here is that we need to binary unpack the data from a call to Applescript. #+BEGIN_SRC emacs-lisp -(defun ha-get-mac-clipboard () - "Returns a list where the first entry is the content type, -either :html or :text, and the second is the clipboard contents." - (destructuring-bind (exit-code contents) - (shell-command-with-exit-code "osascript" "-e" "the clipboard as \"HTML\"") - (if (= 0 exit-code) - (list :html (ha-convert-applescript-to-html contents)) - (list :text (shell-command-to-string "osascript -e 'the clipboard'"))))) + (defun ha-get-mac-clipboard () + "Returns a list where the first entry is the content type, + either :html or :text, and the second is the clipboard contents." + (cl-destructuring-bind (exit-code contents) + (shell-command-with-exit-code "osascript" "-e" "the clipboard as \"HTML\"") + (if (= 0 exit-code) + (list :html (ha-convert-applescript-to-html contents)) + (list :text (shell-command-to-string "osascript -e 'the clipboard'"))))) -(defun ha-convert-applescript-to-html (packed-contents) - "Applescript's clipboard returns the contents in a packed array. -Convert and return this encoding into a UTF-8 string." - (cl-flet ((hex-pack-bytes (tuple) (string-to-number (apply 'string tuple) 16))) - (let* ((data (-> packed-contents - (substring 10 -2) ; strips off the =«data RTF= and =»\= bits - (string-to-list))) - (byte-seq (->> data - (-partition 2) ; group each two hex characters into tuple - (mapcar #'hex-pack-bytes)))) - (decode-coding-string - (mapconcat #'byte-to-string byte-seq "") 'utf-8)))) + (defun ha-convert-applescript-to-html (packed-contents) + "Applescript's clipboard returns the contents in a packed array. + Convert and return this encoding into a UTF-8 string." + (cl-flet ((hex-pack-bytes (tuple) (string-to-number (apply 'string tuple) 16))) + (let* ((data (-> packed-contents + (substring 10 -2) ; strips off the =«data RTF= and =»\= bits + (string-to-list))) + (byte-seq (->> data + (-partition 2) ; group each two hex characters into tuple + (mapcar #'hex-pack-bytes)))) + (decode-coding-string + (mapconcat #'byte-to-string byte-seq "") 'utf-8)))) #+END_SRC And define the same interface for Linux. Keep in mind, we need the exit code from calling a process, so I am going to define/use a helper function (that really should go into the piper project). @@ -71,7 +71,7 @@ And define the same interface for Linux. Keep in mind, we need the exit code fro #+BEGIN_SRC emacs-lisp (defun ha-get-linux-clipboard () "Return the clipbaard for a Unix-based system. See `ha-get-clipboard'." - (destructuring-bind (exit-code contents) + (cl-destructuring-bind (exit-code contents) (shell-command-with-exit-code "xclip" "-o" "-t" "text/html") (if (= 0 exit-code) (list :html contents)