SAS mode and indentation

Rich Heiberger rmh at
Thu Jun 12 16:11:44 CEST 2003

I like the idea of electric run;
I have also wanted it before.  Try this out:

(defun ess-electric-run-semicolon (arg)
  "Insert character.  If the line contains \"run;\" and nothing else then indent line."
  (interactive "P")
  (let (insertpos)
    (if (and (not arg)
		   (skip-chars-backward " \t")
		   (backward-word 1)
		   (and (looking-at "run")
			  (skip-chars-backward " \t")
	  (insert last-command-char)
	    (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)))))

(define-key sas-mode-local-map ";"		'ess-electric-run-semicolon)


More information about the ESS-help mailing list