emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* mirror text in same/other org buffer
@ 2017-11-22  9:53 Xebar Saram
  2017-11-22 11:40 ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2017-11-22  9:53 UTC (permalink / raw)
  To: org mode

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

Hi alll

Im looking for a way to to mirror/auto populate a section of text in
another location in the same org buffer and/or other org file.

for example, i manage my config files in org mode for multiple machines. i
want to have a section like this

#+BEGIN_SRC conf :mkdirp yes :tangle ~/machine A
CODE
#+END_SRC
where the same content of CODE is mirroed/auto generated in another code
block for machine B

#+BEGIN_SRC conf :mkdirp yes :tangle ~/machine B
CODE
#+END_SRC

is this in anyway possible?

[-- Attachment #2: Type: text/html, Size: 705 bytes --]

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

* Re: mirror text in same/other org buffer
  2017-11-22  9:53 mirror text in same/other org buffer Xebar Saram
@ 2017-11-22 11:40 ` Kaushal Modi
  2017-11-23  6:16   ` Xebar Saram
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2017-11-22 11:40 UTC (permalink / raw)
  To: Xebar Saram; +Cc: emacs-org list

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

On Wed, Nov 22, 2017, 4:55 AM Xebar Saram <zeltakc@gmail.com> wrote:

> Hi alll
>

Hello

Im looking for a way to to mirror/auto populate a section of text in
> another location in the same org buffer and/or other org file.
>
> for example, i manage my config files in org mode for multiple machines. i
> want to have a section like this
>
> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine A
> CODE
> #+END_SRC
> where the same content of CODE is mirroed/auto generated in another code
> block for machine B
>
> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine B
> CODE
> #+END_SRC
>
> is this in anyway possible?
>

You cannot have real-time mirroring of content in the Org file itself.

But you can implement that DRY model by using Noweb references (See the
"Noweb reference syntax" node in the Org manual).

You can put the CODE in a separate src block with :noweb-ref set to foo,
and then wherever in other code blocks you want to mirror that, you simply
put <<foo>>.

As I said you won't see the mirroring happen live in the Org buffer. But
you will see the mirroring done in the exported files.

PS: For non-code mirroring (in exported files), there's also do:

  #+INCLUDE: "./can-be-same-file.org::#CUSTOM_ID" :only-contents t

(See the "Include files" node in the Org manual for more.)

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2420 bytes --]

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

* Re: mirror text in same/other org buffer
  2017-11-22 11:40 ` Kaushal Modi
@ 2017-11-23  6:16   ` Xebar Saram
  2017-11-24  6:20     ` Xebar Saram
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2017-11-23  6:16 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

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

thx!

that works well for me :D

best and happy holidays :)

Z

On Wed, Nov 22, 2017 at 1:40 PM, Kaushal Modi <kaushal.modi@gmail.com>
wrote:

> On Wed, Nov 22, 2017, 4:55 AM Xebar Saram <zeltakc@gmail.com> wrote:
>
>> Hi alll
>>
>
> Hello
>
> Im looking for a way to to mirror/auto populate a section of text in
>> another location in the same org buffer and/or other org file.
>>
>> for example, i manage my config files in org mode for multiple machines.
>> i want to have a section like this
>>
>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine A
>> CODE
>> #+END_SRC
>> where the same content of CODE is mirroed/auto generated in another code
>> block for machine B
>>
>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine B
>> CODE
>> #+END_SRC
>>
>> is this in anyway possible?
>>
>
> You cannot have real-time mirroring of content in the Org file itself.
>
> But you can implement that DRY model by using Noweb references (See the
> "Noweb reference syntax" node in the Org manual).
>
> You can put the CODE in a separate src block with :noweb-ref set to foo,
> and then wherever in other code blocks you want to mirror that, you simply
> put <<foo>>.
>
> As I said you won't see the mirroring happen live in the Org buffer. But
> you will see the mirroring done in the exported files.
>
> PS: For non-code mirroring (in exported files), there's also do:
>
>   #+INCLUDE: "./can-be-same-file.org::#CUSTOM_ID" :only-contents t
>
> (See the "Include files" node in the Org manual for more.)
>
> --
>
> Kaushal Modi
>

[-- Attachment #2: Type: text/html, Size: 3053 bytes --]

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

* Re: mirror text in same/other org buffer
  2017-11-23  6:16   ` Xebar Saram
