I added this to my ess-smart-underscore as well.  Thanks Martin and Charles

Matt.

On Wed, Oct 31, 2012 at 11:37 AM, Denis Haine <denis.haine@gmail.com> wrote:

> Chuck's solution works fine, while waiting for a permanent fix in the next
> ess version. Maybe it did not reached the list so here's the lines to add
> to the init file, correcting for an extra parentheses. Thanks for your
> help!
> Denis
>
> (defun ess-smart-underscore ()
> ;;  Smart \"_\" key: insert `ess-S-assign', unless in string/comment.
> ;;If the underscore key is pressed a second time, the assignment
> ;;operator is removed and replaced by the underscore.  `ess-S-assign',
> ;;typically \" <- \", can be customized.  In ESS modes other than R/S,
> ;;an underscore is always inserted.
>   (interactive)
>   ;;(insert (if (ess-inside-string-or-comment-p (point)) "_" ess-S-assign))
>   (save-restriction
>     (ignore-errors
>       (when (and (eq major-mode 'inferior-ess-mode)
>  (> (point) (process-mark (get-buffer-process
>    (current-buffer)))))
>  (narrow-to-region (process-mark (get-ess-process)) (point-max)))
>       (and ess-noweb-mode
>    (noweb-in-code-chunk)
>    (noweb-narrow-to-chunk)))
>     (if (or
>  (ess-inside-string-or-comment-p (point))
>  (not (equal ess-language "S")))
> (insert "_")
>       ;; else:
>       (ess-insert-S-assign))))
>
>
>
>
> 2012/10/31 Martin Maechler <maechler@stat.math.ethz.ch>
>
> > >>>>> Charles Berry <cberry@tajo.ucsd.edu>
> > >>>>>     on Tue, 30 Oct 2012 19:03:41 -0700 writes:
> >
> >     > Sorry to take this off-list, but I seem to be having trouble
> >     > getting thru gmane to ess-help.
> >
> >     > The problem Denis alludes to is that the call to
> >     > ess-inside-string-or-comment-p inside ess-smart-underscore is
> finding
> >     > the quote before the code chunk.
> >
> > yes.
> >     > Narrowing to the code chunk - see below - is needed.
> >
> > yes, indeed. {and in fact needed in other ess commands as well,
> >               such as ess-eval-paragraph-...  !}
> > I have suggested such changes to the ESS core team only a few
> > days ago.
> >
> >     > I think this works, but not tested thoroughly. In
> > ess-smart-underscore:
> >
> >     > (narrow-to-region (process-mark (get-ess-process)) (point-max))))
> >     > +        (and ess-noweb-mode
> >     > +         (noweb-in-code-chunk)
> >     > +         (noweb-narrow-to-chunk))
> >     > (if (or
> >
> >     > HTH,
> >
> > Indeed, it helped:  It was very close to the real solution:
> > (1. parentheses
> >  2. in ESS 12.09-1, all the ESS noweb functions are renamed from
> >   noweb-foo to ess-noweb-foo,   as inside the Emacs sphere,
> >   there's another  noweb-*  version floating around.) :
> >
> > Index: lisp/ess-s-l.el
> > ===================================================================
> > 690c690,693
> > <         (narrow-to-region (process-mark (get-ess-process))
> (point-max))))
> > ---
> > >         (narrow-to-region (process-mark (get-ess-process))
> (point-max)))
> > >       (and ess-noweb-mode
> > >            (ess-noweb-in-code-chunk)
> > >            (ess-noweb-narrow-to-chunk)))
> >
> >
> > ------------------------------------------------------------------------
> > r5277 | maechler | 2012-10-31 12:27:38 +0100 (Wed, 31 Oct 2012) | 1 line
> > Changed paths:
> >    M lisp/ess-s-l.el
> >
> > fix (ess-smart-underscore) inside Rnw --- based on suggestion by Chuck
> > Berry
> > ------------------------------------------------------------------------
> >
> >
> >     > Chuck
> >
> >     > --
> >     > Charles C. Berry                            Dept of
> > Family/Preventive Medicine
> >     > cberry at ucsd edu                            UC San Diego
> >     > http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego
> > 92093-0901
> >
> > ______________________________________________
> > ESS-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>

	[[alternative HTML version deleted]]

