[ESS] ESS + Stata: not reading continuation lines in syntax ///
brend@n@h@|p|n @end|ng |rom u|@|e
Tue Jan 20 22:23:00 CET 2015
Generally speaking, ESS doesn't deal with the fact that Stata has
different rules for handling code is in files (executed by "run" or
"do", or in batch) compared with code that is entered a line at a time.
Similarly, it doesn't deal with the fact the end-of-command delimiters
can be changed (in batch mode).
I deal with this by over-riding the C-c C-r key binding to run the
function at the end of this mail, which is in part based on the
corresponding ESS code. This emulates Stata's manner of running blocks
of code from the do-file editor, by saving the region to a temporary
file, and executing a "do" command on the temporary file (then deleting
it). It also scans backwards for a "#delimit ;" command in case it is
;; Jun 14 2014 21:57:03
;; Merged delimit-do and ess-eval-region to make a new solution
(defun delimit-do (start end toggle &optional clear message)
"Send the current region to the inferior ESS process, Stata do-editor style.
Creates a temporary file, \"do\"-es it, deletes it.
With prefix argument toggle the meaning of `ess-eval-visibly-p';
this does not apply when using the S-plus GUI, see `ess-eval-region-ddeclient'."
(ess-force-buffer-current "Process to use: ")
(message "Starting evaluation...")
(setq message (or message "Eval region"))
;; don't send new lines (avoid screwing the debugger)
(skip-chars-forward "\n\t ")
(setq start (point))
(ess-blink-region start end))
;; don't send new lines at the end (avoid screwing the debugger)
(skip-chars-backward "\n\t ")
(setq end (point)))
(commands (buffer-substring-no-properties start end))
(delimit-do-file (make-temp-file "delimit-do" nil ".do"))
(proc (get-process ess-local-process-name))
(visibly (if toggle (not ess-eval-visibly-p) ess-eval-visibly-p))
(dev-p (process-get proc 'developer))
(tb-p (process-get proc 'tracebug)))
;; Go to the start of the section and look back for #delimit
;; if found set delimit unless the delimiter is not ";"
(setq delimit (re-search-backward "^#delimit +\\(.+\\)$" nil t))
(if (not (string-match ";" (match-string 1))) (setq delimit nil)))
(if clear (insert "clear\n"))
(if delimit (insert "#delimit ;\n"
(insert commands "\n"))
(write-file delimit-do-file nil)
(format "do %s\nrm %s\n" delimit-do-file delimit-do-file))
(if (and (fboundp 'deactivate-mark) ess-eval-deactivate-mark)
;; return value
(list start end))
Brendan Halpin, Head, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F1-002 x 3147
mailto:brendan.halpin using ul.ie ULSociology on Facebook: http://on.fb.me/fjIK9t
More information about the ESS-help