[O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-08-30 Thread immanuel

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.

When org-edit-src-code is called with org-window-setup equal to
'split-window-below or 'split-window-right it will keep splitting the
window if the mouse is clicked on the src block in the org buffer.
This patch tries to address that

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9134d5b5d..c7e201687 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -786,6 +786,13 @@ Raise an error when current buffer is not a source editing buffer."
   (unless (org-src-edit-buffer-p) (error "Not in a source buffer"))
   org-src--source-type)
 
+(defun org-src-select-window-for-buffer (buffer split-fun)
+  "Tries to select an existing window for buffer or splits the window."
+  (select-window
+   (or
+(display-buffer-reuse-window buffer '())
+(funcall split-fun
+
 (defun org-src-switch-to-buffer (buffer context)
   (pcase org-src-window-setup
 (`current-window (pop-to-buffer-same-window buffer))
@@ -794,12 +801,12 @@ Raise an error when current buffer is not a source editing buffer."
 (`split-window-below
  (if (eq context 'exit)
 	 (delete-window)
-   (select-window (split-window-vertically)))
+   (org-src-select-window-for-buffer buffer #'split-window-vertically))
  (pop-to-buffer-same-window buffer))
 (`split-window-right
  (if (eq context 'exit)
 	 (delete-window)
-   (select-window (split-window-horizontally)))
+   (org-src-select-window-for-buffer buffer #'split-window-horizontally))
  (pop-to-buffer-same-window buffer))
 (`other-frame
  (pcase context


Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.2.5 (release_9.2.5-504-g3c24be @ 
/home/immanuel/.emacs.d/straight/build/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-reveal-start-hook '(org-decrypt-entry)
 org-mode-hook '(#[0 "\301\211\207" [imenu-create-index-function 
org-imenu-get-tree] 2] #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5] 
org-babel-result-hide-spec org-babel-hide-all-hashes
 auto-fill-mode)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C) (python . t) (shell . t) 
(plantuml . t))
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines 
org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate 
org-babel-speed-command-activate)
 org-babel-tangle-lang-exts '(("D" . "d") ("C++" . "cpp") ("abc" . "abc") 
("asymptote" . "asy") ("awk" . "awk") ("clojure" . "clj") ("fortran" . "F90") 
("groovy" . "groovy")
  ("haskell" . "hs") ("io" . "io") ("java" . 
"java") ("latex" . "tex") ("LilyPond" . "ly") ("lisp" . "lisp") ("lua" . "lua") 
("maxima" . "max") ("ocaml" . "ml")
  ("perl" . "pl") ("picolisp" . "l") ("processing" 
. "pde") ("ruby" . "rb") ("sed" . "sed") ("vala" . "vala") ("python" . "py") 
("emacs-lisp" . "el")
  ("elisp" . "el"))
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-open-link :export 
org-attach-export-link :complete org-attach-complete-link) ("id" :follow 
org-id-open)
   ("eww" :follow eww :store org-eww-store-link) ("rmail" 
:follow org-rmail-open :store org-rmail-store-link) ("mhe" :follow org-mhe-open 
:store org-mhe-store-link)
   ("irc" :follow org-irc-visit :store org-irc-store-link 
:export org-irc-export) ("info" :follow org-info-open :export org-info-export 
:store org-info-store-link)
   ("gnus" :follow org-gnus-open :store 
org-gnus-store-link) ("docview" :follow org-docview-open :export 
org-docview-export :store org-docview-store-link)
   ("bibtex"

Re: [O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-09-02 Thread Nicolas Goaziou
Hello,

immanuel  writes:

> When org-edit-src-code is called with org-window-setup equal to
> 'split-window-below or 'split-window-right it will keep splitting the
> window if the mouse is clicked on the src block in the org buffer.
> This patch tries to address that

[...]

> +(defun org-src-select-window-for-buffer (buffer split-fun)

You should make it an internal function: `org-src--select-window-for-buffer'.

> +  "Tries to select an existing window for buffer or splits the
> window."

You need to expound the docstring a bit, e.g.:

  "Re-use an existing window or split the current window.
  If BUFFER is current in a window, use it.  Otherwise, split the current
  window, according to SPLIT-FUN, in order to display it.

Also, I think this should be notified in ORG-NEWS file.

Thank you!

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-09-02 Thread Immanuel Litzroth
You want me to do that and send a new patch or are you going
to do it after you apply the patch?
Regards,
Immanuel

On Mon, Sep 2, 2019 at 9:41 PM Nicolas Goaziou  wrote:
>
> Hello,
>
> immanuel  writes:
>
> > When org-edit-src-code is called with org-window-setup equal to
> > 'split-window-below or 'split-window-right it will keep splitting the
> > window if the mouse is clicked on the src block in the org buffer.
> > This patch tries to address that
>
> [...]
>
> > +(defun org-src-select-window-for-buffer (buffer split-fun)
>
> You should make it an internal function: `org-src--select-window-for-buffer'.
>
> > +  "Tries to select an existing window for buffer or splits the
> > window."
>
> You need to expound the docstring a bit, e.g.:
>
>   "Re-use an existing window or split the current window.
>   If BUFFER is current in a window, use it.  Otherwise, split the current
>   window, according to SPLIT-FUN, in order to display it.
>
> Also, I think this should be notified in ORG-NEWS file.
>
> Thank you!
>
> Regards,
>
> --
> Nicolas Goaziou



Re: [O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-09-03 Thread Nicolas Goaziou
Hello,

Immanuel Litzroth  writes:

> You want me to do that and send a new patch or are you going
> to do it after you apply the patch?

The former, if you don't mind.

Regards,

-- 
Nicolas Goaziou