Fork me on GitHub
#emacs
<
2017-05-02
>
bunkers08:05:54

Hi all, I’m just doing an audit of my config and the template I’ve used has this in it

(setq backup-directory-alist `(("." . ,(concat user-emacs-directory
                                               "backups"))))
What does the second item (the unquoted dot) in that list do? For that matter I’m not sure what the first item is for!

benedek09:05:25

the second dot is just for easier readability in terms for alists. afaik it is optional

benedek09:05:00

first item: current dir?

bunkers09:05:15

oh right, so a bit like a comma?

bunkers09:05:18

That’s what I thought about the first dot but this is supposed to be moving the backup file location to backups in the emacs.d directory. If that’s the case then you wouldn’t need to include the current directory would you?

bunkers09:05:47

oh hang on, so it’s associating the current directory with a different one

benedek09:05:08

yup. coolio 🙂

bunkers09:05:37

brilliant, that’s really helpful, thanks!

benedek10:05:54

whoops. sorry for misleading…

qqq15:05:18

is there a way to get (comment .... ) to display in the same style as ;; .... ?

richiardiandrea16:05:01

I didn't know it had (comment...

qqq16:05:13

in clojure

qqq16:05:31

in clojure, my (comment ... ) sexps look like regular sexps

qqq16:05:43

I'd prefer they be gray + italicized like ;; and #_

richiardiandrea16:05:46

@qqq better ask #cider for this

qqq16:05:57

how is this #cider and not #emacs ?

qqq16:05:01

I'm not even using #cider

richiardiandrea16:05:21

Oh ok so it must be clojure-mode

richiardiandrea16:05:42

Probably there is a defface to duplicate in there

richiardiandrea16:05:19

You can use describe-face for checking where the face comes from

qqq16:05:38

This makes sense.

qqq16:05:43

I'm going to try this.

qqq16:05:57

How do I access the code of clojure-mode (besides trying to guess a function in clojure-mode and doing C-h f)

qqq16:05:03

(defface clojure-keyword-face
  '((t (:inherit font-lock-constant-face)))
  "Face used to font-lock Clojure keywords (:something)."
  :package-version '(clojure-mode . "3.0.0"))

(defface clojure-character-face
  '((t (:inherit font-lock-string-face)))
  "Face used to font-lock Clojure character literals."
  :package-version '(clojure-mode . "3.0.0"))

(defface clojure-interop-method-face
  '((t (:inherit font-lock-preprocessor-face)))
  "Face used to font-lock interop method names (camelCase)."
  :package-version '(clojure-mode . "3.0.0"))
actually, that's all the deffaces that there are

dpsutton16:05:54

from this, it appears that ;;, #_ and comment differ. comment must be readable, and therefore making it look commented out could lead to compilation errors or holding onto aliases after they have been removed, etc

qqq16:05:41

that's from the view of the clj compiler

qqq16:05:47

it doesn't give a damn about how emacs displays it

qqq16:05:52

the two are unrelated

qqq16:05:06

(but you're right in that (comment ...) is read + returns nil rather than throw away at read time)

dpsutton16:05:45

of course it doesn't matter how emacs displays it. my point is that there is often comment drift. and if it looks commented out you may not realize that the compiler requires it to move in lockstep and keep aliases, etc

dpsutton16:05:45

just a possible reason as to why the faces are displayed differently

dpsutton16:05:45

ah it looks like the reader doesn't resolve anything, just makes sure the forms "look right"

dpsutton16:05:03

By default, this only applies to code after the `#_' reader
macro.  In order to also font-lock the `(comment ...)' macro as a
comment, you can set the value to:
    \"#_ *\\\\(?1:[^ ]\\\\)\\\\|\\\\(?1:(comment\\\\_>\\\\)\"")

qqq17:05:49

@dpsutton : precisely what I need; thanks!

richiardiandrea17:05:07

@qqq it would be great if you can contribute back to clojure.mode I guess

qqq18:05:21

@richiardiandrea : the code @dpsutton linked to iks already, literally, in the clojure-mode codebase

dpsutton18:05:45

if you felt like doing a little coding you could make that more easily toggle-able

qqq18:05:53

(setq clojure--comment-macro-regexp "# *\\(?1:[^ ]\\)\\|\\(?1:(comment\\>\\)") ^^ is literally all it takes

qqq18:05:05

toggle on: put that in init.el toggle off: comment it out 🙂

dpsutton18:05:14

true, but it requires finding that regex in the source and setq'ing it.

(defun clojure-mode-toggle-comment ()
  (setq clojure-comments-out-comments (not (clojure-comments-out-comments))
  (setq clojure--comment-macro-regexp (clojure-mode-regex-for-comment-style ...)))
or something similar

qqq19:05:06

@richiardiandrea : can you package up @dpsutton 's patch and submit it as a pull request to clojure-mode? 🙂

richiardiandrea19:05:59

sure can, isn't github working for you?

qqq19:05:16

it's working fine for me; I'm just an lazy jerk

richiardiandrea19:05:01

got it, I can for sure, is it the only thing that's needed?

richiardiandrea19:05:25

also, can this be on by default?

qqq19:05:33

I don't know if others have suggestions.

qqq19:05:42

I wouldn't be the right person to make that call.

qqq19:05:08

(comment ...) is kind of weird in that, when the code is run, it actually becomes a nil right ?

qqq19:05:30

how do we trigger clojurebot again ?

richiardiandrea19:05:34

yes but this is something you don't care about in emacs...as long as it is grayed out

richiardiandrea19:05:47

it is just for displaying it correctly

richiardiandrea19:05:11

yeah you are basically executing (str) there

qqq19:05:27

no, I'm executing (str nil) there

qqq19:05:36

(comment ....) isn't stripped away at read time, it becomes a "nil"

qqq19:05:36

I'm abusing it as follows:

(defn foo [ ... ]
  (comment ... )
  (... body of foo ... ))
then, since (comment l..) isn't stripeped away, I can insert all the type info for function foo there

qqq19:05:48

it's really ugly / nasty

richiardiandrea19:05:34

it is not stripped at read time because it is not a reader macro

qqq19:05:55

right, I get that

richiardiandrea19:05:05

anyways, these are just details

qqq19:05:26

yeah, I think the patch is fine; though I'm not really convicned it's really necessary

qqq19:05:59

at least in my expericne, all of my init.el is just setq-ing stuff, not togglikgnoptions

richiardiandrea19:05:09

probably it should be optional, because of that

qqq19:05:25

and also, how often does someone, in the middle of coding, decide

qqq19:05:33

gee, I want to toggle the appearance of (comment ....) 🙂

qqq19:05:42

it seems like the type of thing where you set once, and stick with the decisions for years

richiardiandrea19:05:01

uhm, dunno in any case a defcustom is cheap, I will add it and see what folks think about it

richiardiandrea19:05:37

so @dpsutton where did you take clojure-comments-out-comments?

dpsutton19:05:05

where did i take it? naming things is hard so i just put a placeholder. i was guessing what it might eventually be called, but that's a pretty poor name

dpsutton19:05:18

i wouldn't go with that one 🙂

caio19:05:14

O don't like this as default. Stuff inside comment is still code and would benefit from syntax highlighting

richiardiandrea19:05:33

@dpsutton weird, do I need to refresh somehow the emacs display in order to see that?

dpsutton19:05:49

to see what?

richiardiandrea19:05:01

the different face for (comment

dpsutton19:05:15

no idea. first time looking in clojure-mode, really

dpsutton19:05:24

i think you can eval some code and it will trigger font-lock

dpsutton19:05:31

even just (+ 1 1) or something

richiardiandrea19:05:33

uhm, lemme try that

dpsutton19:05:37

from the repl or the buffer

dpsutton19:05:45

it'll trigger the state handler which calls font-locking

richiardiandrea19:05:07

oh, there is a font-lock-fontify-block

richiardiandrea19:05:42

nice, it works 🙂

dpsutton19:05:21

awesome. did eval-ing code trigger it or did you have to call that function?

richiardiandrea19:05:34

I had to call the above (easier!)

bozhidar20:05:53

Just noticed this online - newcomers to CIDER would probably find it pretty useful.

qqq21:05:24

@bozhidar: where is part 1 ?