Fork me on GitHub

Yeah, that’s standard.


Btw, in CIDER there’s a similar command (and also a matching scratch buffer).


C-c M-: and M-x cider-scratch

Maxim Kim06:04:35

@jeff.terrell it is eval-print-last-sexp standard emacs binding <C-j> in lisp-interaction-mode

👍 1

Thanks for sharing cider-scratch. I'm using the elisp scratch buffer all the time, but having a scratch buffer in Clojure around will be so much sweeter!


Is there a way to get emacs to consider the starting colon in a :keyword to be the start of word when navigating by words?

Maxim Kim09:04:45

@ajs try superword-mode

Maxim Kim09:04:37

But then you will not stop by dashes as in :keyword-dashed

Maxim Kim10:04:30

And I guess it is possible to redefine what "word" is in emacs using syntax-tables as described in

Maxim Kim10:04:19

Try to evaluate (modify-syntax-entry ?: "w") in *scratch* buffer

Maxim Kim10:04:43

it will add : char to word class

Maxim Kim10:04:21

then in the same buffer try to backward/forward word in (hello :world) expression -- for me it stops exactly at colon when I do backward-word having cursor on the last paren

Maxim Kim10:04:41

Next thing, if the behavior suits you, add modify-syntax-entry to your init.el as add-hook for desired mode (clojure-mode I presume)


@habamax (modify-syntax-entry ?: "w") works, but my attempt to add-hook it to clojure-mode is the following, which doesn't seem to do anything:

(defun use-colon-as-word-start ()
  (modify-syntax-entry ?: "w"))

(add-hook 'clojure-mode 'use-colon-as-word-start)


I wish my elisp fu was like my clojure fu. i must be doing something invalid here

Maxim Kim11:04:13

try this:

(defun use-colon-as-word-start ()
  (let ((table (make-syntax-table)))
    (modify-syntax-entry ?: "w" table)
    (set-syntax-table table)))

(add-hook 'clojure-mode-hook 'use-colon-as-word-start)


A worthy try, but still doesn't do it

Maxim Kim12:04:33

or better:

(defun use-colon-as-word-start ()
  (let ((table (make-syntax-table clojure-mode-syntax-table)))
    (modify-syntax-entry ?: "w" table)
    (set-syntax-table table)))

(add-hook 'clojure-mode-hook 'use-colon-as-word-start)
Here you're modifying existing clojure-mode-syntax-table which is better than barebone default standard-syntax-table

Maxim Kim12:04:49

It does for me


do you need to restart emacs? I'm just evaling my init.el, re-opening the clojure file and using M-f and M-b to navigate words.


works fine in scratch buffer

Maxim Kim12:04:40

I have the following in my init.el:

(use-package clojure-mode
  :mode ("\\.\\(clj\\)$" . clojure-mode)
  (defun use-colon-as-word-start ()
    (let ((table (make-syntax-table clojure-mode-syntax-table)))
      (modify-syntax-entry ?: "w" table)
      (set-syntax-table table)))

  (add-hook 'clojure-mode-hook 'use-colon-as-word-start)

  (use-package cider
    (setq cider-repl-display-help-banner t)
    (setq cider-repl-use-pretty-printing t)))

Maxim Kim12:04:35

And I have just restarted emacs, opened test.clj and it works for me


looks like i am not explicitly referring to clojure mode anywhere in my init.el. must be happening implicitly with (require-package 'cider)


i am adding the new content after the require-package for cider

Maxim Kim12:04:23

You do have clojure-mode as major mode for emacs when you open any clj file, don't you?

Maxim Kim12:04:57

what is clojure-mode-hook value then?

Maxim Kim12:04:29

mine is: (use-colon-as-word-start clojure--check-wrong-major-mode)


(er/add-clojure-mode-expansions clojure--check-wrong-major-mode hl-sexp-mode rainbow-delimiters-mode paredit-mode)


that is the value of clojure-mode-hook when I eval it in the mini buffer

Maxim Kim12:04:42

so it is not hooked


i'm not sure what that means

Maxim Kim12:04:20

I mean (add-hook 'clojure-mode-hook 'use-colon-as-word-start) was not evaled


do i need to explicitly set the hook somewhre?


oh i see]

Maxim Kim12:04:28

yes in your init.el


i added the hook to my init.el and evaled that file as I normally do when i'm playing with my config


wait it think i see a syntax error

Maxim Kim12:04:18

you use clojure-mode

Maxim Kim12:04:26

but should clojure-mode-hook

Maxim Kim12:04:35

symbol in add-hook


note above, a few minutes i showed what I'm putting in my init.el which is (add-hook 'clojure-mode 'use-colon-as-word-start) but it should be clojure-mode-hook


ahh i see you noticed that too


it's working now


thanks for the help on that


i spend so many extra keystrokes navigating colons!


Not sure how many of you use evil mode. But I always thought it was annoying commands like <number> <motion key> didn't by default register with evil jump, so you couldn't <Ctrl>-O/I to locations navigated with it. Well turns out there's a config for that. (evil-define-command digit-argument :keep-visual t :repeat nil :jump t) adding :jump t to any of the commands listed in evil-command-properties var allows them to register with evil-jump


quite a few of them already have the jump command, but this allows you to add more. I use relative line numbering so I use the the number motion more than I use go to line commands