emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Switching buffers from babel snippets
@ 2017-01-14 19:17 Alex Bennée
  2017-01-15 11:58 ` Marco Wahl
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Bennée @ 2017-01-14 19:17 UTC (permalink / raw)
  To: emacs-orgmode

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?

--
Alex Bennée

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

* Re: Switching buffers from babel snippets
  2017-01-14 19:17 Switching buffers from babel snippets Alex Bennée
@ 2017-01-15 11:58 ` Marco Wahl
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Wahl @ 2017-01-15 11:58 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Alex Bennée

Alex Bennée <alex.bennee@linaro.org> 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

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

end of thread, other threads:[~2017-01-15 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-14 19:17 Switching buffers from babel snippets Alex Bennée
2017-01-15 11:58 ` Marco Wahl

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