6197 comments
2357 subscribers
Follow me on Twitter (@sachac)
Subscribe! Feed reader E-mail

Don Marti’s e-mail productivity hack

See http://www.linuxworld.com/community/?q=node/387 for inspiration.

;;;_+ Inbox anti-addiction hack
;;
;; The following code implements the inbox productivity hack described
;; by Don Marti in http://www.linuxworld.com/community/?q=node/387 .
;; People are not allowed to check mail for more messages unless the
;; number of ticked items has decreased since the last time checked
;; or `sacha/gnus-inbox-time-threshold' seconds have passed.
;;
;; Use ! (tick article) to mark articles as needing action.
;; Modify the logic if you move messages from your inbox into some kind
;; of archive (which is probably a better idea).

(defvar sacha/gnus-inbox-time-threshold (seconds-to-time (* 60 60 2))
  "*Number of seconds before you can check again if you haven't done any work.
Nil means don't use time.")
(defvar sacha/gnus-inbox-group "mail.misc"
  "*Group to consider as inbox.")

(defvar sacha/gnus-inbox-last-count nil "Number of ticked items in inbox.")
(defvar sacha/gnus-inbox-last-check nil "Timestamp of last check.")

(defun sacha/gnus-inbox-decreased-p ()
  "Return non-nil if you are allowed to check mail.
Based on http://www.linuxworld.com/community/?q=node/387"
  (or (not (numberp sacha/gnus-inbox-last-count)) ;; First time called
      (and sacha/gnus-inbox-last-check
           sacha/gnus-inbox-time-threshold
           (not (time-less-p (time-since sacha/gnus-inbox-last-check)
                             sacha/gnus-inbox-time-threshold)))
      (or (= (sacha/gnus-inbox-count) 0)
          (< (sacha/gnus-inbox-count)
             sacha/gnus-inbox-last-count))))

(defadvice gnus-group-get-new-news (around sacha/gnus-inbox-check-mail activate)
  "Allow only if the inbox count has decreased."
  (if (sacha/gnus-inbox-decreased-p)
      ad-do-it
    (error "Get your mail count below %d first." sacha/gnus-inbox-last-count))
  (setq sacha/gnus-inbox-last-count (sacha/gnus-inbox-count)
        sacha/gnus-inbox-last-check (current-time)))

(defun sacha/gnus-inbox-count ()
  "Return number of ticked items in `sacha/gnus-inbox-group'."
  (save-window-excursion
    (gnus-summary-read-group-1 sacha/gnus-inbox-group nil t nil t)
    (length gnus-newsgroup-marked)))

Random Emacs symbol: set-process-filter-multibyte - Function: Set multibyteness of the strings given to PROCESS's filter.

Short URL: http://sachachua.com/blog/p/4599

On This Day...

  • 2013: Weekly review: Week ending April 12, 2013 — This was the week of video-processing! I cut the livestream recording into talk segments, spliced in close-ups of the screen [...]
  • 2012: Learning how to say no — The most fascinating thing I’m learning about business these days is the art and discipline of saying no. Many people [...]
  • 2011: Still cold? Wear a hat to bed — I remember teasing W- about how he wears a toque to bed. (It’s a small, brimless hat also known as [...]
  • 2010: For love of numbers — I enjoy thinking about money. I mentally calculate unit prices in the produce section (counter-intuitively, loose garlic was cheaper than [...]
  • 2007: Strange wikindx error — Whenever I post a note to wikindx, it pops up a dialog prompting me to save or edit index.php. This [...]
  • 2006: Thank you — My deepest thanks go to all those who have written with such warm words of encouragement and support. From people I [...]
  • 2006: Girl! — I play around with Ruby on Rails, and what do I do? Build one webapp to keep track of what’s in [...]
  • 2006: Woooooohooooooo! Congrats, Ateneo! — You go, kids! That’s totally, totally, totally awesome. Kudos to Allan, Punzki and Topher, and to their coaches (Hi Doc Mana! [...]
  • 2006: Sacha-sense tingling — This is what it’s like to be loved. =) I was having one of my I-hate-being-an-international-student moments when Dominique turned up online, [...]
  • 2006: Limit — A limitless future limits the present. What’s my future? Is this home, is this where I’m supposed to belong? What of [...]
  • 2006: Pinged — And to the friend who pointed out that lots of people are probably pinging me to make sure I’m alright: spot [...]
  • 2006: Reflections — I haven’t been blogging lately. Things have been a bit confusing, but I’m glad that I’m starting to sort things out. [...]
  • 2005: flpsed — flpsed is a WYSIWYG Postscript editor. To edit pdfs, install xpdf, then: ps2pdf, flpsed, pdftops. Interesting… On Technorati: opensource, applications
  • 2005: Went to Pisay — I went to Philippine Science High School to register for the national alumni association and designate a proxy for the elections [...]
  • 2005: Keeping it Personal — Update 2013-04-28: Fixed Japanese encoding error by re-copying from examples. http://www.douglasjohnston.net/weblog/archives/2005/04/09/keeping-personal/ is an insightful blog post on personalizing a planner. It inspires [...]
  • 2005: Chat with Ranulf — I had a nice long chat with Ranulf Goss about life, the universe, and everything. I think it’s absolutely wonderful that he [...]
  • 2004: Tired! — Went to my first aikido session. Was too late for 5:30 session so attended 7:30 session instead. Diane was late and [...]
  • 2004: Thoughts on progress reports — Dean Michael Berris blogged: I personally despise the need to write progress reports in human terms — mainly I want to show [...]
  • 2004: Understanding mathematics web talk — From Joe Corneli: http://www.ma.utexas.edu/~jcorneli/z/understanding%20mathematics/ E-Mail from Joe Corneli