Variable: electric-pair-mode

electric-pair-mode is a customizable variable defined in elec-pair.el.gz.

Value

nil

Documentation

Non-nil if Electric-Pair mode is enabled.

See the electric-pair-mode(var)/electric-pair-mode(fun) command for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node (emacs)Easy Customization) or call the function electric-pair-mode(var)/electric-pair-mode(fun).

View in manual

Probably introduced at or before Emacs version 24.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/elec-pair.el.gz
;;;###autoload
(define-minor-mode electric-pair-mode
  "Toggle automatic pairing of delimiters (Electric Pair mode).

Electric Pair mode is a global minor mode.  When enabled, typing an
opening delimiter (parenthesis, bracket, etc.) automatically inserts the
corresponding closing delimiter.  If the region is active, the
delimiters are inserted around the region instead.

To toggle the mode only in the current buffer, use
`electric-pair-local-mode'."
  :global t :group 'electricity
  (if electric-pair-mode
      (progn
	(add-hook 'post-self-insert-hook
		  #'electric-pair-post-self-insert-function
                  ;; Prioritize this to kick in after
                  ;; `electric-layout-post-self-insert-function': that
                  ;; considerably simplifies interoperation when
                  ;; `electric-pair-mode', `electric-layout-mode' and
                  ;; `electric-indent-mode' are used together.
                  ;; Use `vc-region-history' on these lines for more info.
                  50)
        (add-hook 'post-self-insert-hook
		  #'electric-pair-open-newline-between-pairs-psif
                  50)
	(add-hook 'self-insert-uses-region-functions
		  #'electric-pair-will-use-region))
    (remove-hook 'post-self-insert-hook
                 #'electric-pair-post-self-insert-function)
    (remove-hook 'post-self-insert-hook
                 #'electric-pair-open-newline-between-pairs-psif)
    (remove-hook 'self-insert-uses-region-functions
                 #'electric-pair-will-use-region)))