Function: prolog-electric--dot
prolog-electric--dot is a byte-compiled function defined in
prolog.el.gz.
Signature
(prolog-electric--dot)
Documentation
Make dot electric, if prolog-electric-dot-flag is non-nil.
When invoked at the end of nonempty line, insert dot and newline. When invoked at the end of an empty line, insert a recursive call to the current predicate. When invoked at the beginning of line, insert a head of a new clause of the current predicate.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/prolog.el.gz
(defun prolog-electric--dot ()
"Make dot electric, if `prolog-electric-dot-flag' is non-nil.
When invoked at the end of nonempty line, insert dot and newline.
When invoked at the end of an empty line, insert a recursive call to
the current predicate.
When invoked at the beginning of line, insert a head of a new clause
of the current predicate."
;; Check for situations when the electricity should not be active
(if (or (not prolog-electric-dot-flag)
(not (eq (char-before) ?\.))
current-prefix-arg
(nth 8 (syntax-ppss))
;; Do not be electric in a floating point number or an operator
(not
(save-excursion
(forward-char -1)
(skip-chars-backward " \t")
(let ((num (> (skip-chars-backward "0-9") 0)))
(or (bolp)
(memq (char-syntax (char-before))
(if num '(?w ?_) '(?\) ?w ?_)))))))
;; Do not be electric if inside a parenthesis pair.
(not (= (car (syntax-ppss))
0))
)
nil ;;Not electric.
(cond
;; Beginning of line
((save-excursion (forward-char -1) (bolp))
(delete-region (1- (point)) (point)) ;Delete the dot that called us.
(prolog-insert-predicate-template))
;; At an empty line with at least one whitespace
((save-excursion
(beginning-of-line)
(looking-at "[ \t]+\\.$"))
(delete-region (1- (point)) (point)) ;Delete the dot that called us.
(prolog-insert-predicate-template)
(when prolog-electric-dot-full-predicate-template
(save-excursion
(end-of-line)
(insert ".\n"))))
;; Default
(t
(insert "\n"))
)))