emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [tip for EXWM users] An alternative method for isolate trees
@ 2021-03-01 12:55 Juan Manuel Macías
  2021-03-01 13:37 ` Julian M. Burgos
  0 siblings, 1 reply; 7+ messages in thread
From: Juan Manuel Macías @ 2021-03-01 12:55 UTC (permalink / raw)
  To: orgmode

Hi,

Since EXWM uses Emacs frames as virtual desktops, I have written this
alternative method of `org-tree-to-indirect-buffer', which I share here.
With this method I can have several isolated trees, with their own name,
and access them quickly (with helm-buffer-list, for example):

#+begin_src emacs-lisp
  (defun my-goto-buffer-regexp (regexp)
    (dolist (buffer (buffer-list))
      (let ((name (buffer-name buffer)))
	(when (and name (not (string-equal name ""))
		   (string-match regexp name))
	  (switch-to-buffer buffer)))))

  (defun my-org-tree-to-indirect-buffer ()
    (interactive)
    (let ((buf (buffer-name))
	  (ind-buf (replace-regexp-in-string "\\[.+\\]" "" (nth 4 (org-heading-components))))
	  (org-indirect-buffer-display 'new-frame))
      (org-tree-to-indirect-buffer)
      (my-goto-buffer-regexp ind-buf)
      (rename-buffer (concat buf "::" ind-buf))))
#+end_src

Best regards,

Juan Manuel 


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-01 12:55 [tip for EXWM users] An alternative method for isolate trees Juan Manuel Macías
@ 2021-03-01 13:37 ` Julian M. Burgos
  2021-03-01 14:10   ` Juan Manuel Macías
  0 siblings, 1 reply; 7+ messages in thread
From: Julian M. Burgos @ 2021-03-01 13:37 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: emacs-orgmode

Hi Juan Manuel,

Thank you, although I tested your functions and compared with the original org-tree-to-indirect-buffer, the only difference I see is that your function creates a new exwm workspace.  The original function already creates indirect buffers with their own names (using a slash instead of the double colons).  Or I am missing something?

My best,

Julian

Juan Manuel Macías writes:

> Hi,
>
> Since EXWM uses Emacs frames as virtual desktops, I have written this
> alternative method of `org-tree-to-indirect-buffer', which I share here.
> With this method I can have several isolated trees, with their own name,
> and access them quickly (with helm-buffer-list, for example):
>
> #+begin_src emacs-lisp
>   (defun my-goto-buffer-regexp (regexp)
>     (dolist (buffer (buffer-list))
>       (let ((name (buffer-name buffer)))
> 	(when (and name (not (string-equal name ""))
> 		   (string-match regexp name))
> 	  (switch-to-buffer buffer)))))
>
>   (defun my-org-tree-to-indirect-buffer ()
>     (interactive)
>     (let ((buf (buffer-name))
> 	  (ind-buf (replace-regexp-in-string "\\[.+\\]" "" (nth 4 (org-heading-components))))
> 	  (org-indirect-buffer-display 'new-frame))
>       (org-tree-to-indirect-buffer)
>       (my-goto-buffer-regexp ind-buf)
>       (rename-buffer (concat buf "::" ind-buf))))
> #+end_src
>
> Best regards,
>
> Juan Manuel


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
  Fornubúðir 5, IS-220 Hafnarfjörður, Iceland
www.hafogvatn.is
Sími/Telephone : +354-5752037
Netfang/Email: julian.burgos@hafogvatn.is


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-01 13:37 ` Julian M. Burgos
@ 2021-03-01 14:10   ` Juan Manuel Macías
  2021-03-01 15:37     ` Julian M. Burgos
  0 siblings, 1 reply; 7+ messages in thread
From: Juan Manuel Macías @ 2021-03-01 14:10 UTC (permalink / raw)
  To: Julian M. Burgos; +Cc: orgmode

Hi Julian, thanks for your comment.

"Julian M. Burgos" <julian.burgos@hafogvatn.is> writes:

> Thank you, although I tested your functions and compared with the
> original org-tree-to-indirect-buffer, the only difference I see is
> that your function creates a new exwm workspace. The original function
> already creates indirect buffers with their own names (using a slash
> instead of the double colons). Or I am missing something?

org-tree-to-indirect-buffer creates a new buffer, but (as far as I know)
does not allow accumulating buffers. In other words, you cannot have
several isolated trees at the time. In this method it just occurred to
me to configure org-indirect-buffer-display as new-frame and take
advantage of EXWM frame management.

Best regards,

Juan Manuel


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-01 14:10   ` Juan Manuel Macías
@ 2021-03-01 15:37     ` Julian M. Burgos
  2021-03-01 16:42       ` Juan Manuel Macías
  2021-03-02  5:44       ` Kyle Meyer
  0 siblings, 2 replies; 7+ messages in thread
From: Julian M. Burgos @ 2021-03-01 15:37 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Hi Juan,

You are right. :) I have not noticed that org-tree-to-indirect-buffer reuses the indirect buffer when you call it for a second time.  According to the manual, "with a C-u prefix, do not remove the previously used indirect buffer", but that does not seem to work.  When you do Cu-Cc-Cx-b from a buffer that already has an indirect buffer you get a "cannot modify an area being edited in a dedicated buffer".  If you try it from a different buffer, the prefix is ignored and the indirect buffer is assigned to the tree from the last buffer.

This does not seem to be a limitation from emacs, as it is possible to open multiple indirect buffers from a base buffer, using for example clone-indirect-buffer.  So it should be possible to make a function combining "clone-indirect-buffer" and "org-narrow-to-subtree" perhaps?  I am thinking so this option is available not only to EXWM users.

Ideally, there should be an option to allow org-tree-to-indirect-buffer to create more than one indirect buffer if desired.

My best,

Julian

Juan Manuel Macías writes:

> Hi Julian, thanks for your comment.
>
> "Julian M. Burgos" <julian.burgos@hafogvatn.is> writes:
>
>> Thank you, although I tested your functions and compared with the
>> original org-tree-to-indirect-buffer, the only difference I see is
>> that your function creates a new exwm workspace. The original function
>> already creates indirect buffers with their own names (using a slash
>> instead of the double colons). Or I am missing something?
>
> org-tree-to-indirect-buffer creates a new buffer, but (as far as I know)
> does not allow accumulating buffers. In other words, you cannot have
> several isolated trees at the time. In this method it just occurred to
> me to configure org-indirect-buffer-display as new-frame and take
> advantage of EXWM frame management.
>
> Best regards,
>
> Juan Manuel


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
  Fornubúðir 5, IS-220 Hafnarfjörður, Iceland
www.hafogvatn.is
Sími/Telephone : +354-5752037
Netfang/Email: julian.burgos@hafogvatn.is


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-01 15:37     ` Julian M. Burgos
@ 2021-03-01 16:42       ` Juan Manuel Macías
  2021-03-02  5:44       ` Kyle Meyer
  1 sibling, 0 replies; 7+ messages in thread
From: Juan Manuel Macías @ 2021-03-01 16:42 UTC (permalink / raw)
  To: Julian M. Burgos; +Cc: orgmode

Hi Julian,

"Julian M. Burgos" <julian.burgos@hafogvatn.is> writes:

> This does not seem to be a limitation from emacs, as it is possible to
> open multiple indirect buffers from a base buffer, using for example
> clone-indirect-buffer. So it should be possible to make a function
> combining "clone-indirect-buffer" and "org-narrow-to-subtree" perhaps?
> I am thinking so this option is available not only to EXWM users.

I think that combining clone-indirect-buffer and org-narrow-to-subtree
would work well. Another way to isolate several trees at once is by
using the excellent package org-sidebar
(https://github.com/alphapapa/org-sidebar). In fact, I borrowed from
this package the idea of renaming the new buffers with the string :: (if
I open helm and start typing ::, it shows me the list of isolated trees,
so it's very useful to have a dedicated string). Although my method for
isolating each tree is more pedestrian :-). And it only makes sense in
EXWM...

Best regards,

Juan Manuel 


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-01 15:37     ` Julian M. Burgos
  2021-03-01 16:42       ` Juan Manuel Macías
@ 2021-03-02  5:44       ` Kyle Meyer
  2021-03-02  9:29         ` Julian M. Burgos
  1 sibling, 1 reply; 7+ messages in thread
From: Kyle Meyer @ 2021-03-02  5:44 UTC (permalink / raw)
  To: Julian M. Burgos; +Cc: Juan Manuel Macías, orgmode

Julian M. Burgos writes:

> I have not noticed that org-tree-to-indirect-buffer
> reuses the indirect buffer when you call it for a second time.
> According to the manual, "with a C-u prefix, do not remove the
> previously used indirect buffer", but that does not seem to work.
> When you do Cu-Cc-Cx-b from a buffer that already has an indirect
> buffer you get a "cannot modify an area being edited in a dedicated
> buffer".  If you try it from a different buffer, the prefix is ignored
> and the indirect buffer is assigned to the tree from the last buffer.

Hmm, could you provide a reproducer for the problem?  Here's what I
tried with the current master (afd75d05a), Emacs 27.1, and no custom
configuration.

--8<---------------cut here---------------start------------->8---
* a
a content
* b
b content
--8<---------------cut here---------------end--------------->8---

 - on "a", C-c C-x b  ;; org-tree-to-indirect-buffer
   Displays <file>-a-1 buffer.

 - move to "b", C-u C-c C-x b
   Displays <file>-b-1 buffer, a-1 buffer still exists.


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

* Re: [tip for EXWM users] An alternative method for isolate trees
  2021-03-02  5:44       ` Kyle Meyer
@ 2021-03-02  9:29         ` Julian M. Burgos
  0 siblings, 0 replies; 7+ messages in thread
From: Julian M. Burgos @ 2021-03-02  9:29 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Juan Manuel Macías, orgmode

Hi Kyle,

You are right. When running emacs without my personal config things work as described in the manual.  I should have verified that first.

My best,

Julian

Kyle Meyer writes:

> Julian M. Burgos writes:
>
>> I have not noticed that org-tree-to-indirect-buffer
>> reuses the indirect buffer when you call it for a second time.
>> According to the manual, "with a C-u prefix, do not remove the
>> previously used indirect buffer", but that does not seem to work.
>> When you do Cu-Cc-Cx-b from a buffer that already has an indirect
>> buffer you get a "cannot modify an area being edited in a dedicated
>> buffer".  If you try it from a different buffer, the prefix is ignored
>> and the indirect buffer is assigned to the tree from the last buffer.
>
> Hmm, could you provide a reproducer for the problem?  Here's what I
> tried with the current master (afd75d05a), Emacs 27.1, and no custom
> configuration.
>
> --8<---------------cut here---------------start------------->8---
> * a
> a content
> * b
> b content
> --8<---------------cut here---------------end--------------->8---
>
>  - on "a", C-c C-x b  ;; org-tree-to-indirect-buffer
>    Displays <file>-a-1 buffer.
>
>  - move to "b", C-u C-c C-x b
>    Displays <file>-b-1 buffer, a-1 buffer still exists.


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
  Fornubúðir 5, IS-220 Hafnarfjörður, Iceland
www.hafogvatn.is
Sími/Telephone : +354-5752037
Netfang/Email: julian.burgos@hafogvatn.is


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

end of thread, other threads:[~2021-03-02  9:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 12:55 [tip for EXWM users] An alternative method for isolate trees Juan Manuel Macías
2021-03-01 13:37 ` Julian M. Burgos
2021-03-01 14:10   ` Juan Manuel Macías
2021-03-01 15:37     ` Julian M. Burgos
2021-03-01 16:42       ` Juan Manuel Macías
2021-03-02  5:44       ` Kyle Meyer
2021-03-02  9:29         ` Julian M. Burgos

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