emacs-sideline / sideline

Show information on the side
GNU General Public License v3.0
118 stars 14 forks source link

Empty continuation lines are shown when the buffer is enough narrow (in terminal) #13

Closed aciceri closed 1 year ago

aciceri commented 1 year ago

Hey, great package!

I'm using it with sideline-flymake (opening the issue here since I'm 99% this has not to do with sideline-flymake) in order to show errors but when the buffer is sufficiently narrow (half screen is enough, no need to make it ridiculously narrow) also the sideline's continuation line is shown. Random example:

image

The funny thing is that the continuation is even empty!

A similar thing happen when I try

image

Important detail: I'm on terminal and I haven't tried with graphical Emacs (I compiled it without graphic support).

For now my solution was overriding sideline--create-ov adding a further little offset, this way I always have a useless padding on the right but it's always better than all of these annoying continuations lines.

image

I've tried understanding how the sideline--create-ov function works but it's a bit too much for me, especially at this hour.

aciceri commented 1 year ago

Don't take too much into account what I just wrote, it's not completely clear to me both how the the offset is calculated why this doesn't work. I just found out that after splitting my frame into two equals windows (split-window-right) I encounter this problem only in the left window:

image image

So, it's not even true that the continuation line is empty.

jcs090218 commented 1 year ago

Important detail: I'm on terminal and I haven't tried with graphical Emacs (I compiled it without graphic support).

This is the relevant code between terminal and graphical.

https://github.com/emacs-sideline/sideline/blob/be5d9386ac3cf840d8c61394563e2293f2014131/sideline.el#L276-L279

But I don't think that's relevant to the issue. 🤔

For now my solution was overriding sideline--create-ov adding a further little offset, this way I always have a useless padding on the right but it's always better than all of these annoying continuations lines.

Can you try edit sideline-format-right? Maybe add a space on the right; from " %s" to " %s ". 🤔

aciceri commented 1 year ago

It was the first thing I tried and I believe that in the screenshots I sent in my first message I forgot it set to " %s ".

With " %s ":

image image

With " %s":

image image

Further detail: I'm on Emacs 29.1

aciceri commented 1 year ago
(defun my-sideline--align (&rest lengths)
    "Align sideline string by LENGTHS from the right of the window."
    (list (* (window-font-width)
        (+ (apply #'+ lengths) (if (display-graphic-p) 1 3)))))

(advice-add 'sideline--align :override #'my-sideline--align)

Doing so seems to work even if it's not an optimal solution because the last column is not used sometimes. Said this, today I'll try it at work, if I don't face this problem anymore I can open a PR (if you want).

jcs090218 commented 1 year ago

It was the first thing I tried and I believe that in the screenshots I sent in my first message I forgot it set to " %s ".

Thanks for testing it out! 🚀 Apparently, it does not work! 😓

Doing so seems to work even if it's not an optimal solution because the last column is not used sometimes.

Yeah, I would like to seek the ideal solution. We should figure out the reason why a new line (length too long) has been added.

I've tried it on my machine, and I cannot reproduce this. 🤔 Can you try turning on and off a few minor modes and see what could be the culprit? Or try emacs -q and try to enable one package at a time.

aciceri commented 1 year ago

Minimal steps to reproduce I found:

  1. run emacs -q
  2. open the scratch buffer
  3. paste the following
    
    (require 'sideline)
    (require 'sideline-flymake)
    (setq sideline-flymake-display-mode 'line)
    (setq sideline-backends-right '(sideline-flymake))

(sideline-mode +1) (flymake-mode +1)


4. `M-x eval-buffer`
5. Split the frame with `C-x 3`
6. Write something that causes an error/warning and move the cursor over

![image](https://github.com/emacs-sideline/sideline/assets/2318843/07a7b4d8-2e68-4036-b9af-682fb14945f4)
![image](https://github.com/emacs-sideline/sideline/assets/2318843/531df6ca-38d9-4d45-93b0-9d5e0a9df64c)
jcs090218 commented 1 year ago

Hmm... still can't reproduce it. (on 29.1 as well)

2023-08-08 14 49 10

My next guess is something wrong with the GUI library we are using. 🤔

Edit: I could reproduce it in the terminal! Sorry, I was dumb. 😓 I think the solution above should be sufficient in this case scenario. Can you open a PR for this? Thank you!

aciceri commented 1 year ago

Ahah don't worry. PR opened :)