@ 2017-11-24  6:20     ` Xebar Saram
  2017-11-24  6:30       ` Xebar Saram
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2017-11-24  6:20 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

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

Hi again, i posted a separate issue on multiple code blocks in babel
creating 1 config but then realized this actually is very appropriate for
this thread...apologize for that.

@Kaushal, the method you suggested works really well for 1 code block=1
config file. but what happens when my config file is made out of 1 few
babel code blocks that i tangle together into 1 config file. for example:

 * tmux conf
 :PROPERTIES:
 :header-args: :noweb yes  :tangle /zeltak@132.72.155.204:~/.tmux.conf
 :END:

***** Mouse
      :PROPERTIES:
      :ID:       ba8ce7aa-2b3b-43be-816d-ea2ab515a999
      :END:
#+BEGIN_SRC conf
#-------------->  mouse
setw -g mouse on
set-option -g status-keys vi
#+END_SRC

***** Theme and look
      :PROPERTIES:
      :ID:       85257f51-1306-4caf-a055-a6df3afac1a5
      :END:
#+BEGIN_SRC conf
#--------------> THEME AND LOOK
#default theme picker
source /home/zeltak/.tmux/neonB
#source /home/zeltak/.tmux/solarized-dark
#+END_SRC

how do i add a name (#+NAME) argument that covers all the sub headers that
will make '.tmux.conf'.
and then using noweb how does one reffer to that name <<tmux.conf>> that
will cover all the tiny blocks that create the tmux.conf?

best!

Z


On Thu, Nov 23, 2017 at 8:16 AM, Xebar Saram <zeltakc@gmail.com> wrote:

> thx!
>
> that works well for me :D
>
> best and happy holidays :)
>
> Z
>
> On Wed, Nov 22, 2017 at 1:40 PM, Kaushal Modi <kaushal.modi@gmail.com>
> wrote:
>
>> On Wed, Nov 22, 2017, 4:55 AM Xebar Saram <zeltakc@gmail.com> wrote:
>>
>>> Hi alll
>>>
>>
>> Hello
>>
>> Im looking for a way to to mirror/auto populate a section of text in
>>> another location in the same org buffer and/or other org file.
>>>
>>> for example, i manage my config files in org mode for multiple machines.
>>> i want to have a section like this
>>>
>>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine A
>>> CODE
>>> #+END_SRC
>>> where the same content of CODE is mirroed/auto generated in another code
>>> block for machine B
>>>
>>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine B
>>> CODE
>>> #+END_SRC
>>>
>>> is this in anyway possible?
>>>
>>
>> You cannot have real-time mirroring of content in the Org file itself.
>>
>> But you can implement that DRY model by using Noweb references (See the
>> "Noweb reference syntax" node in the Org manual).
>>
>> You can put the CODE in a separate src block with :noweb-ref set to foo,
>> and then wherever in other code blocks you want to mirror that, you simply
>> put <<foo>>.
>>
>> As I said you won't see the mirroring happen live in the Org buffer. But
>> you will see the mirroring done in the exported files.
>>
>> PS: For non-code mirroring (in exported files), there's also do:
>>
>>   #+INCLUDE: "./can-be-same-file.org::#CUSTOM_ID" :only-contents t
>>
>> (See the "Include files" node in the Org manual for more.)
>>
>> --
>>
>> Kaushal Modi
>>
>
>

[-- Attachment #2: Type: text/html, Size: 5173 bytes --]

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

* Re: mirror text in same/other org buffer
  2017-11-24  6:20     ` Xebar Saram
@ 2017-11-24  6:30       ` Xebar Saram
  2017-11-24 16:28         ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2017-11-24  6:30 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

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

Ok found the answer "hidden" away in a org manual page.. :)

The solution it so to use ':noweb-ref NAME' as an argument in the drawer

sorry for the noise

Z

On Fri, Nov 24, 2017 at 8:20 AM, Xebar Saram <zeltakc@gmail.com> wrote:

