SAS mode and indentation

Rich Heiberger rmh at surfer.sbm.temple.edu
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)
	     (eolp)
	     (save-excursion
		   (skip-chars-backward " \t")
		   (backward-word 1)
		   (and (looking-at "run")
			(progn
			  (skip-chars-backward " \t")
			  (bolp)))))
	(progn
	  (insert last-command-char)
	  (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)))))

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

Rich




More information about the ESS-help mailing list