;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (db-get-frame--drew-adams "TUAREG") (setq frame (db-get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (unless (get-buffer-window buffer) (set-window-buffer (get-largest-window) buffer)) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) ;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (get-frame--drew-adams "TUAREG") (setq frame (get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (unless (get-buffer-window buffer) (set-window-buffer (get-largest-window) buffer)) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) ;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (db-get-frame--drew-adams "TUAREG") (setq frame (db-get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (unless (get-buffer-window buffer) (set-window-buffer (get-largest-window) buffer)) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) The following example relies upon two functions from the frame-fns.el library written by Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el -- which has been consolidated into just one function for the purposes of this example. The original poster has indicated that the function tuareg-run-ocaml is the most likely suspect that causes behavior described by the original poster as: "it split the window to show tuareg toplevel". This example modifies tuareg-run-ocaml by adding an optional second argument of display-buffer for ACTION -- e.g., what do we want to do with the buffer. We use Drew Adams' function to test for whether there is an existing frame named TUAREG: If there is, then we use that. If there is not, then we create a new frame with that name. The If the buffer is already being displayed in that frame, then use the same window -- if not, then the buffer is displayed in the largest visible window in said frame.
;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (get-frame--drew-adams "TUAREG") (setq frame (get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (unless (get-buffer-window buffer) (set-window-buffer (get-largest-window) buffer)) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) The following example relies upon two functions from the frame-fns.el library written by Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el -- which has been consolidated into just one function for the purposes of this example. The original poster has indicated that the function tuareg-run-ocaml is the most likely suspect that causes behavior described by the original poster as: "it split the window to show tuareg toplevel". This example modifies tuareg-run-ocaml by adding an optional second argument of display-buffer for ACTION -- e.g., what do we want to do with the buffer. We use Drew Adams' function to test for whether there is an existing frame named TUAREG: If there is, then we use that. If there is not, then we create a new frame with that name. The buffer is displayed in the largest visible window in said frame.
;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (get-frame--drew-adams "TUAREG") (setq frame (get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (set-window-buffer (get-largest-window) buffer) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) The following example relies upon two functions from the frame-fns.el library written by Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el -- which has been consolidated into just one function for the purposes of this example. The original poster has indicated that the function tuareg-run-ocaml is the most likely suspect that causes behavior described by the original poster as: "it split the window to show tuareg toplevel". This example modifies tuareg-run-ocaml by adding an optional second argument of display-buffer for ACTION -- e.g., what do we want to do with the buffer. We use Drew Adams' function to test for whether there is an existing frame named TUAREG: If there is, then we use that. If there is not, then we create a new frame with that name. If the buffer is already being displayed in that frame, then use the same window -- if not, then the buffer is displayed in the largest visible window in said frame.
;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (get-frame--drew-adams "TUAREG") (setq frame (get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (unless (get-buffer-window buffer) (set-window-buffer (get-largest-window) buffer)) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn))) The following example relies upon two functions from the frame-fns.el library written by Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el -- which has been consolidated into just one function for the purposes of this example. The original poster has indicated that the function tuareg-run-ocaml is the most likely suspect that causes behavior described by the original poster as: "it split the window to show tuareg toplevel". This example modifies tuareg-run-ocaml by adding an optional second argument of display-buffer for ACTION -- e.g., what do we want to do with the buffer. We use Drew Adams' function to test for whether there is an existing frame named TUAREG: If there is, then we use that. If there is not, then we create a new frame with that name. The buffer is displayed in the largest visible window in said frame.
;; Original Author: Drew Adams -- http://www.emacswiki.org/emacs/frame-fns.el ;; @lawlist combined the functions `get-frame-name` and `get-a-frame`. (defun db-get-frame--drew-adams (frame) "Return a frame, if any, named FRAME (a frame or a string). If none, return nil. If FRAME is a frame, it is returned." (let ((get-frame-name--drew-adams (lambda (&optional frame) (unless frame (setq frame (selected-frame))) (if (framep frame) (cdr (assq 'name (frame-parameters frame))) (error "Argument not a frame: `%s'" frame))))) (cond ((framep frame) frame) ((stringp frame) (catch 'get-a-frame-found (dolist (fr (frame-list)) (when (string= frame (funcall get-frame-name--drew-adams fr)) (throw 'get-a-frame-found fr))) nil)) (t (error "Arg neither a string nor a frame: `%s'" frame))))) (defun db-display-buffer-fn (buffer _alist) (let (frame) (if (get-frame--drew-adams "TUAREG") (setq frame (get-frame--drew-adams "TUAREG")) (setq frame (make-frame (list '(name . "TUAREG"))))) (select-frame frame) (raise-frame frame) (set-window-buffer (get-largest-window) buffer) (select-window (get-buffer-window buffer)))) ;; In order to redefine `tuareg-run-ocaml', need to make sure the library is loaded. (require 'tuareg) (defun tuareg-run-ocaml () "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'." (interactive) (tuareg-run-process-if-needed) (display-buffer tuareg-interactive-buffer-name '(db-display-buffer-fn)))