[ESS-bugs] Indentation of included chunks

Terry Therneau therneau at mayo.edu
Wed Jan 23 18:36:27 CET 2013


I use ESS quite a bit for noweb code in R, for which the Rnw mode works nearly perfectly.  
Thanks to you all.
The "nearly" has to do with included chunks.  A common paradym in noweb code is below.  
The problem is that Rnw mode wants to increase the indentation level after every one of 
the imbedded references.
    Such inclusions are legal in Sweave files but are a lot less commmon.
    See the coxme library  for a case where chunks include others, which themselves 
include others, which....  What with sparse computation and complex math, there is more 
explanation than code, so it gets broken up into chapters and sections like a book.


Minor issues:
    I pulled down the latest version of ESS this AM and placed it in /usr/share/emacs/ess, 
moving the older one to ess.old, quit and restarted my emacs session.  Yet when I do a 
"bug report" from the ESS menu it claims version 5.13.
Just to make sure I'm not using an old code.

    Sending the email from emacs fails, something to do with the fact that this box looks 
to another for SMTP service, and that server's name is only known to the thunderbird client.

Terry Therneau


Begin the example :
\begin{document}
  A few words of introduction.

<<main-definition>>=
myfun <- function(arg1, arg2, arg3 ) {
<<myfun-check-input-args>>
<<myfun-do-setup>>  #it wants to indent this line from the one above
<<myfun-compute>>
<<myfun-finish>>
}

Latex paragraph discussing the input arguments and what the checks are about.

<<myfun-check-input-args>>
if (arg1 <0)  blah blah
..
 >>

Now some latex about the computation, often containing lots of mathematics.

<<myfun-compute>>=
  blah blah
 >>

etc.

[ess-site.el]: ess-customize-alist=nil
[ess-site.el _2_]: ess-customize-alist=nil
(S): ess-s-versions-create making M-x defuns for

(R): ess-r-versions-create making M-x defuns for

