emacs/var/elfeed/db/data/80/80e5d2c92e6b72af4faf6d53da596a27b8cd5d20
2022-01-03 12:49:32 -06:00

43 lines
4.1 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="Artyom Bologov" />
<title>Process Mode and Repeat Mode: Taming the dullness</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>
<!--[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">Process Mode and Repeat Mode: Taming the dullness</h1>
<p class="author">Artyom Bologov</p>
</header>
<p>Scroll down, scroll, scroll down, scroll, scroll… Reload, reopen, reload, reload, reopen, reload… Follow this link, follow that link, follow this link, follow another link…</p>
<p>Repeating things is boring. However, sometimes there seems to be no other way to use the browser except repeating things explicitly. That's depressing. Luckily, Nyxt brings <code>process-mode</code> and its derivatives to offload some of the tiring burdens to!</p>
<p>The pattern is usually dead simple: <strong>&quot;Do X every Y seconds and don't disturb me until I turn you off&quot;</strong>. It should be automatable, right? It is.</p>
<h1 id="do-this-every-y-seconds">&quot;Do this every Y seconds&quot;</h1>
<p>Suppose you're a website developer and you want to look at your website in several levels of magnification. It's quite typical when you do responsive design. There can be thousands of magnification levels, though. Repeatedly pressing even a short zooming keybinding can be dull (and harmful for your wrists!) Why not automate it? Just call <code>repeat-mode</code>, choose <code>zoom-page</code> in the appearing prompt, and enjoy the website zooming in every second.</p>
<p><img src="../static/image/article/repeat-mode.png" /></p>
<p>And if you want to repeat something at an interval other than one second, call <code>repeat-every</code> and set it to anything you want :)</p>
<h1 id="and-dont-disturb-me">&quot;… and don't disturb me!&quot;</h1>
<p>Now, what if it fails? Will it show a prompt or some alert? No, it won't. The <code>process-mode</code> is a solution to the &quot;don't disturb me&quot; part of our initial problem. It simply creates a background process, making sure it's not going to cause any harm to Nyxt even in case of critical failure. The only thing you'll see is a warning in the message area. It's not distracting, but quite enough to understand what happened and how to fix it.</p>
<p><code>repeat-mode</code> is simply an extension, a child-mode, of <code>process-mode</code>, and it's as reliable as the <code>process-mode</code> itself. You can create many more modes doing whatever you want on some condition, based on those two. We have tried doing that, and the results are already in Nyxt:</p>
<ul>
<li><a href="https://nyxt.atlas.engineer/article/cruise-control-mode.org">cruise-control-mode</a>, for example, is scrolling a page up and down every tenth of a second. It essentially is a <code>repeat-mode</code> with repeated <code>scroll-down</code> or <code>scroll-up</code> commands.</li>
<li><a href="https://nyxt.atlas.engineer/article/watch-mode.org">watch-mode</a> repeats <code>reload-buffer</code> every five minutes. Again, a trivial extension of <code>repeat-mode</code>!</li>
<li><code>preview-mode</code> reloads a buffer with a local file you've got opened when this file is modified. Convenient when you want to see some HTML without setting up a server :)</li>
</ul>
<p>The possibilities are endless there! If we haven't covered your routine, you can always hack up some derivative of <code>process-mode</code> and become more productive at doing the thing that matters instead of dull routine!</p>
<p>We'll be happy to know what you automate with <code>process-mode</code> and <code>repeat-mode</code> :D</p>
</body>
</html>