unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Line height issues with display-line-number-mode
Date: Wed, 8 May 2019 14:04:17 -0400	[thread overview]
Message-ID: <fb150e54-4bca-ce9c-0a75-37c888f3f97a@gmail.com> (raw)
In-Reply-To: <83v9ylgi6c.fsf@gnu.org>

On 2019-05-08 10:00, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Wed, 8 May 2019 08:24:53 -0400
>>
>>> "This particular case" being what, in technical terms?  A line that
>>> begins with an overlay string?  A line whose entire contents comes
>>> from an overlay string?  Something else?
>>
>> I'm not sure; I think 'a line whose entire contents come from an overlay string' is probably right.
> 
> That's harder than "starts with an overlay string", but still doable,
> I think.  However, I wonder whether it will cover enough use cases.

I wonder too.

>>> And finally, the same question I asked Stefan: why are you using this
>>> trick instead of producing an underline with face properties?  If the
>>> problem is that you want to control the thickness of the underline,
>>> providing such a feature is much easier than tweaking line-number
>>> display for these cases.
>>
>> I'm trying to produce a line that stretches the entire width of the window; can this be done with underlines?  Controlling the thickness of the line is not a strict requirement for me.
> 
> Using an image comes to mind.  Did you consider that?

No, I did not.  I'm not entirely sure how it would work, so I'll read about it.

> Another alternative is an empty line with the underline face.  If you
> want it to fit to window dynamically, you can use the :space display
> property with :align-to property.

Ah, interesting! I tried the following:

(with-current-buffer (get-buffer-create "*test*")
  (insert "test\ntest\ntest")
  (let ((ov (make-overlay 1 6))
        (str (concat (propertize " " 'display '(space :height (1) :align-to right) 'face '(:underline t))
		     "AAA\n"
		     "BBB"
		     (propertize " " 'display '(space :height (1) :align-to right) 'face '(:underline t)))))
    (overlay-put ov 'after-string str)
    (overlay-put ov 'face '(:underline t)))
  (pop-to-buffer (current-buffer)))

It works OK!  But it has a few problems:

* The underline is thicker under the first 'test' than under the rest of the line.  It seems to work better if I don't put the :underline property on the overlay itself… but then I don't understand why 'test' gets underlined at all.
* I need to override the underline that might be present on "BBB"
* There's a line continuation indicator after each long line.  Maybe with a more clever :align-to spec?

>> Additionally, I use think lines not just to draw a colored line, but also for padding around it (so quick-peek in fact displays one think blank line, one thin line with a background, and another thin blank line).  Similarly, in compact-docstrings mode, I use face properties to make certain lines less tall.
> 
> What is the purpose of changing the line height in these cases?

In compact-docstring mode, the idea is to pack more lines on the screen (the package was inspired by an idea of Stefan; see https://lists.gnu.org/archive/html/emacs-devel/2016-05/msg00401.html)

In quick-peek, it's mostly for aesthetics, to add a small amount of space between the line and the text above and below it.

>> - Hide line numbers (but it means computing a height for the line and then comparing it to the height needed for line numbers)
>> - Clip them (like nlinum did; but clipping is easier in the margin than in the buffer area; is that correct?).
> 
> On the margin it just happens to work "by sheer luck", because we
> simply don't care enough about the text displayed on the margins, and
> so don't take it into consideration when computing the line metrics.
> 
> The problems with doing the same in the text area I already described
> in another message.  They are not insurmountable, but "Someone" should
> examine all those corner cases and make sure we behave reasonably with
> such a change.

Thanks for the explanation.


>> - Shrink the font?  Could line numbers be set to the same face as the line feed on their line?
> 
> Maybe with some effort, but wouldn't having smaller numbers on some
> lines look ugly?  It will cause the text to begin more to the left,
> although for empty lines this might not matter, if they use the
> default background.

You're right; this won't work. And it would be especially bad for taller lines (if we enlarged the line number face for these).

>> That being said, the trickiest case is the one with overlays, since (IIUC) I can handle the compact-docstrings case by putting a property on the lines to disable line numbers manually.
> 
> You'd also need to manually indent the line with some overlay string,
> to have it lined up with those that do have line numbers, but other
> than that, yes, it should work.

Thanks. I will try it.




  reply	other threads:[~2019-05-08 18:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 16:40 Line height issues with display-line-number-mode Clément Pit-Claudel
2019-05-07 17:12 ` Noam Postavsky
2019-05-07 18:36   ` Eli Zaretskii
2019-05-07 19:00     ` Eli Zaretskii
2019-05-07 19:09       ` Stefan Monnier
2019-05-07 19:43         ` Eli Zaretskii
2019-05-07 20:30           ` Stefan Monnier
2019-05-08  6:43             ` Eli Zaretskii
2019-05-08 13:39               ` Stefan Monnier
2019-05-08 14:05                 ` Eli Zaretskii
2019-05-08 14:13                   ` Noam Postavsky
2019-05-08 15:04                     ` Stefan Monnier
2019-05-08 18:39                       ` Noam Postavsky
2019-05-08 18:54                         ` Eli Zaretskii
2019-05-10  6:15                           ` Kévin Le Gouguec
2019-05-10  7:58                             ` Eli Zaretskii
2019-05-10 13:24                             ` Stefan Monnier
2019-05-08 14:17                   ` Stefan Monnier
2019-05-08 17:30                     ` Eli Zaretskii
2019-05-08 17:46                       ` Stefan Monnier
2019-05-08 18:02                         ` Eli Zaretskii
2019-05-08 18:39                           ` Stefan Monnier
2019-05-08 18:48                             ` Eli Zaretskii
2019-05-08 19:03                               ` Stefan Monnier
2019-05-07 19:49         ` Ergus
2019-05-08  5:51           ` Eli Zaretskii
2019-05-08 13:40             ` Stefan Monnier
2019-05-08 14:07               ` Eli Zaretskii
2019-05-07 18:31 ` Eli Zaretskii
2019-05-07 21:08   ` Clément Pit-Claudel
2019-05-08  7:01     ` Eli Zaretskii
2019-05-08 12:24       ` Clément Pit-Claudel
2019-05-08 14:00         ` Eli Zaretskii
2019-05-08 18:04           ` Clément Pit-Claudel [this message]
2019-05-08 18:25             ` Eli Zaretskii
2019-05-08 18:45             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb150e54-4bca-ce9c-0a75-37c888f3f97a@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).