[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)
	     (eolp)
	     (or (save-excursion
		   (skip-chars-backward " \t")
		   (bolp))
		 (if ess-auto-newline (progn (ess-indent-line) (newline) t) nil)))
	(progn
	  (insert last-command-event)
	  (ess-indent-line)
	  (if ess-auto-newline
	      (progn
		(newline)
		;; (newline) may have done auto-fill
		(setq insertpos (- (point) 2))
		(ess-indent-line)))
	  (save-excursion
	    (if insertpos (goto-char (1+ insertpos)))
	    (delete-char -1))))
     (if insertpos
	(save-excursion
	  (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