all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>
Cc: 26909@debbugs.gnu.org
Subject: bug#26909: 25.1; A face for margins
Date: Mon, 11 May 2020 17:01:23 -0400	[thread overview]
Message-ID: <f33cb5cf-1779-991b-4b1d-6852cfdd1dc5@gmail.com> (raw)
In-Reply-To: <83lgq096iz.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]

Hi Eli and Yuri,

On 13/05/2017 10.27, Eli Zaretskii wrote:>> From: Yuri Khan <yuri.v.khan@gmail.com>
>> Date: Sat, 13 May 2017 21:07:03 +0700
>>
>> The last two actions demonstrate that customizing the faces of
>> whatever is displayed in the margin is not sufficient. A mechanism is
>> needed that will allow customization of the margin where nothing is
>> displayed. A new face would serve nicely.
> 
> A face can only affect places where something is displayed using that
> face.  Display margins only display text if the buffer specifies text
> properties or overlays which display in the margins.  But what you
> would like to do calls for having a face that would affect screen
> space where _nothing_ is displayed, and such screen space in Emacs is
> always displayed using the frame's background color, not by using some
> face.
> 
> IOW, I don't think introducing a new face would help here.  Some
> additional mechanism would be necessary.

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?
Currently we almost do that in extend_face_to_end_of_line, but short-circuits earlier in that function mean that this part is only applicable when there is e.g. a region.


  if (WINDOW_LEFT_MARGIN_WIDTH (it->w) > 0
      && it->glyph_row->used[LEFT_MARGIN_AREA] == 0)
    {
      it->glyph_row->glyphs[LEFT_MARGIN_AREA][0] = space_glyph;
      it->glyph_row->glyphs[LEFT_MARGIN_AREA][0].face_id =
        default_face->id;
      it->glyph_row->used[LEFT_MARGIN_AREA] = 1;
    }
  if (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0
      && it->glyph_row->used[RIGHT_MARGIN_AREA] == 0)
    {
      it->glyph_row->glyphs[RIGHT_MARGIN_AREA][0] = space_glyph;
      it->glyph_row->glyphs[RIGHT_MARGIN_AREA][0].face_id =
        default_face->id;
      it->glyph_row->used[RIGHT_MARGIN_AREA] = 1;
    }

The (silly) attached patch confirms that removing the short-circuits makes it possible to set a face in the margins, but besides the performance aspect it only applies to lines that have contents.

Is this a reasonable way to go? If not, what might be better way?

Clément.

