Fork me on GitHub
#emacs
<
2018-04-06
>
bozhidar03:04:06

Yeah, that’s standard.

bozhidar03:04:35

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

bozhidar03:04:00

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
munen09:04:55

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!

ajs09:04:00

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 https://www.emacswiki.org/emacs/EmacsSyntaxTable

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)

ajs11:04:18

@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)

ajs11:04:29

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)

ajs12:04:16

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

ajs12:04:17

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.

ajs12:04:34

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)
  :config
  (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
    :config
    (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

ajs12:04:38

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

ajs12:04:54

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)

ajs12:04:31

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

ajs12:04:40

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

ajs12:04:09

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

ajs12:04:21

do i need to explicitly set the hook somewhre?

ajs12:04:27

oh i see]

Maxim Kim12:04:28

yes in your init.el

ajs12:04:45

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

ajs12:04:09

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

ajs12:04:19

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

ajs12:04:30

ahh i see you noticed that too

ajs12:04:32

it's working now

ajs12:04:41

thanks for the help on that

ajs12:04:48

i spend so many extra keystrokes navigating colons!

theeternalpulse22:04:59

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

theeternalpulse22:04:13

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