From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: transcluding some org-elements in multiple places Date: Thu, 05 Jan 2017 11:37:55 -0500 Message-ID: References: <3d4bfe3d30ae4c5a8be905fa6b15f350@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <87shpx5aov.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPB3E-00037D-Fu for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:38:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPB3A-0004X1-Ee for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:38:04 -0500 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:33772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cPB3A-0004Wj-AT for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:38:00 -0500 Received: by mail-qt0-x22a.google.com with SMTP id v23so55512938qtb.0 for ; Thu, 05 Jan 2017 08:37:58 -0800 (PST) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: David Talmage , Org Mode Mailing List I played with it a bit. Here is a link that displays file links as overlays. Clicking on them jump to the source, and C-click will toggle the overlay. It works ok, but I didn't test it a lot. Say you have a table named like this in a file. #+name: test | 555 | 66 | | te | tef | | 555 | ftre 5f | | 555 | ftre 5f | This link will display the table. transclude:file:transcluding-org-elements.org::test This link will display the headline named archive. transclude:file:transcluding-org-elements.org::*archive Here is the code. #+BEGIN_SRC emacs-lisp :results silent (defvar *transclude* t "Put overlays on or not") (setq *transclude* t) (org-link-set-parameters "transclude" :face '(:background "gray80") :follow (lambda (path) (org-open-link-from-string path)) :keymap (let ((map (copy-keymap org-mouse-map))) (define-key map [C-mouse-1] (lambda () (interactive) (setq *transclude* (not *transclude*)) (unless *transclude* (ov-clear 'transclude)) (font-lock-fontify-buffer))) map) :help-echo "Transcluded element. Click to open source. C-mouse-1 to toggle overlay." :activate-func (lambda (start end path bracketp) (if *transclude* (let ((ov (make-overlay start end)) el disp) (ov-put ov 'transclude t) (save-window-excursion (org-open-link-from-string path) (setq el (org-element-context)) (setq disp (buffer-substring (org-element-property :begin el) (- (org-element-property :end el) (or (org-element-property :post-blank el) 0)))) (ov-put ov 'display disp))) (ov-clear 'transclude 'any start end)))) #+END_SRC Matt Price writes: > On Wed, Dec 14, 2016 at 11:55 AM, John Kitchin > wrote: > >> >> David Talmage writes: >> >> > On Fri, Dec 9, 2016 at 11:28 AM, Eric S Fraga wrote: >> > >> >> On Friday, 9 Dec 2016 at 15:29, John Kitchin wrote: >> >> > Hi all, >> >> > >> >> > I have an idea for how I could transclude "copies" or links to >> >> >> >> [...] >> >> >> >> > Any thoughts? Do you see any potential issues? >> >> >> >> Potentially very interesting and useful idea. Some thoughts/issues: >> >> >> >> >> > I'm interested in this, too. In my lab notebook org file, I have a >> section >> > that should be put into its own file and either linked or transcluded in >> > several places. Transclusion would be better because I could see the >> text >> > without following a link. It suits my lazy nature. ;-) >> >> It turns out to be pretty easy to see the text; that can be done with a >> simple overlay. What is not easy, is to be able to edit the text, or use >> the text with org-machinery, e.g. org-map-entries. The text in the >> overlay is not visible to the org-machinery, so you can not get >> properties, edit it, etc... Editing could be made possible with a >> special buffer, but it doesn't seem likely that you can make the overlay >> display work with many org-functions. >> > Have you had an opportunity to work o nthis at all? For my purposes, even > having the transcluded text visible in a buffer + included in an export > would be a major improvement over, say, a link. attempting to edit would, > I guess, pop up a special narrowed buffer that edits the original text. > Those 3 features together would cover maybe 90% of what I personally need, > so if you have the code for this, I would really love to see it. Thank you! > > Matt -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu