[net.emacs] Making CCA C Mode Look Like Montgomery C Mode

martillo@mit-athena.UUCP (Joaquim Martillo) (02/22/85)

The following elisp file when downloaded into emacs will
make CCA Emacs C-Mode act like Montgomery Emacs C-Mode.

That is in the following example;

{
	if(...)
	{
		......;
		......;
	}
}

Return will immediately indent number of initial tabs on the previous
line + 1 if the last tab is succeeded by a {.

} will backtab once if preceded by a tab.




(edefun |Close Squiggle Brace| (arg1 arg2 &optional op1 op2 op3)
	(cond ((and (equal "C"  (#f"& get major mode" #v"& current buffer"))
		    (eql 1 #v"indent using tabs"))
	       (cond ((not (#f"& begin line"))
		      (#f"backward character")
		      (cond ((eql #\tab (emacs-get-char))
			     (#f"backward delete character")))))))
	(emacs-insert-char #\}))

(#f"set key" noarg 0 "Close Squiggle Brace" "}")

(defun count-tabs () 
       (cond ((#f"& end line") 0)
	     (t (let ((character (emacs-get-char)))
		     (cond ((eql #\tab character) (+ 1 (count-tabs)))
			   ((eql #\{ character) 1)
			   (t 0))))))

(edefun |C CRLF| (arg1 arg2 &optional op1 op2 op3)
	(cond ((and (equal "C"  (#f"& get major mode" #v"& current buffer"))
		    (eql 1 #v"indent using tabs"))
  		    (let ((current-col (#f"& find real column" #v"& current column")))
			 (#f"beginning of line")
			 (let ((count (count-tabs)))
			      (#f"& move to real column" #v"& current line" current-col)
			      (#f"CRLF")
			      (dotimes-pp (i count)
					  (emacs-insert-char #\tab)))))
	      (t (#f"CRLF"))))

(#f"set key" noarg 0 "C CRLF" "
")