'font-lock-constant-face
font-lock-string-face))))))
+(ert-deftest cperl-test-hyperactive-electric-else ()
+ "Demonstrate cperl-electric-else behavior.
+If `cperl-electric-keywords' is true, keywords like \"else\" and
+\"continue\" are expanded by a following empty block, with the
+cursor in the appropriate position to write that block. This,
+however, must not happen when the keyword occurs in a variable
+\"$else\" or \"$continue\"."
+ (skip-unless (eq cperl-test-mode #'cperl-mode))
+ ;; `self-insert-command' takes a second argument only since Emacs 27
+ (skip-unless (not (< emacs-major-version 27)))
+ (with-temp-buffer
+ (setq cperl-electric-keywords t)
+ (cperl-mode)
+ (insert "continue")
+ (self-insert-command 1 ?\ )
+ (indent-region (point-min) (point-max))
+ (goto-char (point-min))
+ ;; cperl-mode creates a block here
+ (should (search-forward-regexp "continue {\n[[:blank:]]+\n}")))
+ (with-temp-buffer
+ (setq cperl-electric-keywords t)
+ (cperl-mode)
+ (insert "$continue")
+ (self-insert-command 1 ?\ )
+ (indent-region (point-min) (point-max))
+ (goto-char (point-min))
+ ;; No block should have been created here
+ (should-not (search-forward-regexp "{" nil t))))
+
;;; cperl-mode-tests.el ends here