emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com>
To: Johan Sandblom <js@ndblom.se>
Cc: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: Re: org-date-toggle-inactive
Date: Tue, 25 Sep 2012 14:26:28 -0400	[thread overview]
Message-ID: <CAEWDx5c-LmpVCgnR-fNK1=QZk6XNuvrQ7iN=dyzJsgGiT=Eicg@mail.gmail.com> (raw)
In-Reply-To: <8fff6f801a80accbc63d7607c303ed59@ndblom.se>

[-- Attachment #1: Type: text/plain, Size: 2018 bytes --]

Hello Johan,

On 25 September 2012 14:09, Johan Sandblom <js@ndblom.se> wrote:

> 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)
>

You should be able to just use =org-toggle-timestamp-type=
instead of your snippet.  It performs the check and will toggle
back and forth between active and inactive timestamps.

(add-hook 'org-ctrl-c-ctrl-c-hook
          'org-toggle-timestamp-type)


>
> --
> 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
>
>
Regards,

--
Jon

[-- Attachment #2: Type: text/html, Size: 3058 bytes --]

  reply	other threads:[~2012-09-25 18:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 18:09 org-date-toggle-inactive Johan Sandblom
2012-09-25 18:26 ` Jonathan Leech-Pepin [this message]
2012-09-25 21:44   ` org-date-toggle-inactive Bastien
2012-09-26  6:33     ` org-date-toggle-inactive Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEWDx5c-LmpVCgnR-fNK1=QZk6XNuvrQ7iN=dyzJsgGiT=Eicg@mail.gmail.com' \
    --to=jonathan.leechpepin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=js@ndblom.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).