0

I want to enable paredit-mode on all clojure, cljs and elisp buffers by default, which is probably going to happen through the .spacemacs file. This is what I have so far in the user-config function of my .spacemacs:

;; paredit autoload
  (autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
  (add-hook 'clojure-mode #'enable-paredit-mode)
  (add-hook 'clojurescript-mode #'enable-paredit-mode)

But it doesn't really work. What am I doing wrong?

-- EDIT -- I've tried

;; paredit autoload
  (autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
  (add-hook 'clojure-mode-hook 'enable-paredit-mode)
  (add-hook 'clojurescript-mode-hook 'enable-paredit-mode)

and

;; paredit autoload
  (autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
  (add-hook 'clojure-mode-hook #'enable-paredit-mode)
  (add-hook 'clojurescript-mode-hook #'enable-paredit-mode)

and neither works.

-- EDIT --

The value of clojure-mode-hook is:

(#f(compiled-function
    ()
    #<bytecode 0x464d0c01>)
   (lambda nil
     (set
      (make-local-variable 'sesman-system)
      'CIDER))
   clojure--check-wrong-major-mode clj-refactor-mode cider-mode spacemacs//init-jump-handlers-clojure-mode)
  • I don’t know what you’ve done wrong but clearly your hook to enable paredit has not made it into clojure-mode-hook. Maybe you need to wrap those in an eval-after-load. Do you have any evidence that the code you’ve written actually runs? – Dan Robertson May 27 at 13:58
0

I think in your first attempt you wrote clojure-mode instead of closure-mode-hook, and likewise for clojurescript-mode. But changing it didn’t fix things. My best guess is that your changes to those hooks get clobbered when the mode loads.

Try using eval-after-load to only make the change after the hooks are defined:

(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(eval-after-load ‘clojure-mode
  '((add-hook 'clojure-mode-hook #'enable-paredit-mode)
    (add-hook 'clojurescript-mode-hook #'enable-paredit)))
| improve this answer | |
  • I tried that but it didn't work – lamp bottle May 27 at 13:47
  • If you want help you will need to be more descriptive with what is not working. You should also explain what else you have tried. Please update your question accordingly with the code that didn’t work. The code in your question definitely won’t work. Also, what is the value of clojure-mode-hook? – Dan Robertson May 27 at 13:50
  • How do you find the value of clojure-mode-hook? – lamp bottle May 27 at 13:53
  • Do C-h v clojure-mode-hook RET – Dan Robertson May 27 at 13:54
  • check out my edit for the clojure-mode-hook value – lamp bottle May 27 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.