Search code examples
emacsparedit

Emacs - Load ParEdit Mode on Startup


Is there a straightforward way to enable paredit mode by default every time I launch emacs? I have this code in my .emacs:

(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(show-paren-mode 1)
(global-rainbow-delimiters-mode 1)
(global-hl-line-mode 1)
(global-linum-mode t)
(paredit-mode 1)

Every mode except for paredit-mode gets loaded. Why is this happening?

Thank you.


Solution

  • You probably don't want to enable Paredit globally:

    Paredit behaves badly if parentheses are unbalanced, so exercise caution when forcing Paredit Mode to be enabled, and consider fixing unbalanced parentheses instead.

    Instead, you can invoke it for modes where it makes sense, e.g.

    (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)