Adding my hot-new Ironsworn package to my loader
This commit is contained in:
parent
ac229daab0
commit
6b2df99faf
2 changed files with 32 additions and 21 deletions
|
@ -58,8 +58,19 @@ Been working on a project for getting Emacs helping as a /Dungeon Master's Assis
|
||||||
(use-package rpgdm
|
(use-package rpgdm
|
||||||
:straight (:local-repo "~/other/rpgdm")
|
:straight (:local-repo "~/other/rpgdm")
|
||||||
:commands (rpgdm-mode rpgdm-tables-load)
|
:commands (rpgdm-mode rpgdm-tables-load)
|
||||||
|
:init (setq rpgdm-base (expand-file-name "~/other/rpgdm"))
|
||||||
:config (ha-leader "t D" '("rpg dm" . rpgdm-mode))))
|
:config (ha-leader "t D" '("rpg dm" . rpgdm-mode))))
|
||||||
#+END_SRC
|
#+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:
|
* Technical Artifacts :noexport:
|
||||||
Let's =provide= a name so we can =require= this file:
|
Let's =provide= a name so we can =require= this file:
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun ha-get-mac-clipboard ()
|
(defun ha-get-mac-clipboard ()
|
||||||
"Returns a list where the first entry is the content type,
|
"Returns a list where the first entry is the content type,
|
||||||
either :html or :text, and the second is the clipboard contents."
|
either :html or :text, and the second is the clipboard contents."
|
||||||
(destructuring-bind (exit-code contents)
|
(cl-destructuring-bind (exit-code contents)
|
||||||
(shell-command-with-exit-code "osascript" "-e" "the clipboard as \"HTML\"")
|
(shell-command-with-exit-code "osascript" "-e" "the clipboard as \"HTML\"")
|
||||||
(if (= 0 exit-code)
|
(if (= 0 exit-code)
|
||||||
(list :html (ha-convert-applescript-to-html contents))
|
(list :html (ha-convert-applescript-to-html contents))
|
||||||
(list :text (shell-command-to-string "osascript -e 'the clipboard'")))))
|
(list :text (shell-command-to-string "osascript -e 'the clipboard'")))))
|
||||||
|
|
||||||
(defun ha-convert-applescript-to-html (packed-contents)
|
(defun ha-convert-applescript-to-html (packed-contents)
|
||||||
"Applescript's clipboard returns the contents in a packed array.
|
"Applescript's clipboard returns the contents in a packed array.
|
||||||
Convert and return this encoding into a UTF-8 string."
|
Convert and return this encoding into a UTF-8 string."
|
||||||
(cl-flet ((hex-pack-bytes (tuple) (string-to-number (apply 'string tuple) 16)))
|
(cl-flet ((hex-pack-bytes (tuple) (string-to-number (apply 'string tuple) 16)))
|
||||||
(let* ((data (-> packed-contents
|
(let* ((data (-> packed-contents
|
||||||
(substring 10 -2) ; strips off the =«data RTF= and =»\= bits
|
(substring 10 -2) ; strips off the =«data RTF= and =»\= bits
|
||||||
(string-to-list)))
|
(string-to-list)))
|
||||||
(byte-seq (->> data
|
(byte-seq (->> data
|
||||||
(-partition 2) ; group each two hex characters into tuple
|
(-partition 2) ; group each two hex characters into tuple
|
||||||
(mapcar #'hex-pack-bytes))))
|
(mapcar #'hex-pack-bytes))))
|
||||||
(decode-coding-string
|
(decode-coding-string
|
||||||
(mapconcat #'byte-to-string byte-seq "") 'utf-8))))
|
(mapconcat #'byte-to-string byte-seq "") 'utf-8))))
|
||||||
#+END_SRC
|
#+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).
|
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
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun ha-get-linux-clipboard ()
|
(defun ha-get-linux-clipboard ()
|
||||||
"Return the clipbaard for a Unix-based system. See `ha-get-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")
|
(shell-command-with-exit-code "xclip" "-o" "-t" "text/html")
|
||||||
(if (= 0 exit-code)
|
(if (= 0 exit-code)
|
||||||
(list :html contents)
|
(list :html contents)
|
||||||
|
|
Loading…
Reference in a new issue