> Hi again, i posted a separate issue on multiple code blocks in babel
> creating 1 config but then realized this actually is very appropriate for
> this thread...apologize for that.
>
> @Kaushal, the method you suggested works really well for 1 code block=1
> config file. but what happens when my config file is made out of 1 few
> babel code blocks that i tangle together into 1 config file. for example:
>
>  * tmux conf
>  :PROPERTIES:
>  :header-args: :noweb yes  :tangle /zeltak@132.72.155.204:~/.tmux.conf
>  :END:
>
> ***** Mouse
>       :PROPERTIES:
>       :ID:       ba8ce7aa-2b3b-43be-816d-ea2ab515a999
>       :END:
> #+BEGIN_SRC conf
> #-------------->  mouse
> setw -g mouse on
> set-option -g status-keys vi
> #+END_SRC
>
> ***** Theme and look
>       :PROPERTIES:
>       :ID:       85257f51-1306-4caf-a055-a6df3afac1a5
>       :END:
> #+BEGIN_SRC conf
> #--------------> THEME AND LOOK
> #default theme picker
> source /home/zeltak/.tmux/neonB
> #source /home/zeltak/.tmux/solarized-dark
> #+END_SRC
>
> how do i add a name (#+NAME) argument that covers all the sub headers that
> will make '.tmux.conf'.
> and then using noweb how does one reffer to that name <<tmux.conf>> that
> will cover all the tiny blocks that create the tmux.conf?
>
> best!
>
> Z
>
>
> On Thu, Nov 23, 2017 at 8:16 AM, Xebar Saram <zeltakc@gmail.com> wrote:
>
>> thx!
>>
>> that works well for me :D
>>
>> best and happy holidays :)
>>
>> Z
>>
>> On Wed, Nov 22, 2017 at 1:40 PM, Kaushal Modi <kaushal.modi@gmail.com>
>> wrote:
>>
>>> On Wed, Nov 22, 2017, 4:55 AM Xebar Saram <zeltakc@gmail.com> wrote:
>>>
>>>> Hi alll
>>>>
>>>
>>> Hello
>>>
>>> Im looking for a way to to mirror/auto populate a section of text in
>>>> another location in the same org buffer and/or other org file.
>>>>
>>>> for example, i manage my config files in org mode for multiple
>>>> machines. i want to have a section like this
>>>>
>>>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine A
>>>> CODE
>>>> #+END_SRC
>>>> where the same content of CODE is mirroed/auto generated in another
>>>> code block for machine B
>>>>
>>>> #+BEGIN_SRC conf :mkdirp yes :tangle ~/machine B
>>>> CODE
>>>> #+END_SRC
>>>>
>>>> is this in anyway possible?
>>>>
>>>
>>> You cannot have real-time mirroring of content in the Org file itself.
>>>
>>> But you can implement that DRY model by using Noweb references (See the
>>> "Noweb reference syntax" node in the Org manual).
>>>
>>> You can put the CODE in a separate src block with :noweb-ref set to foo,
>>> and then wherever in other code blocks you want to mirror that, you simply
>>> put <<foo>>.
>>>
>>> As I said you won't see the mirroring happen live in the Org buffer. But
>>> you will see the mirroring done in the exported files.
>>>
>>> PS: For non-code mirroring (in exported files), there's also do:
>>>
>>>   #+INCLUDE: "./can-be-same-file.org::#CUSTOM_ID" :only-contents t
>>>
>>> (See the "Include files" node in the Org manual for more.)
>>>
>>> --
>>>
>>> Kaushal Modi
>>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 6789 bytes --]

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

* Re: mirror text in same/other org buffer
  2017-11-24  6:30       ` Xebar Saram
@ 2017-11-24 16:28         ` Kaushal Modi
  0 siblings, 0 replies; 6+ messages in thread
From: Kaushal Modi @ 2017-11-24 16:28 UTC (permalink / raw)
  To: Xebar Saram; +Cc: emacs-org list

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

On Fri, Nov 24, 2017, 1:30 AM Xebar Saram <zeltakc@gmail.com> wrote:

> Ok found the answer "hidden" away in a org manual page.. :)
>
> The solution it so to use ':noweb-ref NAME' as an argument in the drawer
>

Yes. I actually prefer to use that method. You need the #+NAME style block
naming only when you want to call a Noweb block with an argument.

sorry for the noise
>

No worries.

> --

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1727 bytes --]

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

end of thread, other threads:[~2017-11-24 16:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22  9:53 mirror text in same/other org buffer Xebar Saram
2017-11-22 11:40 ` Kaushal Modi
2017-11-23  6:16   ` Xebar Saram
2017-11-24  6:20     ` Xebar Saram
2017-11-24  6:30       ` Xebar Saram
2017-11-24 16:28         ` Kaushal Modi

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