jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
352 stars 14 forks source link

Addressing stipple attribute issue on NS and PGTK systems #54

Closed jamescherti closed 1 month ago

jamescherti commented 1 month ago

The stipple attributes doesn't work on NS and PGTK, though it functions perfectly on Linux and GTK3.

I’m wondering whether the indent-bars package should automatically behave as if indent-bars-prefer-character is set to t on NS and PGTK systems. This might help maintain the package's reputation for stability, as users might think it’s broken if they don’t see the bars.

What do you think, @jdtsmith?

jdtsmith commented 1 month ago

I'm hopeful this situation will be corrected soon. PGTK is fixed (for Emacs 30), an there has been some progress on the NS port in Emacs 30 (though color is not yet working). Once discussion of the ELPA package resumes I plan to press on this a bit with emacs-devel.

jamescherti commented 1 month ago

Let's hope this situation will be corrected soon.

(However, for NS or PGTK users with Emacs versions earlier than 30, indent-bars could automatically choose to use characters instead of stipple attributes.)

jdtsmith commented 1 month ago

I could include a warning message for these versions. I don't want to hard-code it because sometimes people back-port changes. Unfortunately Emacs pretends to fully support stipples in all GUI versions, and never indicates an error, so there's no reliable way to check for support (other than by hand).

I'm also unclear about "Cairo". Do you know, is that orthogonal/unrelated to PGTK vs. GTK? I've had reports of stipple issues with Cairo as well; can you confirm this?

jdtsmith commented 1 month ago

Do you (or anyone else) have access to a PGTK machine? What is gtk-version-string on it?

jamescherti commented 1 month ago

Do you (or anyone else) have access to a PGTK machine? What is gtk-version-string on it?

I have never tried PGTK Emacs.

I could include a warning message for these versions. I don't want to hard-code it because sometimes people back-port changes. Unfortunately Emacs pretends to fully support stipples in all GUI versions, and never indicates an error, so there's no reliable way to check for support (other than by hand).

That makes sense. A warning message could definitely help indent-bars users.

I'm also unclear about "Cairo". Do you know, is that orthogonal/unrelated to PGTK vs. GTK? I've had reports of stipple issues with Cairo as well; can you confirm this?

