[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9932: 24.0.90; electric pair mode is getting enabled globally , not
From: |
Stefan Monnier |
Subject: |
bug#9932: 24.0.90; electric pair mode is getting enabled globally , not just for a buffer. |
Date: |
Tue, 08 Nov 2011 23:23:29 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) |
> Electric pair mode enables globally. I would rather prefer it to be
> buffer local.
> I think it would be good to have an electric-pair-mode for a single
> buffer and an electric-pair-global-mode/global-electric-pair-mode for
> enabling the feature globally.
How 'bout a way to turn it off buffer-locally, so you can have it
enabled globally but can also disable it in some modes?
E.g. the patch below would be enough for that, after which you could do
(add-hook 'text-mode-hook
(lambda () (set (make-local-variable 'electric-pair-mode) nil)))
to turn if off in all modes derived from text-mode.
We could easily provide this in 24.1, whereas what you suggest would
have to wait for 24.2.
Stefan
=== modified file 'lisp/electric.el'
--- lisp/electric.el 2011-10-19 21:57:06 +0000
+++ lisp/electric.el 2011-11-09 04:21:51 +0000
@@ -284,6 +284,7 @@
(defun electric-pair-post-self-insert-function ()
(let* ((syntax (and (eq (char-before) last-command-event) ; Sanity check.
+ electric-pair-mode
(let ((x (assq last-command-event electric-pair-pairs)))
(cond
(x (if (eq (car x) (cdr x)) ?\" ?\())