Subject: bug#26909: 25.1; A face for margins

From: Clément Pit-Claudel <[email-masked]>
Date: Tue, 12 May 2020 13:06:00 -0400

On 12/05/2020 12.52, Eli Zaretskii wrote:
>> Cc: [email-masked]
>> From: Clément Pit-Claudel <[email-masked]>
>> Date: Mon, 11 May 2020 17:01:23 -0400
>>
>> A margin face would be great to have.  
>> How reasonable would it be to fill the margins with a stretched space?  Would it be too costly?
> 
> It would slow down redisplay, especially if the window is large, but
> maybe the slow-down will not be so awful.

Got it.

> Something like that, yes.  But you will need to make sure
> extend_face_to_end_of_line is called also for empty lines.  And of
> course the "silly" changes need to be made less silly. 

Where the less silly strategy would be to only run the extend_face code when the margins face isn't customized, right?

> And you need
> to compute the pixel-width of the stretch glyph, since the code you
> cited only places a single SPC character there, which is not what you
> want if the margin is wider than one column.

Hmm, I think the code already does that? At least it seems to work with the patch I sent.

>> --- a/src/xfaces.c
>> +++ b/src/xfaces.c
>> @@ -4768,6 +4768,7 @@ lookup_basic_face (struct window *w, struct frame *f, int face_id)
>>      case TAB_BAR_FACE_ID:		name = Qtab_bar;		break;
>>      case TOOL_BAR_FACE_ID:		name = Qtool_bar;		break;
>>      case FRINGE_FACE_ID:		name = Qfringe;			break;
>> +    case MARGIN_FACE_ID:		name = Qmargin;			break;
> 
> If this is going to be an additional basic face, then why do you call
> lookup_named_face  and not lookup_basic_face?

It's because I have no idea what a basic face is, so I just cribbed from places that use the fringe face.  It does things like the following, and I have no idea what those mean:

      face_id = NILP (face) ? lookup_named_face (w, f, Qfringe, false)
	: lookup_derived_face (w, f, face, FRINGE_FACE_ID, 0);
      if (face_id < 0)
	face_id = FRINGE_FACE_ID;