[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide b1c52facb6 12/21: Keyboard macro transcription
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide b1c52facb6 12/21: Keyboard macro transcription |
Date: |
Tue, 17 Dec 2024 13:00:53 -0500 (EST) |
branch: elpa/dslide
commit b1c52facb613a37f71af8c04bd61f9cecdbdfb25
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
Keyboard macro transcription
---
NEWS.org | 2 ++
doc/manual.org | 3 ++
dslide.el | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/demo.org | 1 +
4 files changed, 95 insertions(+)
diff --git a/NEWS.org b/NEWS.org
index 7b18247e42..463d5e580f 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -15,6 +15,8 @@
- New actions (*KMACROS!*) fit a more clear pattern
** Added ➕
- 🧬 Experimental new kmacro action can run keyboard kmacros to script "live
demonstrations". Describe ~dslide-action-kmacro~ to view the documentation.
There is a demo in the usual [] file. All related functions and variables are
under the =dslide-action-kmacro= or =dslide-kmacro= prefixes.
+- 🧬 Experimental keyboard macro recording with
~dslide-kmacro-transcribe-set-mark~, every time you call ~kmacro-end-macro~,
dslide will transcribe a macro playback expression into your presentation. All
related commands, functions, and variables are under the
=dslide-kmacro-transcribe= prefix
+- ~dslide-deck-present~ is a distinct command from ~dslide-deck-start~. It
will create a new frame instead of showing the presentation in the current
frame. The ~dslide-present-hook~ will be run in this frame when the deck is
ready. If you customize this hook, you can easily separate configuration for
development and presentation.
- Babel blocks, which will now all be executed by default, respect the =:eval=
parameter. Values such as =never= or =never-export= will skip the block.
Other values are equivalent to =yes=. Values like =query= do *not* ask yet.
Expect that in 0.7.0. 🚧
#+begin_src org
,#+begin_src elisp :eval never
diff --git a/doc/manual.org b/doc/manual.org
index f17c1dc405..dbaef1396e 100644
--- a/doc/manual.org
+++ b/doc/manual.org
@@ -331,6 +331,9 @@ The ~dslide-action-kmacro~ will run pre-recorded sequences
of keystrokes as if y
By playing back keyboard macros, you can encode real Emacs workflows as steps
in a presentation. Don't just talk about how your software works. Use the
software with fully reproducible steps that users can understand in a tactile,
human way.
+#+cindex: transcribing keyboard macros as steps
+To record kmacros as presentation steps, use the
~dslide-kmacro-transcribe-set-mark~ command. It will save a marker and every
time you call ~kmacro-end-macro~, it will transcribe that macro as an
expression that ~dslide-action-kmacro~ knows how to play back.
+
🆒 The jitter uses a Laplace distribution to sample a perturbation power. This
power is mapped onto the zero-to-infinity factor range by raising e to the
power of jitter. This is multiplied by =:frequency=, which is a duration. As
a result, while the jitter is usually pretty small, it does have some wild
variation, which does look a bit more human.
** Hiding Markup 🥷🏿
:PROPERTIES:
diff --git a/dslide.el b/dslide.el
index da9af4f6d6..a3c7ab6cf6 100644
--- a/dslide.el
+++ b/dslide.el
@@ -379,6 +379,20 @@ on in the contents view. The default is also just a way
more
obvious display style."
:type 'boolean)
+(defcustom dslide-kmacro-transcribe-hook nil
+ "Hook run whenever dslide transcribes a keyboard macro.
+Maybe add a highlight on the recorded macro to make it more
+obvious when a new one was recorded. I don't know. It's your
+hook. I just work here."
+ :type 'hook)
+
+(defcustom dslide-kmacro-transcribe-prompt "Label for transcribed macro: "
+ "Ask for a comment to label newly transcribed macros.
+Transcribed macros can have a comment prepended to make it
+obvious what they do. Set this prompt to nil if you don't wish
+to be bothered while recording."
+ :type 'string)
+
(defface dslide-contents-selection-face
'((t :inherit org-level-1 :inverse-video t :extend t))
"Face for highlighting the current slide root.")
@@ -405,6 +419,14 @@ See `dslide-base-follows-slide'.")
(defvar dslide--kmacro-timer nil
"Allow cleanup and prevent macros from running concurrently.")
+(defvar dslide--kmacro-transcribe-mark nil
+ "Marker storage for macro transcription.")
+
+(defvar dslide--kmacro-transcribe-last nil
+ "Most recently transcribed keyboard macro.
+Uses eq comparison in case there are two calls to
+`kmacro-end-macro' for the same macro.")
+
;; Tell the compiler that these variables exist
(defvar dslide-mode)
@@ -3067,6 +3089,34 @@ for commands without visible side effects."
(let ((message-log-max nil))
(message "%s" feedback))))
+(defun dslide--kmacro-transcribe (&rest _)
+ "Records each new kmacro as a new dslide action keyword."
+ (unless dslide--kmacro-transcribe-mark
+ (dslide-kmacro-transcribe-quit))
+ (when-let ((macro last-kbd-macro))
+ ;; TODO seems like kmacro-end-macro is smart enough that we don't need to
+ ;; check this
+ (if (eq macro dslide--kmacro-transcribe-last)
+ (display-warning '(dslide dslide-kmacro)
+ "Duplicate macro recording detected")
+ (with-current-buffer (marker-buffer dslide--kmacro-transcribe-mark)
+ (goto-char (marker-position dslide--kmacro-transcribe-mark))
+ (when-let ((visible (get-buffer-window (current-buffer) 'visible)))
+ (set-window-point visible (point)))
+ (beginning-of-line)
+ (unless (looking-at-p "^[[:space:]]*$")
+ (user-error "Transcription mark not on emptly line.\
+ Reset and run `kmacro-end-macro'"))
+ (when dslide-kmacro-transcribe-prompt
+ (when-let ((comment (read-string dslide-kmacro-transcribe-prompt)))
+ (insert (format "# %s\n" comment))))
+ ;; TODO add some highlighting of recorded macro
+ (insert (format "#+dslide_kmacro: :keys %S\n\n" macro))
+ (set-marker dslide--kmacro-transcribe-mark (point))
+ (run-hooks 'dslide-kmacro-transcribe-hook))
+ (setq dslide--kmacro-transcribe-last macro)
+ (message "Macro transcribed!"))))
+
;; TODO these could check for inheritance from some base class, which would
save
;; people who write action names in the class property etc.
(defun dslide--classes (class-names)
@@ -3447,6 +3497,45 @@ Call `dslide-cursor-restore' to revert."
;; * User Commands
+;;;###autoload
+(defun dslide-kmacro-transcribe-set-mark ()
+ "Sets a current mark for trnascribing macros for plaback.
+Point must be on an empty line, in an org buffer. Every call to
+`kmacro-end-macro' will check if there is a new macro and insert
+it as a dslide action."
+ (interactive)
+ (unless (derived-mode-p 'org-mode)
+ (user-error "Not org mode"))
+ (unless (save-excursion
+ (beginning-of-line)
+ (looking-at-p "^[[:space:]]*$"))
+ (user-error "Not on an empty line"))
+ (setq dslide--kmacro-transcribe-mark
+ (save-excursion
+ (beginning-of-line)
+ (point-marker)))
+ (push-mark (point))
+ (advice-add #'kmacro-end-macro
+ :after #'dslide--kmacro-transcribe)
+ (message "Transcription ready!"))
+
+;;;###autoload
+(defun dslide-kmacro-transcribe-quit ()
+ "Stop transcribing new macros."
+ (interactive)
+ (unless (or (advice-member-p #'dslide--kmacro-transcribe
+ #'kmacro-end-macro)
+ dslide--kmacro-transcribe-last
+ dslide--kmacro-transcribe-mark)
+ (user-error "Not transcribing"))
+ (advice-remove #'kmacro-end-macro
+ #'dslide--kmacro-transcribe)
+ (setq dslide--kmacro-transcribe-last nil)
+ (when dslide--kmacro-transcribe-mark
+ (set-marker dslide--kmacro-transcribe-mark nil))
+ (setq dslide--kmacro-transcribe-mark nil)
+ (message "Transcription stopped."))
+
;;;###autoload
(defun dslide-deck-stop ()
"Stop the presentation.
diff --git a/test/demo.org b/test/demo.org
index f4e6efcc95..134dff56df 100644
--- a/test/demo.org
+++ b/test/demo.org
@@ -441,6 +441,7 @@ The essence of democracy is the resolve of individuals
working together to shape
* Keyboard Macros
/New feature!/ You can play back keyboard macros.
+Check the Dslide manual. =M-x info-display-manual dslide=. There is a new
command called ~dslide-kbd-macro-mark-set~ that will transcribe macros whenever
you finish recording one. Each macro will be a step in the presentation.
Pretty gnarly, dude. 🐢
** Keyboard Macro Example ✨
Press ➡️ to run the (invisible) recorded macro 🤠.
- [nongnu] elpa/dslide updated (0da4acfb73 -> b8e1399cc5), ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide dc441317fa 06/21: Image action is default. Checks for very-non-image links., ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide b1c52facb6 12/21: Keyboard macro transcription,
ELPA Syncer <=
- [nongnu] elpa/dslide 39495bb1c2 05/21: warn when propertize is given unquoted lists. better parsing., ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide ad5bac3df1 08/21: Image defaults to no standalone display, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide b8509903cc 03/21: start news for 0.6.0, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 1ae8c7ce0c 02/21: Line noise, packaging, non-behavior changes, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7d5a4f7dc6 01/21: Remove defunct test file from version control, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7bea90a632 09/21: Babel block :direction parameter. No more spam!, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide fbf801fc91 10/21: Notes about org-confirm-babel-evaluate, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7d527c9032 14/21: Generated files, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 0ad1ec8218 15/21: Fix for window scroll when opening contents, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 2323468110 16/21: small corrections in the demo, ELPA Syncer, 2024/12/17