From: <news@aleblanc.cotse.net>
To: emacs-orgmode@gnu.org
Subject: Re: alter all subtrees containing specific tag
Date: Mon, 09 Mar 2009 00:56:41 +0000 [thread overview]
Message-ID: <87ocwbms3a.fsf@it.com> (raw)
In-Reply-To: E40241E3-D6BC-4BA5-81D4-DC3382A2A4A2@uva.nl
Carsten Dominik <dominik@science.uva.nl> writes:
>
>> Is there a quick way to get the start and end points of a subtree,
>> or
>> place region around it? and a quick way to jump to the next heading
>> with a given tag?
>
> (org-mark-subtree) ;; this will include the headline
>
> (re-search-forward "^\\*+ .*?:ENCRYPT:" nil t)
>
> - Carsten
Couldn't find the org-mark-subtree function, but the following code
works for me.
It will toggle the encryption of all subtrees in the current buffer that
are tagged with :ENCRYPT:, i.e. if the subtree is encrypted (starting
from the first line after the header, and finishing on the last
non-empty line of the subtree), it will be decrypted, otherwise it will
be encrypted.
You can use either gpg keys or a passphrase to encrypt subtrees. To use
gpg keys, enter the names of the owners of the keys at the prompt,
otherwise just press enter to use a passphrase only.
If the passphrase does not match for any encrypted subtrees they will be
left as is.
Perhaps someone could post this on Worg? (I am lazy).
(defun org-toggle-encryption (rcpts passphrase)
(interactive (list (split-string (read-string "Recipients (default is none): ") "[ \t,]+")
(pgg-read-passphrase "GnuPG passphrase: ")))
(org-map-entries '(let (start end teststring)
(org-show-subtree)
(next-line)
(org-beginning-of-line)
(setq start (point))
(setq teststring (buffer-substring start (+ start 27)))
(condition-case nil
(progn
(outline-forward-same-level 1)
(previous-line))
(error (goto-char (point-max))))
(org-end-of-line)
(setq end (point))
(if (equal teststring "-----BEGIN PGP MESSAGE-----")
(if (pgg-decrypt-region start end passphrase)
(pgg-display-output-buffer start end t)
(message "Can't decrypt region!"))
(if (equal rcpts '(""))
(pgg-encrypt-symmetric-region start end passphrase)
(pgg-encrypt-region start end rcpts nil passphrase))
(pgg-display-output-buffer start end t)))
"+ENCRYPT"))
--
aleblanc
next prev parent reply other threads:[~2009-03-09 3:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 4:31 alter all subtrees containing specific tag news
2009-03-08 13:29 ` Carsten Dominik
2009-03-08 18:00 ` news
2009-03-09 0:56 ` news [this message]
2009-03-09 2:32 ` news
2009-03-09 12:28 ` news
2009-03-08 13:42 ` Ian Barton
2009-03-08 18:01 ` news
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ocwbms3a.fsf@it.com \
--to=news@aleblanc.cotse.net \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.