Fork me on GitHub
#emacs
<
2016-02-24
>
nha08:02:21

When searching files with projectile, I get some results several times. https://infinit.io/_/uHRFe6P Has anyone the same problem as me ?

bozhidar09:02:06

@lowl4tency: you shouldn’t use defconst to change variables

Kira Sotnikov09:02:50

bozhidar: hm, it's working better than default simple_smile

bozhidar09:02:51

as for the let examples

bozhidar09:02:04

I meant you should use setq

bozhidar09:02:16

defconst is for constant definition...

bozhidar09:02:32

anyways, not idea what you want to do with the let bindings

bozhidar09:02:48

I’m assuming you want to change the indentation level just in some particular scope

bozhidar09:02:59

in which case the second let should work

bozhidar09:02:37

dynamically tweaking indentation doesn’t seem reasonable to me, but as I said - I have no idea what you’re trying to do

Kira Sotnikov09:02:04

Okay, let me describe, I'd like to change indentation level from default 4 to 2 spaces. In docs author suggests to change it via json-reformat, but when I change it, it doesn't work at all.

Kira Sotnikov09:02:31

json-reformat:indent-width (integer)

    Change indentation level (default 4)

Kira Sotnikov09:02:12

if I set up next:

(defcustom json-reformat:indent-width 2
  "How much indentation `json-reformat-region' should do at each level."
  :type 'integer
  :safe #'integerp
  :group 'json-reformat)
I stil get 4 spaces of indent

Kira Sotnikov09:02:07

If I set defconst it's working simple_smile

bozhidar09:02:22

you should do (setq json-reformat:indent-width 2)

bozhidar09:02:36

that’s the proper way to modify a defcustom

Kira Sotnikov10:02:49

bozhidar: thanks!

Kira Sotnikov10:02:20

Actually, I've started read elisp reference, and now it's more clear for me simple_smile

Kira Sotnikov10:02:56

bozhidar: one more stupid q, when is appropriated to use defconst?

Kira Sotnikov10:02:17

;;;###autoload
(setq js-indent-level 2)
(defun json-mode-beautify ()
  "Beautify / pretty-print the active region (or the entire buffer if no active region)."
  (interactive)
  (let ((json-reformat:indent-width js-indent-level ))
    (if (use-region-p)
        (json-reformat-region (region-beginning) (region-end))
      (json-reformat-region (buffer-end -1) (buffer-end 1)))))

(define-key json-mode-map (kbd "C-c C-f") 'json-mode-beautify)

bozhidar10:02:01

@lowl4tency: when you have to define a constant, of course simple_smile

Kira Sotnikov10:02:20

js-indent-level is not const? simple_smile

bozhidar10:02:03

most likely it’s a defcustom

bozhidar10:02:19

a variable customizable via the customize UI

Kira Sotnikov10:02:55

bozhidar: thanks a lot, I guess I must read specs of elisp before asking )

bozhidar10:02:05

never a bad idea simple_smile

Kira Sotnikov10:02:10

I love emacs, it inspires me

bozhidar11:02:39

we all do - it’s the single greatest piece of software ever created simple_smile

Kira Sotnikov11:02:13

totally agreed!