I am using Emacs (versions 29.4 and 30) compiled with --with-x-toolkit=gtk3 and Cairo (verified by (featurep 'cairo) returning t). In this setup, indent-bars works flawlessly.

(I also compiled Emacs 29.4 with --with-cairo-xcb on Linux/GTK3, and indent-bars still displays the bars correctly.)

jamescherti commented 1 month ago

For some reason, when I tried indent-bars on another Debian Bookworm Linux computer with the same Debian version, same Emacs version, and same compile flags, the stipple attributes didn't work. It's odd. (The theme and features variables of both computers is exactly the same)

jdtsmith commented 1 month ago

For real? That's maddening, but there must be some difference. Did you also try the simple Stipple test in the README to be sure it wasn't some configuration issue? I haven't had a lot of takers in actually testing across all the various systems, so I'm shooting in the dark. It's super helpful to have this info.

@minad: sounds like Cairo maybe isn't the culprit.

jamescherti commented 1 month ago

This is how it looks on the Debian computer where indent-bars does not work: image

This is how it looks on the Debian computer where it does work: image

(Both computers are exact replicas with the same installed packages, Emacs init files, and Emacs compilation flags. Very odd.)

I executed this code to perform the test:

(let* ((w (window-font-width))
       (stipple `(,w 1 ,(apply #'unibyte-string
                   (append (make-list (1- (/ (+ w 7) 8)) ?\0)
                       '(1))))))
  (insert "\n" (propertize (concat  (make-string 15 ?\s)
                    "THIS IS A TEST"
                    (make-string 15 ?\s))
                           'face `(:background "red" :foreground "blue" :stipple ,stipple))))

I recompiled Emacs in both machine: image

Same issue.

jdtsmith commented 1 month ago

So strange. The GTK and Cairo versions are exactly the same? How about font (just guessing here)?

jamescherti commented 1 month ago

GTK and Cairo versions are identical (3.24.38 and 1.16.0, respectively). The Linux distribution is the same, the window manager is the same, and the font is also the same:

(set-frame-font "Iosevka Term Semibold-12" nil t)

The main difference between the two computers is their specifications (number of CPUs, RAM, etc.). It doesn't work on the older machine, but it works on the newer one. However, this is probably not what's preventing the stipple attributes from appearing.

jdtsmith commented 1 month ago

Monitor dpi?

jamescherti commented 1 month ago

The monitor's DPI could be the issue, as it's the main difference between the two computers. Stipples may depend on the display's pixel density to render properly. Have you ever discussed this with the Emacs developers?

(To help users, I’ve added a paragraph to talk about indent-bars compatibility included an Elisp code to the the article that sets indent-bars-prefer-character to t when the window system is NS or PGTK.)

jdtsmith commented 1 month ago

I'd prefer not to hard-code indent-bars-prefer-character, but rather find and fix the issue. What is (window-font-width) on each system? Play around with the stipple value in the test above and see if you can see anything? If we can understand the real issue maybe we can fix it.

jamescherti commented 1 month ago

In both systems, (window-font-width) return "9".

jdtsmith commented 1 month ago

In both systems, (window-font-width) return "9".

Strange, the high-dpi is often larger. Can you change the stipple list to 5 1's and 4 0's above?

jamescherti commented 1 month ago

Please provide the exact test Elisp code so we can ensure the result matches the specified code.

jdtsmith commented 1 month ago

Try this:

(let* ((w (window-font-width))
       (stipple `(,w 1 ,(apply #'unibyte-string (make-list (/ (+ w 7) 8) 186)))))
  (insert "\n" (propertize (concat  (make-string 15 ?\s)
                    "THIS IS A TEST"
                    (make-string 15 ?\s))
                           'face `(:background "red" :foreground "blue" :stipple ,stipple))))

Should look something like:

image
jamescherti commented 1 month ago

Emacs version: image

Result: image

jdtsmith commented 1 month ago

OK thanks. So that's pretty definitive. Two things to try if you can:

jdtsmith commented 1 month ago

@jamescherti any chance to take a look here? I think you may have found a potential explanation for some conflicting accounts on stipple compatibility (Linux non-PGTK). It would be great to amass a bit more evidence then open a bug report, so we can hopefully get some of this handled prior to Emacs 30 release.

jamescherti commented 1 month ago

I've just realized that neither monitor is high-DPI. I would be happy to help. What specific test would you like me to run on the laptop where it's not working (non-high-DPI)? Should I use the non-Cairo version on the laptop where it isn't working? If so, please send me the compilation flags (How about: --without-cairo? Are there any other flags?).

jdtsmith commented 1 month ago

Well that's even stranger then. Yes, --without-cairo is good to try; unfortunately I'm not an expert on Linux build flags. Is system-configuration-features identical on both systems? There must be something different about these two systems!

jamescherti commented 1 month ago

I compared the features variable on both machines, and it is identical.

I will proceed with testing using --without-cairo and will keep you updated.

jamescherti commented 1 month ago

Compiling with the --without-cairo flag worked in the computer where --with-cairo it wasn't working.

However, this doesn't explain why it worked on the other computer with --with-cairo or --with-cairo-xcb (I tried both).

jdtsmith commented 1 month ago

Interesting, so Cairo is implicated after all, right? I'm not familiar with Cairo unfortunately. Would you be able to open a bug report (by sending an email to bug-gnu-emacs@gnu.org)?

jamescherti commented 1 month ago

I'll leave it to you to send a bug report, as you can describe the behavior of indent-bars in more detail. On the second computer, the Stipple attribute doesn't work when Cairo is enabled. However, on the first (faster) computer, the stipple attribute works even with Cairo enabled. The Emacs features, Linux distribution, Emacs version (I tried the 29.4, emacs-30, and the master branch) and compilation flags are identical on both machines. This inconsistency doesn't make sense and may point to a bug in Emacs.

jdtsmith commented 1 month ago

Update: I'll submit a report and copy you.

The report wouldn't be about indent-bars, just the stipple test above. To get traction on the issue, it would be preferable if you submitted, and I can chime in with any details (i.e. just post the bug number here). You always imagine a team of Emacs developers pouncing on bugs and testing across a build-farm of Emacs hosts, but they are severely understaffed in this department. You're lucky to get the attention of one, and if they don't have the right system setup to reproduce it, or someone to test potential fixes, the bug just gets ignored.

Alternatively I can submit it and copy you, if you are able and willing to install test patches they propose.

jamescherti commented 1 month ago

Yes, please submit it and include me in the communication. I’d be happy to test the patches on the computer where the stipple attribute isn’t working.

jdtsmith commented 1 month ago

Great thanks. Check your Reddit PM for a req RE email.

jdtsmith commented 1 month ago

I haven't been able to connect with you to get an email. The bug report is filed, and it would be useful if you could copy yourself into the conversation. I find the easiest way to do that is download MBOX, and import it into my mail client, then reply-all from there. Po Lu is surprised about Cairo being an issue, since the capability is shared with PGTK.

BTW, did you compile Emacs v30 on both of your Cairo systems?

jamescherti commented 1 month ago

BTW, did you compile Emacs v30 on both of your Cairo systems?

Yes

It is working on the first computers: image

But not on the other computer.

You can see that indent-bars-prefer-character is set to nil in the screenshot above.

Both computers have the same Linux distribution (Debian Bookworm/stable), the same Emacs version (30.0.9), and Emacs was compiled using the same flags on both computers.

jdtsmith commented 1 month ago

Thanks. I ask because your earlier version screenshot mentions v29.4. Let's see if Po has any ideas.

jamescherti commented 1 month ago

The version in my previous screenshot was different because I tested the stipple attribute and indent-bars across multiple versions (29.4, 30, 31) on both computers, and observed the same outcome.

jdtsmith commented 1 month ago

Truly mysterious. Must be some other Cairo setting then. Are there any other config settings for display that differ between the systems? I know we've ruled out high-DPI.

jamescherti commented 1 month ago

I programmatically configure my computers using Ansible and scripts, which replicate the same configuration across multiple machines. The configurations are generally uniform.

What specific display configuration settings are you referring to, JD?

jdtsmith commented 1 month ago

I see. I'm not a desktop Linux user so I can't really say; just fishing in the dark here. I suspect the bug discussion will generate these same type of questions ("so what's different?"). Sounds like you have compiled multiple identical Emacs versions on two identical systems, and gotten different stipple results (always good on system 1, only good on system 2 --without-cairo). That might indicate there are some as yet hidden variables: e.g. system settings (Cairo settings?) which are not expressed in the emacs build flags that could differ between 1 & 2. Or some other non-gremlin logical reason :).