-
-
Notifications
You must be signed in to change notification settings - Fork 48
Frame-local diff-hl-margin-mode? #212
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
Comments
We could do something like this: diff --git a/diff-hl-margin.el b/diff-hl-margin.el
index c3fffde..a754a43 100644
--- a/diff-hl-margin.el
+++ b/diff-hl-margin.el
@@ -78,6 +78,10 @@
(set-default symbol value)
(setq diff-hl-margin-spec-cache nil)))
+(defcustom diff-hl-margin-nongraphic-only nil
+ "Only use the margin when a text-only terminal is used."
+ :type 'boolean)
+
;;;###autoload
(define-minor-mode diff-hl-margin-mode
"Toggle displaying `diff-hl-mode' highlights on the margin."
@@ -147,10 +151,13 @@ You probably shouldn't use this function directly."
,(propertize char 'face
(intern (format "diff-hl-margin-%s" type)))))))))
-(defun diff-hl-highlight-on-margin (ovl type _shape)
- (let ((spec (cdr (assoc (cons type diff-hl-side)
- (diff-hl-margin-spec-cache)))))
- (overlay-put ovl 'before-string spec)))
+(defun diff-hl-highlight-on-margin (ovl type shape)
+ (if (and diff-hl-margin-nongraphic-only
+ (display-graphic-p))
+ (funcall diff-hl-margin-old-highlight-function ovl type shape)
+ (let ((spec (cdr (assoc (cons type diff-hl-side)
+ (diff-hl-margin-spec-cache)))))
+ (overlay-put ovl 'before-string spec))))
(provide 'diff-hl-margin)
Apply the patch, change the variable to The only roadbump, I guess, is that the mode also changes the corresponding margin width (from 0 to 1, usually). But if you wanted to use the margin for something else, that shouldn't be a problem. How make it frame-local isn't obvious, though I suppose the value could be changed on every update. Not sure if there will be any performance implications. |
Apply the patch offered in dgutov#212 by dgutov. Introduce `diff-hl-margin-nongraphic-only` customization option, allowing users to enable margin highlights only in text-only terminals. Update `diff-hl-highlight-on-margin` to respect this setting by delegating to the old highlight function when running in a graphical environment.
Thank you for this essential package!
I have a question: do you know if it's possible to make
diff-hl-margin-mode
frame-local? I.e. so that TTY frames have it on, but graphical frames have it off.Use case: I access my Emacs server locally (graphically) and remotely (over SSH / TTY). Every time I switch, I have to nudge diff-hl to update margin mode (off locally, on remotely). I think ideally it would just be on for TTY frames, if that's possible.
I noticed that there is
diff-hl-margin-local-mode
, but I don't think that's quite it since that makes it buffer-local, but the same buffer can be open in both a graphical and TTY frame.Thanks!
The text was updated successfully, but these errors were encountered: