[ESS] Failure to parse long R functions when ess-eval-visibly nil

Vitalie Spinu @p|nuv|t @end|ng |rom gm@||@com
Thu Oct 8 00:45:40 CEST 2015


Interesting. I never noticed this with tramp, but I am not using long functions
either.

A workaround for this is to load the file with C-c C-l. That is, keep all you
functions in a *remote* file and load it whenever needed.

Working with tramp with remote files could be very slow due to the backups on
the server side. The following setting makes it much faster:

 (setq tramp-auto-save-directory "~/.backups/tramp/")


  Vitalie

>> On Wed, Oct 07 2015 17:16, Robert McGehee wrote:

> Vitalie/Andreas,
> Thanks for the reply. Just got tramp up and running. It does seem the way
> to go due to the added functionality. The problem seems to be slightly
> harder to recreate in tramp, however it does not go away. I'm able to
> reproduce syntax errors consistently in tramp if I expand my toy example to
> several hundred lines. I invoke R in tramp using M-x R then
> '/ssh:server:/tmp' for remote directory name. So for me at least it is not
> an eshell problem. I suspect that the large latency I see in my connection
> exacerbates the issue for me (as well as possibly running inside of
> Cygwin).

> Also, upon examining lots of the syntax errors, it seems that characters
> are never actually dropped in the middle of a line, but that lines are
> prematurely ended. That is, the last few characters of a line might be
> dropped, but never the first few.

> Here's an example error (after 537 lines) from my toy example:

