emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [ox, patch] Quickly INCLUDE from own file
@ 2014-10-07  9:40 Rasmus
  2014-10-07 14:02 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus @ 2014-10-07  9:40 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

Hi,

The attached patch allows for "quick" (== without filename) inclusion
from the same file.  Why?  'Cause I'm lazy and it would be useful to
push boring, location-specific stuff to the end of the file.

Here's an example:

    * poor man's ~:ignoreheading:~
    #+INCLUDE: "::*foo" :only-contents t

    #+INCLUDE: "::tbl"

    * foo                                                   :noexport:
    1

    * bar                                                   :noexport:
    #+NAME: tbl
    | 1 |

You need the preceding "::" to be able tell the difference between the
file "tbl" and the table "tbl".  Granted, this doesn't look like an
org link.  If that's an issue, for each link sans location it could be
tested if it exists in the current buffer.

Do you think something like this would be desirable?

—Rasmus

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-Quickly-INCLUDE-contents-from-same-file.patch --]
[-- Type: text/x-diff, Size: 859 bytes --]

From f8fcf5b6816fa7e3e4cc9cc64b12c5cced4a546c Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@pank.eu>
Date: Tue, 7 Oct 2014 11:20:10 +0200
Subject: [PATCH] ox: Quickly INCLUDE contents from same file.

* ox.el (org-export-expand-include-keyword): Try buffer file
name if filename is nil.
---
 lisp/ox.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index ec52203..ded3b2f 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3349,8 +3349,9 @@ paths."
 				      (setq matched
 					    (replace-match "" nil nil matched 1)))
 				    (expand-file-name
-				     (org-remove-double-quotes
-				      matched)
+				     (or (org-string-nw-p
+					  (org-remove-double-quotes matched))
+					 (buffer-file-name))
 				     dir)))
 			      (setq value (replace-match "" nil nil value)))))
 		 (only-contents
-- 
2.1.2


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

end of thread, other threads:[~2014-10-07 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-07  9:40 [ox, patch] Quickly INCLUDE from own file Rasmus
2014-10-07 14:02 ` Nicolas Goaziou

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