[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] org-date-toggle-inactive

From: Johan Sandblom
Subject: [O] org-date-toggle-inactive
Date: Tue, 25 Sep 2012 20:09:26 +0200
User-agent: Binero Webmail/0.8.0

I wrote the following which allows me ctrl-c-ctrl-c on a date in an org file and thereby toggle the inactive state of the date. I find it useful when applying to courses that I am later [not] admitted to. Perhaps it is useful to someone else. Perhaps also there are obvious improvements to the code. Lastly, perhaps there is a better place to submit such snippets. I appreciate feedback.

Regards, Johan

(setq org-date-regexp
"[\\[<][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9] [[:alpha:]]\\{2,3\\} ?.*?[]>]")

(defun org-at-date-p ()
  "Am I inside an org date?"
    (if (looking-at org-date-regexp)
      (if (> (skip-chars-backward "-[:alnum:]: ") -40)
          (let ((left (- (point) 1)))
              (search-backward-regexp "[\\[<]" left t)
            (if (looking-at org-date-regexp)

(defun org-date-toggle-inactive ()
  (if (org-at-date-p)
          (search-backward-regexp "[\\[<]")
          (if (string-equal "<" (match-string 0))
              (replace-match "[")
            (replace-match "<"))
          (search-forward-regexp "[]>]")
          (if (string-equal ">" (match-string 0))
              (replace-match "]")
            (replace-match ">"))

(add-hook 'org-ctrl-c-ctrl-c-hook

Johan Sandblom, MD PhD
m +46735521477
What is wanted is not the will to believe, but the
will to find out, which is the exact opposite
--Bertrand Russell

reply via email to

[Prev in Thread] Current Thread [Next in Thread]