Function: simula-electric-label
simula-electric-label is an interactive and byte-compiled function
defined in simula.el.gz.
Signature
(simula-electric-label)
Documentation
If this is a label that starts the line, reindent the line.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/simula.el.gz
(defun simula-electric-label ()
"If this is a label that starts the line, reindent the line."
(interactive)
(expand-abbrev)
(insert ?:)
(let ((origin (- (point-max) (point)))
(case-fold-search t)
;; don't mix a label with an assignment operator := :-
;; therefore take a peek at next typed character...
(next-char (read-event)))
(unwind-protect
(setq unread-command-events (append unread-command-events
(list next-char)))
;; Problem: find out if character just read is a command char
;; that would insert something after ':' making it a label.
;; At least \n, \r (and maybe \t) falls into this category.
;; This is a real crock, it depends on traditional keymap
;; bindings, that is, printing characters doing self-insert,
;; and no other command sequence inserting '-' or '='.
;; simula-electric-label can be easily fooled...
(if (and (not (memq next-char '(?= ?-)))
(or (memq next-char '(?\n ?\r))
(and (eq next-char ?\t)
simula-tab-always-indent)
(not (memq (following-char) '(?= ?-))))
(not (simula-context))
;; label?
(progn
(backward-char 1)
(skip-chars-backward " \t\f")
(skip-chars-backward "a-zA-Z0-9_")
(if (looking-at "virtual\\>")
nil
(skip-chars-backward " \t\f")
(bolp))))
(let ((amount (simula-calculate-indent)))
(delete-horizontal-space)
(indent-to amount)))
(goto-char (- (point-max) origin)))))