From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Barnier Subject: Re: [PATCH] [babel] Add option to display process buffer when editing R source code blocks Date: Tue, 13 Apr 2010 11:46:26 +0200 Message-ID: <874ojfadn1.fsf@z.nozav.org> References: <87sk77tjd8.fsf@z.nozav.org> <87d3y94ssd.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1ciD-0008Dl-NB for emacs-orgmode@gnu.org; Tue, 13 Apr 2010 05:47:17 -0400 Received: from [140.186.70.92] (port=49690 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1ci5-0007Wx-Jn for emacs-orgmode@gnu.org; Tue, 13 Apr 2010 05:47:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1chX-0001NZ-AB for emacs-orgmode@gnu.org; Tue, 13 Apr 2010 05:46:37 -0400 Received: from lo.gmane.org ([80.91.229.12]:42397) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1chW-0001NQ-Vy for emacs-orgmode@gnu.org; Tue, 13 Apr 2010 05:46:35 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O1chV-0007cL-MH for emacs-orgmode@gnu.org; Tue, 13 Apr 2010 11:46:33 +0200 Received: from z.nozav.org ([91.121.121.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Apr 2010 11:46:33 +0200 Received: from julien by z.nozav.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Apr 2010 11:46:33 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Dan, > Could I suggest a slightly different route? We already have the > functions org-babel-switch-to-session and org-babel-load-session, which > work for any language. These switch to the process buffer, like your > patch does. I agree with you about wanting a function that ends up > displaying the process buffer and the code edit buffer. I have the > following personal function which achieves that: > > (defun dan/org-babel-switch-to-code-with-session (&optional arg) > "Switch to code edit buffer and display session" > (interactive "P") > (save-excursion > (org-babel-switch-to-session arg nil)) > (org-edit-src-code)) > > Could you experiment with these functions, and see if they are > satisfactory, amd let us know if we can improve things? E.g. we could > include a function like my one above to display both the session with > the edit-buffer. Ah, yes, I didn't notice the existence of org-babel-switch-to-session. It is indeed much cleaner that my patch :-) The "features" I would miss compared top my quick and dirty-function is the fact that the source code buffer is displayed above the session one (I really don't like having the session above), the fact that when I quit the source code editing, the session buffer is closed too, and the ability to keep org file buffer open with the source and the session ones. I can reproduce the behavios I was looking for with the following modifications to your function. But this is another quick and dirty hack, and I can't say if it cuold meet the needs of others : (defun dan/org-babel-switch-to-code-with-session (&optional arg keep-org) "Switch to code edit buffer and display session. If keep-org is non nil, keep the org file buffer open, too." (interactive "P") (let ((info (org-babel-get-src-block-info))) (org-edit-src-code) (if keep-org (split-window-vertically) (delete-other-windows)) (save-excursion (org-babel-switch-to-session arg info)) (other-window -1))) I think I'll stick with this function for the moment. > Note that o-b-load-session additionally loads the body of the block into > the session; and that switch-session, if called with a prefix arg, > assigns variables from the header args in the session[1]. These are > bound to M-down and M-up when on a code block. Ah yes, didn't know these ones either... > Oh, and also... org-babel-switch-to-session and org-babel-load-session > use the emacs function pop-to-buffer. That means that there's all sorts > of extra control you can have over how the windows are displayed. See > the documentation for things like pop-to-buffer, pop-up-windows, > split-window-sensibly, special-display-buffer-names, etc. Yes, I feel I have some more customization opportunities lying in these documentation pages... Thanks for your detailed answer ! -- Julien