emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* include an .org file and lower the level of all its headers
@ 2010-11-10  9:46 Jianshi Huang
  2010-11-10 11:09 ` Scot Becker
  2010-11-12 19:42 ` Carsten Dominik
  0 siblings, 2 replies; 8+ messages in thread
From: Jianshi Huang @ 2010-11-10  9:46 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-10  9:46 include an .org file and lower the level of all its headers Jianshi Huang
@ 2010-11-10 11:09 ` Scot Becker
  2010-11-10 19:06   ` Mark Elston
  2010-11-12 19:42 ` Carsten Dominik
  1 sibling, 1 reply; 8+ messages in thread
From: Scot Becker @ 2010-11-10 11:09 UTC (permalink / raw)
  To: Jianshi Huang; +Cc: emacs-orgmode


[-- 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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-10 11:09 ` Scot Becker
@ 2010-11-10 19:06   ` Mark Elston
  2010-11-10 19:35     ` Samuel Wales
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Elston @ 2010-11-10 19:06 UTC (permalink / raw)
  To: 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
>

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

* Re: include an .org file and lower the level of all its headers
  2010-11-10 19:06   ` Mark Elston
@ 2010-11-10 19:35     ` Samuel Wales
  0 siblings, 0 replies; 8+ messages in thread
From: Samuel Wales @ 2010-11-10 19:35 UTC (permalink / raw)
  To: Mark Elston; +Cc: emacs-orgmode

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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-10  9:46 include an .org file and lower the level of all its headers Jianshi Huang
  2010-11-10 11:09 ` Scot Becker
@ 2010-11-12 19:42 ` Carsten Dominik
  2010-11-14  7:01   ` Puneeth
  1 sibling, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2010-11-12 19:42 UTC (permalink / raw)
  To: Jianshi Huang; +Cc: emacs-orgmode


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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-12 19:42 ` Carsten Dominik
@ 2010-11-14  7:01   ` Puneeth
  2010-11-15 10:18     ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Puneeth @ 2010-11-14  7:01 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Jianshi Huang

[-- 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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-14  7:01   ` Puneeth
@ 2010-11-15 10:18     ` Carsten Dominik
  2011-04-20 18:48       ` Robert Goldman
  0 siblings, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2010-11-15 10:18 UTC (permalink / raw)
  To: Puneeth; +Cc: emacs-orgmode, Jianshi Huang

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

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

* Re: include an .org file and lower the level of all its headers
  2010-11-15 10:18     ` Carsten Dominik
@ 2011-04-20 18:48       ` Robert Goldman
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Goldman @ 2011-04-20 18:48 UTC (permalink / raw)
  To: Org Mode

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

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

end of thread, other threads:[~2011-04-20 18:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-10  9:46 include an .org file and lower the level of all its headers Jianshi Huang
2010-11-10 11:09 ` Scot Becker
2010-11-10 19:06   ` Mark Elston
2010-11-10 19:35     ` Samuel Wales
2010-11-12 19:42 ` Carsten Dominik
2010-11-14  7:01   ` Puneeth
2010-11-15 10:18     ` Carsten Dominik
2011-04-20 18:48       ` Robert Goldman

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