emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: alter all subtrees containing specific tag


From: news
Subject: [Orgmode] Re: alter all subtrees containing specific tag
Date: Mon, 09 Mar 2009 02:32:09 +0000

Carsten Dominik <address@hidden> 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

Just discovered a bug in my previously posted function. It doesn't work
too well if you have lower level subtrees tagged for encryption.
Here is the fixed version:

(defun aleblanc-org-toggle-encryption (rcpts passphrase)
  (interactive (list (split-string (read-string "Recipients (default is none): 
") "[ \t,]+")
                     (pgg-read-passphrase "GnuPG passphrase: ")))
  (show-all)
  (org-map-entries '(let (start end teststring)
                      (org-outline-level)
                      (next-line)
                      (org-beginning-of-line)
                      (setq start (point))
                      (setq teststring (buffer-substring start (+ start 27)))
                      (outline-get-next-sibling)
                      (if (not (equal (point) (point-max)))
                          (previous-line))
                      (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





reply via email to

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