[ESS] ESS + Stata: not reading continuation lines in syntax ///

Aaron Ponce @@rjpon @end|ng |rom gm@||@com
Wed Jan 21 00:03:19 CET 2015


Brilliant, thank you! This helps tremendously. I just had to change
"get-ess-process" to "ess-get-process" since it was giving me trouble, and
I'm guessing it was renamed at some point (
https://stat.ethz.ch/pipermail/ess-help/2013-March/008711.html). Other than
that, everything is working smoothly for the time being. Thank you from one
sociologist to another!

AP



On Tue, Jan 20, 2015 at 4:23 PM, Brendan Halpin <brendan.halpin using ul.ie>
wrote:

> 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
> set.
>
> Regards,
>
> Brendan
>
> ;; 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'."
>   (interactive "r\nP")
>   (ess-force-buffer-current "Process to use: ")
>   (message "Starting evaluation...")
>   (setq message (or message "Eval region"))
>
>   (save-excursion
>     ;; 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)))
>
>     (with-temp-buffer
>       (if clear (insert "clear\n"))
>       (if delimit (insert "#delimit ;\n"
>                           commands
>                           "\n#delimit cr\n")
>         (insert commands "\n"))
>       (write-file delimit-do-file nil)
>       (kill-buffer (current-buffer)))
>
>     (process-send-string
>      (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)
>       (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
> http://teaching.sociology.ul.ie/bhalpin/wordpress
>  twitter:@ULSociology
>



-- 
Aaron Ponce (MA, JD)
Professional Translator
Spanish, French, Portuguese, Norwegian --> English
Bloomington, IN 47401
U.S.A.

	[[alternative HTML version deleted]]




More information about the ESS-help mailing list