Commit 40b3dcd2 authored by Tom Willemse's avatar Tom Willemse Committed by João Távora

New `electric-pair-local-mode'

Fixes: big#19528

* lisp/elec-pair.el (electric-pair-local-mode): New command.
(electric-pair-mode): Mention `electric-pair-local-mode' in the
docstring.
parent be5e9348
......@@ -870,7 +870,9 @@ mode to skip whitespace forward before deciding whether to skip over
the closing delimiter.
@end itemize
To toggle Electric Pair mode, type @kbd{M-x electric-pair-mode}.
To toggle Electric Pair mode, type @kbd{M-x electric-pair-mode}. To
toggle the mode in a single buffer, use @kbd{M-x
electric-pair-local-mode}.
@node Comments
@section Manipulating Comments
......
......@@ -215,6 +215,9 @@ Unicode standards.
** You can access `mouse-buffer-menu' (C-down-mouse-1) using C-f10.
+++
** New buffer-local `electric-pair-local-mode'.
* Changes in Specialized Modes and Packages in Emacs 25.1
** xterm-mouse-mode now supports mouse-tracking (if your xterm supports it).
......
2015-03-28 Tom Willemse <tom@ryuslash.org>
* elec-pair.el (electric-pair-local-mode): New command.
(electric-pair-mode): Mention `electric-pair-local-mode' in the
docstring.
2015-03-28 Jan Djärv <jan.h.d@swipnet.se>
* emacs-lisp/package.el (package-refresh-contents): Add a message at
......
......@@ -557,7 +557,8 @@ the mode if ARG is omitted or nil.
Electric Pair mode is a global minor mode. When enabled, typing
an open parenthesis automatically inserts the corresponding
closing parenthesis. (Likewise for brackets, etc.)."
closing parenthesis. (Likewise for brackets, etc.). To toggle
the mode in a single buffer, use `electric-pair-local-mode'."
:global t :group 'electricity
(if electric-pair-mode
(progn
......@@ -571,6 +572,19 @@ closing parenthesis. (Likewise for brackets, etc.)."
(remove-hook 'self-insert-uses-region-functions
#'electric-pair-will-use-region)))
;;;###autoload
(define-minor-mode electric-pair-local-mode
"Toggle `electric-pair-mode' only in this buffer."
:variable (buffer-local-value 'electric-pair-mode (current-buffer))
(cond
((eq electric-pair-mode (default-value 'electric-pair-mode))
(kill-local-variable 'electric-pair-mode))
((not (default-value 'electric-pair-mode))
;; Locally enabled, but globally disabled.
(electric-pair-mode 1) ; Setup the hooks.
(setq-default electric-pair-mode nil) ; But keep it globally disabled.
)))
(provide 'elec-pair)
;;; elec-pair.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment