emacs

Drew Verlee 2025-07-16T02:37:06.090529Z

My current strategy for resolving git merges is to turn off clojure mode, into just plain text, grab a cup of coffee and pull myself by my bootstraps. Every tool i touch in emacs, and even when i try to use intelliji or vscode, more then half the time, just makes it harder because it's trying to provide some structure thats not useful for manipulating clojure. The thing is a merge conflict file is basically no longer clojure, the compiler is gone, git can't help me make a clojure program whole again in a meaningful way. I would be happy to be proven wrong, but everything i see it "go well" it was also trivially easy to resolve a merge using no tools at all, and the tools often make manipulating the bigger changes even more cumbersome. How does everyone else feel?

technosophist 2025-07-17T11:23:03.772729Z

IME, difftastic works great at the CLI. I've struggled to get emacs tools to work great. I've dabbled with ediff and not found it helpful. Usually I don't have to turn off clojure-mode, because paredit will just kind of choke, or I just cut and paste lines anyway without using structural editing commands. For many years I've wanted some kind of structural diff tool that understands LISP. I continue to dream...

Drew Verlee 2025-07-17T15:58:12.103089Z

@technosophist i dream as well. I think the issue is that git isn't really for building programs. So my expectation that the git merge conflict is a good starting place is just wrong.

Drew Verlee 2025-07-17T16:01:39.526459Z

Like it probably makes more sense to just schedule a meeting with whatever person did the other branch and talk it out. Again, i have handled these conflicts for years, it just always feels stressful and i think that's because my plan, using git merge conflicts, to resolve it, sucks.

gunnar 2025-07-16T05:07:11.139769Z

I'm using IntelliJ for Kotlin/Java, and there's one aspect of the merge tool that I find quite useful: it tells me whether the merge result will compile or not. Never used it for Clojure, though.

oyakushev 2025-07-16T09:00:03.327829Z

Magit has magit-ediff (press e on the file with conflicts). It's very useful for me.

☝️ 5
gunnar 2025-07-16T09:13:23.093699Z

Just briefly touched it, got confused and quit πŸ˜„ But I understand its powers, so I need to take some time and get used to it!

oyakushev 2025-07-16T09:16:54.586059Z

https://www.youtube.com/watch?v=476kAEi-_8o looks like a reasonable intro. A bit spacemacs-flavored but should apply to regular Emacs too

gunnar 2025-07-16T09:21:22.121479Z

Thanks!

escherize 2025-07-16T15:06:03.114919Z

There is some new tool claims to "use treesitter to do semantic merges", but it is in it's infancy: https://github.com/afnanenayet/diffsitter#disclaimer

escherize 2025-07-16T15:07:50.897389Z

For viewing diffs, difftastic is works really really well with Clojure:

escherize 2025-07-16T15:08:54.350769Z

gunnar 2025-07-16T16:29:54.146559Z

Cool!

Drew Verlee 2025-07-16T18:48:22.580619Z

@alexyakushev i'll watch that video thanks!! I do use Magit-ediff, but maybe, even after 6 years with it, i'm not using it well. 😒 Magit-ediff, can 'kind of' be configured to understand clojure compiler diffs, but i still find it rather noisy in what it shows as a change, and it doesn't tend to handle, in my memory, relatively simple things like a function was moved from one file to another in a way thats more helpful then screaming that text has been added and removed. I guess what i'm ranting about is the tools seem to set me up for failure in that they put structure around things that don't matter. Programs are built by smashing together two other programs based on what line numbers happened to match up between them. But thats what a git merge experience feels like it's doing, it only works out then the merge is merging 2 paths that were carefully kept very close together. In which case the tool itself hardly seems necessary imo. On top of that, my emacs setup is a house of cards and is swear something is wonky with my magit-ediff experience. But I feel like i would need someone who was wise in it's ways to sit down with me to understand if it was a me or it, or just our relationship (how i use it, or some other package getting in the way). Finally, the merge tools themselves don't help you edit clojure code, the merge files tend to break tooling (extra parens, etc...) so those tools all start screaming bloody murder (and often cause a lag, which is why i shut them off). @escherize i'll give that a look, i feel like i'm using something similar that integrates into emacs, but what i see in your picture looks far more precise. I tend to rant about this issue, merging clojure code, at least once a yea, i feel like it's a pain point where a lot of the nice abstractions and tooling I have all break down all at once and the best thing to do is to avoid having to think about evolving your program through this lens, e.g ideally you resolve the code in conversation with who ever is building the other program so you merge the programs using clojure not a merge tool. I'm trying to understand how, we, me, you, my team, clojure devs, can change our mindset around this and build using clojure rather then git smash. To be clear, it's not a "big deal" but nothing ever feels like it is, it's always a death by a thousand cuts over here lol.

