118 lines
7.4 KiB
Plaintext
118 lines
7.4 KiB
Plaintext
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="generator" content="pandoc" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
|
<meta name="author" content="By John Mercouris" />
|
|
<title>Macro edit: democratizing automation</title>
|
|
<style type="text/css">
|
|
code{white-space: pre-wrap;}
|
|
span.smallcaps{font-variant: small-caps;}
|
|
span.underline{text-decoration: underline;}
|
|
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
|
</style>
|
|
<style type="text/css">
|
|
a.sourceLine { display: inline-block; line-height: 1.25; }
|
|
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
|
|
a.sourceLine:empty { height: 1.2em; position: absolute; }
|
|
.sourceCode { overflow: visible; }
|
|
code.sourceCode { white-space: pre; position: relative; }
|
|
div.sourceCode { margin: 1em 0; }
|
|
pre.sourceCode { margin: 0; }
|
|
@media screen {
|
|
div.sourceCode { overflow: auto; }
|
|
}
|
|
@media print {
|
|
code.sourceCode { white-space: pre-wrap; }
|
|
a.sourceLine { text-indent: -1em; padding-left: 1em; }
|
|
}
|
|
pre.numberSource a.sourceLine
|
|
{ position: relative; }
|
|
pre.numberSource a.sourceLine:empty
|
|
{ position: absolute; }
|
|
pre.numberSource a.sourceLine::before
|
|
{ content: attr(data-line-number);
|
|
position: absolute; left: -5em; text-align: right; vertical-align: baseline;
|
|
border: none; pointer-events: all;
|
|
-webkit-touch-callout: none; -webkit-user-select: none;
|
|
-khtml-user-select: none; -moz-user-select: none;
|
|
-ms-user-select: none; user-select: none;
|
|
padding: 0 4px; width: 4em;
|
|
color: #aaaaaa;
|
|
}
|
|
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
|
div.sourceCode
|
|
{ }
|
|
@media screen {
|
|
a.sourceLine::before { text-decoration: underline; }
|
|
}
|
|
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
|
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
|
code span.at { color: #7d9029; } /* Attribute */
|
|
code span.bn { color: #40a070; } /* BaseN */
|
|
code span.bu { } /* BuiltIn */
|
|
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
|
code span.ch { color: #4070a0; } /* Char */
|
|
code span.cn { color: #880000; } /* Constant */
|
|
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
|
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
|
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
|
code span.dt { color: #902000; } /* DataType */
|
|
code span.dv { color: #40a070; } /* DecVal */
|
|
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
|
code span.ex { } /* Extension */
|
|
code span.fl { color: #40a070; } /* Float */
|
|
code span.fu { color: #06287e; } /* Function */
|
|
code span.im { } /* Import */
|
|
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
|
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
|
code span.op { color: #666666; } /* Operator */
|
|
code span.ot { color: #007020; } /* Other */
|
|
code span.pp { color: #bc7a00; } /* Preprocessor */
|
|
code span.sc { color: #4070a0; } /* SpecialChar */
|
|
code span.ss { color: #bb6688; } /* SpecialString */
|
|
code span.st { color: #4070a0; } /* String */
|
|
code span.va { color: #19177c; } /* Variable */
|
|
code span.vs { color: #4070a0; } /* VerbatimString */
|
|
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
|
</style>
|
|
<!--[if lt IE 9]>
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
|
<![endif]-->
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1 class="title">Macro edit: democratizing automation</h1>
|
|
<p class="author">By John Mercouris</p>
|
|
</header>
|
|
<p>It is no secret that computers are effective at automation. We use their power to multiply our impact- as an extension of our minds.</p>
|
|
<p>Until recently, this power has been largely inaccessible for the vast majority of users. Today, we change this, Nyxt has taken the first steps towards the democratization of automation.</p>
|
|
<p>So, what is the first step? Simple automation for everyone. Let me introduce <code>edit-macro</code>. Edit macro allows the user to define a sequence of actions to execute. The user can then save, and reuse their macro whenever they want. Let's go through a simple example demonstrating their power.</p>
|
|
<p>To begin, we start with the command <code>edit-macro</code>.</p>
|
|
<p><img src="../static/image/article/edit-macro.png" /></p>
|
|
<p>Upon executing <code>edit-macro</code>, you'll be presented with the macro editor screen.</p>
|
|
<p><img src="../static/image/article/macro-edit-start.png" /></p>
|
|
<p>In this example, we'll be creating a simple macro that prints the current buffer, and then switches to the next one. You can imagine that invoking this macro several times in a row would allow you to quickly print all of your buffers.</p>
|
|
<p>Let's start off by giving our macro a name, let's call it <code>print-and-next</code>. After giving it a name, we have to select which commands we want it to execute. To do so, we click "+ Add Command".</p>
|
|
<p><img src="../static/image/article/macro-add-command.png" /></p>
|
|
<p>We are now presented with a screen that lists all of the commands available in Nyxt. We select a command, press return, and it is added to our command list.</p>
|
|
<p><img src="../static/image/article/macro-add-print-buffer.png" /></p>
|
|
<p><img src="../static/image/article/macro-add-print-buffer-confirm.png" /></p>
|
|
<p>Now we'll add our next command: <code>switch-buffer-next</code>.</p>
|
|
<p><img src="../static/image/article/macro-add-switch-buffer-next.png" /></p>
|
|
<p><img src="../static/image/article/macro-add-switch-buffer-next-confirm.png" /></p>
|
|
<p>We are now ready to test! To test press "Evaluate macro". This will compile our macro and make it runnable from the <code>execute-command</code> menu.</p>
|
|
<p><img src="../static/image/article/execute-print-and-next.png" /></p>
|
|
<p>If everything works as expected, that's it, we're done! We can use our macro, we can bind to a hotkey, use it in another macro etc. The possibilities are literally endless.</p>
|
|
<p>Should we wish to save our macro for future sessions, all we have to do is press "Save macro". Nyxt will then automatically save our macro into our <code>auto-config.lisp</code> file. If you are curious, here is the code that our macro produces:</p>
|
|
<div class="sourceCode" id="print-and-next" data-org-language="lisp"><pre class="sourceCode commonlisp"><code class="sourceCode commonlisp"><a class="sourceLine" id="print-and-next-1" data-line-number="1">(DEFINE-COMMAND-GLOBAL |print-and-next|</a>
|
|
<a class="sourceLine" id="print-and-next-2" data-line-number="2"> NIL</a>
|
|
<a class="sourceLine" id="print-and-next-3" data-line-number="3"> <span class="st">"User generated macro form"</span></a>
|
|
<a class="sourceLine" id="print-and-next-4" data-line-number="4"> (SWITCH-BUFFER-NEXT)</a>
|
|
<a class="sourceLine" id="print-and-next-5" data-line-number="5"> (PRINT-BUFFER))</a></code></pre></div>
|
|
<p>As you can see, macros are very powerful. That said, there remains a lot of important work to be done: in subsequent variants we hope to introduce branching, variables, and more (without overwhelming the user)! We see the development of this automation interface as an important first step towards the democratization of automation.</p>
|
|
<p>We hope you enjoy it, and thanks for reading :-)</p>
|
|
</body>
|
|
</html>
|