Fork me on GitHub
#emacs
<
2019-04-10
>
aryyya04:04:00

Does anybody here use Emacs? I’d like to use clojure-mode, paredit-mode, show-paren-mode and rainbow-delimiters-mode for editing Clojure files but I can’t figure out how to enable these automatically. I’ve been enabling them manually.

😆 4
practicalli-johnny09:04:27

This is one reason I use the Spacemacs configuration for Emacs. I just open a Clojure file or add the word clojure to the Spacemacs layer config and Get coding http://spacemacs.org/ If you want craft your own Emacs config, then take a look at http://www.cider.mx/en/latest/additional_packages/ for some ideas.

practicalli-johnny09:04:19

If you need more ideas on configuring all these packages, take a look at https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/clojure

practicalli-johnny09:04:49

Or just join the #cider channel on this Slack community for help (or #spacemacs channel if you choose that approach)

yuhan05:04:50

you could add those other modes to clojure-mode-hook using add-hook

yuhan05:04:18

clojure-mode itself should be enabled automatically on .clj files

orestis06:04:57

(use-package clojure-mode
  ;;:pin melpa-stable
  :ensure t
  :config

  (setq clojure-toplevel-inside-comment-form t)

  (add-hook 'clojure-mode-hook #'paredit-mode)
  (add-hook 'clojure-mode-hook #'subword-mode)
  (add-hook 'clojure-mode-hook #'rainbow-delimiters-mode))

orestis06:04:18

@aryyya.xyz This is an example from my init.el

cmack13:04:18

use-package has a :hook option which can make those last three

:hook (paredit-mode subword-mode rainbow-delimiters-mode)

solf15:04:47

How to do nested for with cl-loop? i.e. something like this:

(cl-loop
 for i from 0 to 3
 for j from 0 to 1
 collect (list i j))

# Wanted result, not what actually happens:
=> ((0 0) (0 1) (1 0) (1 1) (2 0) (2 1) (3 0) (3 1))

solf15:04:27

The equivalent of python [(x, y) for x in range(3) for y in range(2)]

solf16:04:13

Apparently cl-loop doesn't support nested loops, the best I have is:

(-flatten-n 1 (cl-loop
	       for i from 0 to 3
	       collect
	       (cl-loop
		for j from 0 to 1
		collect (list i j))))

cmack16:04:07

(cl-loop for i from 0 to 3 nconc (cl-loop for j from 0 to 1 collect (list i j)))