From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Sandblom Subject: org-date-toggle-inactive Date: Tue, 25 Sep 2012 20:09:26 +0200 Message-ID: <8fff6f801a80accbc63d7607c303ed59@ndblom.se> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGZaC-0005Na-0e for emacs-orgmode@gnu.org; Tue, 25 Sep 2012 14:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGZa4-0002B1-MK for emacs-orgmode@gnu.org; Tue, 25 Sep 2012 14:10:07 -0400 Received: from vsp-authed02.binero.net ([195.74.38.226]:49750 helo=vsp-authed-02-02.binero.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TGZa4-0002AX-Cq for emacs-orgmode@gnu.org; Tue, 25 Sep 2012 14:10:00 -0400 Received: from smtp01.binero.se (unknown [195.74.38.28]) by vsp-authed-02-02.binero.net (Halon Mail Gateway) with ESMTP for ; Tue, 25 Sep 2012 20:09:27 +0200 (CEST) Received: from webmail.binero.se (unknown [195.74.38.9]) (Authenticated sender: js@ndblom.se) by smtp-10-01.atm.binero.net (Postfix) with ESMTPA id F1EBE3A153 for ; Tue, 25 Sep 2012 20:09:26 +0200 (CEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Emacs orgmode 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?" (interactive) (save-excursion (if (looking-at org-date-regexp) t (if (> (skip-chars-backward "-[:alnum:]: ") -40) (let ((left (- (point) 1))) (progn (search-backward-regexp "[\\[<]" left t) (if (looking-at org-date-regexp) t))))))) (defun org-date-toggle-inactive () (interactive) (if (org-at-date-p) (save-excursion (progn (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 ">")) t)) nil)) (add-hook 'org-ctrl-c-ctrl-c-hook 'org-date-toggle-inactive) -- 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