[ESS] In Stata mode, where do graphs display?

Brendan Halpin brend@n@h@|p|n @end|ng |rom u|@|e
Wed Feb 24 19:23:14 CET 2016

First question:

Console Stata doesn't show graphs. What I do is export it to EPS and
view that:

. graph export /tmp/x.eps, replace
. !evince /tmp/x.eps &

This is for Linux, the detail will differ according to OS.

Second question: re line ends:

What Stata does itself with its "do-file" editor is to write the region
to a temporary file, issue a command within Stata to "do" the temporary
file, and then delete it. I emulate this with a function with which I
replace the usual eval-region command. This is largely based on
ess-eval-region. See below.



;; Stata equivalent of ess-eval-region

(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'."
  (interactive "r\nP")
  (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)
    (goto-char start)
    (skip-chars-forward "\n\t ")
    (setq start (point))

    (unless mark-active
      (ess-blink-region start end))

    ;; don't send new lines at the end (avoid screwing the debugger)
    (goto-char end)
    (skip-chars-backward "\n\t ")
    (setq end (point)))

  (let* (delimit
         (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 ";" 
      (goto-char start)
      (setq delimit (re-search-backward "^#delimit +\\(.+\\)$" nil t))
      (if delimit 
          (if (not (string-match ";" (match-string 1))) (setq delimit nil))))

      (if clear (insert "clear\n"))
      (if delimit (insert "#delimit ;\n" 
                          "\n#delimit cr\n")
        (insert commands "\n"))
      (write-file delimit-do-file nil)
      (kill-buffer (current-buffer)))

     (get-ess-process ess-current-process-name)
     (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             Room F1-002 x 3147
mailto:brendan.halpin using ul.ie    ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology

More information about the ESS-help mailing list