[ESS] paragraph filling in R scripts

tyler tyler.smith at mail.mcgill.ca
Mon Jun 15 05:44:37 CEST 2009


"Dr. Alun Pope" <AlunPope at rismark.com.au> writes:

> Thanks Tyler, for your quick response.  Yes, you have understood the
> problem correctly and what you say about how auto-filling works (is it
> ess or Emacs?) would certainly produce the behaviour I encountered.  I
> shall wait a few days and then post a proper example when I have time to
> search for a solution myself and if I haven't heard of a solution in the
> meantime.
>

See if the attached patch for ess-utils.el (also pasted below, I'm not
sure how Gnus handles attachments yet) fixes your problem. There may be
better/more general ways to do this, but it's a start.

Cheers,

Tyler

Index: lisp/ess-utils.el
===================================================================
--- lisp/ess-utils.el	(revision 4161)
+++ lisp/ess-utils.el	(working copy)
@@ -590,7 +590,10 @@
 				 (beginning-of-line)
 				 (and (re-search-forward comment-start-skip
 							 limit t)
-				      (eq (point) limit)))))))
+				      (eq (point) limit)))))
+		     ;; inserted by Tyler to inhibit breaking before <-
+		     (not (save-excursion (goto-char fill-point)
+					  (looking-at ".\\s *<-")))))
 	      ;; Ok, we have a useful place to break the line.  Do it.
 	      (let ((prev-column (current-column)))
 		;; If point is at the fill-point, do not `save-excursion'.

-------------- next part --------------


>
> -----Original Message-----
> From: ess-help-bounces at stat.math.ethz.ch
> [mailto:ess-help-bounces at stat.math.ethz.ch] On Behalf Of Tyler William
> Smith
> Sent: Monday, 15 June 2009 5:29 AM
> To: Dr. Alun Pope; ess-help at stat.math.ethz.ch
> Subject: Re: [ESS] paragraph filling in R scripts
>
> Dr. Alun Pope wrote: 
>
> Thanks for looking at this.  I have not encountered the problem you
> mention, but I have come across the following problem which is related.
>
> Suppose I have a perfectly good expression such as this
>
> very.long.meaningful.object.name[some.indexing.also.long,] <-
> some.longish.expressions
>
> When I tidy the code by end-delete-return on that line, the line appears
> as:
>
> very.long.meaningful.object.name[some.indexing.also.long,]
> <- some.longish.expressions
>
> Hi Alun,
>
> I'm away from my computer at the moment, but I think this is a different
> issue. If I understand you correctly, what you're seeing is the Emacs'
> auto-filling breaking up an R statement in inappropriate places. As I
> understand it, line-wrapping/filling functions just look for white space
> beyond a specified column number, and use that to break your line into
> two pieces. If that space happens to fall immediately before the <-
> operator, you get a bad break. 
>
> I suspect this is fixable, but the code I sent in my last message won't
> help. I will poke around at this when I get a chance, unless wiser folk
> have already got a solution.
>
> Cheers,
>
> Tyler
>
> -----Original Message-----
> From: ess-help-bounces at stat.math.ethz.ch
> [mailto:ess-help-bounces at stat.math.ethz.ch] On Behalf Of tyler
> Sent: Saturday, 13 June 2009 12:19 PM
> To: ess-help at stat.math.ethz.ch
> Subject: [ESS] paragraph filling in R scripts
>
> Hi again,
>
> Another bug from way back, this one reported for 5.3.6:
>
> https://stat.ethz.ch/pipermail/ess-bugs/2007q4/000468.html
>
> I fixed this with the following lines from my .emacs, but patching
> essl-s.el would be cleaner.
>
> (defun my-ess-mode-hook ()
>   (setq paragraph-start
>         (concat paragraph-start
>                 "\\|.*<-\\|\\s +\\(while\\|if\\|else\\|for\\)")))
> (add-hook 'ess-mode-hook 'my-ess-mode-hook)
>
> I haven't looked at this in ages, since my hook fixed the problem for
> me. There may be better solutions, but this works fine for me.
>
> Cheers,
>
> Tyler
>
> --
> What is wanted is not the will to believe, but the will to find out,
> which is the exact opposite.           --Bertrand Russell
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>
> ______________________________________________________
> This email has been scanned by the Access Networks/MessageLabs Email
> Security System.For more information please visit
> http://www.indicium.com.au/
> ______________________________________________________
>
> IMPORTANT NOTICE
> This e-mail may be confidential, may be legally privileged, and is for
> the intended recipient only. Unauthorized access, disclosure, copying,
> distribution, or reliance on any of it by anyone else is prohibited and
> may a criminal offence.  Please delete if received in error and e-mail
> confirmation to sender
> ______________________________________________________
> This email has been scanned by the Access Networks/MessageLabs Email
> Security System.For more information please visit
> http://www.indicium.com.au/
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>
> ______________________________________________________
> This email has been scanned by the Access Networks/MessageLabs Email
> Security System.For more information please visit
> http://www.indicium.com.au/
> ______________________________________________________
>
> IMPORTANT NOTICE
> This e-mail may be confidential, may be legally privileged, and is for the intended recipient only. Unauthorized access, disclosure, copying, distribution, or reliance on any of it by anyone else is prohibited and may a criminal offence.  Please delete if received in error and e-mail confirmation to sender
> ______________________________________________________
> This email has been scanned by the Access Networks/MessageLabs Email Security System.For more information please visit http://www.indicium.com.au/
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>

-- 
What is wanted is not the will to believe, but the will to find out,
which is the exact opposite.           --Bertrand Russell


More information about the ESS-help mailing list