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.
This commit is contained in:
Tom Willemse 2015-03-28 14:43:33 +00:00 committed by João Távora
parent be5e9348dc
commit 40b3dcd2c0
4 changed files with 27 additions and 2 deletions

View file

@ -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

View file

@ -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).

View file

@ -1,3 +1,9 @@
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

View file

@ -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