From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marco Wahl Subject: Re: Switching buffers from babel snippets Date: Sun, 15 Jan 2017 12:58:26 +0100 Message-ID: <84r344a61p.fsf@gmail.com> References: <87ziit1mff.fsf@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSjSb-0005K4-Qj for emacs-orgmode@gnu.org; Sun, 15 Jan 2017 06:58:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cSjSY-0006hI-Qj for emacs-orgmode@gnu.org; Sun, 15 Jan 2017 06:58:57 -0500 Received: from [195.159.176.226] (port=39647 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cSjSY-0006gz-JO for emacs-orgmode@gnu.org; Sun, 15 Jan 2017 06:58:54 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cSjSK-00083f-Mh for emacs-orgmode@gnu.org; Sun, 15 Jan 2017 12:58:40 +0100 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 Cc: Alex =?utf-8?Q?Benn=C3=A9e?= Alex Bennée writes: Hi, > I've trying to further automate my maintainer tasks by moving things > into babel snippets. I have one to find a cover letter and edit the > file: > > #+name: edit-cover-letter > #+begin_src emacs-lisp :var cover=create-qemu-pull[0] > > (find-file (expand-file-name (concat default-directory (car cover)))) > (mail-mode) > #+end_src > > However when I run the code although the file is loaded and in the right > mode I never see the buffer come up and have to switch to it manually. I > expect this is because the code is running under some sort of > safe-excursion. Is there anyway to pass a final buffer back to org-mode > after the code is run and switch to it? Actually I don't know why the switch to the other buffer does not apply with the babel execution. For a practical realization you could use a timer. #+begin_src emacs-lisp :var cover="cover.txt" (let ((buf (find-file cover))) (mail-mode) (run-at-time 1 nil #'switch-to-buffer buf)) #+end_src Ciao Marco