[-- Attachment #2: 0001-Add-a-margin-face-remove-short-circuits-in-extend_fa.patch --]
[-- Type: text/x-patch, Size: 3728 bytes --]

From a8a13cec225b00117557e5c84999a877843099da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
Date: Mon, 11 May 2020 16:52:51 -0400
Subject: [PATCH] Add a margin face, remove short-circuits in
 extend_face_to_end_of_line

---
 src/dispextern.h |  1 +
 src/xdisp.c      | 10 ++++++----
 src/xfaces.c     |  3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index 0b1f3d14ae..2650d49e02 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1814,6 +1814,7 @@ #define FACE_UNIBYTE_P(FACE) ((FACE)->charset < 0)
   MODE_LINE_INACTIVE_FACE_ID,
   TOOL_BAR_FACE_ID,
   FRINGE_FACE_ID,
+  MARGIN_FACE_ID,
   HEADER_LINE_FACE_ID,
   SCROLL_BAR_FACE_ID,
   BORDER_FACE_ID,
diff --git a/src/xdisp.c b/src/xdisp.c
index 140d134572..5a7bf58828 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21759,7 +21759,8 @@ extend_face_to_end_of_line (struct it *it)
       /* If the window has display margins, we will need to extend
 	 their face even if the text area is filled.  */
       && !(WINDOW_LEFT_MARGIN_WIDTH (it->w) > 0
-	   || WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0))
+	   || WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0)
+      && false)
     return;
 
   const int extend_face_id = (it->face_id == DEFAULT_FACE_ID
@@ -21785,7 +21786,8 @@ extend_face_to_end_of_line (struct it *it)
       && !face->stipple
 #endif
       && !it->glyph_row->reversed_p
-      && !Vdisplay_fill_column_indicator)
+      && !Vdisplay_fill_column_indicator
+      && false)
     return;
 
   /* Set the glyph row flag indicating that the face of the last glyph
@@ -21834,7 +21836,7 @@ extend_face_to_end_of_line (struct it *it)
 	    {
 	      it->glyph_row->glyphs[LEFT_MARGIN_AREA][0] = space_glyph;
 	      it->glyph_row->glyphs[LEFT_MARGIN_AREA][0].face_id =
-		default_face->id;
+		lookup_named_face (it->w, f, Qmargin, false);
 	      it->glyph_row->used[LEFT_MARGIN_AREA] = 1;
 	    }
 	  if (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0
@@ -21842,7 +21844,7 @@ extend_face_to_end_of_line (struct it *it)
 	    {
 	      it->glyph_row->glyphs[RIGHT_MARGIN_AREA][0] = space_glyph;
 	      it->glyph_row->glyphs[RIGHT_MARGIN_AREA][0].face_id =
-		default_face->id;
+		lookup_named_face (it->w, f, Qmargin, false);
 	      it->glyph_row->used[RIGHT_MARGIN_AREA] = 1;
 	    }
 
diff --git a/src/xfaces.c b/src/xfaces.c
index bab142ade0..f604c43928 100644
--- 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;
     case SCROLL_BAR_FACE_ID:		name = Qscroll_bar;		break;
     case BORDER_FACE_ID:		name = Qborder;			break;
     case CURSOR_FACE_ID:		name = Qcursor;			break;
@@ -5463,6 +5464,7 @@ realize_basic_faces (struct frame *f)
       realize_named_face (f, Qmode_line_inactive, MODE_LINE_INACTIVE_FACE_ID);
       realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID);
       realize_named_face (f, Qfringe, FRINGE_FACE_ID);
+      realize_named_face (f, Qmargin, MARGIN_FACE_ID);
       realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID);
       realize_named_face (f, Qscroll_bar, SCROLL_BAR_FACE_ID);
       realize_named_face (f, Qborder, BORDER_FACE_ID);
@@ -6808,6 +6810,7 @@ syms_of_xfaces (void)
   DEFSYM (Qtool_bar, "tool-bar");
   DEFSYM (Qtab_bar, "tab-bar");
   DEFSYM (Qfringe, "fringe");
+  DEFSYM (Qmargin, "margin");
   DEFSYM (Qtab_line, "tab-line");
   DEFSYM (Qheader_line, "header-line");
   DEFSYM (Qscroll_bar, "scroll-bar");
-- 
2.17.1


  parent reply	other threads:[~2020-05-11 21:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-13 14:07 bug#26909: 25.1; A face for margins Yuri Khan
2017-05-13 14:27 ` Eli Zaretskii
2017-05-13 14:59   ` Yuri Khan
2017-05-13 16:40     ` Eli Zaretskii
2017-05-13 17:19       ` Yuri Khan
2017-05-13 17:42         ` Eli Zaretskii
2020-05-11 21:01   ` Clément Pit-Claudel [this message]
2020-05-12 16:52     ` Eli Zaretskii
2020-05-12 17:06       ` Clément Pit-Claudel
2020-05-12 17:21         ` Eli Zaretskii
2020-05-12 17:28           ` Clément Pit-Claudel
2020-05-12 17:40             ` Eli Zaretskii
2020-10-01  2:49     ` Lars Ingebrigtsen

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

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

  git send-email \
    --in-reply-to=f33cb5cf-1779-991b-4b1d-6852cfdd1dc5@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=26909@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.