Search code examples
emacsorg-modevoting

How to vote for a heading in org-mode?


I have thousands of headings in org-mode agenda files and use this structure for a long time. I want to set up org-mode so that it has a voting system. I press a hotkey, org-mode adds +1 to a heading and then I can filter the headings by the number of votes.


Upd. I have to clarify the question. I can see how this can be done:

* heading
  :PROPERTIES:
  :VOTES:    5
  :END:

1) property drawers are searchable http://orgmode.org/worg/org-tutorials/advanced-searching.html, so I can use the comparison operators for filtering, e.g. VOTES>4.

2) I can use the propertу API http://orgmode.org/manual/Using-the-property-API.html for increasing and decreasing the counter.


Solution

  • Here is the solution. I add + to a speed command in org-mode. You could also bind this to some key.

    (defun plusone ()
      "Increase the VOTES property in an org-heading by one. Create
    the property if needed."
      (interactive)
      (org-entry-put
       (point)
       "VOTES"
       (format "%s" (+ 1 (string-to-number
                  (or
                   (org-entry-get (point) "VOTES")
                   "0"))))))
    
    (add-to-list 'org-speed-commands-user '("+" . (plusone)))