Function: cperl-electric-else

cperl-electric-else is a byte-compiled function defined in cperl-mode.el.gz.

Signature

(cperl-electric-else)

Documentation

Insert a construction appropriate after a keyword.

Help message may be switched off by setting cperl-message-electric-keyword to nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-electric-else ()
  "Insert a construction appropriate after a keyword.
Help message may be switched off by setting `cperl-message-electric-keyword'
to nil."
  (let ((beg (line-beginning-position)))
    (and (save-excursion
           (skip-chars-backward "[:alpha:]")
	   (cperl-after-expr-p nil "{;:"))
	 (save-excursion
	   (not
	    (re-search-backward
	     "[#\"'`]\\|\\<q\\(\\|[wqxr]\\)\\>"
	     beg t)))
	 (save-excursion (or (not (re-search-backward "^=" nil t))
			     (looking-at "=cut")
			     (looking-at "=end")
			     (and cperl-use-syntax-table-text-property
				  (not (eq (get-text-property (point)
							      'syntax-type)
					   'pod)))))
	 (progn
	   (cperl-indent-line)
	   ;;(insert " {\n\n}")
           (cond
            (cperl-extra-newline-before-brace
             (insert "\n")
             (insert "{")
             (cperl-indent-line)
             (insert "\n\n}"))
            (t
             (insert " {\n\n}")))
	   (or (looking-at "[ \t]\\|$") (insert " "))
	   (cperl-indent-line)
	   (forward-line -1)
	   (cperl-indent-line)
           (push cperl-del-back-ch unread-command-events)
	   (setq this-command 'cperl-electric-else)
	   (if cperl-message-electric-keyword
	       (message "Precede char by C-q to avoid expansion"))))))