[ESS] Curly brace indentation

2016-12-05 Thread Jan T Kim via ESS-help
Hello All,

since some time, I get the following indentation behaviour: If I type

f <- function(x)
{
return(x * x);
}

this gets indented as

f <- function(x)
{
return(x * x);
}

i.e. the closing curly brace is not vertically aligned with the opening one.

If I then go on and indent the buffer (C-x h C-M-\), the indentation is
updated to


f <- function(x)
{
return(x * x);
}

so the opening and closing curly braces are now vertically aligned.

This behaviour started several months ago. Reviewing the change logs,
I speculate that upgrading (via Ubuntu package manager) to a package
providing 15.09, where "the indentation logic has been refactored",
may be the cause of the change, but as I've done little R coding for
a while I can't really pinpoint this.

I recently got a new computer at work and used that opportunity to
check that the behaviour occurs with a new account, i.e. without any
~/.emacs file.

After some code delving and hacking I've managed to adjust the electric
curly braces by adding this to my .emacs:

(defun jtk-ess-electric-brace (arg)
  "modified / extended ess-electric-brace"
  (interactive "P")
  (progn
; (message "modified ess-electric-brace running")
(ess-electric-brace arg)
(ess-indent-command)
  )
)


(defun jtk-ess-mode-hook ()
  (progn
(local-set-key (kbd "{") 'jtk-ess-electric-brace)
(local-set-key (kbd "}") 'jtk-ess-electric-brace)
  )
)

So essentially I have the brace indented immediately after inserting
it via the original ess-electric-brace command. However, this solution
is not 100% perfect as the indentation of closing braces occurs only
after some delay caused by briefly flashing the cursor at the corresponding
opening brace.

Quite possibly I'm using a clumsy approach to try to get indentation during
typing consistent with that produced by indent-region, so suggestions where
I may have messed up are welcome.

Best regards & thanks in advance for any pointers, Jan
-- 
 +- Jan T. Kim ---+
 | email: jtt...@gmail.com|
 | WWW:   http://www.jtkim.dreamhosters.com/  |
 *-=<  hierarchical systems are for files, not for humans  >=-*

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] how to edit openbugs model file?

2016-12-05 Thread Paul Johnson
Thanks, everybody.  I'm taking the suggestion Martin offered, since
this thing is required to be named *.txt in the current OpenBUGS.

Solution

Put this at the end of the *.txt file:

# Local Variables:
# mode: R
# End:

That works.

This question was raised by an interesting problem. This might be a
useful a warning to others using Emacs and OpenBugs.  Punch line:
character encoding must be ASCII.

The student typed in a bugs model file on his system, using Emacs.
The default character encoding was set as UTF8. Then his model files
kept crashing OpenBugs and I could not understand why. It warned about
unfamiliar characters,  I kept checking to see that file encoding was
UTF8.

Doh! Then I remembered that OpenBUGS asks for ASCII files!  Symbols
like "*" and "~" are given different encoding in ASCII and UTF8. The
"~" looks exactly the same, whether ASCII or UTF8, but luckily for us,
that student's computer showed the UTF8 "*" as a highlighted character
that was in a different line position.

If you put the cursor on a character and run C-u C-x =, then you see a
nice display about the encoding. There's an especially helpful post
about it:
http://stackoverflow.com/questions/10500323/how-to-see-the-files-encoding-in-emacs.

>From within Emacs, I cannot replicate that problem that the student
generated. No matter how I set buffer-file-encoding-system, I get
ASCII whenever I type "*" or "~". I'm guessing that because the
student is from another country, and English is not his native
language, that his Locale is different somehow.  But I can't see
what's different about it. Interesting and frustrating!

pj

On Sat, Dec 3, 2016 at 8:40 AM, Sparapani, Rodney  wrote:
> Hi Paul:
>
> Use BUGS mode which is part of ESS…
> (require ‘ess-bugs-d)
>
> Then name your file model.bug
>
> Rodney
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



-- 
Paul E. Johnson   http://pj.freefaculty.org
Director, Center for Research Methods and Data Analysis http://crmda.ku.edu

To write to me directly, please address me at pauljohn at ku.edu.

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help