aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2017-06-24 16:58:01 +0300
committerEli Zaretskii2017-06-24 16:58:01 +0300
commit6e18841b17c9b7ca9f38b923db4195cade05da2e (patch)
treea57a1bb8e33cbb43f5af326aece7912d05b6a6d5 /src
parent71a7294d0a775a8969ec077eb3633da6bdad7c62 (diff)
downloademacs-6e18841b17c9b7ca9f38b923db4195cade05da2e.tar.gz
emacs-6e18841b17c9b7ca9f38b923db4195cade05da2e.zip
Allow Lisp program to disable line-number display for specific lines
* etc/NEWS: Update the documentation. * src/xdisp.c (syms_of_xdisp) <display-line-numbers-disable>: New symbol. (should_produce_line_number): New function. (display_line): Use should_produce_line_number to determine whether a line number should be produced for each glyph row.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index cf396de203e..d35170ed43e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20887,6 +20887,32 @@ maybe_produce_line_number (struct it *it)
20887 bidi_unshelve_cache (itdata, false); 20887 bidi_unshelve_cache (itdata, false);
20888} 20888}
20889 20889
20890/* Return true if this glyph row needs a line number to be produced
20891 for it. */
20892static bool
20893should_produce_line_number (struct it *it)
20894{
20895 if (NILP (Vdisplay_line_numbers))
20896 return false;
20897
20898 /* Don't display line numbers in minibuffer windows. */
20899 if (MINI_WINDOW_P (it->w))
20900 return false;
20901
20902#ifdef HAVE_WINDOW_SYSTEM
20903 /* Don't display line number in tooltip frames. */
20904 if (FRAMEP (tip_frame) && EQ (WINDOW_FRAME (it->w), tip_frame))
20905 return false;
20906#endif
20907
20908 /* If the character at current position has a non-nil special
20909 property, disable line numbers for this row. */
20910 Lisp_Object val = Fget_char_property (make_number (IT_CHARPOS (*it)),
20911 Qdisplay_line_numbers_disable,
20912 it->window);
20913 return NILP (val) ? true : false;
20914}
20915
20890/* Return true if ROW has no glyphs except those inserted by the 20916/* Return true if ROW has no glyphs except those inserted by the
20891 display engine. This is needed for indicate-empty-lines and 20917 display engine. This is needed for indicate-empty-lines and
20892 similar features when the glyph row starts with glyphs which didn't 20918 similar features when the glyph row starts with glyphs which didn't
@@ -20984,6 +21010,8 @@ display_line (struct it *it, int cursor_vpos)
20984 (window_hscroll_limited (it->w, it->f) - it->w->min_hscroll) 21010 (window_hscroll_limited (it->w, it->f) - it->w->min_hscroll)
20985 * FRAME_COLUMN_WIDTH (it->f); 21011 * FRAME_COLUMN_WIDTH (it->f);
20986 21012
21013 bool line_number_needed = should_produce_line_number (it);
21014
20987 /* Move over display elements that are not visible because we are 21015 /* Move over display elements that are not visible because we are
20988 hscrolled. This may stop at an x-position < first_visible_x 21016 hscrolled. This may stop at an x-position < first_visible_x
20989 if the first glyph is partially visible or if we hit a line end. */ 21017 if the first glyph is partially visible or if we hit a line end. */
@@ -21021,23 +21049,13 @@ display_line (struct it *it, int cursor_vpos)
21021 min_bpos = BYTEPOS (this_line_min_pos); 21049 min_bpos = BYTEPOS (this_line_min_pos);
21022 21050
21023 /* Produce line number, if needed. */ 21051 /* Produce line number, if needed. */
21024 if (!NILP (Vdisplay_line_numbers) 21052 if (line_number_needed)
21025#ifdef HAVE_WINDOW_SYSTEM
21026 && !(FRAMEP (tip_frame)
21027 && EQ (WINDOW_FRAME (it->w), tip_frame))
21028#endif
21029 && (!MINI_WINDOW_P (it->w)))
21030 maybe_produce_line_number (it); 21053 maybe_produce_line_number (it);
21031 } 21054 }
21032 else if (it->area == TEXT_AREA) 21055 else if (it->area == TEXT_AREA)
21033 { 21056 {
21034 /* Line numbers should precede the line-prefix or wrap-prefix. */ 21057 /* Line numbers should precede the line-prefix or wrap-prefix. */
21035 if (!NILP (Vdisplay_line_numbers) 21058 if (line_number_needed)
21036#ifdef HAVE_WINDOW_SYSTEM
21037 && !(FRAMEP (tip_frame)
21038 && EQ (WINDOW_FRAME (it->w), tip_frame))
21039#endif
21040 && (!MINI_WINDOW_P (it->w)))
21041 maybe_produce_line_number (it); 21059 maybe_produce_line_number (it);
21042 21060
21043 /* We only do this when not calling move_it_in_display_line_to 21061 /* We only do this when not calling move_it_in_display_line_to
@@ -21203,13 +21221,7 @@ display_line (struct it *it, int cursor_vpos)
21203 if (it->area == TEXT_AREA && pending_handle_line_prefix) 21221 if (it->area == TEXT_AREA && pending_handle_line_prefix)
21204 { 21222 {
21205 /* Line numbers should precede the line-prefix or wrap-prefix. */ 21223 /* Line numbers should precede the line-prefix or wrap-prefix. */
21206 if (!NILP (Vdisplay_line_numbers) 21224 if (line_number_needed)
21207#ifdef HAVE_WINDOW_SYSTEM
21208 && !(FRAMEP (tip_frame)
21209 && EQ (WINDOW_FRAME (it->w), tip_frame))
21210#endif
21211 && (!MINI_WINDOW_P (it->w)
21212 || (minibuf_level && EQ (it->window, minibuf_window))))
21213 maybe_produce_line_number (it); 21225 maybe_produce_line_number (it);
21214 21226
21215 pending_handle_line_prefix = false; 21227 pending_handle_line_prefix = false;
@@ -31905,6 +31917,8 @@ They are still logged to the *Messages* buffer. */);
31905 /* Names of the faces used to display line numbers. */ 31917 /* Names of the faces used to display line numbers. */
31906 DEFSYM (Qline_number, "line-number"); 31918 DEFSYM (Qline_number, "line-number");
31907 DEFSYM (Qline_number_current_line, "line-number-current-line"); 31919 DEFSYM (Qline_number_current_line, "line-number-current-line");
31920 /* Name of a text property which disables line-number display. */
31921 DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
31908 31922
31909 /* Name and number of the face used to highlight escape glyphs. */ 31923 /* Name and number of the face used to highlight escape glyphs. */
31910 DEFSYM (Qescape_glyph, "escape-glyph"); 31924 DEFSYM (Qescape_glyph, "escape-glyph");