annotate lisp/org/ob-screen.el @ 110746:5c1a707ab452

Fix compilation warnings. * lib-src/test-distrib.c (cool_read): * lib-src/movemail.c (main, concat): * lib-src/make-docfile.c (scan_file, write_c_args): * emacsclient.c (get_server_config): Fix -Wconversion warning. (egetenv): Move conditional definition earlier. (progname): Use const. * lib-src/sorted-doc.c (xstrdup): Use const.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 03 Oct 2010 16:35:22 -0700
parents a150e8a14679
children 5cb272c831e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109462
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
1 ;;; ob-screen.el --- org-babel support for interactive terminal
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
2
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
3 ;; Copyright (C) 2009, 2010 Free Software Foundation
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
4
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
5 ;; Author: Benjamin Andresen
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
6 ;; Keywords: literate programming, interactive shell
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
7 ;; Homepage: http://orgmode.org
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
8 ;; Version: 7.01
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
9
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
11
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
15 ;; (at your option) any later version.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
16
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
21
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
24
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
25 ;;; Commentary:
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
26
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
27 ;; Org-Babel support for interactive terminals. Mostly shell scripts.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
28 ;; Heavily inspired by 'eev' from Eduardo Ochs
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
29 ;;
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
30 ;; Adding :cmd and :terminal as header arguments
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
31 ;; :terminal must support the -T (title) and -e (command) parameter
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
32 ;;
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
33 ;; You can test the default setup. (xterm + sh) with
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
34 ;; M-x org-babel-screen-test RET
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
35
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
36 ;;; Code:
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
37 (require 'ob)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
38 (require 'ob-ref)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
39
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
40 (defvar org-babel-screen-location "screen"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
41 "The command location for screen.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
42 In case you want to use a different screen than one selected by your $PATH")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
43
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
44 (defvar org-babel-default-header-args:screen
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
45 '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm"))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
46 "Default arguments to use when running screen source blocks.")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
47
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
48 (defun org-babel-expand-body:screen (body params &optional processed-params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
49 "Expand BODY according to PARAMS, return the expanded body." body)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
50
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
51 (defun org-babel-execute:screen (body params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
52 "Send a block of code via screen to a terminal using Babel.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
53 \"default\" session is be used when none is specified."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
54 (message "Sending source code block to interactive terminal session...")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
55 (save-window-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
56 (let* ((processed-params (org-babel-process-params params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
57 (session (nth 0 processed-params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
58 (socket (org-babel-screen-session-socketname session)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
59 (unless socket (org-babel-prep-session:screen session params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
60 (org-babel-screen-session-execute-string
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
61 session (org-babel-expand-body:screen body params)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
62
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
63 (defun org-babel-prep-session:screen (session params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
64 "Prepare SESSION according to the header arguments specified in PARAMS."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
65 (let* ((processed-params (org-babel-process-params params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
66 (session (nth 0 processed-params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
67 (vars (nth 1 processed-params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
68 (socket (org-babel-screen-session-socketname session))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
69 (vars (org-babel-ref-variables params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
70 (cmd (cdr (assoc :cmd params)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
71 (terminal (cdr (assoc :terminal params)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
72 (process-name (concat "org-babel: terminal (" session ")")))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
73 (apply 'start-process process-name "*Messages*"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
74 terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
75 "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" session)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
76 ,cmd))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
77 ;; XXX: Is there a better way than the following?
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
78 (while (not (org-babel-screen-session-socketname session))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
79 ;; wait until screen session is available before returning
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
80 )))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
81
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
82 ;; helper functions
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
83
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
84 (defun org-babel-screen-session-execute-string (session body)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
85 "If SESSION exists, send BODY to it."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
86 (let ((socket (org-babel-screen-session-socketname session)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
87 (when socket
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
88 (let ((tmpfile (org-babel-screen-session-write-temp-file session body)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
89 (apply 'start-process (concat "org-babel: screen (" session ")") "*Messages*"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
90 org-babel-screen-location
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
91 `("-S" ,socket "-X" "eval" "msgwait 0"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
92 ,(concat "readreg z " tmpfile)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
93 "paste z"))))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
94
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
95 (defun org-babel-screen-session-socketname (session)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
96 "Check if SESSION exists by parsing output of \"screen -ls\"."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
97 (let* ((screen-ls (shell-command-to-string "screen -ls"))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
98 (sockets (delq
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
99 nil
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
100 (mapcar
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
101 (lambda (x)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
102 (when (string-match (rx (or "(Attached)" "(Detached)")) x)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
103 x))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
104 (split-string screen-ls "\n"))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
105 (match-socket (car
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
106 (delq
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
107 nil
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
108 (mapcar
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
109 (lambda (x)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
110 (when (string-match
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
111 (concat "org-babel-session-" session) x)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
112 x))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
113 sockets)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
114 (when match-socket (car (split-string match-socket)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
115
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
116 (defun org-babel-screen-session-write-temp-file (session body)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
117 "Save BODY in a temp file that is named after SESSION."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
118 (let ((tmpfile (concat "/tmp/screen.org-babel-session-" session)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
119 (with-temp-file tmpfile
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
120 (insert body)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
121
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
122 ;; org-babel has superflous spaces
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
123 (goto-char (point-min))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
124 (delete-matching-lines "^ +$"))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
125 tmpfile))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
126
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
127 (defun org-babel-screen-test ()
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
128 "Test if the default setup works.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
129 The terminal should shortly flicker."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
130 (interactive)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
131 (let* ((session "org-babel-testing")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
132 (random-string (format "%s" (random 99999)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
133 (tmpfile "/tmp/org-babel-screen.test")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
134 (body (concat "echo '" random-string "' > " tmpfile "\nexit\n"))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
135 process tmp-string)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
136 (org-babel-execute:screen body org-babel-default-header-args:screen)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
137 ;; XXX: need to find a better way to do the following
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
138 (while (not (file-readable-p tmpfile))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
139 ;; do something, otherwise this will be optimized away
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
140 (format "org-babel-screen: File not readable yet."))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
141 (setq tmp-string (with-temp-buffer
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
142 (insert-file-contents-literally tmpfile)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
143 (buffer-substring (point-min) (point-max))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
144 (delete-file tmpfile)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
145 (message (concat "org-babel-screen: Setup "
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
146 (if (string-match random-string tmp-string)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
147 "WORKS."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
148 "DOESN'T work.")))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
149
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
150 (provide 'ob-screen)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
151
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
152 ;; arch-tag: 908e5afe-89a0-4f27-b982-23f1f2e3bac9
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
153
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
154 ;;; ob-screen.el ends here