<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>tag:blog.danieljanus.pl,2019:category:procrastination</id>
  <title>Daniel Janus – procrastination</title>
  <link href="http://blog.danieljanus.pl/category/procrastination/"/>
  <updated>2008-12-18T00:00:00Z</updated>
  <author>
    <name>Daniel Janus</name>
    <uri>http://danieljanus.pl</uri>
    <email>dj@danieljanus.pl</email>
  </author>
  <entry>
    <id>tag:blog.danieljanus.pl,2008-12-18:post:fighting-procrastination</id>
    <title>anti-procrastination.el</title>
    <link href="http://blog.danieljanus.pl/fighting-procrastination/"/>
    <updated>2008-12-18T00:00:00Z</updated>
    <content type="html">&lt;div&gt;&lt;p&gt;Fighting procrastination has been my major concern these days. I’ve devised a number of experimental tools to help me with that. One of them is called &lt;a href="http://bach.ipipan.waw.pl/~nathell/projects/snafu.php"&gt;snafu&lt;/a&gt; and can generate reports of your activity throughout the whole day of work. It’s in a preliminary state, but works (at least since I’ve found and fixed a long-standing bug in it which would cause it to barf every now and then), and I already have a number of ideas for its further expansion.&lt;/p&gt;&lt;p&gt;Reports alone, however, do not quite muster enough motivation for work. I’m doing most of my editing/programming work in Emacs, so yesterday I grabbed the Emacs Lisp manual and came up with a couple of extra lines at the end of my &lt;code&gt;.emacs&lt;/code&gt;.&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs lisp"&gt;&lt;span class="hljs-comment"&gt;;;; Written by Daniel Janus, 2008/12/18.&lt;/span&gt;
&lt;span class="hljs-comment"&gt;;;; This snippet is placed into the public domain.  Feel free&lt;/span&gt;
&lt;span class="hljs-comment"&gt;;;; to use it in any way you wish.  I am not responsible for&lt;/span&gt;
&lt;span class="hljs-comment"&gt;;;; any damage resulting from its usage.&lt;/span&gt;

(&lt;span class="hljs-name"&gt;defvar&lt;/span&gt; store-last-modification-time &lt;span class="hljs-literal"&gt;t&lt;/span&gt;)
(&lt;span class="hljs-name"&gt;defvar&lt;/span&gt; last-modification-time &lt;span class="hljs-literal"&gt;nil&lt;/span&gt;)
(&lt;span class="hljs-name"&gt;defun&lt;/span&gt; mark-last-modification-time (&lt;span class="hljs-name"&gt;beg&lt;/span&gt; end len)
  (&lt;span class="hljs-name"&gt;let&lt;/span&gt; ((&lt;span class="hljs-name"&gt;b1&lt;/span&gt; (&lt;span class="hljs-name"&gt;substring&lt;/span&gt; (&lt;span class="hljs-name"&gt;buffer-name&lt;/span&gt; (&lt;span class="hljs-name"&gt;current-buffer&lt;/span&gt;)) &lt;span class="hljs-number"&gt;0&lt;/span&gt; &lt;span class="hljs-number"&gt;1&lt;/span&gt;)))
    (&lt;span class="hljs-name"&gt;when&lt;/span&gt; (&lt;span class="hljs-name"&gt;and&lt;/span&gt; store-last-modification-time
               (&lt;span class="hljs-name"&gt;not&lt;/span&gt; (&lt;span class="hljs-name"&gt;string=&lt;/span&gt; b1 &lt;span class="hljs-string"&gt;&amp;quot; &amp;quot;&lt;/span&gt;))
               (&lt;span class="hljs-name"&gt;not&lt;/span&gt; (&lt;span class="hljs-name"&gt;string=&lt;/span&gt; b1 &lt;span class="hljs-string"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;)))
      (&lt;span class="hljs-name"&gt;setq&lt;/span&gt; last-modification-time (&lt;span class="hljs-name"&gt;current-time&lt;/span&gt;)))))
(&lt;span class="hljs-name"&gt;add-hook&lt;/span&gt; &amp;#x27;after-change-functions &amp;#x27;mark-last-modification-time)
(&lt;span class="hljs-name"&gt;defun&lt;/span&gt; write-lmt ()
  (&lt;span class="hljs-name"&gt;setq&lt;/span&gt; store-last-modification-time &lt;span class="hljs-literal"&gt;nil&lt;/span&gt;)
  (&lt;span class="hljs-name"&gt;when&lt;/span&gt; last-modification-time
    (&lt;span class="hljs-name"&gt;with-temp-file&lt;/span&gt; &lt;span class="hljs-string"&gt;&amp;quot;/tmp/emacs-lmt&amp;quot;&lt;/span&gt;
      (&lt;span class="hljs-name"&gt;multiple-value-bind&lt;/span&gt; (&lt;span class="hljs-name"&gt;a&lt;/span&gt; b c) last-modification-time
        (&lt;span class="hljs-name"&gt;princ&lt;/span&gt; a (&lt;span class="hljs-name"&gt;current-buffer&lt;/span&gt;))
        (&lt;span class="hljs-name"&gt;terpri&lt;/span&gt; (&lt;span class="hljs-name"&gt;current-buffer&lt;/span&gt;))
        (&lt;span class="hljs-name"&gt;princ&lt;/span&gt; b (&lt;span class="hljs-name"&gt;current-buffer&lt;/span&gt;)))))
  (&lt;span class="hljs-name"&gt;setq&lt;/span&gt; store-last-modification-time &lt;span class="hljs-literal"&gt;t&lt;/span&gt;))
(&lt;span class="hljs-name"&gt;run-at-time&lt;/span&gt; &lt;span class="hljs-literal"&gt;nil&lt;/span&gt; &lt;span class="hljs-number"&gt;1&lt;/span&gt; &amp;#x27;write-lmt)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Every second (to change that to every 10 seconds, change the &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;10&lt;/code&gt; in the last line) it creates a file named &lt;code&gt;/tmp/emacs-lmt&lt;/code&gt; which contains the time of last modification of any non-system buffer.&lt;/p&gt;&lt;p&gt;That’s all there is to it, at least on the Emacs side. The other part is a simple shell script, which uses &lt;a href="http://www.mplayerhq.hu/"&gt;MPlayer&lt;/a&gt; to display a nag-screen for five seconds, and then give me some time to start doing anything useful before nagging me again:&lt;/p&gt;&lt;pre&gt;&lt;code class="hljs bash"&gt;&lt;span class="hljs-meta"&gt;#!/bin/bash&lt;/span&gt;
TIMEOUT=300
&lt;span class="hljs-keyword"&gt;while&lt;/span&gt; &lt;span class="hljs-literal"&gt;true&lt;/span&gt;; &lt;span class="hljs-keyword"&gt;do&lt;/span&gt;
   &lt;span class="hljs-built_in"&gt;cat&lt;/span&gt; /tmp/emacs-lmt | (
      &lt;span class="hljs-built_in"&gt;read&lt;/span&gt; a; &lt;span class="hljs-built_in"&gt;read&lt;/span&gt; b;
      c=&lt;span class="hljs-string"&gt;&amp;quot;`date +%s`&amp;quot;&lt;/span&gt;;
      &lt;span class="hljs-built_in"&gt;let&lt;/span&gt; x=c-65536*a-b;
      &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; &lt;span class="hljs-built_in"&gt;test&lt;/span&gt; &lt;span class="hljs-variable"&gt;$x&lt;/span&gt; -gt &lt;span class="hljs-variable"&gt;$TIMEOUT&lt;/span&gt;;
          &lt;span class="hljs-keyword"&gt;then&lt;/span&gt; mplayer -fs &lt;span class="hljs-variable"&gt;$HOME&lt;/span&gt;/p.avi;
               &lt;span class="hljs-built_in"&gt;sleep&lt;/span&gt; 15;
      &lt;span class="hljs-keyword"&gt;fi&lt;/span&gt;)
   &lt;span class="hljs-built_in"&gt;sleep&lt;/span&gt; 1
&lt;span class="hljs-keyword"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The nag-screen in my case is an animation which I’ve created using MEncoder from a single frame which looks &lt;a href="http://bach.ipipan.waw.pl/~nathell/procrastination.png"&gt;like this&lt;/a&gt;. Beware the expletives! (This is one of the few cases I find their usage justified, as the strong message bites the conscience more strongly.)&lt;/p&gt;&lt;p&gt;I’ve only been testing this setup for one day, but so far it’s working flawlessly: I got more done yesterday than for the two previous days combined, and that’s excluding the hour or so that took me to write these snippets.&lt;/p&gt;&lt;p&gt;If anyone else happens to give it a try, I’d love to hear any comments.&lt;/p&gt;&lt;/div&gt;</content>
  </entry>
</feed>
