how to enable Show-Paren mode only for *.el files

elisp, emacs

Solution

As already said, `show-paren-mode` is a global minor mode. That said, one might be able to run it only on some buffer with something like:

(show-paren-mode)                       ;; activate the needed timer
(setq show-paren-mode ())                ;; The timer will do nothing if this is nil

(defun show-paren-local-mode ()
  (interactive)
  (make-local-variable 'show-paren-mode) ;; The value of shom-paren-mode will be local to this buffer.
  (setq show-paren-mode t))

(add-hook 'emacs-lisp-mode-hook 'show-paren-local-mode)

It's untested, it might not work. Looking at the doc in might work, but looking at the code it might work. This might work only with some version of show-paren-mode.

Problem

How can I enable Show-Paren mode only for *.el files? I have tried ``` (add-hook 'emacs-lisp-mode-hook '(lambda() (show-paren-mode 1) )) ``` But it still enables Show-Paren mode for all the cases. Even in `*scratch*` buffer I have Show-Paren mode enabled.

Original source