Following is what I came up with, following terdon's ideas.
I'm pretty happy with it, it does what I wanted, over a few files in the my-martini-files
variable.
Edit : A temporary count has been added, which allows to stack progress, and still reset the count sometimes, not to take heavy copy/paste that shouldn't add words into account for the progress achieved.
I bound it to f4 for a report, C-f4 to re-initialize the count (of files), S-f4 to stack progress, and C-S-f4 to start a new day, all counts at 0.
Fanciness would now consist in integrating it to the modeline, but that's another matter.
;; Teh Martini method
(require 'wc) ; The file terdon links to.
(defun wc-in-buffer (file)
"Return the number of words in the buffer opening the file
passed as an argument. It should already be open."
(with-current-buffer (get-file-buffer file)
(wc-non-interactive (point-min) (point-max)))
)
(defun my-martini-sum ()
"Sum words over my-martini-files."
(apply '+
(loop for file in my-martini-files
collect (wc-in-buffer file)))
)
(setq my-martini-files '("~/path/to/file.org"
"~/path/to/another/file.org"
;; Taken from org-agenda-files
))
(defun my-martini-update ()
"Update my-martini-count from files."
(interactive)
(setq my-martini-count (my-martini-sum))
(message "Files lengths updated."))
(defun my-martini-reset ()
"Reset counts and stack for a new day."
(interactive)
(my-martini-update)
(setq my-martini-stack 0)
(message "Martini counts re-initialized."))
(defun my-martini-stack ()
"Stack the current progress, and update.
To be used before pasting loads of unsignificant words."
(interactive)
(setq my-martini-stack (+ my-martini-stack (- (my-martini-sum) my-martini-count)))
(message "Current count is stacked. Mess at will, just update afterwards.")
)
(defun my-martini-report ()
"Display changes in total word count since last update."
(interactive)
(message (concat "As for now, "
(number-to-string (+ my-martini-stack (- (my-martini-sum) my-martini-count)))
" new words have been added today."))
)
(global-set-key [f4] 'my-martini-report)
(global-set-key [\C-f4] 'my-martini-update)
(global-set-key [\S-f4] 'my-martini-stack)
(global-set-key [\C-\S-f4] 'my-martini-reset)
Any comments or suggestions to improve the code are dearly welcome.
I'll read into more detail tonight, but that'll go with free text in org-mode, LaTeX sequences won't be an issue for now. Moreover, once the “update” part is managed, I guess it should be easy to replace
wc
by somecount-true-words-lost-in-markup
function for any markup language, for which I saw a few answers already existed. – Nikana Reklawyks – 2012-12-02T18:06:53.147Ok so tonight became yet another asap, but here's the update :·) Thanks a lot for your ideas. Oh, and my elisp got a lot better tonight thanks to that =) – Nikana Reklawyks – 2012-12-05T08:00:15.703