Drew Verlee 2025-07-16T18:50:55.559429Z

yeah, i think i use difftastic in emacs. Diffsitter doesnt' even say it supports clojure, interesting.

Drew Verlee 2025-07-16T18:57:29.850329Z

i guess tree-sitter, which diffsitter and difftastic are both built on, are trying to understand the language, thats moving in the direction that would help more. I wonder if on top of those tools, it wouldn't be upsurd to build something which tried help merge on a clojure level. E.g a merge on a map would be 1. left side 2. right side 3. both sides in side map.

Drew Verlee 2025-07-16T18:58:18.774339Z

it's a small thing, but losing 30 minutes because you accidentally messed up the parens hurts moral.

ag 2025-07-16T19:17:38.351099Z

There's also https://github.com/Wilfred/difftastic but I haven't tried it myself

Drew Verlee 2025-07-16T02:38:14.521529Z

And if your like, oh man no, i really use these things on really annoying merges, please record yourself and submit it to youtube. no edits 😈

πŸ’― 2
2025-07-16T07:15:42.974789Z

https://www.youtube.com/watch?v=9S2pMZ6U5Tc

❀️ 1
Ed 2025-07-16T07:40:18.730339Z

Yup. I use smerge-mode and smerge-ediff and it mostly just works. I use smerge-keep-current a lot ;)

ag 2025-07-16T15:53:53.975169Z

TIL about OSC - terminal escape control sequences. I've been trying to figure out an annoyance that somehow I never had before, mainly because I use TRAMP-mode to edit files over ssh and rarely leave GUI. Emacs running in terminal over ssh doesn't propagate yanking into the system clipboard. Turns out Thomas Dickey has https://en.wikipedia.org/wiki/Xterm escape codes in xterm back in the 1990s (or maybe even before that) and they can be used for various things like emitting desktop notifications. I ended up writing an advising function for my yanking command. This is Doom syntax for advising, I'm sure you can figure out the vanilla emacs way if you need it.

(defadvice! osc52-clipboard-in-ssh-session-a (&rest _)
    "Make Emacs propagate yanked shit to system clipboard.

    OSC 52 is an escape sequence for clipboard operations in terminals!
    OSC - OS command (part of the terminal control sequences)
    52 = the specific command number for clipboard operations

    It's a standardized way to say:
    `hey terminal, put this crap in the system clipboard`"
    :after 'evil-yank
    (when (and (not (display-graphic-p))
               (getenv "SSH_CONNECTION"))
      (let* ((text (current-kill 0 t))
             (base64 (base64-encode-string
                      (encode-coding-string text 'utf-8) t)))
        (send-string-to-terminal
         (format "\033]52;c;%s\007" base64)))))

πŸ†’ 1
😎 2
Ed 2025-07-17T10:33:46.871239Z

That's cool. I had a different solution to a similar problem that shells out to run tmux or wl-copy/`wl-paste` but I tend not to do it over ssh connections. But I have other problems that this may well help with ... thanks πŸ˜‰

ag 2025-07-17T20:50:05.170529Z

Oh well, my point is more like educational than prescriptive. I realized that I need to also handle the opposite - pasting is also not respective of the system clipboard in this scenario. I guess maybe just use https://github.com/spudlyo/clipetty if you have this problem

ag 2025-07-17T20:51:52.904659Z

hmm... scrolling through the source code of clipetty, it doesn't seem to handle pasting either - only yanking

trevor 2025-07-20T16:10:57.330069Z

This is an incredibly useful blog post for using Emacs in the terminal - https://whhone.com/posts/emacs-in-a-terminal/

Ovi Stoica 2025-07-17T06:52:40.498659Z

That’s cool. I remember having a similar annoyance. I will surely revisit this