? ?
Notes from a Medium-Sized Island [entries|archive|friends|userinfo]

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Nov. 2nd, 2004|12:52 am]
Wrote a emacs minor mode for automatically storing my current wordcount to a file with a time stamp, as suggested by tom7. This may be not very idiomatic elisp, being as I am not very experienced with it. I had to jump out to perl to acutally, gasp, deal with numbers larger than 2 to the 27.

(defun nano-data () 
  (set-buffer (find-file-noselect "wordcount-history"))
  (goto-char (point-max))
  (let* ((tm (current-time))
	 (str1 (int-to-string (car tm)))
	 (str2 (int-to-string (cadr tm)))
	 (shellcmd (concat "wc -w 2004-*.tex | tail -1 | perl -lane 'print ((" str1 " * 65536 +  " str2 ") . \" $F[0]\" )' ")))
    (insert (shell-command-to-string shellcmd)))

(define-minor-mode nanowri-mode
  "just an after-save-hook hack for now"
  (if nanowri-mode 
    (add-hook 'after-save-hook 'nano-data nil t) 
    (remove-hook 'after-save-hook 'nano-data)))

set terminal x11 persist
plot "wordcount-history" using ($1 / 1000 - 1.09928e6):($2) with lines notitle


From: lambdacalculus
2004-11-02 06:00 am (UTC)
Cool. I would have just done all the wordcounting on the unix side (actually, that is what I did) with like >> to append to the file. Also, here is my gnuplot file, which you might find useful:

set term postscript
set xlabel 'date'
set data style lines
set xdata time
set xrange [1096772635:1101911825]

set title 'nanowrimo 2004 word count'
set ylabel 'words'
set output 'graph.ps'
set yrange [0:20000]

# use unix epoch seconds
set timefmt "%s"

plot 'history.plot' using ($1):($2) title 'words', (((x - 1099319825) / (24 * 3600)) * 1666) + 5769 title 'goal'

I guess the main point is that you can use unix time format instead of just doing math so that the x labels make sense.
(Reply) (Thread)
[User Picture]From: mpnolan
2004-11-02 03:33 pm (UTC)
Last year did you write at the fastest rate at the beginning, middle, or end of the month?
(Reply) (Thread)
[User Picture]From: mpnolan
2004-11-02 09:36 pm (UTC)
Nevermind. Now that LJ isn't so slow, I went back and read your entries from November 2003.
(Reply) (Parent) (Thread)