From mboxrd@z Thu Jan 1 00:00:00 1970 From: immanuel Subject: Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)] Date: Fri, 30 Aug 2019 13:44:37 +0200 Message-ID: <87r252swre.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:37600) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3hCG-0001GE-2a for emacs-orgmode@gnu.org; Fri, 30 Aug 2019 09:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3hCC-0005aL-7I for emacs-orgmode@gnu.org; Fri, 30 Aug 2019 09:44:09 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:46703) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i3hCB-0005HU-Pd for emacs-orgmode@gnu.org; Fri, 30 Aug 2019 09:44:08 -0400 Received: by mail-ed1-x52a.google.com with SMTP id z51so8011385edz.13 for ; Fri, 30 Aug 2019 06:44:05 -0700 (PDT) Received: from prometheus ([37.48.116.173]) by smtp.gmail.com with ESMTPSA id j26sm770478edq.97.2019.08.30.04.44.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Aug 2019 04:44:37 -0700 (PDT) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=org-src-switch-to-buffer.patch Content-Description: fix resplitting of window 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 --=-=-= Content-Type: text/plain 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 ) --=-=-=--