Fork me on GitHub
#emacs
<
2022-03-31
>
Carlo01:03:09

wait, I just witnessed a behavior I wish I knew more about: I was working on a file in a project, than I followed some symbol definition in a dependency, I made some modifications there and I could immediately use the new function in my project. But then, I closed emacs. When I reopened it, and started a new repl, the dependency still had the patch. How is that possible? Where's the patched version stored?

Carlo01:03:59

I found them in ~/.gitlibs, but where's the reference to a particular checkout stored in my project then?

Carlo01:03:52

Ok, I see that some kind of info has to be contained in the .cpcache folder in my project, but I'd still like to know better how it works. Are these caches per-project?

jumar04:03:38

You should be able to see the filename when you jump to a dependency's file. That will tell you what thing you are changing. I use mostly leiningen and there the modifications aren't easily "saveable" in the same way, I think (because such dependencies are typically JAR files)

vemv07:03:11

The mechanism is pretty easy to understand:

~/.gitlibs/libs/eftest/eftest $ ls
4fc03680c590aca6a13aa837c07b6eb54b7dbab9
there's one dir per git SHA. if two projects consume the same git dep at the same git sha, they use the same dir If they specify different SHAs, there will be two different checkouts residing in two independent directories

vemv07:03:45

it makes sense that modifications are persistent - these are vanilla checkouts that you can modify like any other one. Perhaps CIDER should enable read-only-mode to not make modifications so easy (after you would M-x read-only-mode to disable it again if you know what you're doing)

jumar08:03:21

With lein deps it's typically read-only but I guess that's because they are JAR files.

Carlo09:03:49

No, I love the fact that they are so easily editable! 😍

quoll14:03:56

This may be for @tomd, but others may know... Please note: I don't really know emacs at all. If you say, "Have you tried X" then my response will be, "I didn't know that X existed, and I have no idea how to even start trying to use it". With a basic setup of emacs+evil, does anyone know how I can get ^R to do "redo", please? My previous system worked correctly, but I've just installed emacs on 2 new systems and am encountering this problem. I note that the https://github.com/syl20bnr/spacemacs/issues/14036, so I'm wondering if it's a more general issue? I discovered the evil-undo-system setting, but installing undo-tree and setting it to that didn't work, and neither did installing undo-fu and trying that one. (I only kept one installed at a time).

πŸ‘ 2
tomd14:03:47

evil's maps should set this up for you by default:

(define-key evil-normal-state-map "\C-r" 'evil-redo)
what happens if you do C-h k C-r in normal mode?

tomd14:03:27

(`C-h k` is describe-key which is handy for debugging this sort of thing)

tomd14:03:04

also if you do C-h v evil-undo-system <return> and let me know what that is - customizing this is the easiest way to make redo just workβ„’ and probably the actual answer to your question

quoll15:03:39

I do have "C-h k" in my notes, and I use it a lot πŸ™‚ When you say, "normal mode" do you mean when evil is not enabled? Or evil is enabled and you're not in insert mode? (if it's the latter, then it's bound to (evil-redo count)

quoll15:03:49

evil-undo-system is set to nil

quoll15:03:22

BTW, the system I fiddled with all weekend is another machine. This one right now is basically emacs+cider+evil, and not much else. There is very little manual config at all

tomd15:03:39

sorry, technically I meant "normal state" (the latter)

quoll15:03:29

That's OK. It's what I thought you meant, but I didn't want to mess you up

πŸ™‚ 1
tomd15:03:30

ok so you just need to customize evil-undo-system and you should be fine:

(customize-set-variable 'evil-undo-system 'undo-tree)
in your init.el should do it

quoll15:03:26

Oh... I wasn't aware of the customize- prefix

tomd15:03:01

yeah it's the "proper" way to set things that were defcustom'd

quoll15:03:11

oh... now it wants me to enabled 'global-undo-tree-mode' to use undo-tree commands?

tomd15:03:00

ah sorry I thought you had undo-tree up and running. you can choose undo-fu if you have that

quoll15:03:58

like I said, new install

tomd15:03:17

sorry you mentioned something about undo tree at the top and I didn't read properly

tomd15:03:21

you can choose undo-redo if you're on emacs 28 or later, and that's built in

tomd15:03:05

(they're all much of a muchness afaic, but if you have specific undo/requirements, then you may want to look into the differences)

quoll15:03:13

Sorry... On the weekend I was trying this with another machine. I installed undo-tree, and that didn't work. I then uninstalled it and installed undo-fu, and that didn't work. Today I'm on a work machine. I haven't installed either undo-tree nor undo-fu, mostly because I don't know how to use them, and I couldn't hook them up to evil

πŸ‘Œ 1
tomd15:03:47

if you're not on emacs 28, I'd install undo-fu and set that as you evil-undo-system. it's very simple from my experience

quoll15:03:33

Sorry... I was just trying to see if I could get brew to update to a more recent emacs, but it doesn't seem to know about anything after 27.2

quoll15:03:49

Whew. This worked. Thank you very much.

quoll15:03:20

I was stuck on trying: (setq evil-undo-system 'undo-fu) as this doesn't work

quoll15:03:22

(or (set 'evil-undo-system 'undo-fu), which I believe is the same thing, but I tried both anyway πŸ™‚ )

tomd15:03:31

ah glad it's up and running for you πŸ™‚

tomd15:03:43

customize-set-variable ftw

πŸ‘ 1
ag18:03:24

@ericdallo is there a way to show nested levels of a map in lsp breadcrumbs header? i.e. when the cursor positioned in a map like {:foo {:bar {:zap 1}}} inside the innermost element, could I make it to display in breadcrumbs :foo :bar :zap?

ericdallo18:03:45

I think it could be possible, but it'd need a some work on clojure-lsp side, not that easy though

ag18:03:42

Alright, I was curious thinking maybe lsp does that already. lsp does so many cool things, I don't even know anymore what it can and can't do... lol

πŸ˜… 1
ahungry18:03:14

This is a little helper I wrote some time ago for Emacs+CIDER - at the time, I don't think there was an equivalent (not sure if there is now):

(defun my-cider-tinker ()
  "Evals current defn at point and attempts to call it with user args."
  (interactive)
  (lexical-let* ((my-form (read-string "args: "))
                 (eval-result (call-interactively #'cider-eval-defun-at-point))
                 (my-buffer (current-buffer))
                 (my-place (cider-defun-at-point 'bounds)))
    (cider-interactive-eval
     (format
      "(let [x (@*1 %s)]
(prn)
(prn \"my-cider-tinker result:\")
(prn x)
x)"
      my-form)
     (cider-interactive-eval-handler my-buffer my-place))))
When executed on a form (typically a function defn), it prompts the user for args, and then runs the form/fn with those args and prints the result

1
ag19:04:01

fyi: lexical-let is obsolete since the introduction of true lexical binding in Emacs 24.1.