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

Indent bars in popup window #73

Closed
SteepturN opened this issue Oct 2, 2024 · 8 comments
Closed

Indent bars in popup window #73

SteepturN opened this issue Oct 2, 2024 · 8 comments

Comments

@SteepturN
Copy link

Vertical bars appear in popup window when cursor is aligned vertically with the highlighted sections, if I disable the mode, they disappear.

Screenshot from 2024-10-03 01-06-40
Screenshot from 2024-10-03 01-06-50
Screenshot from 2024-10-03 01-07-34
Screenshot from 2024-10-03 01-08-04

Adding slightly changed code from https://stackoverflow.com/a/27960576/17344383 seems to solve the issue:

(defun my:force-modes (rule-mode &rest modes)
  "switch on/off several modes depending of state of
    the controlling minor mode
  "
  (let ((rule-state (if rule-mode 1 -1)
       ))
    (mapcar (lambda (k) (funcall k rule-state)) modes)
  )
)



(defvar my:prev-indent-bars-mode nil)
(make-variable-buffer-local 'my:prev-indent-bars-mode)
(defvar my:prev-indent-bars-pushed nil)
(make-variable-buffer-local 'my:prev-indent-bars-pushed)

(defun my:push-indent-bars (&rest skip)
  (if my:prev-indent-bars-pushed () (progn
    (setq my:prev-indent-bars-mode indent-bars-mode)
    (setq my:prev-indent-bars-pushed t)
    (my:force-modes nil 'indent-bars-mode)
  ))
)

(defun my:pop-indent-bars (&rest skip)
  (if my:prev-indent-bars-pushed (progn
    (setq my:prev-indent-bars-pushed nil)
    (my:force-modes my:prev-indent-bars-mode 'indent-bars-mode)
  ))
)
(setq indent-bars-no-stipple-char-font-weight)
(advice-add 'popup-draw :before #'my:push-indent-bars)
(advice-add 'popup-delete :after #'my:pop-indent-bars)
@jdtsmith
Copy link
Owner

jdtsmith commented Oct 2, 2024

This looks to be an identical problem to the recently discussed #67. Can you C-u x = on (or directly after) those inserted lines? As for magit-blame, there are probably overlays with :before-string set there.

@SteepturN
Copy link
Author

C-u x = doesn't work with my config, I used command from #67 M-: (overlay-get (car (last (overlays-at (point)))) 'before-string) and got

#("!" 0 1 (display (right-fringe flycheck-fringe-bitmap-double-arrow flycheck-fringe-info)))

It's the same with the cursor at place where the bug is seen, and directly after. I have indent-bars-starting-column = 0, changing it to nil does nothing. indent-bars-reset changes nothing too.
I don't have magit mode here, only these:

Minor modes enabled in this buffer: +Emacs-Lisp-Non-Package Auto-Save
Better-Jumper-Local Company Corfu Diff-Hl Display-Line-Numbers Dtrt-Indent Eldoc
Emojify Evil-Local Evil-Snipe-Local Evil-Snipe-Override-Local Flycheck
Flycheck-Popup-Tip Font-Lock Highlight-Numbers Hl-Line Hl-Todo Indent-Bars
Ligature Smartparens Undo-Fu-Session Undo-Tree Vi-Tilde-Fringe Ws-Butler Yas
The major mode is Python mode defined in python.el:

@jdtsmith
Copy link
Owner

jdtsmith commented Oct 3, 2024

C-u x = doesn't work with my config

Sorry I meant C-u C-x =.

have indent-bars-starting-column = 0, changing it to nil does nothing. indent-bars-reset changes nothing too.

If you change it to nil and reset, the left bar disappears but the unwanted stipple bars remain?

The problem is, I don't know how the text "Missing function..." etc. gets placed into the buffer in detail; can you investigate and let me know in detail? This is some kind of flycheck thing? That text is inheriting bars when it is placed there. Just as for magit-blame, it can be altered not to do that (and arguably should).

@jdtsmith
Copy link
Owner

jdtsmith commented Oct 3, 2024

Tip for future requests (here or elsewhere): mention the actual package that's being affected, makes it much easier. I gather it's from flyckeck-popup-tip.el. I think if you add :stipple nil to this list of "defeated" attributes in the message format for that, it should remove the bars.

@SteepturN
Copy link
Author

Thanks for the tip! I’ll definitely keep that in mind for future requests. You're right, adding :stipple nil fixed the bug: I've found what is the face from which all popups are inherited (tooltip face) and set its stipple value to nil:

'(tooltip ((t (:stipple nil :background "#121212" :foreground "#f6f3e8"))))

@jdtsmith
Copy link
Owner

jdtsmith commented Oct 3, 2024

Good tip, thanks. I'll mention that in the README. Rather than hard-coding colors, you might be able to use

(set-face-attribute 'tooltip nil :stipple nil)

when enabling indent-bars and in the after-enable-theme-hook. That way it should work with other themes which are loaded.

@brownts
Copy link
Contributor

brownts commented Oct 3, 2024

@jdtsmith, I apologize for "globbing" onto this issue, and I'll create a new issue if you think it's worth it, but I really just had a question about issues in this vein. Is your guidance with issues like this to push the issue upstream? The reason I ask, is that I see similar problems with Emacs built-ins, using the default theme.

For example, when setting show-paren-context-when-offscreen is set to overlay and indent-bars-starting-column is 0. I also see similar problems with visual-wrap-prefix-mode when indent-bars-starting-column is set to 0.

I read the FAQ, but I wasn't clear what your stance was on built-in packages which also seem to suffer from these problems.

I can create a separate issue for my specific problems, noted above, but didn't know if it warranted a new issue, since I see there were already a couple related ones that existed.

@jdtsmith
Copy link
Owner

jdtsmith commented Oct 4, 2024

Yeah, unfortunately there's not a lot indent-bars can do to tell other modes which inherit face properties not to pick up the :stipple attribute it uses. Users can sometimes modify faces, as suggested above for tooltip. But really this is a bug, and should be fixed upstream (whether builtin or 3rd party). So yes, for built-ins, please collect these and report a bug (M-x report-emacs-bug) providing as much information as you can about the problem. Note that this isn't just a :stipple problem. E.g. if you had underscore or strikethrough on that text, you wouldn't want to inherit that either.

Usually leaving the indent-bars-starting-column at its default value will mitigate these problems, since many "line overlays" are placed at the beginning of line. That was in fact part of the motivation to start bars at the 1st indent level (also that col=0 bars are superfluous due to the window boundary always being adjacent).

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

3 participants