From: Noam Postavsky Date: Sun, 7 Jul 2019 16:22:37 +0000 (-0400) Subject: Don't load elec-pair in elisp-mode (Bug#36539) X-Git-Tag: emacs-27.0.90~1857 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8f54998827e416fe1fca7bc384bf0a6281b73f1b;p=emacs.git Don't load elec-pair in elisp-mode (Bug#36539) * lisp/progmodes/elisp-mode.el (emacs-lisp-set-electric-text-pairs): New function. (emacs-lisp-mode): Add it to electric-pair-mode-hook, if elec-pair hasn't been loaded yet. --- diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 16851c0d826..da7a731ec22 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -219,6 +219,18 @@ Comments in the form will be lost." :type 'hook :group 'lisp) +(defun emacs-lisp-set-electric-text-pairs () + "Set `electric-pair-text-pairs' for all `emacs-lisp-mode' buffers." + (defvar electric-pair-text-pairs) + (let ((elisp-pairs (append '((?\` . ?\') (?‘ . ?’)) + electric-pair-text-pairs))) + (save-current-buffer + (dolist (buf (buffer-list)) + (set-buffer buf) + (when (derived-mode-p 'emacs-lisp-mode) + (setq-local electric-pair-text-pairs elisp-pairs))))) + (remove-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs)) + ;;;###autoload (define-derived-mode emacs-lisp-mode prog-mode "Emacs-Lisp" "Major mode for editing Lisp code to run in Emacs. @@ -231,12 +243,12 @@ Blank lines separate paragraphs. Semicolons start comments. (defvar project-vc-external-roots-function) (lisp-mode-variables nil nil 'elisp) (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers) - (unless noninteractive - (require 'elec-pair) - (defvar electric-pair-text-pairs) - (setq-local electric-pair-text-pairs - (append '((?\` . ?\') (?‘ . ?’)) electric-pair-text-pairs)) - (setq-local electric-quote-string t)) + (if (boundp 'electric-pair-text-pairs) + (setq-local electric-pair-text-pairs + (append '((?\` . ?\') (?‘ . ?’)) + electric-pair-text-pairs)) + (add-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs)) + (setq-local electric-quote-string t) (setq imenu-case-fold-search nil) (add-function :before-until (local 'eldoc-documentation-function) #'elisp-eldoc-documentation-function)