Fork me on GitHub

When searching files with projectile, I get some results several times. Has anyone the same problem as me ?


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

Kira Sotnikov09:02:50

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


as for the let examples


I meant you should use setq


defconst is for constant definition...


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


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


in which case the second let should work


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


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


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

(setq js-indent-level 2)
(defun json-mode-beautify ()
  "Beautify / pretty-print the active region (or the entire buffer if no active region)."
  (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)


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

Kira Sotnikov10:02:20

js-indent-level is not const? simple_smile


most likely it’s a defcustom


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 )


never a bad idea simple_smile

Kira Sotnikov10:02:10

I love emacs, it inspires me


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

Kira Sotnikov11:02:13

totally agreed!