emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [FEATURE REQUEST] No tangle of code blocks within archived subtrees
@ 2020-09-05  1:31 flare
  2020-09-05  4:48 ` Tom Gillespie
  0 siblings, 1 reply; 6+ messages in thread
From: flare @ 2020-09-05  1:31 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/html, Size: 7481 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
  2020-09-05  1:31 [FEATURE REQUEST] No tangle of code blocks within archived subtrees flare
@ 2020-09-05  4:48 ` Tom Gillespie
  2020-09-06  9:36   ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Gillespie @ 2020-09-05  4:48 UTC (permalink / raw)
  To: flare; +Cc: emacs-orgmode

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
  2020-09-05  4:48 ` Tom Gillespie
@ 2020-09-06  9:36   ` Bastien
  2020-09-06 10:00     ` Tom Gillespie
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2020-09-06  9:36 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: flare, emacs-orgmode

Hi Tom,

Tom Gillespie <tgbugs@gmail.com> writes:

>    This seems like it is probably a bug given that everything else
> about archive headings is disabled.

Yes, I agree this should considered as a bug.

I have a fix for it, which is to ignore archived subtrees along with
commented ones when tangling.

org-in-commented-heading-p is used in these Babel functions:

- org-babel-exp-process-buffer
- org-babel-ref-resolve
- org-babel-expand-noweb-references

Should we treat archived subtrees like commented ones in these
contexts too?  Respectively when exporting, resolving refs and
expanding noweb references?

I'd favor such an equal treatment of commented/archived subtrees but
I'd like to make sure it sounds good to everyone before.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
  2020-09-06  9:36   ` Bastien
@ 2020-09-06 10:00     ` Tom Gillespie
  2020-09-07  4:52       ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Gillespie @ 2020-09-06 10:00 UTC (permalink / raw)
  To: Bastien; +Cc: flare, emacs-orgmode

Hi Bastien,
    My initial reaction was to say yes to all of these in the name of
consistency, but there are nuances for org-babel-ref-resolve and
org-babel-expand-noweb-references that are different than for
org-babel-exp-process-buffer. If I have a block that nowebbs in
another block, and at some point that other block is archived, do we
treat it as if the block never existed? I don't think we do. Same for
org-babel-ref-resolve. Those names exist and we know they exist, we
just don't display/export them. I'm basing this on the assumption that
users who archive headings don't want to see them/search them, not
that they wanted to remove them entirely or refactor things related to
them. It might make sense to warn if a block that is nowebbed in has
been archived so the user can do something about it if they want, but
I think having archiving effectively induce a null pointer is a bad
idea. I wonder what other perspectives there are on this. Best!
Tom

On Sun, Sep 6, 2020 at 2:37 AM Bastien <bzg@gnu.org> wrote:
> - org-babel-exp-process-buffer
Yes
> - org-babel-ref-resolve
Probably not?
> - org-babel-expand-noweb-references
Probably not?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
  2020-09-06 10:00     ` Tom Gillespie
@ 2020-09-07  4:52       ` Bastien
  2020-09-08  6:54         ` Tom Gillespie
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2020-09-07  4:52 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: flare, emacs-orgmode

Thanks Tom for the feedback.

>> - org-babel-exp-process-buffer
> Yes
>> - org-babel-ref-resolve
> Probably not?
>> - org-babel-expand-noweb-references
> Probably not?

I've done this in master now, see 9f0af69dd2.

Best,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FEATURE REQUEST] No tangle of code blocks within archived subtrees
  2020-09-07  4:52       ` Bastien
@ 2020-09-08  6:54         ` Tom Gillespie
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Gillespie @ 2020-09-08  6:54 UTC (permalink / raw)
  To: Bastien; +Cc: flare, emacs-orgmode

Great, thank you. Also handy to see the "right" way to traverse up the
tree. Best!
Tom

On Sun, Sep 6, 2020 at 9:52 PM Bastien <bzg@gnu.org> wrote:
>
> Thanks Tom for the feedback.
>
> >> - org-babel-exp-process-buffer
> > Yes
> >> - org-babel-ref-resolve
> > Probably not?
> >> - org-babel-expand-noweb-references
> > Probably not?
>
> I've done this in master now, see 9f0af69dd2.
>
> Best,
>
> --
>  Bastien


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-08  6:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05  1:31 [FEATURE REQUEST] No tangle of code blocks within archived subtrees flare
2020-09-05  4:48 ` Tom Gillespie
2020-09-06  9:36   ` Bastien
2020-09-06 10:00     ` Tom Gillespie
2020-09-07  4:52       ` Bastien
2020-09-08  6:54         ` Tom Gillespie

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