From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subject: Re: alter all subtrees containing specific tag Date: Mon, 09 Mar 2009 00:56:41 +0000 Message-ID: <87ocwbms3a.fsf@it.com> References: <877i303a9w.fsf@it.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LgW8x-0002zc-10 for emacs-orgmode@gnu.org; Sun, 08 Mar 2009 23:27:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LgW8w-0002zP-B0 for emacs-orgmode@gnu.org; Sun, 08 Mar 2009 23:27:06 -0400 Received: from [199.232.76.173] (port=58117 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LgW8w-0002zM-4P for emacs-orgmode@gnu.org; Sun, 08 Mar 2009 23:27:06 -0400 Received: from mx20.gnu.org ([199.232.41.8]:38879) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LgW8v-0007wf-Je for emacs-orgmode@gnu.org; Sun, 08 Mar 2009 23:27:06 -0400 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LgTqf-0002lS-9X for emacs-orgmode@gnu.org; Sun, 08 Mar 2009 21:00:05 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LgTna-0007re-JW for emacs-orgmode@gnu.org; Mon, 09 Mar 2009 00:56:54 +0000 Received: from 87-194-46-7.bethere.co.uk ([87.194.46.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 Mar 2009 00:56:54 +0000 Received: from news by 87-194-46-7.bethere.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 Mar 2009 00:56:54 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Carsten Dominik 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