diff --git a/etc/ESSR/R/mpi.R b/etc/ESSR/R/mpi.R index 53d7e470f..c29bfb48b 100644 --- a/etc/ESSR/R/mpi.R +++ b/etc/ESSR/R/mpi.R @@ -7,7 +7,8 @@ else as.character(el) }) payload <- paste(dots, collapse = "") - cat(sprintf("_%s%s\\", head, payload)) + ## see docstring for ess-mpi-handle-messages + cat(sprintf("\035\036%s\037%s\036\035", head, payload)) } .ess_mpi_message <- function(msg){ diff --git a/lisp/ess-tracebug.el b/lisp/ess-tracebug.el index 234697e1a..8bab28f94 100644 --- a/lisp/ess-tracebug.el +++ b/lisp/ess-tracebug.el @@ -1182,10 +1182,10 @@ Kill the *ess.dbg.[R_name]* buffer." ;;; MPI ;; http://jkorpela.fi/chars/c0.html -;; https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequences -(defvar ess-mpi-message-start-delimiter "_") -(defvar ess-mpi-message-field-separator "") -(defvar ess-mpi-message-end-delimiter "\\") +;; https://en.wikipedia.org/wiki/C0_and_C1_control_codes +(defvar ess--mpi-message-start-delimiter "\035\036") ; GS RS +(defvar ess--mpi-message-field-separator "\037") ; US +(defvar ess--mpi-message-end-delimiter "\036\035") ; RS GS (define-obsolete-variable-alias 'ess-mpi-alist 'ess-mpi-handlers "ESS 19.04") (defvar ess-mpi-handlers @@ -1229,10 +1229,12 @@ value from EXPR and then sent to the subprocess." (defun ess-mpi-handle-messages (buf) "Handle all mpi messages in BUF and delete them. -The MPI message has the form TYPEFIELD... where TYPE is the -type of the messages on which handlers in `ess-mpi-handlers' are -dispatched. And FIELDs are strings. Return :incomplete if BUF -ends with an incomplete message." +The MPI message has the form \035\036TYPE\037FIELD\036\035 where TYPE +is the type of the messages on which handlers in +`ess-mpi-handlers' are dispatched, and FIELDs are strings. Note +that the MPI message contains literal ASCII control codes as +delimiters. Return :incomplete if BUF ends with an incomplete +message." (let ((obuf (current-buffer)) (out nil)) (with-current-buffer buf @@ -1240,15 +1242,15 @@ ends with an incomplete message." ;; This should be smarter because Emacs might cut it in the middle of the ;; message. In practice this almost never happen because we are ;; accumulating output into the cache buffer. - (while (search-forward ess-mpi-message-start-delimiter nil t) + (while (search-forward ess--mpi-message-start-delimiter nil t) (let ((mbeg0 (match-beginning 0)) (mbeg (match-end 0))) - (if (search-forward ess-mpi-message-end-delimiter nil t) + (if (search-forward ess--mpi-message-end-delimiter nil t) (let* ((mend (match-beginning 0)) (mend0 (match-end 0)) (msg (buffer-substring mbeg mend)) (payload (mapcar #'ess-mpi-convert - (split-string msg ess-mpi-message-field-separator))) + (split-string msg ess--mpi-message-field-separator))) (head (pop payload)) (handler (cdr (assoc head ess-mpi-handlers)))) (unwind-protect @@ -1257,7 +1259,8 @@ ends with an incomplete message." (apply handler payload)) (error "No handler defined for MPI message '%s" head)) (goto-char mbeg0) - (delete-region mbeg0 mend0))) + (let ((inhibit-read-only t)) + (delete-region mbeg0 mend0)))) (setq out :incomplete)))) out))) diff --git a/lisp/essd-els.el b/lisp/essd-els.el index c72805726..a5487c95f 100644 --- a/lisp/essd-els.el +++ b/lisp/essd-els.el @@ -154,7 +154,8 @@ DIALECT is the desired ess-dialect. If nil, ask for dialect" (ess-eval-linewise (format "options(pager='%s')\n" (or inferior-ess-remote-pager inferior-ess-pager)) nil nil nil 'wait) - (ess-r-load-ESSR)) + (ess-r-load-ESSR) + (when ess-use-tracebug (ess-tracebug 1))) (when (equal ess-dialect "S+") (ess-command ess-S+--injected-code))