From 9ca5f7ec8b9f68791b5e4d6dd9f31f8eda6a0e88 Mon Sep 17 00:00:00 2001 From: Detlef Groth Date: Sun, 12 Nov 2023 08:37:49 +0100 Subject: [PATCH] adding function execute-region for macro development --- jasspa/macros/me.ehf | 14 +++++++++++++- jasspa/macros/misc.emf | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/jasspa/macros/me.ehf b/jasspa/macros/me.ehf index a75faaf..4aa9521 100644 --- a/jasspa/macros/me.ehf +++ b/jasspa/macros/me.ehf @@ -767,6 +767,7 @@ Miscellaneous Information lslmdelete-some-buffers(2)le Delete buffers with query lslmexecute-buffer(2)le Execute script lines from a buffer lslmexecute-line(2)le Execute a typed in script line + lslmexecute-region(3)le Execute marked script lines lslmfind-buffer(2)le (cDC-x bcA) Switch to a named buffer lslminsert-file-name(2)le (cDC-x C-ycA) Insert filename into current buffer lslmlist-buffers(2)le (cDC-x C-bcA) List all buffers and show their status @@ -997,6 +998,7 @@ Miscellaneous Information lslmexecute-kbd-macro(2)le (cDC-x ecA) Execute a keyboard macro lslmexecute-line(2)le Execute a typed in script line lslmexecute-named-command(2)le [cDesc xcA] Execute a named command + lslmexecute-region(3)le Execute marked script lines lslminsert-macro(2)le Insert keyboard macro into buffer lslmkbd-macro-query(2)le (cDC-x qcA) Query termination of keyboard macro lslmname-kbd-macro(2)le Assign a name to the last keyboard macro @@ -1949,6 +1951,7 @@ Miscellaneous Information lslmexecute-kbd-macro(2)le (cDC-x ecA) Execute a keyboard macro lslmexecute-line(2)le Execute a typed in script line lslmexecute-named-command(2)le [cDesc xcA] Execute a named command + lslmexecute-region(3)le Execute marked script lines lslmexecute-string(2)le Execute a string as a command lslmexecute-tool(3)le Execute a user defined shell tool lslmexit-emacs(2)le Exit MicroEmacs @@ -2324,6 +2327,7 @@ Miscellaneous Information lslmexecute-kbd-macro(2)le (cDC-x ecA) Execute a keyboard macro lslmexecute-line(2)le Execute a typed in script line lslmexecute-named-command(2)le [cDesc xcA] Execute a named command + lslmexecute-region(3)le Execute marked script lines lslmexecute-string(2)le Execute a string as a command lslmexit-emacs(2)le Exit MicroEmacs lslmexpand-abbrev(2)le Expand an abbreviation @@ -3519,6 +3523,7 @@ Miscellaneous Information lslmexecute-kbd-macro(2)le (cDC-x ecA) Execute a keyboard macro lslmexecute-line(2)le Execute a typed in script line lslmexecute-named-command(2)le [cDesc xcA] Execute a named command + lslmexecute-region(3)le Execute marked script lines lslmexecute-string(2)le Execute a string as a command lslmexecute-tool(3)le Execute a user defined shell tool lslmexit-emacs(2)le Exit MicroEmacs @@ -14664,6 +14669,7 @@ $a lslmset-mark(2)le, lslmcopy-region(2)le, lslm$window-mark-col(5)le, lslm$window-mark-line(5)le. ! 2 execute-buffer ! 2 execute-line +! 3 execute-region cEcENAME cEcA @@ -14671,6 +14677,8 @@ $a execute-buffer - Execute script lines from a buffer |execute-line execute-line - Execute a script line from the command line +|execute-region + execute-region - Execute marked script lines from a buffer $a @@ -14679,7 +14687,7 @@ $a cDexecute-buffercA "cCbuffer-namecA" cDexecute-linecA ["cCcommand-linecA"] - + cDexecute-regioncA cEcEDESCRIPTION cEcA @@ -14691,6 +14699,10 @@ $a cDexecute-linecA executes a in script line entered from the command line. Typically this is used in macros. + cDexecute-regioncA executes Macro commands in a marked buffer region. + Typically this is used in macro development. Please note that all possible + narrows, hidden regions, are removed after execution, so show up again. + cDexecute-regioncA is implemented in misc.emf. cEcESEE ALSO cEcA diff --git a/jasspa/macros/misc.emf b/jasspa/macros/misc.emf index 749a681..4b2515e 100644 --- a/jasspa/macros/misc.emf +++ b/jasspa/macros/misc.emf @@ -158,3 +158,25 @@ define-macro write-region delete-buffer $buffer-bname goto-position "\x88" !emacro + +; execute-region - mark a aregion of code and the execute it +; useful in macro development +; code taken from me23 +; implemented by Steven Phillips +define-macro execute-region + set-alpha-mark "a" + 3 narrow-buffer + !force !force !force execute-buffer $buffer-bname + !if &set #l0 ¬ $status + set-alpha-mark "a" + !endif + end-of-buffer + forward-line + 2 narrow-buffer ; me23 it is 2? + goto-alpha-mark "a" + !if #l0 + ml-write &spr "[Error executing region in %s, line %d]" $buffer-bname $window-line + !abort + !endif + +!emacro