emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees


From: Tom Gillespie
Subject: Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
Date: Fri, 4 Sep 2020 21:48:44 -0700

Hi Gabriel,
   This seems like it is probably a bug given that everything else
about archive headings
is disabled. In the meantime, depending on how many blocks you are
dealing with you
could hack around this by using the following header argument.
#+header: :tangle (unless-archived "/ssh:host:/path/to/file")
The implementation of unless-archived is below along with a demo org file.
Best!
Tom

* Bootstrap
This is a giant hack which only works because the state of Emacs
when resolving the tangle header is sitting on the block in question
which I'm guessing is an implementation detail.
#+begin_src elisp
(defun unless-archived (path)
  (save-excursion
    (if (let ((heading (outline-previous-heading)) archived)
          (while (and (not archived) heading)
            (let ((element (org-element-at-point)))
              (setq archived (org-element-property :archivedp element)))
            (setq heading (ignore-errors (outline-up-heading 1)))
            (message "%s" heading))
          archived)
        "no"
      path)))
#+end_src
* sysadmin
** some server I don't use anymore                                 :ARCHIVE:
*** distractor heading
*** tangled code in here
#+header: :tangle (unless-archived "/ssh:localhost:/tmp/some-file.sh")
#+begin_src bash
"yes this tangles when archived"
#+end_src



reply via email to

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