From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Stanton Subject: Re: Python code block hangs with :session if python-mode is loaded Date: Sat, 31 Mar 2012 16:02:04 -0700 Message-ID: <40C7B1BFC291ED4E9D10436D07736A334702EB9E7D@EXMAIL7.haas.uc.berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SE7JO-00068r-1L for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 19:02:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SE7JH-0003o3-Kr for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 19:02:21 -0400 Received: from gateway-a.haas.berkeley.edu ([128.32.222.29]:51869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SE7JG-0003mY-Dg for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 19:02:15 -0400 Content-Language: en-US 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "'emacs-orgmode@gnu.org'" > If I do not have (require 'python-mode) in my init.el, the following also > works fine: > > #+begin_src python :results output :session print "%d + %d =3D %d" % (2, = 3, > 2+3) > 2**5 > #+end_src > > #+RESULTS: > : 2 + 3 =3D 5 > : 32 > > However, if (require 'python-mode) is in my init.el file, pressing C-c C-= c in > the second code block causes Emacs to hang with the message "Executing > python code block". I can get out by pressing C-g, but it never returns > otherwise. A quick follow-up, in case it's useful: 1) This is with org-mode 7.8.07, but the same occurred with 7.8.06, in both= cases running under Emacs 23.0.94, and I get the same behavior under both = OS X and Windows. 2) If I toggle debug-on-quit, here's what I see when I press C-g: Debugger entered--Lisp error: (quit) accept-process-output(#) (while (progn (goto-char comint-last-input-end) (not (save-excursion (and= (re-search-forward (regexp-quote org-babel-python-eoe-indicator) nil t) (r= e-search-forward comint-prompt-regexp nil t))))) (accept-process-output (ge= t-buffer-process (current-buffer)))) (progn (goto-char (process-mark (get-buffer-process (current-buffer)))) (= let ((start (point)) (end (point-max))) (setq dangling-text (buffer-substri= ng start end)) (delete-region start end)) (input-body body) (send-wait) (se= nd-wait) (insert org-babel-python-eoe-indicator) (send-wait) (while (progn = (goto-char comint-last-input-end) (not (save-excursion (and (re-search-forw= ard (regexp-quote org-babel-python-eoe-indicator) nil t) (re-search-forward= comint-prompt-regexp nil t))))) (accept-process-output (get-buffer-process= (current-buffer)))) (goto-char (process-mark (get-buffer-process (current-= buffer)))) (insert dangling-text)) (unwind-protect (progn (goto-char (process-mark (get-buffer-process (curr= ent-buffer)))) (let ((start (point)) (end (point-max))) (setq dangling-text= (buffer-substring start end)) (delete-region start end)) (input-body body)= (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait= ) (while (progn (goto-char comint-last-input-end) (not (save-excursion (and= (re-search-forward ... nil t) (re-search-forward comint-prompt-regexp nil = t))))) (accept-process-output (get-buffer-process (current-buffer)))) (goto= -char (process-mark (get-buffer-process (current-buffer)))) (insert danglin= g-text)) (remove-hook (quote comint-output-filter-functions) (quote my-filt= ))) (progn (fset (quote my-filt) (function* (lambda (text) (block my-filt (se= tq string-buffer (concat string-buffer text)))))) (add-hook (quote comint-o= utput-filter-functions) (quote my-filt)) (unwind-protect (progn (goto-char = (process-mark (get-buffer-process (current-buffer)))) (let ((start (point))= (end (point-max))) (setq dangling-text (buffer-substring start end)) (dele= te-region start end)) (input-body body) (send-wait) (send-wait) (insert org= -babel-python-eoe-indicator) (send-wait) (while (progn (goto-char comint-la= st-input-end) (not (save-excursion (and ... ...)))) (accept-process-output = (get-buffer-process (current-buffer)))) (goto-char (process-mark (get-buffe= r-process (current-buffer)))) (insert dangling-text)) (remove-hook (quote c= omint-output-filter-functions) (quote my-filt)))) (unwind-protect (progn (fset (quote my-filt) (function* (lambda (text) (b= lock my-filt (setq string-buffer (concat string-buffer text)))))) (add-hook= (quote comint-output-filter-functions) (quote my-filt)) (unwind-protect (p= rogn (goto-char (process-mark (get-buffer-process (current-buffer)))) (let = ((start (point)) (end (point-max))) (setq dangling-text (buffer-substring s= tart end)) (delete-region start end)) (input-body body) (send-wait) (send-w= ait) (insert org-babel-python-eoe-indicator) (send-wait) (while (progn (got= o-char comint-last-input-end) (not (save-excursion ...))) (accept-process-o= utput (get-buffer-process (current-buffer)))) (goto-char (process-mark (get= -buffer-process (current-buffer)))) (insert dangling-text)) (remove-hook (q= uote comint-output-filter-functions) (quote my-filt)))) (if --cl-letf-bound= -- (fset (quote my-filt) --cl-letf-save--) (fmakunbound (quote my-filt)))) (let* ((--cl-letf-bound-- (fboundp (quote my-filt))) (--cl-letf-save-- (a= nd --cl-letf-bound-- (symbol-function (quote my-filt))))) (unwind-protect (= progn (fset (quote my-filt) (function* (lambda (text) (block my-filt (setq = string-buffer ...))))) (add-hook (quote comint-output-filter-functions) (qu= ote my-filt)) (unwind-protect (progn (goto-char (process-mark (get-buffer-p= rocess ...))) (let ((start ...) (end ...)) (setq dangling-text (buffer-subs= tring start end)) (delete-region start end)) (input-body body) (send-wait) = (send-wait) (insert org-babel-python-eoe-indicator) (send-wait) (while (pro= gn (goto-char comint-last-input-end) (not ...)) (accept-process-output (get= -buffer-process ...))) (goto-char (process-mark (get-buffer-process ...))) = (insert dangling-text)) (remove-hook (quote comint-output-filter-functions)= (quote my-filt)))) (if --cl-letf-bound-- (fset (quote my-filt) --cl-letf-s= ave--) (fmakunbound (quote my-filt))))) (letf (((symbol-function (quote my-filt)) (function* (lambda (text) (bloc= k my-filt (setq string-buffer (concat string-buffer text))))))) (add-hook (= quote comint-output-filter-functions) (quote my-filt)) (unwind-protect (pro= gn (goto-char (process-mark (get-buffer-process (current-buffer)))) (let ((= start (point)) (end (point-max))) (setq dangling-text (buffer-substring sta= rt end)) (delete-region start end)) (input-body body) (send-wait) (send-wai= t) (insert org-babel-python-eoe-indicator) (send-wait) (while (progn (goto-= char comint-last-input-end) (not (save-excursion (and ... ...)))) (accept-p= rocess-output (get-buffer-process (current-buffer)))) (goto-char (process-m= ark (get-buffer-process (current-buffer)))) (insert dangling-text)) (remove= -hook (quote comint-output-filter-functions) (quote my-filt)))) (letf* (((symbol-function (quote my-filt)) (function* (lambda (text) (blo= ck my-filt (setq string-buffer (concat string-buffer text))))))) (add-hook = (quote comint-output-filter-functions) (quote my-filt)) (unwind-protect (pr= ogn (goto-char (process-mark (get-buffer-process (current-buffer)))) (let (= (start (point)) (end (point-max))) (setq dangling-text (buffer-substring st= art end)) (delete-region start end)) (input-body body) (send-wait) (send-wa= it) (insert org-babel-python-eoe-indicator) (send-wait) (while (progn (goto= -char comint-last-input-end) (not (save-excursion (and ... ...)))) (accept-= process-output (get-buffer-process (current-buffer)))) (goto-char (process-= mark (get-buffer-process (current-buffer)))) (insert dangling-text)) (remov= e-hook (quote comint-output-filter-functions) (quote my-filt)))) (flet ((my-filt (text) (setq string-buffer (concat string-buffer text))))= (add-hook (quote comint-output-filter-functions) (quote my-filt)) (unwind-= protect (progn (goto-char (process-mark (get-buffer-process (current-buffer= )))) (let ((start (point)) (end (point-max))) (setq dangling-text (buffer-s= ubstring start end)) (delete-region start end)) (input-body body) (send-wai= t) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait) (while (= progn (goto-char comint-last-input-end) (not (save-excursion (and ... ...))= )) (accept-process-output (get-buffer-process (current-buffer)))) (goto-cha= r (process-mark (get-buffer-process (current-buffer)))) (insert dangling-te= xt)) (remove-hook (quote comint-output-filter-functions) (quote my-filt)))) (let ((string-buffer "") dangling-text raw) (flet ((my-filt (text) (setq = string-buffer (concat string-buffer text)))) (add-hook (quote comint-output= -filter-functions) (quote my-filt)) (unwind-protect (progn (goto-char (proc= ess-mark (get-buffer-process (current-buffer)))) (let ((start (point)) (end= (point-max))) (setq dangling-text (buffer-substring start end)) (delete-re= gion start end)) (input-body body) (send-wait) (send-wait) (insert org-babe= l-python-eoe-indicator) (send-wait) (while (progn (goto-char comint-last-in= put-end) (not (save-excursion ...))) (accept-process-output (get-buffer-pro= cess (current-buffer)))) (goto-char (process-mark (get-buffer-process (curr= ent-buffer)))) (insert dangling-text)) (remove-hook (quote comint-output-fi= lter-functions) (quote my-filt)))) (if (and t body (string-match (replace-r= egexp-in-string "\n" "[ \n]+" (regexp-quote (or body ""))) string-buffer)) (setq raw (substring str= ing-buffer (match-end 0)))) (split-string string-buffer comint-prompt-regex= p)) (progn (unless (org-babel-comint-buffer-livep session) (error "buffer %s = doesn't exist or has no process" session)) (set-buffer session) (let ((stri= ng-buffer "") dangling-text raw) (flet ((my-filt (text) (setq string-buffer= (concat string-buffer text)))) (add-hook (quote comint-output-filter-funct= ions) (quote my-filt)) (unwind-protect (progn (goto-char (process-mark (get= -buffer-process ...))) (let ((start ...) (end ...)) (setq dangling-text (bu= ffer-substring start end)) (delete-region start end)) (input-body body) (se= nd-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait) (w= hile (progn (goto-char comint-last-input-end) (not ...)) (accept-process-ou= tput (get-buffer-process ...))) (goto-char (process-mark (get-buffer-proces= s ...))) (insert dangling-text)) (remove-hook (quote comint-output-filter-f= unctions) (quote my-filt)))) (if (and t body (string-match (replace-regexp-= in-string "\n" "[ \n]+" (regexp-quote (or body ""))) string-buffer)) (setq raw (substring str= ing-buffer (match-end 0)))) (split-string string-buffer comint-prompt-regex= p))) (unwind-protect (progn (unless (org-babel-comint-buffer-livep session) (e= rror "buffer %s doesn't exist or has no process" session)) (set-buffer sess= ion) (let ((string-buffer "") dangling-text raw) (flet ((my-filt (text) (se= tq string-buffer (concat string-buffer text)))) (add-hook (quote comint-out= put-filter-functions) (quote my-filt)) (unwind-protect (progn (goto-char (p= rocess-mark ...)) (let (... ...) (setq dangling-text ...) (delete-region st= art end)) (input-body body) (send-wait) (send-wait) (insert org-babel-pytho= n-eoe-indicator) (send-wait) (while (progn ... ...) (accept-process-output = ...)) (goto-char (process-mark ...)) (insert dangling-text)) (remove-hook (= quote comint-output-filter-functions) (quote my-filt)))) (if (and t body (s= tring-match (replace-regexp-in-string "\n" "[ \n]+" (regexp-quote ...)) string-buffer)) (setq raw (substring string-buffe= r (match-end 0)))) (split-string string-buffer comint-prompt-regexp))) (set= -match-data save-match-data-internal (quote evaporate))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (un= less (org-babel-comint-buffer-livep session) (error "buffer %s doesn't exis= t or has no process" session)) (set-buffer session) (let ((string-buffer ""= ) dangling-text raw) (flet ((my-filt (text) (setq string-buffer ...))) (add= -hook (quote comint-output-filter-functions) (quote my-filt)) (unwind-prote= ct (progn (goto-char ...) (let ... ... ...) (input-body body) (send-wait) (= send-wait) (insert org-babel-python-eoe-indicator) (send-wait) (while ... .= ..) (goto-char ...) (insert dangling-text)) (remove-hook (quote comint-outp= ut-filter-functions) (quote my-filt)))) (if (and t body (string-match (repl= ace-regexp-in-string "\n" "[ \n]+" ...) string-buffer)) (setq raw (substring string-buffer (match-end 0)= ))) (split-string string-buffer comint-prompt-regexp))) (set-match-data sav= e-match-data-internal (quote evaporate)))) (save-match-data (unless (org-babel-comint-buffer-livep session) (error "= buffer %s doesn't exist or has no process" session)) (set-buffer session) (= let ((string-buffer "") dangling-text raw) (flet ((my-filt (text) (setq str= ing-buffer (concat string-buffer text)))) (add-hook (quote comint-output-fi= lter-functions) (quote my-filt)) (unwind-protect (progn (goto-char (process= -mark (get-buffer-process ...))) (let ((start ...) (end ...)) (setq danglin= g-text (buffer-substring start end)) (delete-region start end)) (input-body= body) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (sen= d-wait) (while (progn (goto-char comint-last-input-end) (not ...)) (accept-= process-output (get-buffer-process ...))) (goto-char (process-mark (get-buf= fer-process ...))) (insert dangling-text)) (remove-hook (quote comint-outpu= t-filter-functions) (quote my-filt)))) (if (and t body (string-match (repla= ce-regexp-in-string "\n" "[ \n]+" (regexp-quote (or body ""))) string-buffer)) (setq raw (substring str= ing-buffer (match-end 0)))) (split-string string-buffer comint-prompt-regex= p))) (save-excursion (save-match-data (unless (org-babel-comint-buffer-livep s= ession) (error "buffer %s doesn't exist or has no process" session)) (set-b= uffer session) (let ((string-buffer "") dangling-text raw) (flet ((my-filt = (text) (setq string-buffer (concat string-buffer text)))) (add-hook (quote = comint-output-filter-functions) (quote my-filt)) (unwind-protect (progn (go= to-char (process-mark ...)) (let (... ...) (setq dangling-text ...) (delete= -region start end)) (input-body body) (send-wait) (send-wait) (insert org-b= abel-python-eoe-indicator) (send-wait) (while (progn ... ...) (accept-proce= ss-output ...)) (goto-char (process-mark ...)) (insert dangling-text)) (rem= ove-hook (quote comint-output-filter-functions) (quote my-filt)))) (if (and= t body (string-match (replace-regexp-in-string "\n" "[ \n]+" (regexp-quote ...)) string-buffer)) (setq raw (substring string-buffe= r (match-end 0)))) (split-string string-buffer comint-prompt-regexp)))) (org-babel-comint-in-buffer session (let ((string-buffer "") dangling-tex= t raw) (flet ((my-filt (text) (setq string-buffer (concat string-buffer tex= t)))) (add-hook (quote comint-output-filter-functions) (quote my-filt)) (un= wind-protect (progn (goto-char (process-mark (get-buffer-process ...))) (le= t ((start ...) (end ...)) (setq dangling-text (buffer-substring start end))= (delete-region start end)) (input-body body) (send-wait) (send-wait) (inse= rt org-babel-python-eoe-indicator) (send-wait) (while (progn (goto-char com= int-last-input-end) (not ...)) (accept-process-output (get-buffer-process .= ..))) (goto-char (process-mark (get-buffer-process ...))) (insert dangling-= text)) (remove-hook (quote comint-output-filter-functions) (quote my-filt))= )) (if (and t body (string-match (replace-regexp-in-string "\n" "[ \n]+" (regexp-quote (or body ""))) string-buffer)) (setq raw (substring str= ing-buffer (match-end 0)))) (split-string string-buffer comint-prompt-regex= p))) (org-babel-comint-with-output (session org-babel-python-eoe-indicator t b= ody) (input-body body) (send-wait) (send-wait) (insert org-babel-python-eoe= -indicator) (send-wait)) (butlast (org-babel-comint-with-output (session org-babel-python-eoe-indi= cator t body) (input-body body) (send-wait) (send-wait) (insert org-babel-p= ython-eoe-indicator) (send-wait)) 2) (mapconcat (function org-babel-trim) (butlast (org-babel-comint-with-outp= ut (session org-babel-python-eoe-indicator t body) (input-body body) (send-= wait) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait)) 2) "= \n") (cond ((eql result-type (quote output)) (mapconcat (function org-babel-tr= im) (butlast (org-babel-comint-with-output (session org-babel-python-eoe-in= dicator t body) (input-body body) (send-wait) (send-wait) (insert org-babel= -python-eoe-indicator) (send-wait)) 2) "\n")) ((eql result-type (quote valu= e)) (let ((tmp-file (org-babel-temp-file "python-"))) (org-babel-comint-wit= h-output (session org-babel-python-eoe-indicator nil body) (let ((comint-pr= ocess-echoes nil)) (input-body body) (dump-last-value tmp-file (member "pp"= result-params)) (send-wait) (send-wait) (insert org-babel-python-eoe-indic= ator) (send-wait))) (org-babel-eval-read-file tmp-file)))) (case result-type (output (mapconcat (function org-babel-trim) (butlast (= org-babel-comint-with-output (session org-babel-python-eoe-indicator t body= ) (input-body body) (send-wait) (send-wait) (insert org-babel-python-eoe-in= dicator) (send-wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file= "python-"))) (org-babel-comint-with-output (session org-babel-python-eoe-i= ndicator nil body) (let ((comint-process-echoes nil)) (input-body body) (du= mp-last-value tmp-file (member "pp" result-params)) (send-wait) (send-wait)= (insert org-babel-python-eoe-indicator) (send-wait))) (org-babel-eval-read= -file tmp-file)))) ((lambda (results) (unless (string=3D (substring org-babel-python-eoe-ind= icator 1 -1) results) (if (or (member "code" result-params) (member "pp" re= sult-params) (and (member "output" result-params) (not (member "table" resu= lt-params)))) results (org-babel-python-table-or-string results)))) (case r= esult-type (output (mapconcat (function org-babel-trim) (butlast (org-babel= -comint-with-output (session org-babel-python-eoe-indicator t body) (input-= body body) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) = (send-wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-= "))) (org-babel-comint-with-output (session org-babel-python-eoe-indicator = nil body) (let ((comint-process-echoes nil)) (input-body body) (dump-last-v= alue tmp-file (member "pp" result-params)) (send-wait) (send-wait) (insert = org-babel-python-eoe-indicator) (send-wait))) (org-babel-eval-read-file tmp= -file))))) (progn (fset (quote input-body) (function* (lambda (body) (block input-bo= dy (mapc (lambda (line) (insert line) (send-wait)) (split-string body "[ \n]")) (send-wait))))) ((lambda (results) (unless (string=3D (substring org= -babel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-pa= rams) (member "pp" result-params) (and (member "output" result-params) (not= ...))) results (org-babel-python-table-or-string results)))) (case result-= type (output (mapconcat (function org-babel-trim) (butlast (org-babel-comin= t-with-output (session org-babel-python-eoe-indicator t body) (input-body b= ody) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send-= wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-"))) (= org-babel-comint-with-output (session org-babel-python-eoe-indicator nil bo= dy) (let (...) (input-body body) (dump-last-value tmp-file ...) (send-wait)= (send-wait) (insert org-babel-python-eoe-indicator) (send-wait))) (org-bab= el-eval-read-file tmp-file)))))) (unwind-protect (progn (fset (quote input-body) (function* (lambda (body)= (block input-body (mapc (lambda ... ... ...) (split-string body "[ \n]")) (send-wait))))) ((lambda (results) (unless (string=3D (substring org= -babel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-pa= rams) (member "pp" result-params) (and ... ...)) results (org-babel-python-= table-or-string results)))) (case result-type (output (mapconcat (function = org-babel-trim) (butlast (org-babel-comint-with-output ... ... ... ... ... = ...) 2) "\n")) (value (let ((tmp-file ...)) (org-babel-comint-with-output (= session org-babel-python-eoe-indicator nil body) (let ... ... ... ... ... .= .. ...)) (org-babel-eval-read-file tmp-file)))))) (if --cl-letf-bound-- (fs= et (quote input-body) --cl-letf-save--) (fmakunbound (quote input-body)))) (let* ((--cl-letf-bound-- (fboundp (quote input-body))) (--cl-letf-save--= (and --cl-letf-bound-- (symbol-function (quote input-body))))) (unwind-pro= tect (progn (fset (quote input-body) (function* (lambda (body) (block input= -body (mapc ... ...) (send-wait))))) ((lambda (results) (unless (string=3D = (substring org-babel-python-eoe-indicator 1 -1) results) (if (or ... ... ..= .) results (org-babel-python-table-or-string results)))) (case result-type = (output (mapconcat (function org-babel-trim) (butlast ... 2) "\n")) (value = (let (...) (org-babel-comint-with-output ... ...) (org-babel-eval-read-file= tmp-file)))))) (if --cl-letf-bound-- (fset (quote input-body) --cl-letf-sa= ve--) (fmakunbound (quote input-body))))) (letf (((symbol-function (quote input-body)) (function* (lambda (body) (b= lock input-body (mapc (lambda ... ... ...) (split-string body "[ \n]")) (send-wait)))))) ((lambda (results) (unless (string=3D (substring or= g-babel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-p= arams) (member "pp" result-params) (and (member "output" result-params) (no= t ...))) results (org-babel-python-table-or-string results)))) (case result= -type (output (mapconcat (function org-babel-trim) (butlast (org-babel-comi= nt-with-output (session org-babel-python-eoe-indicator t body) (input-body = body) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send= -wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-"))) = (org-babel-comint-with-output (session org-babel-python-eoe-indicator nil b= ody) (let (...) (input-body body) (dump-last-value tmp-file ...) (send-wait= ) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait))) (org-ba= bel-eval-read-file tmp-file)))))) (progn (fset (quote dump-last-value) (function* (lambda (tmp-file pp) (bl= ock dump-last-value (mapc (lambda (statement) (insert statement) (send-wait= )) (if pp (list "import pprint" ...) (list ...))))))) (letf (((symbol-funct= ion (quote input-body)) (function* (lambda (body) (block input-body (mapc .= .. ...) (send-wait)))))) ((lambda (results) (unless (string=3D (substring o= rg-babel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-= params) (member "pp" result-params) (and ... ...)) results (org-babel-pytho= n-table-or-string results)))) (case result-type (output (mapconcat (functio= n org-babel-trim) (butlast (org-babel-comint-with-output ... ... ... ... ..= . ...) 2) "\n")) (value (let ((tmp-file ...)) (org-babel-comint-with-output= (session org-babel-python-eoe-indicator nil body) (let ... ... ... ... ...= ... ...)) (org-babel-eval-read-file tmp-file))))))) (unwind-protect (progn (fset (quote dump-last-value) (function* (lambda (= tmp-file pp) (block dump-last-value (mapc (lambda ... ... ...) (if pp ... .= ..)))))) (letf (((symbol-function (quote input-body)) (function* (lambda (b= ody) (block input-body ... ...))))) ((lambda (results) (unless (string=3D (= substring org-babel-python-eoe-indicator 1 -1) results) (if (or ... ... ...= ) results (org-babel-python-table-or-string results)))) (case result-type (= output (mapconcat (function org-babel-trim) (butlast ... 2) "\n")) (value (= let (...) (org-babel-comint-with-output ... ...) (org-babel-eval-read-file = tmp-file))))))) (if --cl-letf-bound-- (fset (quote dump-last-value) --cl-le= tf-save--) (fmakunbound (quote dump-last-value)))) (let* ((--cl-letf-bound-- (fboundp (quote dump-last-value))) (--cl-letf-s= ave-- (and --cl-letf-bound-- (symbol-function (quote dump-last-value))))) (= unwind-protect (progn (fset (quote dump-last-value) (function* (lambda (tmp= -file pp) (block dump-last-value (mapc ... ...))))) (letf (((symbol-functio= n (quote input-body)) (function* (lambda ... ...)))) ((lambda (results) (un= less (string=3D ... results) (if ... results ...))) (case result-type (outp= ut (mapconcat ... ... "\n")) (value (let ... ... ...)))))) (if --cl-letf-bo= und-- (fset (quote dump-last-value) --cl-letf-save--) (fmakunbound (quote d= ump-last-value))))) (letf (((symbol-function (quote dump-last-value)) (function* (lambda (tmp= -file pp) (block dump-last-value (mapc (lambda ... ... ...) (if pp ... ...)= )))))) (letf (((symbol-function (quote input-body)) (function* (lambda (bod= y) (block input-body (mapc ... ...) (send-wait)))))) ((lambda (results) (un= less (string=3D (substring org-babel-python-eoe-indicator 1 -1) results) (i= f (or (member "code" result-params) (member "pp" result-params) (and ... ..= .)) results (org-babel-python-table-or-string results)))) (case result-type= (output (mapconcat (function org-babel-trim) (butlast (org-babel-comint-wi= th-output ... ... ... ... ... ...) 2) "\n")) (value (let ((tmp-file ...)) (= org-babel-comint-with-output (session org-babel-python-eoe-indicator nil bo= dy) (let ... ... ... ... ... ... ...)) (org-babel-eval-read-file tmp-file))= ))))) (progn (fset (quote send-wait) (function* (lambda nil (block send-wait (c= omint-send-input nil t) (sleep-for 0 5))))) (letf (((symbol-function (quote= dump-last-value)) (function* (lambda (tmp-file pp) (block dump-last-value = (mapc ... ...)))))) (letf (((symbol-function (quote input-body)) (function*= (lambda (body) (block input-body ... ...))))) ((lambda (results) (unless (= string=3D (substring org-babel-python-eoe-indicator 1 -1) results) (if (or = ... ... ...) results (org-babel-python-table-or-string results)))) (case re= sult-type (output (mapconcat (function org-babel-trim) (butlast ... 2) "\n"= )) (value (let (...) (org-babel-comint-with-output ... ...) (org-babel-eval= -read-file tmp-file)))))))) (unwind-protect (progn (fset (quote send-wait) (function* (lambda nil (bl= ock send-wait (comint-send-input nil t) (sleep-for 0 5))))) (letf (((symbol= -function (quote dump-last-value)) (function* (lambda (tmp-file pp) (block = dump-last-value ...))))) (letf (((symbol-function (quote input-body)) (func= tion* (lambda ... ...)))) ((lambda (results) (unless (string=3D ... results= ) (if ... results ...))) (case result-type (output (mapconcat ... ... "\n")= ) (value (let ... ... ...))))))) (if --cl-letf-bound-- (fset (quote send-wa= it) --cl-letf-save--) (fmakunbound (quote send-wait)))) (let* ((--cl-letf-bound-- (fboundp (quote send-wait))) (--cl-letf-save-- = (and --cl-letf-bound-- (symbol-function (quote send-wait))))) (unwind-prote= ct (progn (fset (quote send-wait) (function* (lambda nil (block send-wait (= comint-send-input nil t) (sleep-for 0 5))))) (letf (((symbol-function (quot= e dump-last-value)) (function* (lambda ... ...)))) (letf (((symbol-function= ...) (function* ...))) ((lambda (results) (unless ... ...)) (case result-t= ype (output ...) (value ...)))))) (if --cl-letf-bound-- (fset (quote send-w= ait) --cl-letf-save--) (fmakunbound (quote send-wait))))) (letf (((symbol-function (quote send-wait)) (function* (lambda nil (block= send-wait (comint-send-input nil t) (sleep-for 0 5)))))) (letf (((symbol-f= unction (quote dump-last-value)) (function* (lambda (tmp-file pp) (block du= mp-last-value (mapc ... ...)))))) (letf (((symbol-function (quote input-bod= y)) (function* (lambda (body) (block input-body ... ...))))) ((lambda (resu= lts) (unless (string=3D (substring org-babel-python-eoe-indicator 1 -1) res= ults) (if (or ... ... ...) results (org-babel-python-table-or-string result= s)))) (case result-type (output (mapconcat (function org-babel-trim) (butla= st ... 2) "\n")) (value (let (...) (org-babel-comint-with-output ... ...) (= org-babel-eval-read-file tmp-file)))))))) (letf* (((symbol-function (quote send-wait)) (function* (lambda nil (bloc= k send-wait (comint-send-input nil t) (sleep-for 0 5))))) ((symbol-function= (quote dump-last-value)) (function* (lambda (tmp-file pp) (block dump-last= -value (mapc (lambda ... ... ...) (if pp ... ...)))))) ((symbol-function (q= uote input-body)) (function* (lambda (body) (block input-body (mapc (lambda= ... ... ...) (split-string body "[ \n]")) (send-wait)))))) ((lambda (results) (unless (string=3D (substring or= g-babel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-p= arams) (member "pp" result-params) (and (member "output" result-params) (no= t ...))) results (org-babel-python-table-or-string results)))) (case result= -type (output (mapconcat (function org-babel-trim) (butlast (org-babel-comi= nt-with-output (session org-babel-python-eoe-indicator t body) (input-body = body) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send= -wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-"))) = (org-babel-comint-with-output (session org-babel-python-eoe-indicator nil b= ody) (let (...) (input-body body) (dump-last-value tmp-file ...) (send-wait= ) (send-wait) (insert org-babel-python-eoe-indicator) (send-wait))) (org-ba= bel-eval-read-file tmp-file)))))) (flet ((send-wait nil (comint-send-input nil t) (sleep-for 0 5)) (dump-la= st-value (tmp-file pp) (mapc (lambda (statement) (insert statement) (send-w= ait)) (if pp (list "import pprint" (format "open('%s', 'w').write(pprint.pf= ormat(_))" (org-babel-process-file-name tmp-file ...))) (list (format "open= ('%s', 'w').write(str(_))" (org-babel-process-file-name tmp-file ...)))))) = (input-body (body) (mapc (lambda (line) (insert line) (send-wait)) (split-s= tring body "[ \n]")) (send-wait))) ((lambda (results) (unless (string=3D (substring org-b= abel-python-eoe-indicator 1 -1) results) (if (or (member "code" result-para= ms) (member "pp" result-params) (and (member "output" result-params) (not .= ..))) results (org-babel-python-table-or-string results)))) (case result-ty= pe (output (mapconcat (function org-babel-trim) (butlast (org-babel-comint-= with-output (session org-babel-python-eoe-indicator t body) (input-body bod= y) (send-wait) (send-wait) (insert org-babel-python-eoe-indicator) (send-wa= it)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-"))) (or= g-babel-comint-with-output (session org-babel-python-eoe-indicator nil body= ) (let (...) (input-body body) (dump-last-value tmp-file ...) (send-wait) (= send-wait) (insert org-babel-python-eoe-indicator) (send-wait))) (org-babel= -eval-read-file tmp-file)))))) org-babel-python-evaluate-session(# "print \"%d + %d =3D= %d\" % (2, 3, 2+3)\n2**5" output ("output" "replace")) (if session (org-babel-python-evaluate-session session body result-type r= esult-params) (org-babel-python-evaluate-external-process body result-type = result-params preamble)) org-babel-python-evaluate(# "print \"%d + %d =3D %d\" % = (2, 3, 2+3)\n2**5" output ("output" "replace") nil) (let* ((session (org-babel-python-initiate-session (cdr (assoc :session p= arams)))) (result-params (cdr (assoc :result-params params))) (result-type = (cdr (assoc :result-type params))) (return-val (when (and (eq result-type (= quote value)) (not session)) (cdr (assoc :return params)))) (preamble (cdr = (assoc :preamble params))) (full-body (org-babel-expand-body:generic (conca= t body (if return-val (format "return %s" return-val) "")) params (org-babe= l-variable-assignments:python params))) (result (org-babel-python-evaluate = session full-body result-type result-params preamble))) (org-babel-reassemb= le-table result (org-babel-pick-name (cdr (assoc :colname-names params)) (c= dr (assoc :colnames params))) (org-babel-pick-name (cdr (assoc :rowname-nam= es params)) (cdr (assoc :rownames params))))) org-babel-execute:python("print \"%d + %d =3D %d\" % (2, 3, 2+3)\n2**5" (= (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . = "no") (:tangle . "no") (:exports . "code") (:results . "replace output") (:= hlines . "no") (:padnewline . "yes") (:session) (:result-type . output) (:r= esult-params "output" "replace") (:rowname-names) (:colname-names))) funcall(org-babel-execute:python "print \"%d + %d =3D %d\" % (2, 3, 2+3)\= n2**5" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:= noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace out= put") (:hlines . "no") (:padnewline . "yes") (:session) (:result-type . out= put) (:result-params "output" "replace") (:rowname-names) (:colname-names))= ) ((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote v= alue)) (or (member "vector" result-params) (member "table" result-params)) = (not (listp result))) (list (list result)) result)) (funcall cmd body param= s)) (setq result ((lambda (result) (if (and (eq (cdr (assoc :result-type para= ms)) (quote value)) (or (member "vector" result-params) (member "table" res= ult-params)) (not (listp result))) (list (list result)) result)) (funcall c= md body params))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (g= oto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (f= orward-char 1) (setq result (org-babel-read-result)) (message (replace-rege= xp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s= code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4= info)) "")) (setq result ((lambda (result) (if (and (eq (cdr ...) (quote v= alue)) (or (member "vector" result-params) (member "table" result-params)) = (not (listp result))) (list (list result)) result)) (funcall cmd body param= s))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (as= soc :file params)) (insert (org-babel-format-result result (cdr (assoc :sep= ...)))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-resu= lt result result-params info new-hash indent lang) (run-hooks (quote org-ba= bel-after-execute-hook)) result) (progn (fset (quote call-process-region) (function* (lambda (&rest args) = (block call-process-region (apply (quote org-babel-tramp-handle-call-proces= s-region) args))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (f= boundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (c= dr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function= for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (= save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (= end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (mess= age (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (mess= age "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (form= at " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq .= .. ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd = body params))) (when (cdr (assoc :file params)) (when result (with-temp-fil= e (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr .= ..))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result = result result-params info new-hash indent lang) (run-hooks (quote org-babel= -after-execute-hook)) result)) (unwind-protect (progn (fset (quote call-process-region) (function* (lamb= da (&rest args) (block call-process-region (apply (quote org-babel-tramp-ha= ndle-call-process-region) args))))) (flet ((lang-check (f) (let ((f ...)) (= when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-= name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (i= f (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-= char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forwa= rd-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-i= n-string "%" "%%" (format "%S" result))) result) (message "executing %s cod= e block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 inf= o)) "")) (setq result ((lambda (result) (if (and ... ... ...) (list ...) re= sult)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when r= esult (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-= result result ...)))) (setq result (cdr (assoc :file params)))) (org-babel-= insert-result result result-params info new-hash indent lang) (run-hooks (q= uote org-babel-after-execute-hook)) result)) (if --cl-letf-bound-- (fset (q= uote call-process-region) --cl-letf-save--) (fmakunbound (quote call-proces= s-region)))) (let* ((--cl-letf-bound-- (fboundp (quote call-process-region))) (--cl-le= tf-save-- (and --cl-letf-bound-- (symbol-function (quote call-process-regio= n))))) (unwind-protect (progn (fset (quote call-process-region) (function* = (lambda (&rest args) (block call-process-region (apply ... args))))) (flet = ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-check lang)= (lang-check (symbol-name ...)) (error "No org-babel-execute function for %= s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-e= xcursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of= -line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (r= eplace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "e= xecuting %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (= %s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... ... result))= (funcall cmd body params))) (when (cdr (assoc :file params)) (when result = (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (assoc :file par= ams)))) (org-babel-insert-result result result-params info new-hash indent = lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if --cl-le= tf-bound-- (fset (quote call-process-region) --cl-letf-save--) (fmakunbound= (quote call-process-region))))) (letf (((symbol-function (quote call-process-region)) (function* (lambda = (&rest args) (block call-process-region (apply (quote org-babel-tramp-handl= e-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern .= ..))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (= symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-ex= ecute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-has= h old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-resul= t nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-= result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result)))= result) (message "executing %s code block%s..." (capitalize lang) (if (nth= 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) = (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result))= (funcall cmd body params))) (when (cdr (assoc :file params)) (when result = (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result= result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-= insert-result result result-params info new-hash indent lang) (run-hooks (q= uote org-babel-after-execute-hook)) result)) (letf* (((symbol-function (quote call-process-region)) (function* (lambda= (&rest args) (block call-process-region (apply (quote org-babel-tramp-hand= le-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern = ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check = (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-e= xecute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-ha= sh old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-resu= lt nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read= -result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))= ) result) (message "executing %s code block%s..." (capitalize lang) (if (nt= h 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result)= (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)= ) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result= (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-resul= t result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel= -insert-result result result-params info new-hash indent lang) (run-hooks (= quote org-babel-after-execute-hook)) result)) (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-ha= ndle-call-process-region) args))) (flet ((lang-check (f) (let ((f (intern .= ..))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (= symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-ex= ecute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-has= h old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-resul= t nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-= result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result)))= result) (message "executing %s code block%s..." (capitalize lang) (if (nth= 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) = (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result))= (funcall cmd body params))) (when (cdr (assoc :file params)) (when result = (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result= result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-= insert-result result result-params info new-hash indent lang) (run-hooks (q= uote org-babel-after-execute-hook)) result)) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote or= g-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (l= et ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-= check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s= !" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-ex= cursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-= line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (re= place-regexp-in-string "%" "%%" (format "%S" result))) result) (message "ex= ecuting %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%= s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ... ... ...)= (list ...) result)) (funcall cmd body params))) (when (cdr (assoc :file pa= rams)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org= -babel-format-result result ...)))) (setq result (cdr (assoc :file params))= )) (org-babel-insert-result result result-params info new-hash indent lang)= (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-proce= ss-region (quote org-babel-call-process-region-original))) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (= org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (= not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr (assoc :cache pa= rams))))) (result-params (cdr (assoc :result-params params))) (new-hash (wh= en cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-= current-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb-p para= ms :eval) (org-babel-expand-noweb-references info) (nth 1 info)))) (dir (cd= r (assoc :dir params))) (default-directory (or (and dir (file-name-as-direc= tory dir)) default-directory)) (org-babel-call-process-region-original (if = (boundp (quote org-babel-call-process-region-original)) org-babel-call-proc= ess-region-original (symbol-function (quote call-process-region)))) (indent= (car (last info))) result cmd) (unwind-protect (flet ((call-process-region= (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) arg= s))) (flet ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-= check lang) (lang-check (symbol-name ...)) (error "No org-babel-execute fun= ction for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-has= h)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil inf= o)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) = (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) = (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) = (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... .= .. result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (w= hen result (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (asso= c :file params)))) (org-babel-insert-result result result-params info new-h= ash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) = (setq call-process-region (quote org-babel-call-process-region-original)))) (progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-p= arams (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\?= (and (not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr (assoc :c= ache params))))) (result-params (cdr (assoc :result-params params))) (new-h= ash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org= -babel-current-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb= -p params :eval) (org-babel-expand-noweb-references info) (nth 1 info)))) (= dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-a= s-directory dir)) default-directory)) (org-babel-call-process-region-origin= al (if (boundp (quote org-babel-call-process-region-original)) org-babel-ca= ll-process-region-original (symbol-function (quote call-process-region)))) = (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process= -region (&rest args) (apply (quote org-babel-tramp-handle-call-process-regi= on) args))) (flet ((lang-check (f) (let ... ...))) (setq cmd (or (lang-chec= k lang) (lang-check ...) (error "No org-babel-execute function for %s!" lan= g)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursio= n (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1= ) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-= regexp-in-string "%" "%%" ...)) result) (message "executing %s code block%s= ..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq res= ult ((lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file p= arams)) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (or= g-babel-insert-result result result-params info new-hash indent lang) (run-= hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-reg= ion (quote org-babel-call-process-region-original))))) (if (org-babel-confirm-evaluate (let ((i info)) (setf (nth 2 i) (org-babe= l-merge-params (nth 2 info) params)) i)) (progn (let* ((lang (nth 0 info)) = (params (if params (org-babel-process-params (org-babel-merge-params ... pa= rams)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (= string=3D "yes" (cdr ...)))) (result-params (cdr (assoc :result-params para= ms))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when = cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (if (org= -babel-noweb-p params :eval) (org-babel-expand-noweb-references info) (nth = 1 info)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir = (file-name-as-directory dir)) default-directory)) (org-babel-call-process-r= egion-original (if (boundp (quote org-babel-call-process-region-original)) = org-babel-call-process-region-original (symbol-function (quote call-process= -region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((= call-process-region (&rest args) (apply ... args))) (flet ((lang-check ... = ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal new-h= ash old-hash)) (save-excursion (goto-char ...) (end-of-line 1) (forward-cha= r 1) (setq result ...) (message ...) result) (message "executing %s code bl= ock%s..." (capitalize lang) (if ... ... "")) (setq result (... ...)) (when = (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result res= ult result-params info new-hash indent lang) (run-hooks (quote org-babel-af= ter-execute-hook)) result)) (setq call-process-region (quote org-babel-call= -process-region-original)))))) (when (org-babel-confirm-evaluate (let ((i info)) (setf (nth 2 i) (org-ba= bel-merge-params (nth 2 info) params)) i)) (let* ((lang (nth 0 info)) (para= ms (if params (org-babel-process-params (org-babel-merge-params (nth 2 info= ) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params= )) (string=3D "yes" (cdr (assoc :cache params))))) (result-params (cdr (ass= oc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash in= fo))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf= (nth 1 info) (if (org-babel-noweb-p params :eval) (org-babel-expand-noweb-= references info) (nth 1 info)))) (dir (cdr (assoc :dir params))) (default-d= irectory (or (and dir (file-name-as-directory dir)) default-directory)) (or= g-babel-call-process-region-original (if (boundp (quote org-babel-call-proc= ess-region-original)) org-babel-call-process-region-original (symbol-functi= on (quote call-process-region)))) (indent (car (last info))) result cmd) (u= nwind-protect (flet ((call-process-region (&rest args) (apply (quote org-ba= bel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let .= .. ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No org-b= abel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal = new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-bloc= k-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babe= l-read-result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (= message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (= format " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body p= arams))) (when (cdr (assoc :file params)) (when result (with-temp-file ... = ...)) (setq result (cdr ...))) (org-babel-insert-result result result-param= s info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook= )) result)) (setq call-process-region (quote org-babel-call-process-region-= original))))) (let ((info (or info (org-babel-get-src-block-info)))) (when (org-babel-c= onfirm-evaluate (let ((i info)) (setf (nth 2 i) (org-babel-merge-params (nt= h 2 info) params)) i)) (let* ((lang (nth 0 info)) (params (if params (org-b= abel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (ca= che\? (and (not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr ...)= ))) (result-params (cdr (assoc :result-params params))) (new-hash (when cac= he\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-curren= t-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb-p params :ev= al) (org-babel-expand-noweb-references info) (nth 1 info)))) (dir (cdr (ass= oc :dir params))) (default-directory (or (and dir (file-name-as-directory d= ir)) default-directory)) (org-babel-call-process-region-original (if (bound= p (quote org-babel-call-process-region-original)) org-babel-call-process-re= gion-original (symbol-function (quote call-process-region)))) (indent (car = (last info))) result cmd) (unwind-protect (flet ((call-process-region (&res= t args) (apply ... args))) (flet ((lang-check ... ...)) (setq cmd (or ... .= .. ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excu= rsion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (m= essage ...) result) (message "executing %s code block%s..." (capitalize lan= g) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when result ..= .) (setq result ...)) (org-babel-insert-result result result-params info ne= w-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result= )) (setq call-process-region (quote org-babel-call-process-region-original)= ))))) org-babel-execute-src-block(nil ("python" "print \"%d + %d =3D %d\" % (2,= 3, 2+3)\n2**5" ((:comments . "") (:shebang . "") (:cache . "no") (:padline= . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "re= place output") (:hlines . "no") (:padnewline . "yes") (:session) (:result-t= ype . output) (:result-params "output" "replace") (:rowname-names) (:colnam= e-names)) "" nil 0)) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block cu= rrent-prefix-arg info) t) (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src= -block current-prefix-arg info) t) nil) (let ((info (org-babel-get-src-block-info))) (if info (progn (org-babel-e= val-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info= ) t) nil)) org-babel-execute-src-block-maybe() (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe)) org-babel-execute-maybe() (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-execute-maybe)) (unless org-babel-no-eval-on-ctrl-c-ctrl-c (org-babel-execute-maybe)) org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) (cond ((or (and (boundp (quote org-clock-overlays)) org-clock-overlays) o= rg-occur-highlights org-latex-fragment-image-overlays) (and (boundp (quote = org-clock-overlays)) (org-clock-remove-overlays)) (org-remove-occur-highlig= hts) (org-remove-latex-fragment-image-overlays) (message "Temporary highlig= hts/overlays removed from current buffer")) ((and (local-variable-p (quote = org-finish-function) (current-buffer)) (fboundp org-finish-function)) (func= all org-finish-function)) ((run-hook-with-args-until-success (quote org-ctr= l-c-ctrl-c-hook))) ((org-in-regexp org-ts-regexp-both) (org-timestamp-chang= e 0 (quote day))) ((or (looking-at org-property-start-re) (org-at-property-= p)) (call-interactively (quote org-property-action))) ((org-at-target-p) (c= all-interactively (quote org-update-radio-target-regexp))) ((and (org-in-re= gexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]") (or (org-at-heading-p) (org-at-= item-p))) (call-interactively (quote org-update-statistics-cookies))) ((org= -at-heading-p) (call-interactively (quote org-set-tags))) ((org-at-table\.e= l-p) (message "Use C-c ' to edit table.el tables")) ((org-at-table-p) (org-= table-maybe-eval-formula) (if arg (call-interactively (quote org-table-reca= lculate)) (org-table-maybe-recalculate-line)) (call-interactively (quote or= g-table-align)) (orgtbl-send-table (quote maybe))) ((or (org-footnote-at-re= ference-p) (org-footnote-at-definition-p)) (call-interactively (quote org-f= ootnote-action))) ((org-at-item-checkbox-p) (let* ((cbox (match-string 1)) = (struct (org-list-struct)) (old-struct (copy-tree struct)) (parents (org-li= st-parents-alist struct)) (orderedp (org-entry-get nil "ORDERED")) (firstp = (=3D (org-list-get-top-point struct) (point-at-bol))) block-item) (let ((ne= w-box (cond (... "[-]") (... nil) (... "[ ]") (t "[X]")))) (if (and firstp = arg) (mapc (lambda (pos) (org-list-set-checkbox pos struct new-box)) (org-l= ist-get-all-items (point-at-bol) struct (org-list-prevs-alist struct))) (or= g-list-set-checkbox (point-at-bol) struct new-box))) (org-list-struct-fix-i= nd struct parents 2) (org-list-struct-fix-item-end struct) (let ((prevs (or= g-list-prevs-alist struct))) (org-list-struct-fix-bul struct prevs) (org-li= st-struct-fix-ind struct parents) (setq block-item (org-list-struct-fix-box= struct parents prevs orderedp))) (org-list-struct-apply-struct struct old-= struct) (org-update-checkbox-count-maybe) (when block-item (message "Checkb= oxes were removed due to unchecked box at line %d" (org-current-line block-= item))) (when firstp (org-list-send-list (quote maybe))))) ((org-at-item-p)= (let* ((struct (org-list-struct)) (firstp (=3D (org-list-get-top-point str= uct) (point-at-bol))) old-struct) (when arg (setq old-struct (copy-tree str= uct)) (if firstp (mapc (lambda (pos) (unless ... ...)) (org-list-get-all-it= ems (point-at-bol) struct (org-list-prevs-alist struct))) (org-list-set-che= ckbox (point-at-bol) struct "[ ]"))) (org-list-write-struct struct (org-lis= t-parents-alist struct) old-struct) (when arg (org-update-checkbox-count-ma= ybe)) (when firstp (org-list-send-list (quote maybe))))) ((save-excursion (= beginning-of-line 1) (looking-at org-dblock-start-re)) (beginning-of-line 1= ) (save-excursion (org-update-dblock))) ((save-excursion (beginning-of-line= 1) (looking-at "[ ]*#\\+\\([A-Z]+\\)")) (cond ((equal (match-strin= g 1) "TBLFM") (save-excursion (beginning-of-line 1) (skip-chars-backward " \n ") (if (org-at-table-p) (org-call-with-arg (quote org-table-recalcu= late) (or arg t))))) (t (let ((org-inhibit-startup-visibility-stuff t) (org= -startup-align-all-tables nil)) (when (boundp (quote org-table-coordinate-o= verlays)) (mapc (quote delete-overlay) org-table-coordinate-overlays) (setq= org-table-coordinate-overlays nil)) (org-save-outline-visibility (quote us= e-markers) (org-mode-restart))) (message "Local setup has been refreshed"))= )) ((org-clock-update-time-maybe)) (t (or (run-hook-with-args-until-success= (quote org-ctrl-c-ctrl-c-final-hook)) (error "C-c C-c can do nothing usefu= l at this location")))) (let ((org-enable-table-editor t)) (cond ((or (and (boundp (quote org-clo= ck-overlays)) org-clock-overlays) org-occur-highlights org-latex-fragment-i= mage-overlays) (and (boundp (quote org-clock-overlays)) (org-clock-remove-o= verlays)) (org-remove-occur-highlights) (org-remove-latex-fragment-image-ov= erlays) (message "Temporary highlights/overlays removed from current buffer= ")) ((and (local-variable-p (quote org-finish-function) (current-buffer)) (= fboundp org-finish-function)) (funcall org-finish-function)) ((run-hook-wit= h-args-until-success (quote org-ctrl-c-ctrl-c-hook))) ((org-in-regexp org-t= s-regexp-both) (org-timestamp-change 0 (quote day))) ((or (looking-at org-p= roperty-start-re) (org-at-property-p)) (call-interactively (quote org-prope= rty-action))) ((org-at-target-p) (call-interactively (quote org-update-radi= o-target-regexp))) ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\= ]") (or (org-at-heading-p) (org-at-item-p))) (call-interactively (quote org= -update-statistics-cookies))) ((org-at-heading-p) (call-interactively (quot= e org-set-tags))) ((org-at-table\.el-p) (message "Use C-c ' to edit table.e= l tables")) ((org-at-table-p) (org-table-maybe-eval-formula) (if arg (call-= interactively (quote org-table-recalculate)) (org-table-maybe-recalculate-l= ine)) (call-interactively (quote org-table-align)) (orgtbl-send-table (quot= e maybe))) ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p= )) (call-interactively (quote org-footnote-action))) ((org-at-item-checkbox= -p) (let* ((cbox (match-string 1)) (struct (org-list-struct)) (old-struct (= copy-tree struct)) (parents (org-list-parents-alist struct)) (orderedp (org= -entry-get nil "ORDERED")) (firstp (=3D (org-list-get-top-point struct) (po= int-at-bol))) block-item) (let ((new-box (cond ... ... ... ...))) (if (and = firstp arg) (mapc (lambda ... ...) (org-list-get-all-items ... struct ...))= (org-list-set-checkbox (point-at-bol) struct new-box))) (org-list-struct-f= ix-ind struct parents 2) (org-list-struct-fix-item-end struct) (let ((prevs= (org-list-prevs-alist struct))) (org-list-struct-fix-bul struct prevs) (or= g-list-struct-fix-ind struct parents) (setq block-item (org-list-struct-fix= -box struct parents prevs orderedp))) (org-list-struct-apply-struct struct = old-struct) (org-update-checkbox-count-maybe) (when block-item (message "Ch= eckboxes were removed due to unchecked box at line %d" (org-current-line bl= ock-item))) (when firstp (org-list-send-list (quote maybe))))) ((org-at-ite= m-p) (let* ((struct (org-list-struct)) (firstp (=3D (org-list-get-top-point= struct) (point-at-bol))) old-struct) (when arg (setq old-struct (copy-tree= struct)) (if firstp (mapc (lambda ... ...) (org-list-get-all-items ... str= uct ...)) (org-list-set-checkbox (point-at-bol) struct "[ ]"))) (org-list-w= rite-struct struct (org-list-parents-alist struct) old-struct) (when arg (o= rg-update-checkbox-count-maybe)) (when firstp (org-list-send-list (quote ma= ybe))))) ((save-excursion (beginning-of-line 1) (looking-at org-dblock-star= t-re)) (beginning-of-line 1) (save-excursion (org-update-dblock))) ((save-e= xcursion (beginning-of-line 1) (looking-at "[ ]*#\\+\\([A-Z]+\\)")) (con= d ((equal (match-string 1) "TBLFM") (save-excursion (beginning-of-line 1) (= skip-chars-backward " \n ") (if (org-at-table-p) (org-call-with-arg ... ...)))) (t (let ((or= g-inhibit-startup-visibility-stuff t) (org-startup-align-all-tables nil)) (= when (boundp ...) (mapc ... org-table-coordinate-overlays) (setq org-table-= coordinate-overlays nil)) (org-save-outline-visibility (quote use-markers) = (org-mode-restart))) (message "Local setup has been refreshed")))) ((org-cl= ock-update-time-maybe)) (t (or (run-hook-with-args-until-success (quote org= -ctrl-c-ctrl-c-final-hook)) (error "C-c C-c can do nothing useful at this l= ocation"))))) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil)