Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about margin-mode #215

Open
LionyxML opened this issue Mar 25, 2024 · 4 comments
Open

Question about margin-mode #215

LionyxML opened this issue Mar 25, 2024 · 4 comments

Comments

@LionyxML
Copy link

Hello there!

Long time user here! Thanks for this awesome package!

Quick question.

Is it possible to make diff-hl, when working on margin-mode, keep the current content of the margin?

Like, I have some checkers marks:

image

And diff-hl kind of "overrides" it.

image

I don't now if this is overriding the styles or the content, but I am thinking of an option like:

Is there any char on margin? 
- No: do nothing, works like it is today
- Yes: Keep the current char and foreground face, change only the background face to insert/delete/...

Of course, controlled by a defcustom like diff-hl-keep-margin-content.

Thanks!

@dgutov
Copy link
Owner

dgutov commented Mar 25, 2024

Hi!

We have the ability to switch to the different side for the margin display.

Combining the margin indicators is out of scope for this package, but should ultimately be doable. It's a feature for the core Emacs, I'd say. I think there is somewhere a similar feature request in its bug tracker, or perhaps even a prototype implementation (not 100% sure).

@LionyxML
Copy link
Author

LionyxML commented Mar 26, 2024

Thanks for the quick response @dgutov!

Well, since the general feature (merging) is not possible. Let me talk you trough my use case. 😄

I was messing with what this nice person did: https://www.reddit.com/r/emacs/comments/1bawdau/making_flymake_supports_error_indicators_in_margin/

One thing that always kept me from fully switching to flymake was the inability of using it on TUI Emacs, since it only works on fringe and we have no fringes on TUI.

Well, I was actually writing you a response, but I built upon the reeditor original idea and came up (some hours later) with a package: https://github.com/LionyxML/flymake-margin (I just pushed it so you could take a look into it).

As hl-diff, it is possible to change margins sides, but I was thinking about someway we could make hl-diff and flymake-margin "merge" (lots of ' here) contents.

I came up with a function in my minor mode that can get the symbol flymake is currently displaying on the margin (flymake-get-margin-symbol), I mention it on the README.

I was thinking that if hl-diff when asking for a symbol present in diff-hl-margin-symbols-alist for the line could first run a customizable function that would receive the current line number and return a string (or if not set, continue with the symbol the list is providing).

This would make hl-diff open to receive functions from modes like flymake-margin able to provide its own contents.

Of couse hl-diff would change the background according to each git state and add the string passed trough this interactive function. We could have more options here like 'merging git symbol to flymake'.

I know it might seem a bit presumptuous of me to come here and suggest all of this out of nowhere, but I truly believe that taking a moment to consider it could benefit us all in some way. 😄

Thanks!

@dgutov
Copy link
Owner

dgutov commented Mar 28, 2024

I think you could plug into the same option that diff-hl-margin-mode does: diff-hl-highlight-function. That function is called when appropriately, so you could provide your own rendering, including using combined string.

diff-hl-highlight-on-margin (the function that the margin mode uses) is pretty small, so it shouldn't be much of a problem to copy and adjust for your liking, including the addition of "flymake symbols on this line".

@dgutov
Copy link
Owner

dgutov commented Mar 28, 2024

Let me know if you'll have any problems doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants