Simple org-clock and gnome/pidgin integration

See update below

I have been trying to get back to using org-mode and its clocking functionality, more often than not. I used to use it a lot, a few years ago, and haven't been using it, since I had been in my last job.

To help with it, I decided to integrate clocking in and out with changing status on Pidgin, and turning notifications on and off in Gnome. Here's a few lines of code that does this for me.

(defadvice org-clock-in (after pc/org-clock-in (&optional select start-time))
  "Turn gnome notifications off."
   "SetStatus" 2)
  (shell-command "purple-remote setstatus?status=unavailable"))

(defadvice org-clock-out (after pc/org-clock-out (&optional switch-to-state fail-quietly at-time))
  "Turn gnome notifications back on."
   "SetStatus" 0)
  (shell-command "purple-remote setstatus?status=available"))

Update <2014-11-01 Sat>

@baali tried to use my code, and it turns out it didn't work for him, because I forgot to mention that (ad-activate 'org-clock-in) needs to be run, after the defadvice code. I have no idea how it worked for me, without doing that. May be because I have defadvice for other functions?

Also, while debugging this, I found that defadvice is a deprecated way of doing this, and add-function is the way to go now. But, instead of advising the function, I decided to make use of org-clock-in-hook.

Here is the new code.

(defun pc/turn-off-notifications ()
  "Turn gnome notifications off."
   "SetStatus" 2)
  (shell-command "purple-remote setstatus?status=unavailable"))

(defun pc/turn-on-notifications ()
  "Turn gnome notifications back on."
   "SetStatus" 0)
  (shell-command "purple-remote setstatus?status=available"))

(add-hook 'org-clock-in-hook 'pc/turn-off-notifications)
(add-hook 'org-clock-out-hook 'pc/turn-on-notifications)

Learning to use Org-drill

Org-drill is an Org-mode extension that provides spaced-repetition and flash-card functionality. It has a wonderful documentation on Worg, but somehow I couldn't get myself to read the whole document, and setup org-drill, until now.

The setup is quite straight forward, once you have org-mode along with the contrib packages. Just (require 'org-drill), and you are all set! To add a new card, all you need to do is add a :drill: tag to the items you wish to "Org-drill". You can start a review session with simply M-x org-drill. You will be shown flash cards, and you can rate how correct and comfortable you were, in answering the questions. Based on your responses, the cards are scheduled for review. Start another review session, whenever you need one!

What I could only understand once I got myself to read the whole document was that:

  • The default scope of a drill session is the current file. But, you can start sessions with scopes like current tree, current directory, or a specified list of files. This is super-useful!
  • The review sessions are not automatically scheduled, based on when you schedule failed flash-cards. Scheduling the review for a card only sets a due-date for them, and effects, what you are asked in your next session.

Cram mode and incremental reading are also things I want to try, as I go along.

Happy Learning!

Recurse Center, 2014-08-08

  • I spent the morning doing some white-boarding interview practice with a Jorge and Brian.
  • I spent the rest of the day, playing with PyPy and working through a tutorial that teaches us to write a BF interpreter.
  • I spent the Saturday revamping my Emacs config. The main issue with my config was having a "package" list, of all the packages that the configuration uses, in case we are trying to duplicate it elsewhere. I noticed that this gets out of sync, because I install packages by hand and never update this list. I wrote up some code, that keeps this list in sync with all the packages I have installed. I configured el-get to play well with my config, and am pretty happy with my setup, though I still have to add some matching/searching features with helm/ido/whatever else.
  • I spent the Sunday writing a patch to xtab to be able to limit the number of tabs in Chromium by the memory it uses.

Org based posts in Nikola

Chen Bin asked me to share my Nikola+Org work-flow, and share an example post.

The org source for any post can be found by changing the URL of a post from .html to .org.

I don't have much of a work-flow, because I don't post too often, but here is what I typically do, to make a new post.

I start off by creating a new post using

$ nikola new_post

and then give the post a title and start editing the post in Emacs.

I have a simple snippet that lets me insert tags, based on existing tags.

Once I'm happy with the content of a post, I run nikola auto to build the source and serve it locally, and see if the post "looks" reasonable, after being rendered.

Once, I'm happy with it, I commit the post and deploy it using nikola deploy.


# Commands to execute to deploy. Can be anything, for example,
# you may use rsync:
# "rsync -rav output/*"
# And then do a backup, or ping pingomatic.
# To do manual deployment, set it to []

I also have a plugin, that posts captured bookmarks and quotes onto the blog, with a single command. I should probably make the sources of my blog open, and push it onto GitHub.

Update [2015-05-13 Wed]

  • I use my own plugin for Nikola which lets me write posts in org-mode. There is a similar plugin by Chen Bin, that exports posts to intermediate html, that is then used by Nikola.
  • The source for my blog is now on GitHub
  • I also have custom elisp to be able to make a new post, and deploy the site from within Emacs.

Org-mode Workshop

Well, I'm not sure if it's worth writing about. I conducted my first org-mode workshop along with Prof. Venkatesh Choppella at IIIT-Hyderabad. It was a 3 hour demo+talk kind of a thing, with a small audience of about 20 people, most of whom were new to Emacs.

We covered almost all the aspects of Org-mode after giving a brief introduction to Emacs. Outlining and note-taking part was simple and easy to understand, but the audience couldn't really appreciate the part of keeping TODO lists and agendas and other stuff. I'm hoping, the reason was not me taking over from Venkatesh.

I think the workshop should've been more hands-on and we should've asked people to try out stuff on the spot, instead of showing off the things possible with Emacs. They probably would've appreciated a few things better, that way.

Hopefully, we will be doing more workshops on Org-mode and there are surely somethings to take away from this one. I hope at least one of the participants, gets hooked to Org-mode.

The talk outline is here.

Git powered wikis improved: My bit

I accidentally came across the blog-post Git-powered wikis improved - GitHub. And this particular paragraph caught my eye:

The new editor has the capability to support every markup language that GitHub Wikis support. If you're a fan of Markdown, Textile, pod or RDoc, the function bar buttons (e.g. bold, italic, underline, etc.) will now work. We've even written brand new inline help for many of GitHub Wiki's supported markup languages.

The language definitions the editor uses are JSON-based and easy to edit. If you'd like us to support a markup language that we don't currently support, Gollum, GitHub's wiki software, is entirely open source – fork our code and send us a pull request with changes that support your choice language.

I sent a quick patch for org-mode in the function bar, and it has been accepted. :)