> + + + + . + + . + + . + + . + + . + + . + + . + + . + + . + + . + + . + + .
> + + . + + . + + . + + . + + . + + . + + . + + . + + . + + . + Error in
> ss(file, echo = echo, local = local, print.eval = print.eval,  :
>   /tmp/unknown!10544Zgb:538:5: unexpected end of line
> 537:         x <- d(e(f(g,"H"),"I"),"J",k="L")
> 538:     if
>          ^

> On Wed, Oct 7, 2015 at 4:25 PM, Andreas Leha <
> andreas.leha using med.uni-goettingen.de> wrote:

>> Hi Vitalie,
>>
>> Vitalie Spinu <spinuvit using gmail.com> writes:
>> > This is a known problem with ess-remote. I have no idea why the
>> characters are
>> > lost. It's some emacs shell bug which I couldn't figure out last time I
>> looked
>> > into it. This problem is almost impossible to reproduce consistently and
>> debug
>> > properly.
>> >
>> > I suggest you stick with tramp. This problem never occurs with tramp and
>> you
>> > have full set of ESS features on remotes, while ess-remote provides only
>> a very
>> > limited functionality.
>> >
>>
>> I have reported this problem a while back, too [1].
>>
>> I'd also recommend using tramp where possible.  I just want to mention
>> again, that to my knowledge that won't work with screen/tmux sessions on
>> the remote side.  So, that advice won't help for most of my remote work.
>>
>> (Most of my remote sessions live inside a screen session, because my
>> remote sessions are typically long and computationally intensive and
>> often even initiate submissions to a cluster.  If they were not, I would
>> run that on the local machine.)
>>
>>
>>
>> Thanks,
>> Andreas
>>
>>
>> [1] http://permalink.gmane.org/gmane.emacs.ess.general/8690>
>>
>>
>> >>> On Wed, Oct 07 2015 13:47, Robert McGehee wrote:
>> >
>> >> Hello,
>> >> I'm having an issue in which sufficiently long and complex functions
>> will
>> >> fail to correctly evaluate in R (with e.g. ess-eval-function) if
>> >> ess-eval-visibly is nil rather than true. Instead I receive syntax
>> errors
>> >> part way through the function that seem to indicate that a line or
>> >> character was accidentally dropped during the ess eval making the
>> function
>> >> un-parsable. If I turn on visibility (ess-eval-visibly t), the problem
>> >> disappears but the evaluation takes a long time due to latency on my
>> setup.
>> >> Moreover, the problem isn't perfectly reproducible as the syntax error
>> will
>> >> occur somewhat at random. However, with a sufficiently long and complex
>> >> function (e.g. 300+ lines) I'm virtually guaranteed an error.
>> >
>> >> Unfortunately, my setup is likely unusual so I'm not sure if this is an
>> ESS
>> >> error. However, I wanted to post in case anyone had any ideas on a fix
>> >> (besides just turning ess-eval-visibly to true).
>> >
>> >> For my setup, I run emacs 24.5.1 on my local (USA) Windows box via
>> Cygwin
>> >> and have ESS 15.09 installed from source. I connect to a remote
>> (European)
>> >> Linux server via emacs shell and ssh, then start R (3.2.2) and start
>> >> ESS-mode with M-x ess-remote. I run emacs locally rather than on the
>> server
>> >> side as I'm connecting to a server across the Atlantic ocean and
>> latency is
>> >> too high for X11 forwarding. Additionally, given the latency, I have to
>> >> wait a considerable amount of time to eval an R function visibly,
>> whereas
>> >> it happens extremely fast if I turn off visible eval. Thus, I'd much
>> prefer
>> >> a working non-visible eval.
>> >
>> >> Here's a simple function I used to generate the syntax error. It has the
>> >> advantage of nearly guaranteeing a parsing failure if any character is
>> >> missing.
>> >
>> >> a <- function(x) {
>> >>     if (a(b,"c"))
>> >>         x <- d(e(f(g,"H"),"I"),"J",k="L")
>> >>     if (a(b,"c"))
>> >>         x <- d(e(f(g,"H"),"I"),"J",k="L")
>> >> <...snip... repeated ~300 times>
>> >>     if (a(b,"c"))
>> >>         x <- d(e(f(g,"H"),"I"),"J",k="L")
>> >> }
>> >
>> >> ## Here is the error I got indicating two closing parentheses "))" were
>> >> dropped during eval:
>> >> Error: unexpected symbol in:
>> >> "    if (a(b,"c"
>> >>         x"
>> >
>> >> (Possibly unrelated, if any line has two consecutive tab characters,
>> then
>> >> ESS will actually print the contents of the home directory of the remote
>> >> server, which is exceptionally weird.)
>> >
>> >> Please let me know if anyone has any thoughts on this. Otherwise I'll
>> just
>> >> turn ess-eval-visibly back to true.
>> >
>> >> Thanks!
>> >> Robert
>> >
>> >> PS.
>> >> Here is the relevant portion of my .emacs file:
>> >
>> >> (require 'cl)
>> >> (load "cc-mode")
>> >> (load "compile")
>> >
>> >> (require 'ess-site)
>> >> (setq comint-scroll-to-bottom-on-input t)
>> >> (setq comint-scroll-to-bottom-on-output t)
>> >> (setq ess-eval-visibly nil)
>> >> (setq ess-nuke-trailing-whitespace-p t)
>> >> (setq-default ess-directory "/tmp/")
>> >> (define-key key-translation-map [?\C-h] [?\C-?])
>> >
>> >> (transient-mark-mode t)
>> >> (setq display-time-day-and-date t)
>> >> (display-time-mode 1)
>> >> (setq visible-bell t)
>> >> (setq undo-outer-limit 100000)
>> >
>> >> (setq line-number-display-limit nil)
>> >> (setq line-number-display-limit-width 2000)
>> >> (setq column-number-mode t)
>> >> (require 'paren)
>> >> (if (fboundp 'show-paren-mode) (show-paren-mode 1))
>> >
>> >> (setenv "PID" nil)
>> >> (put 'upcase-region 'disabled nil)
>> >> (add-hook 'ess-mode-hook
>> >>       (lambda ()
>> >>         (ess-set-style 'C++ 'quiet)
>> >>         (add-hook 'local-write-file-hooks
>> >>               (lambda ()
>> >>             (ess-nuke-trailing-whitespace)))))
>> >> (setq truncate-partial-width-windows nil)
>> >
>> >>      [[alternative HTML version deleted]]
>> >
>> >> ______________________________________________
>> >> ESS-help using r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/ess-help> >
>> > ______________________________________________
>> > ESS-help using r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/ess-help>
>> ______________________________________________
>> ESS-help using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help>

> 	[[alternative HTML version deleted]]

> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help




More information about the ESS-help mailing list