[ESS] problems with curly braces { }

Rodney Sparapani rsparapa at mcw.edu
Thu May 27 22:22:11 CEST 2010

On 05/27/10 01:52 PM, Rodney Sparapani wrote:
> Hi Josh:
> Very weird. I see the same thing. This is coming from ess-electric-brace
> from ess-mode.el This feature is discussed here
> http://ess.r-project.org/Manual/ess.html#Indenting
> But, the documentation gives no inkling of turning this feature off or
> what to do if it is broken?!?

Here's a workaround; use the definition of ess-electric-brace
below.  It works, but it eats the next character.  That is
usually a return and is handled correctly; but, if it's, say a
semicolon for a comment, then you have to do it twice.
I don't understand what this function is supposed
to be doing by looking at it's code and I don't know what
(interactive "P") is all about either.

(defun ess-electric-brace (arg)
   "Insert character and correct line's indentation."
   (interactive "c")
;; skeleton-pair takes precedence
(if (and (boundp 'skeleton-pair) skeleton-pair (featurep 'skeleton))
   (skeleton-pair-insert-maybe "{")
;; else
   (let (insertpos)
     (if (and (not arg)
	     (or (save-excursion
		   (skip-chars-backward " \t")
		 (if ess-auto-newline (progn (ess-indent-line) (newline) t) nil)))
	  (insert last-command-event)
	  (if ess-auto-newline
		;; (newline) may have done auto-fill
		(setq insertpos (- (point) 2))
	    (if insertpos (goto-char (1+ insertpos)))
	    (delete-char -1))))
     (if insertpos
	  (goto-char insertpos)
	  (self-insert-command (prefix-numeric-value arg)))
       (self-insert-command (prefix-numeric-value arg))))))

More information about the ESS-help mailing list