summaryrefslogtreecommitdiff
path: root/lisp/ob-comint.el
diff options
context:
space:
mode:
authorSébastien Delafond <sdelafond@gmail.com>2016-11-07 10:41:54 +0100
committerSébastien Delafond <sdelafond@gmail.com>2016-11-07 10:41:54 +0100
commit1a7cd65ca362047cd97d4127d49108994baebc6c (patch)
treef18735f3b77120ef2e91043f2f662b03e47ccbb0 /lisp/ob-comint.el
parent55074078ca876273e3fa58ee6838cba90d2b6100 (diff)
parentec84430cf4e09ba25ec675debdf802bc28111e06 (diff)
Merge tag 'upstream/9.0'
Upstream version 9.0
Diffstat (limited to 'lisp/ob-comint.el')
-rw-r--r--lisp/ob-comint.el34
1 files changed, 16 insertions, 18 deletions
diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 8145d2c..dd696c2 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -1,4 +1,4 @@
-;;; ob-comint.el --- org-babel functions for interaction with comint buffers
+;;; ob-comint.el --- Babel Functions for Interaction with Comint Buffers -*- lexical-binding: t; -*-
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
@@ -33,9 +33,7 @@
(require 'ob-core)
(require 'org-compat)
(require 'comint)
-(eval-when-compile (require 'cl))
-(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
-(declare-function tramp-flush-directory-property "tramp" (vec directory))
+(require 'tramp)
(defun org-babel-comint-buffer-livep (buffer)
"Check if BUFFER is a comint buffer with a live process."
@@ -53,8 +51,9 @@ executed inside the protection of `save-excursion' and
(error "Buffer %s does not exist or has no process" ,buffer))
(save-match-data
(with-current-buffer ,buffer
- (let ((comint-input-filter (lambda (input) nil)))
- ,@body)))))
+ (save-excursion
+ (let ((comint-input-filter (lambda (_input) nil)))
+ ,@body))))))
(def-edebug-spec org-babel-comint-in-buffer (form body))
(defmacro org-babel-comint-with-output (meta &rest body)
@@ -79,7 +78,7 @@ or user `keyboard-quit' during execution of body."
(comint-output-filter-functions
(cons (lambda (text) (setq string-buffer (concat string-buffer text)))
comint-output-filter-functions))
- dangling-text raw)
+ dangling-text)
;; got located, and save dangling text
(goto-char (process-mark (get-buffer-process (current-buffer))))
(let ((start (point))
@@ -107,12 +106,12 @@ or user `keyboard-quit' during execution of body."
(insert dangling-text)
;; remove echo'd FULL-BODY from input
- (if (and ,remove-echo ,full-body
- (string-match
- (replace-regexp-in-string
- "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
- string-buffer))
- (setq raw (substring string-buffer (match-end 0))))
+ (when (and ,remove-echo ,full-body
+ (string-match
+ (replace-regexp-in-string
+ "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
+ string-buffer))
+ (setq string-buffer (substring string-buffer (match-end 0))))
(split-string string-buffer comint-prompt-regexp)))))
(def-edebug-spec org-babel-comint-with-output (sexp body))
@@ -145,15 +144,14 @@ Don't return until FILE exists. Code in STRING must ensure that
FILE exists at end of evaluation."
(unless (org-babel-comint-buffer-livep buffer)
(error "Buffer %s does not exist or has no process" buffer))
- (if (file-exists-p file) (delete-file file))
+ (when (file-exists-p file) (delete-file file))
(process-send-string
(get-buffer-process buffer)
(if (= (aref string (1- (length string))) ?\n) string (concat string "\n")))
;; From Tramp 2.1.19 the following cache flush is not necessary
- (if (file-remote-p default-directory)
- (let (v)
- (with-parsed-tramp-file-name default-directory nil
- (tramp-flush-directory-property v ""))))
+ (when (file-remote-p default-directory)
+ (with-parsed-tramp-file-name default-directory nil
+ (tramp-flush-directory-property v "")))
(while (not (file-exists-p file)) (sit-for (or period 0.25))))
(provide 'ob-comint)