org-transclusion icon indicating copy to clipboard operation
org-transclusion copied to clipboard

Some feature request

Open driftcrow opened this issue 3 years ago • 3 comments

thanks very much for an extremely useful mode. I like this package, and I wish this package can stead build-in ox-include package.

I consider #+include for a while, I wish it can have some features like:

  • support include multiple file format (ms office docx、xlsx... any other file format ,even an image file , just provide some pre-define format convert funtion)
  • support remote source file (url fetch page、files ...)
  • support user's customize pre-process with include contend (like file format covert, image file adjust ....)
  • support user's customize after-process with include contend ( content clean, advanced select....)
  • support some option like :if or :when define condition include

the important thing to implementation all these features is support user can customize pre-process .

I have create a project includeplus implementation some of these features, it just a prototype , can used basicly。 principle is: contact all string in #+plus:setences to expression , then process these before expand-include

#+plus:(url-fetch-some-thing) (file-formate-covert) (content-clean) #+plus: (filter-with-REGX) ..... #+include: xxxx

my elisp skill is too low and have no time to learn , and some features are overlaped。so I wish you can interest with these and implementation all these features in your awesome package.

driftcrow avatar Jun 29 '21 09:06 driftcrow

Thank you for your kind words.

I have been giving my thoughts into your request for a while. It contains elements that go beyond my original motivation for Org-transclusion and my current Elisp skills.

I wrote Org-transclusion to help me write a book (non-technical). I would like to stick to this original intent for now. Beyond this, I would need to ask others to contribute to the package.

Now let me respond to the elements of your feature request.

support include multiple file format (ms office docx、xlsx... any other file format ,even an image file , just provide some pre-define format convert funtion)

To some degree, this is already part of Org Mode (not even Org-transclusion). You can have image files in Org files.

For Microsoft Office files, I see them as export targets, rather than parts of your writing material. For my personal writing projects, I would not need to pull in some parts of MS Word files to compose my writing -- my notes are in text format.

I feel that benefits of this feature are not worth the potentially large efforts.

support remote source file (url fetch page、files ...)

In a way, I feel that it might be somehow possible with Org Mode already... The way Org-transclusion works is to use the standard Org Mode's link functions -- as long as they can get to a remote file, open it as a buffer, I think it might be already possible.

I don't work with remote source files, so I don't know how Org Mode does this. Perhaps something you could try on your end and see if gaps can be easily filled.

In the next update, I am considering a feature that supports parts of source files (beyond extension .txt). It might be of your interest.

support user's customize pre-process with include contend (like file format covert, image file adjust ....)

For the current release, I have made substantial changes to the internal working of Org-transclusion. This should make it easier to do "pre-process" -- it is to be leveraged for the next release. Actually, the existing features are already using this "pre-processing" feature.

It is made for text files. I don't think I will do anything special for image files. But I feel that it might be already possible with flexibility of Elisp script. You could use shell commands (even on Windows) to call Imagemagick (or equivalent) to manipulate your images within your custom function, and then link it in an Org file. Perhaps this is an avenue you would like to explore for a custom function.

support user's customize after-process with include contend ( content clean, advanced select....)

It's similar to pre-process but I'm not sure if I need this to be part of Org-transclusion -- in a way, it's already done -- the format of the text transcluded is "post-processed" to take into account the indentation settings of the user -- some users turn indentation on, others, off.

Anything beyond this, at this stage, you would be looking to use the standard advising facilities of Emacs.

support some option like :if or :when define condition include

It's an interesting thought -- what would be your use case? Is this something useful for programmers?

I do not think I will do anything like this myself. If I want to transclude a text content, I put #+transclude:; if I don't need that text content, I simply don't do it.

nobiot avatar Jul 03 '21 10:07 nobiot

Thank for you patience.

Yes, The main feature I wanted is pre-process. sorry for my disorganised words caused confuse. and my purpose is work for text format too, the image file here is just mean a text link :cry:

pre-process and after-process may mean one thing, separate them just for easy to understand. in my opinion, pre-process do some thing when before create include temp buffer (like: covert some files to text, then insert it to temp buffer ... all these functions can created by user self) , and after-process process on this temp buffer ( like: kill or keep some line according REGX...)

:if :when can used when like export use different backend , or when different project export defined in publish config.

the first two feature are not really, these can reached through pre-process feature if you implementation it.

digressions: why I need these features? In my office and any others, all other peoples don't use emacs, they usually use ms word write something ,and excel for table..., and I want use org-mode write anything , so I wish org-mode can cooperate with these file format, in theory the source block can archive some of goals, but this method has some problem in some thing: reuse code 、structure clean、control content location level ..., so I think include is the best place to implementation these.

if these can be implementation, then I can arrange my colleague maintenance some data about his job , he can use the tool excel or others , and I can simply and free include the needed data from his data files. this is one scene, and I think there are many scenes can use this .

driftcrow avatar Jul 04 '21 04:07 driftcrow

It was not clear in my previous reponse; pre- and post-process are already implemented in the current version.

I have not done a clear instructiow how you might be able to use the facilities. Just as a quick overview:

  1. Pre-processing is done via org-transclusion-add-functions
  2. Post-processing is done via org-transclusion-content-format-functions

They are meant to make it easy to extend the core functionaly, which I would like to keep minimal but as robust and easy-to-maintain as I can with my current skills.

The new version 0.2.1 is now being implemented with using them as if it were an extension -- it is to enhance the function to transclude source files beyond .txt file (See section Road Map after v0.2.0 in issue #81). You can inspect how the pre- and post-processing are done by looking at org-transclusion-src-lines.el in the working branch for v0.2.1. The new features are being added via hooks placed before and after transclusion.

nobiot avatar Jul 04 '21 16:07 nobiot