emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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 11:44 immanuel
  2019-09-02 19:41 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: immanuel @ 2019-08-30 11:44 UTC (permalink / raw)
  To: emacs-orgmode

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


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix resplitting of window --]
[-- Type: text/x-diff, Size: 1306 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 4307 bytes --]



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" :follow org-bibtex-open :store org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-bbdb-complete-link :store org-bbdb-store-link) ("w3m" :store org-w3m-store-link) ("file+sys")
                       ("file+emacs") ("shell" :follow org-link--open-shell) ("news" :follow #[257 "\301\300\302Q!\207" ["news" browse-url ":"] 5 "\n\n(fn URL)"])
                       ("mailto" :follow #[257 "\301\300\302Q!\207" ["mailto" browse-url ":"] 5 "\n\n(fn URL)"])
                       ("https" :follow #[257 "\301\300\302Q!\207" ["https" browse-url ":"] 5 "\n\n(fn URL)"])
                       ("http" :follow #[257 "\301\300\302Q!\207" ["http" browse-url ":"] 5 "\n\n(fn URL)"])
                       ("ftp" :follow #[257 "\301\300\302Q!\207" ["ftp" browse-url ":"] 5 "\n\n(fn URL)"]) ("help" :follow org-link--open-elisp) ("file" :complete org-link-complete-file)
                       ("elisp" :follow org-link--open-elisp) ("doi" :follow org-link--open-doi))
 org-link-elisp-confirm-function 'yes-or-no-p
 org-attach-id-to-path-function 'org-attach-id-folder-format
 org-src-window-setup 'split-window-below
 org-confirm-babel-evaluate nil
 )

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

* Re: 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 11:44 Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)] immanuel
@ 2019-09-02 19:41 ` Nicolas Goaziou
  2019-09-02 21:26   ` Immanuel Litzroth
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2019-09-02 19:41 UTC (permalink / raw)
  To: immanuel; +Cc: emacs-orgmode

Hello,

immanuel <immanuel.litzroth@gmail.com> 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

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

* Re: 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 19:41 ` Nicolas Goaziou
@ 2019-09-02 21:26   ` Immanuel Litzroth
  2019-09-03 16:17     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Immanuel Litzroth @ 2019-09-02 21:26 UTC (permalink / raw)
  To: immanuel, emacs-orgmode

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 <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> immanuel <immanuel.litzroth@gmail.com> 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

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

* Re: 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 21:26   ` Immanuel Litzroth
@ 2019-09-03 16:17     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2019-09-03 16:17 UTC (permalink / raw)
  To: Immanuel Litzroth; +Cc: emacs-orgmode

Hello,

Immanuel Litzroth <immanuel.litzroth@gmail.com> 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

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

end of thread, other threads:[~2019-09-03 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 11:44 Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)] immanuel
2019-09-02 19:41 ` Nicolas Goaziou
2019-09-02 21:26   ` Immanuel Litzroth
2019-09-03 16:17     ` Nicolas Goaziou

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