(n-i-m-l: 1)(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send
(ess-mode-1): ess-language=S, ess-dialect=R buf=test.Rnw
(ess-mode-1.5): alist=((ess-local-customize-alist quote R-customize-alist) (ess-dialect . 
R) (ess-suffix . R) (ess-dump-filename-template ess-replace-regexp-in-string S$ ess-suffix 
ess-dump-filename-template-proto) (ess-mode-syntax-table . R-syntax-table) 
(ess-mode-editing-alist . R-editing-alist) (ess-change-sp-regexp . ess-R-change-sp-regexp) 
(ess-help-sec-regex . ess-help-R-sec-regex) (ess-help-sec-keys-alist . 
ess-help-R-sec-keys-alist) (ess-loop-timeout . ess-S-loop-timeout) (ess-cmd-delay . 
ess-R-cmd-delay) (ess-function-pattern . ess-R-function-pattern) (ess-object-name-db-file 
. ess-r-namedb.el) (ess-imenu-mode-function quote ess-imenu-R) (inferior-ess-program . 
inferior-R-program-name) (inferior-ess-objects-command . inferior-R-objects-command) 
(inferior-ess-font-lock-keywords . inferior-ess-R-font-lock-keywords) 
(inferior-ess-search-list-command . search()
) (inferior-ess-help-command . inferior-ess-r-help-command) (inferior-ess-help-filetype) 
(inferior-ess-exit-command . q()) (inferior-ess-exit-prompt . Save workspace image? 
[y/n/c]: ) (inferior-ess-primary-prompt . \([A-Z][][A-Za-z0-9.]*\)?> ) 
(inferior-ess-secondary-prompt . + ?) (inferior-ess-start-file) (inferior-ess-start-args . 
) (ess-STERM . iESS) (ess-editor . R-editor) (ess-pager . R-pager) (ess-language . S) 
(inferior-ess-exit-command . q()
) (inferior-ess-language-start eval inferior-S-language-start) 
(comint-use-prompt-regexp-instead-of-fields . t))
(ess-mode-1.6): editing-alist=((paragraph-start concat \s-*$\| page-delimiter) 
(paragraph-separate concat \s-*$\| page-delimiter) (paragraph-ignore-fill-prefix . t) 
(require-final-newline . t) (comment-start . #) (comment-add . 1) (comment-start-skip . #+ 
*) (comment-column . 40) (indent-line-function quote S-indent-line) 
(parse-sexp-ignore-comments . t) (ess-style . ess-default-style) (ess-local-process-name) 
(ess-mode-syntax-table . S-syntax-table) (add-log-current-defun-header-regexp . 
^\(.+\)\s-+<-[
]*function) (font-lock-defaults quote (ess-R-mode-font-lock-keywords nil nil ((46 . w) (95 
. w)))))
(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send

Finished setting up ESS-mode.
(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send
(ess-mode-1): ess-language=S, ess-dialect=R buf=test.R
(ess-mode-1.5): alist=((ess-local-customize-alist quote R-customize-alist) (ess-dialect . 
R) (ess-suffix . R) (ess-dump-filename-template ess-replace-regexp-in-string S$ ess-suffix 
ess-dump-filename-template-proto) (ess-mode-syntax-table . R-syntax-table) 
(ess-mode-editing-alist . R-editing-alist) (ess-change-sp-regexp . ess-R-change-sp-regexp) 
(ess-help-sec-regex . ess-help-R-sec-regex) (ess-help-sec-keys-alist . 
ess-help-R-sec-keys-alist) (ess-loop-timeout . ess-S-loop-timeout) (ess-cmd-delay . 
ess-R-cmd-delay) (ess-function-pattern . ess-R-function-pattern) (ess-object-name-db-file 
. ess-r-namedb.el) (ess-imenu-mode-function quote ess-imenu-R) (inferior-ess-program . 
inferior-R-program-name) (inferior-ess-objects-command . inferior-R-objects-command) 
(inferior-ess-font-lock-keywords . inferior-ess-R-font-lock-keywords) 
(inferior-ess-search-list-command . search()
) (inferior-ess-help-command . inferior-ess-r-help-command) (inferior-ess-help-filetype) 
(inferior-ess-exit-command . q()) (inferior-ess-exit-prompt . Save workspace image? 
[y/n/c]: ) (inferior-ess-primary-prompt . \([A-Z][][A-Za-z0-9.]*\)?> ) 
(inferior-ess-secondary-prompt . + ?) (inferior-ess-start-file) (inferior-ess-start-args . 
) (ess-STERM . iESS) (ess-editor . R-editor) (ess-pager . R-pager) (ess-language . S) 
(inferior-ess-exit-command . q()
) (inferior-ess-language-start eval inferior-S-language-start) 
(comint-use-prompt-regexp-instead-of-fields . t))
(ess-mode-1.6): editing-alist=((paragraph-start concat \s-*$\| page-delimiter) 
(paragraph-separate concat \s-*$\| page-delimiter) (paragraph-ignore-fill-prefix . t) 
(require-final-newline . t) (comment-start . #) (comment-add . 1) (comment-start-skip . #+ 
*) (comment-column . 40) (indent-line-function quote S-indent-line) 
(parse-sexp-ignore-comments . t) (ess-style . ess-default-style) (ess-local-process-name) 
(ess-mode-syntax-table . S-syntax-table) (add-log-current-defun-header-regexp . 
^\(.+\)\s-+<-[
]*function) (font-lock-defaults quote (ess-R-mode-font-lock-keywords nil nil ((46 . w) (95 
. w)))))
(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send

Finished setting up ESS-mode.
(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send
(ess-mode-1): ess-language=S, ess-dialect=R buf=test.R
(ess-mode-1.5): alist=((ess-local-customize-alist quote R-customize-alist) (ess-dialect . 
R) (ess-suffix . R) (ess-dump-filename-template ess-replace-regexp-in-string S$ ess-suffix 
ess-dump-filename-template-proto) (ess-mode-syntax-table . R-syntax-table) 
(ess-mode-editing-alist . R-editing-alist) (ess-change-sp-regexp . ess-R-change-sp-regexp) 
(ess-help-sec-regex . ess-help-R-sec-regex) (ess-help-sec-keys-alist . 
ess-help-R-sec-keys-alist) (ess-loop-timeout . ess-S-loop-timeout) (ess-cmd-delay . 
ess-R-cmd-delay) (ess-function-pattern . ess-R-function-pattern) (ess-object-name-db-file 
. ess-r-namedb.el) (ess-imenu-mode-function quote ess-imenu-R) (inferior-ess-program . 
inferior-R-program-name) (inferior-ess-objects-command . inferior-R-objects-command) 
(inferior-ess-font-lock-keywords . inferior-ess-R-font-lock-keywords) 
(inferior-ess-search-list-command . search()
) (inferior-ess-help-command . inferior-ess-r-help-command) (inferior-ess-help-filetype) 
(inferior-ess-exit-command . q()) (inferior-ess-exit-prompt . Save workspace image? 
[y/n/c]: ) (inferior-ess-primary-prompt . \([A-Z][][A-Za-z0-9.]*\)?> ) 
(inferior-ess-secondary-prompt . + ?) (inferior-ess-start-file) (inferior-ess-start-args . 
) (ess-STERM . iESS) (ess-editor . R-editor) (ess-pager . R-pager) (ess-language . S) 
(inferior-ess-exit-command . q()
) (inferior-ess-language-start eval inferior-S-language-start) 
(comint-use-prompt-regexp-instead-of-fields . t))
(ess-mode-1.6): editing-alist=((paragraph-start concat \s-*$\| page-delimiter) 
(paragraph-separate concat \s-*$\| page-delimiter) (paragraph-ignore-fill-prefix . t) 
(require-final-newline . t) (comment-start . #) (comment-add . 1) (comment-start-skip . #+ 
*) (comment-column . 40) (indent-line-function quote S-indent-line) 
(parse-sexp-ignore-comments . t) (ess-style . ess-default-style) (ess-local-process-name) 
(ess-mode-syntax-table . S-syntax-table) (add-log-current-defun-header-regexp . 
^\(.+\)\s-+<-[
]*function) (font-lock-defaults quote (ess-R-mode-font-lock-keywords nil nil ((46 . w) (95 
. w)))))
(ess-setq-vars-LOCAL): language=S, dialect=R, buf=nil, comint..echoes=nil, 
comint..sender=comint-simple-send

Finished setting up ESS-mode.


Emacs  : GNU Emacs 23.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.5)
  of 2011-08-14 on rothera, modified by Debian
Package: ess-mode 5.13

current state:
==============
(setq
  ess-language "S"
  ess-dialect "R"
  ess-ask-for-ess-directory t
  ess-ask-about-transfile nil
  ess-directory nil
  ess-keep-dump-files "always"
  ess-source-directory "/tmp/"
  )



More information about the ESS-bugs mailing list