If not anything more, I hope, at least a couple of curious people will explore org-mode and find it useful.

CHAGANTI 635888 Emacs

Puneeth Chaganti, hereby agrees as follows:

Developer hereby agrees to assign and does hereby assign to FSF Developer's copyright in changes and/or enhancements to the suite of programs known as GNU EMACS, including any accompanying documentation files and supporting files as well as the actual program code.

Yay! I can now write code, that can go into Org-mode and Emacs! I'm looking forward to this!

Why I like Org as a markup

Org-mode, as a mode, is obviously awesome. The ability to move around whole blocks of text, for re-organizing documents and the usability of tables are just two brilliant features.

But, the org markup itself is such a cool thing. I've been looking at rst all day, and it's such a pain to find out where your headings are, what level your current sub-heading is at, etc. (I'll probably do a bit better, with some getting used to. I'm an org-addict. ;)). With org-mode it's so intuitive! It's so easy to find out, with just one quick look! I don't think any other markup has this coolness! Org-mode FTW!

Pandoc can now do Org

Pandoc is a haskell library and a command line tool, that can convert markup from one to another and it does it pretty well. Until now it supported quite a few markups, but not orgmode. But now, Orgmode support has been added! Yay!

But, it can only read from other formats and write to org-mode format. The other way around, is not possible, but you can do that straight from org-mode, right?

I've often felt the need for an org-importer and hence decided to do something about it. I stumbled upon Pandoc, when I was moving my blog, and found it pretty neat. After, yet another request for an importer, on the org-mode mailing list, I decided to look at Pandoc. I was somehow under the impression that it was written in Python. But it turned out, I had to learn Haskell! A good excuse to learn a new language, eh? I brushed through a tutorial for a couple of days (and was blown off by the paradigm of the language) and was able to port the RST writer in Pandoc, to an Org writer. :)

You can get the latest version from here

Some fun from #org-mode

This is a conversation from #org-mode, published without permission from plovs, BerntH and bremner. If any of you want any of the content removed, I will do so.

<punchagan> hi all

<BerntH> hi punchagan [18:36]

<punchagan> BerntH: ever used/tried blorg or blorgit? [18:47]

<punchagan> I like the way org-publish works, but blorg exports one org file as a blog. If blorg were to be re-written on top of org-publish, how should it be done? use one file per post or just one file for the whole blog? [18:52]

<bremner> punchagan: another option is to use ikiwiki and use the org-mode plugin to render pages. This is what i do, although only a bit of the site is in org. [19:44]

<punchagan> bremner: can I have a look at your site? [19:45]

<bremner> sure, it ain't pretty, but: [19:46]

<punchagan> thanks. I'll keep this in mind. [19:47]

<punchagan> I just loved the way this site looks and behaves –

<bremner> well, the side bar at least is possible with ikiwiki. Other than that I suppose it is mainly a matter of css [19:48]

<BerntH> punchagan: nope [19:49]

<punchagan> ok BerntH [19:50]

<plovs> punchagan ikiwiki does have an org-mode plugin [19:56]

<punchagan> plovs: yes, bremner told me that and I've seen on Worg too. :)

<plovs> punchagan ah, yes, sorry

<punchagan> plovs: it's alright. [19:59]

<plovs> punchagan another possibility is org2blog, which uses wordpress

<punchagan> plovs: I'm the author of it. :D

<plovs> lol, ik, that punchagan [20:17]

<punchagan> lol

<punchagan> plovs: were you kidding? or serious? [20:19]

<plovs> punchagan sorry to say i was serious, but it will not happen again :-)

<plovs> i really like org2blog, played with it yesterday

<punchagan> plovs: no. I was just wondering if you were playing around with me. :P

<punchagan> I'm happy some one thinks it is useful.

<plovs> lol, no, i just didn't recognized your name, although it is kind of hard to miss [20:21]

<punchagan> I hope you don't mind, if I make this anecdote public?