Function: pascal-set-auto-comments
pascal-set-auto-comments is a byte-compiled function defined in
pascal.el.gz.
Signature
(pascal-set-auto-comments)
Documentation
Insert { case } or { NAME } on this line if appropriate.
Insert { case } if there is an end on the line which
ends a case block. Insert { NAME } if there is an end
on the line which ends a function or procedure named NAME.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/pascal.el.gz
;;;
;;; Other functions
;;;
(defun pascal-set-auto-comments ()
"Insert `{ case }' or `{ NAME }' on this line if appropriate.
Insert `{ case }' if there is an `end' on the line which
ends a case block. Insert `{ NAME }' if there is an `end'
on the line which ends a function or procedure named NAME."
(save-excursion
(forward-line -1)
(skip-chars-forward " \t")
(if (and (looking-at "\\<end;")
(not (save-excursion
(end-of-line)
(search-backward "{" (point-at-bol) t))))
(let ((type (car (pascal-calculate-indent))))
(if (eq type 'declaration)
()
(if (eq type 'case)
;; This is a case block
(progn
(end-of-line)
(delete-horizontal-space)
(insert " { case }"))
(let ((nest 1))
;; Check if this is the end of a function
(save-excursion
(while (not (or (looking-at pascal-defun-re) (bobp)))
(backward-sexp 1)
(cond ((looking-at pascal-beg-block-re)
(setq nest (1- nest)))
((looking-at pascal-end-block-re)
(setq nest (1+ nest)))))
(if (bobp)
(setq nest 1)))
(if (zerop nest)
(progn
(end-of-line)
(delete-horizontal-space)
(insert " { ")
(let (b e)
(save-excursion
(setq b (progn (pascal-beg-of-defun)
(skip-chars-forward "^ \t")
(skip-chars-forward " \t")
(point))
e (progn (skip-chars-forward "a-zA-Z0-9_")
(point))))
(insert-buffer-substring (current-buffer) b e))
(insert " }"))))))))))