Hi, I know I can include any file using #+INCLUDE. I need to include several org files, but they were edited independently as a complete document. Now I want to lower the levels of headers in these org files automatically during inclusion. Is there a way to do that? Cheers, Jianshi
[-- Attachment #1.1: Type: text/plain, Size: 885 bytes --] Jianshi, I've never heard of any way to do that with an #+INCLUDE. There are variables that automatically demote subtrees that you yank in with CTRL-Y, but that's a hard-INCLUDE, so to speak, and you probably have your reasons for wanting to keep them in separate files. Scot On Wed, Nov 10, 2010 at 9:46 AM, Jianshi Huang <jianshi.huang@gmail.com>wrote: > Hi, > > I know I can include any file using #+INCLUDE. > > I need to include several org files, but they were edited > independently as a complete document. > > Now I want to lower the levels of headers in these org files > automatically during inclusion. Is there a way to do that? > > > Cheers, > Jianshi > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > [-- Attachment #1.2: Type: text/html, Size: 1370 bytes --] [-- Attachment #2: Type: text/plain, Size: 201 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Scott,
I don't know about Jianshi's specific needs but I have also wanted
the same thing for myself.
I often put together "standard" information on a variety of topics that
I talk about in separate files. When I put together a talk for a given
topic I include many of these sub-topics in a given talk. However, I
usually need different "surrounding" material to preface these topics
and draw conclusions relevant to the main topic. I would like to be
able to continue to have these sub-topics in separate files and just
include them (by reference - so to speak) in my notes without having
to adjust their heading levels or pasting them directly into my notes.
Mark
On 11/10/2010 3:09 AM, Scot Becker wrote:
> Jianshi,
>
> I've never heard of any way to do that with an #+INCLUDE. There are
> variables that automatically demote subtrees that you yank in with
> CTRL-Y, but that's a hard-INCLUDE, so to speak, and you probably have
> your reasons for wanting to keep them in separate files.
>
> Scot
>
>
> On Wed, Nov 10, 2010 at 9:46 AM, Jianshi Huang <jianshi.huang@gmail.com
> <mailto:jianshi.huang@gmail.com>> wrote:
>
> Hi,
>
> I know I can include any file using #+INCLUDE.
>
> I need to include several org files, but they were edited
> independently as a complete document.
>
> Now I want to lower the levels of headers in these org files
> automatically during inclusion. Is there a way to do that?
>
>
> Cheers,
> Jianshi
>
I have often wanted this, specified by org-id, to include a subtree. I would not want it to be in a separate file, but that could be arranged also, in principle. I have also wanted to include the body text of a node without any structure at all directly into some text. Just insert those paragraphs into the middle of the body text of a node using org-id to specify the text to be included. I don't know if we are all talking about the same thing. If babel or links don't work adequately for this purpose the way they are now, there is a specific proposal for a universal syntax that might be useful. It hasn't been implemented yet. Search for "extensible syntax" and "parsing risk" and "ID markers". It's been discussed for text color and link visitedness, among other things. Samuel
On Nov 10, 2010, at 3:46 AM, Jianshi Huang wrote:
> Hi,
>
> I know I can include any file using #+INCLUDE.
>
> I need to include several org files, but they were edited
> independently as a complete document.
>
> Now I want to lower the levels of headers in these org files
> automatically during inclusion. Is there a way to do that?
No. But since #+include accepts arguments, it could be implemented,
something like
#+include "aaa.org" :minlevel 4
or so. I would accept a good patch to this effect.
- Carsten
[-- Attachment #1: Type: text/plain, Size: 729 bytes --] On Sat, Nov 13, 2010 at 1:12 AM, Carsten Dominik <carsten.dominik@gmail.com> wrote: > > On Nov 10, 2010, at 3:46 AM, Jianshi Huang wrote: > >> Hi, >> >> I know I can include any file using #+INCLUDE. >> >> I need to include several org files, but they were edited >> independently as a complete document. >> >> Now I want to lower the levels of headers in these org files >> automatically during inclusion. Is there a way to do that? > > No. But since #+include accepts arguments, it could be implemented, > something like > > #+include "aaa.org" :minlevel 4 > > or so. I would accept a good patch to this effect. Here's a patch. I tested it with a simple document and works fine. Thanks, Puneeth [-- Attachment #2: org-export-minlevel.patch.txt --] [-- Type: text/plain, Size: 2031 bytes --] diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 2affcba..08c0ac6 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2126,12 +2126,13 @@ TYPE must be a string, any of: (defun org-export-handle-include-files () "Include the contents of include files, with proper formatting." (let ((case-fold-search t) - params file markup lang start end prefix prefix1 switches all) + params file markup lang start end prefix prefix1 switches all minlevel) (goto-char (point-min)) (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t) (setq params (read (concat "(" (match-string 1) ")")) prefix (org-get-and-remove-property 'params :prefix) prefix1 (org-get-and-remove-property 'params :prefix1) + minlevel (org-get-and-remove-property 'params :minlevel) file (org-symname-or-string (pop params)) markup (org-symname-or-string (pop params)) lang (and (member markup '("src" "SRC")) @@ -2154,7 +2155,7 @@ TYPE must be a string, any of: end (format "#+end_%s" markup)))) (insert (or start "")) (insert (org-get-file-contents (expand-file-name file) - prefix prefix1 markup)) + prefix prefix1 markup minlevel)) (or (bolp) (newline)) (insert (or end "")))) all)) @@ -2171,7 +2172,7 @@ TYPE must be a string, any of: (when intersection (error "Recursive #+INCLUDE: %S" intersection)))))) -(defun org-get-file-contents (file &optional prefix prefix1 markup) +(defun org-get-file-contents (file &optional prefix prefix1 markup minlevel) "Get the contents of FILE and return them as a string. If PREFIX is a string, prepend it to each line. If PREFIX1 is a string, prepend it to the first line instead of PREFIX. @@ -2193,6 +2194,9 @@ take care of the block they are in." (goto-char (match-beginning 0)) (insert ",") (end-of-line 1))) + (when minlevel + (dotimes (lvl minlevel) + (org-map-region 'org-demote (point-min) (point-max)))) (buffer-string))) (defun org-get-and-remove-property (listvar prop) [-- Attachment #3: Type: text/plain, Size: 201 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Accepted. I added the proper ChangeLog entries and documented the
change in the manual.
Thanks
- Carsten
On Nov 14, 2010, at 8:01 AM, Puneeth wrote:
> On Sat, Nov 13, 2010 at 1:12 AM, Carsten Dominik
> <carsten.dominik@gmail.com> wrote:
>>
>> On Nov 10, 2010, at 3:46 AM, Jianshi Huang wrote:
>>
>>> Hi,
>>>
>>> I know I can include any file using #+INCLUDE.
>>>
>>> I need to include several org files, but they were edited
>>> independently as a complete document.
>>>
>>> Now I want to lower the levels of headers in these org files
>>> automatically during inclusion. Is there a way to do that?
>>
>> No. But since #+include accepts arguments, it could be implemented,
>> something like
>>
>> #+include "aaa.org" :minlevel 4
>>
>> or so. I would accept a good patch to this effect.
>
> Here's a patch. I tested it with a simple document and works fine.
>
> Thanks,
> Puneeth
> <org-export-minlevel.patch.txt>
- Carsten
This is a feature that I was just looking for, and I'm pretty excited about it. However, I find that providing this new facility leads me to look for another one: relativizing links. It seems like when I include another file, the links in that other file get messed up. In particular, I have figures in the sub-file, and AFAICT it looks like the sub-files file links aren't working correctly. Or maybe that's not what's really wrong: the symptoms I am seeing are missing pdfs + a blizzard of warnings that look like this: No match - create this as a new heading? (y or n) I suspect that this message is intended to be seen at a time when its meaning will be more obvious to the user. Any suggestions? thanks, r