Commit a336300c authored by Jimmy Aguilar Mena's avatar Jimmy Aguilar Mena

;Corrected display-fill-column-indicator mode.

Small corrections in the documentation and code format to merge into master.
parent 5b842bd7
...@@ -1181,10 +1181,11 @@ When the mode is enabled through the functions ...@@ -1181,10 +1181,11 @@ When the mode is enabled through the functions
@code{display-fill-column-indicator-mode} or @code{display-fill-column-indicator-mode} or
@code{global-display-fill-column-indicator-mode}, the initialization @code{global-display-fill-column-indicator-mode}, the initialization
functions check if this variable is @code{non-nil}, otherwise the functions check if this variable is @code{non-nil}, otherwise the
initialization tries to set it to U+2502 or '|'. initialization tries to set it to U+2502 or @sampl{|}.
@item fill-column-face @item fill-column-indicator
Specifies the face used to display the indicator it inherits its @vindex fill-column-indicator
Specifies the face used to display the indicator. It inherits its
default values from shadow and the default face. default values from shadow and the default face.
@end table @end table
......
...@@ -340,7 +340,7 @@ longer. ...@@ -340,7 +340,7 @@ longer.
** Multicolor fonts such as "Noto Color Emoji" can be displayed on ** Multicolor fonts such as "Noto Color Emoji" can be displayed on
Emacs configured with Cairo drawing and linked with cairo >= 1.16.0. Emacs configured with Cairo drawing and linked with cairo >= 1.16.0.
--- +++
** Emacs now optionally displays a fill column indicator. ** Emacs now optionally displays a fill column indicator.
This is similar to what 'fill-column-indicator' package provides, but This is similar to what 'fill-column-indicator' package provides, but
...@@ -354,28 +354,7 @@ The indicator is not displayed at all in minibuffer windows and ...@@ -354,28 +354,7 @@ The indicator is not displayed at all in minibuffer windows and
in tooltips, as it is not useful there. in tooltips, as it is not useful there.
There are 2 new buffer local variables and 1 face to customize this There are 2 new buffer local variables and 1 face to customize this
mode: mode they are described in the manual "(emacs) Display".
*** 'display-fill-column-indicator-column' is the column where the
indicator should be set. It can take positive numerical values for
the column or the special value t. Any other value disables the
indicator. The default value is t.
When the value is t it means that the variable 'fill-column' will
be used.
*** 'display-fill-column-indicator-char' is the character used for the
indicator. This character can be any valid char including unicode
ones if the user's font supports them.
When the mode is enabled throw the functions
'display-fill-column-indicator-mode' and
'global-display-fill-column-indicator-mode', they check if there
is a value non-nil for this variable, otherwise the initialization
tries to set it to U+2502 or '|'.
*** 'fill-column-face' is the face used to display the indicator it
inherits it default values from shadow and the default faces.
* Editing Changes in Emacs 27.1 * Editing Changes in Emacs 27.1
......
...@@ -650,11 +650,14 @@ since it could result in memory overflow and make Emacs crash." ...@@ -650,11 +650,14 @@ since it could result in memory overflow and make Emacs crash."
"26.1") "26.1")
(display-fill-column-indicator display-fill-column-indicator (display-fill-column-indicator display-fill-column-indicator
(choice boolean "27.1")
(const :tag "Off (nil)" :value nil)
(const :tag "On (t)" :value t))
"27.1")
(display-fill-column-indicator-column display-fill-column-indicator (display-fill-column-indicator-column display-fill-column-indicator
(choice
(const :tag "Use fill-column variable"
:value t)
(const :tag "Fixed column number"
:value 70
:format "%v"))
integer "27.1") integer "27.1")
(display-fill-column-indicator-character display-fill-column-indicator (display-fill-column-indicator-character display-fill-column-indicator
character "27.1") character "27.1")
......
;;; display-fill-column-indicator.el --- interface for display-fill-column-indicator -*- lexical-binding: t -*- ;;; display-fill-column-indicator.el --- interface for display-fill-column-indicator -*- lexical-binding: t -*-
;; Copyright (C) 2017-2019 Free Software Foundation, Inc. ;; Copyright (C) 2019 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org ;; Maintainer: emacs-devel@gnu.org
;; Keywords: convenience ;; Keywords: convenience
...@@ -37,18 +37,18 @@ ...@@ -37,18 +37,18 @@
;;; Code: ;;; Code:
(defgroup display-fill-column-indicator nil (defgroup display-fill-column-indicator nil
"Display a fill column indicator in th buffer." "Display a fill column indicator in the buffer."
:group 'convenience :group 'convenience
:group 'display) :group 'display)
;;;###autoload ;;;###autoload
(define-minor-mode display-fill-column-indicator-mode (define-minor-mode display-fill-column-indicator-mode
"Toggle display fill column indicator. "Toggle display of fill-column indicator.
This uses `display-fill-column-indicator' internally. This uses `display-fill-column-indicator' internally.
To change the position of the column displayed by default, To change the position of the column displayed by default
customize `display-fill-column-indicator-column' you can change the customize `display-fill-column-indicator-column'. You can change the
character for the indicator setting `display-fill-column-indicator-character'." character for the indicator setting `display-fill-column-indicator-character'."
:lighter nil :lighter nil
(if display-fill-column-indicator-mode (if display-fill-column-indicator-mode
......
...@@ -2501,15 +2501,11 @@ unwanted effects." ...@@ -2501,15 +2501,11 @@ unwanted effects."
:group 'display-line-numbers) :group 'display-line-numbers)
;; Definition stolen from display-line-numbers. ;; Definition stolen from display-line-numbers.
(defface fill-column-face (defface fill-column-indicator
'((t :inherit (shadow default))) '((t :inherit (shadow default)))
"Face for displaying fill column indicator line. "Face for displaying fill column indicator.
This face is used when `display-fill-column-indicator-mode' is This face is used when `display-fill-column-indicator-mode' is
non-nil. non-nil."
If you customize the font of this face, make sure it is a
monospaced font, otherwise the line's characters will not line
up horizontally."
:version "27.1" :version "27.1"
:group 'basic-faces :group 'basic-faces
:group 'display-fill-column-indicator) :group 'display-fill-column-indicator)
......
...@@ -379,11 +379,14 @@ static Lisp_Object list_of_error; ...@@ -379,11 +379,14 @@ static Lisp_Object list_of_error;
|| *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \ || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \
/* Test all the conditions needed to print the fill column indicator. */ /* Test all the conditions needed to print the fill column indicator. */
#define FILL_COLUMN_INDICATOR_NEEDED(it) \ #define FILL_COLUMN_INDICATOR_NEEDED(it) \
!NILP (Vdisplay_fill_column_indicator) \ Vdisplay_fill_column_indicator \
&& (it->continuation_lines_width == 0) \ && (it->continuation_lines_width == 0) \
&& (!NILP (Vdisplay_fill_column_indicator_column)) \ && (!NILP (Vdisplay_fill_column_indicator_column)) \
&& FIXNATP (Vdisplay_fill_column_indicator_character) && FIXNATP (Vdisplay_fill_column_indicator_character) \
&& ((EQ (Vdisplay_fill_column_indicator_column, Qt) \
&& FIXNATP (BVAR (current_buffer, fill_column))) \
|| (FIXNATP (Vdisplay_fill_column_indicator_column)))
/* True means print newline to stdout before next mini-buffer message. */ /* True means print newline to stdout before next mini-buffer message. */
...@@ -20168,17 +20171,16 @@ append_space_for_newline (struct it *it, bool default_face_p) ...@@ -20168,17 +20171,16 @@ append_space_for_newline (struct it *it, bool default_face_p)
/* Corner case for when display-fill-column-indicator-mode /* Corner case for when display-fill-column-indicator-mode
is active and the extra character should be added in the is active and the extra character should be added in the
same place than the line */ same place than the line. */
if ((it->w->pseudo_window_p == 0) if ((it->w->pseudo_window_p == 0)
&& FILL_COLUMN_INDICATOR_NEEDED(it)) && FILL_COLUMN_INDICATOR_NEEDED(it))
{ {
int fill_column_indicator_column = -1; int fill_column_indicator_column = -1;
if (EQ (Vdisplay_fill_column_indicator_column, Qt) if (EQ (Vdisplay_fill_column_indicator_column, Qt))
&& FIXNATP (BVAR (current_buffer, fill_column)))
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (BVAR (current_buffer, fill_column)); XFIXNAT (BVAR (current_buffer, fill_column));
else if (FIXNATP (Vdisplay_fill_column_indicator_column)) else
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (Vdisplay_fill_column_indicator_column); XFIXNAT (Vdisplay_fill_column_indicator_column);
...@@ -20198,7 +20200,7 @@ append_space_for_newline (struct it *it, bool default_face_p) ...@@ -20198,7 +20200,7 @@ append_space_for_newline (struct it *it, bool default_face_p)
it->c = it->char_to_display = it->c = it->char_to_display =
XFIXNAT (Vdisplay_fill_column_indicator_character); XFIXNAT (Vdisplay_fill_column_indicator_character);
it->face_id = it->face_id =
merge_faces (it->w, Qfill_column_face, merge_faces (it->w, Qfill_column_indicator,
0, DEFAULT_FACE_ID); 0, DEFAULT_FACE_ID);
face = FACE_FROM_ID(it->f, it->face_id); face = FACE_FROM_ID(it->f, it->face_id);
goto produce_glyphs; goto produce_glyphs;
...@@ -20221,8 +20223,8 @@ append_space_for_newline (struct it *it, bool default_face_p) ...@@ -20221,8 +20223,8 @@ append_space_for_newline (struct it *it, bool default_face_p)
set. */ set. */
if (it->glyph_row->reversed_p if (it->glyph_row->reversed_p
/* But if the appended newline glyph goes all the way to /* But if the appended newline glyph goes all the way to
the end of the row, there will be no stretch glyph, the end of the row, there will be no stretch glyph,
so leave the box flag set. */ so leave the box flag set. */
&& saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x)
it->end_of_box_run_p = false; it->end_of_box_run_p = false;
...@@ -20376,7 +20378,7 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20376,7 +20378,7 @@ extend_face_to_end_of_line (struct it *it)
&& !face->stipple && !face->stipple
#endif #endif
&& !it->glyph_row->reversed_p && !it->glyph_row->reversed_p
&& NILP (Vdisplay_fill_column_indicator)) && !Vdisplay_fill_column_indicator)
return; return;
/* Set the glyph row flag indicating that the face of the last glyph /* Set the glyph row flag indicating that the face of the last glyph
...@@ -20431,17 +20433,16 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20431,17 +20433,16 @@ extend_face_to_end_of_line (struct it *it)
/* Display fill column indicator if not in modeline or /* Display fill column indicator if not in modeline or
toolbar and display fill column indicator mode is toolbar and display fill column indicator mode is
active */ active. */
if ((it->w->pseudo_window_p == 0) if ((it->w->pseudo_window_p == 0)
&& FILL_COLUMN_INDICATOR_NEEDED(it)) && FILL_COLUMN_INDICATOR_NEEDED(it))
{ {
int fill_column_indicator_column = -1; int fill_column_indicator_column = -1;
if (EQ (Vdisplay_fill_column_indicator_column, Qt) if (EQ (Vdisplay_fill_column_indicator_column, Qt))
&& FIXNATP (BVAR (current_buffer, fill_column)))
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (BVAR (current_buffer, fill_column)); XFIXNAT (BVAR (current_buffer, fill_column));
else if (FIXNATP (Vdisplay_fill_column_indicator_column)) else
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (Vdisplay_fill_column_indicator_column); XFIXNAT (Vdisplay_fill_column_indicator_column);
...@@ -20466,7 +20467,7 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20466,7 +20467,7 @@ extend_face_to_end_of_line (struct it *it)
Lisp_Object save_object = it->object; Lisp_Object save_object = it->object;
/* The stretch width needs to considet the latter /* The stretch width needs to considet the latter
added glyph */ added glyph. */
const int stretch_width = const int stretch_width =
column_x - it->current_x - char_width; column_x - it->current_x - char_width;
...@@ -20474,34 +20475,35 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20474,34 +20475,35 @@ extend_face_to_end_of_line (struct it *it)
it->avoid_cursor_p = true; it->avoid_cursor_p = true;
it->object = Qnil; it->object = Qnil;
/* Only generate a stretch glysph if there is distance /* Only generate a stretch glyph if there is distance
between current_x and and the indicator position */ between current_x and and the indicator position. */
if (stretch_width > 0) if (stretch_width > 0)
{ {
int stretch_ascent = (((it->ascent + it->descent) int stretch_ascent = (((it->ascent + it->descent)
* FONT_BASE (font)) / FONT_HEIGHT (font)); * FONT_BASE (font)) / FONT_HEIGHT (font));
append_stretch_glyph (it, Qnil, stretch_width, append_stretch_glyph (it, Qnil, stretch_width,
it->ascent + it->descent, it->ascent + it->descent,
stretch_ascent); stretch_ascent);
} }
/* Generate the glysph indicator only if /* Generate the glyph indicator only if
append_space_for_newline didn't already. */ append_space_for_newline didn't already. */
if (it->current_x < column_x) if (it->current_x < column_x)
{ {
it->char_to_display = it->char_to_display =
XFIXNAT (Vdisplay_fill_column_indicator_character); XFIXNAT (Vdisplay_fill_column_indicator_character);
it->face_id = it->face_id =
merge_faces (it->w, Qfill_column_face, merge_faces (it->w, Qfill_column_indicator,
0, DEFAULT_FACE_ID); 0, DEFAULT_FACE_ID);
PRODUCE_GLYPHS (it); PRODUCE_GLYPHS (it);
} }
/* Restore the face after the indicator was generated */ /* Restore the face after the indicator was generated. */
it->face_id = saved_face_id; it->face_id = saved_face_id;
/* If there is space after the indicator generate an /* If there is space after the indicator generate an
extra empty glysph to restore the face. */ extra empty glyph to restore the face. Issue was
observed in X systems. */
it->char_to_display = ' '; it->char_to_display = ' ';
PRODUCE_GLYPHS (it); PRODUCE_GLYPHS (it);
...@@ -20514,14 +20516,13 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20514,14 +20516,13 @@ extend_face_to_end_of_line (struct it *it)
} }
} }
#ifdef HAVE_WINDOW_SYSTEM #ifdef HAVE_WINDOW_SYSTEM
if (it->glyph_row->reversed_p) if (it->glyph_row->reversed_p)
{ {
/* Prepend a stretch glyph to the row, such that the /* Prepend a stretch glyph to the row, such that the
rightmost glyph will be drawn flushed all the way to the rightmost glyph will be drawn flushed all the way to the
right margin of the window. The stretch glyph that will right margin of the window. The stretch glyph that will
occupy the empty space, if any, to the left of the occupy the empty space, if any, to the left of the
glyphs. */ glyph. */
struct font *font = face->font ? face->font : FRAME_FONT (f); struct font *font = face->font ? face->font : FRAME_FONT (f);
struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA];
struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA];
...@@ -20635,18 +20636,19 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20635,18 +20636,19 @@ extend_face_to_end_of_line (struct it *it)
else else
it->face_id = face->id; it->face_id = face->id;
/* Display fill-column-line if needed. */ /* Display fill-column indicator if needed. */
if (FILL_COLUMN_INDICATOR_NEEDED(it)) if (FILL_COLUMN_INDICATOR_NEEDED(it))
{ {
int fill_column_indicator_column = -1; int fill_column_indicator_column = -1;
/* Vdisplay_fill_column_indicator_column accepts the special /* Vdisplay_fill_column_indicator_column accepts the special
value t to use the default fill-column variable. */ value t to use the default fill-column variable. The
if (EQ (Vdisplay_fill_column_indicator_column, Qt) conditions are all defined in the macro
&& FIXNATP (BVAR (current_buffer, fill_column))) FILL_COLUMN_INDICATOR_NEEDED. */
if (EQ (Vdisplay_fill_column_indicator_column, Qt))
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (BVAR (current_buffer, fill_column)) + it->lnum_pixel_width; XFIXNAT (BVAR (current_buffer, fill_column)) + it->lnum_pixel_width;
else if (FIXNATP (Vdisplay_fill_column_indicator_column)) else
fill_column_indicator_column = fill_column_indicator_column =
XFIXNAT (Vdisplay_fill_column_indicator_column) + it->lnum_pixel_width; XFIXNAT (Vdisplay_fill_column_indicator_column) + it->lnum_pixel_width;
...@@ -20656,7 +20658,7 @@ extend_face_to_end_of_line (struct it *it) ...@@ -20656,7 +20658,7 @@ extend_face_to_end_of_line (struct it *it)
{ {
const int saved_face = it->face_id; const int saved_face = it->face_id;
it->face_id = it->face_id =
merge_faces (it->w, Qfill_column_face, 0, DEFAULT_FACE_ID); merge_faces (it->w, Qfill_column_indicator, 0, DEFAULT_FACE_ID);
it->c = it->char_to_display = it->c = it->char_to_display =
XFIXNAT (Vdisplay_fill_column_indicator_character); XFIXNAT (Vdisplay_fill_column_indicator_character);
PRODUCE_GLYPHS (it); PRODUCE_GLYPHS (it);
...@@ -32839,8 +32841,8 @@ be let-bound around code that needs to disable messages temporarily. */); ...@@ -32839,8 +32841,8 @@ be let-bound around code that needs to disable messages temporarily. */);
/* Name of a text property which disables line-number display. */ /* Name of a text property which disables line-number display. */
DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable"); DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
/* Names of the face used to display fill column indicator character. */ /* Name of the face used to display fill column indicator character. */
DEFSYM (Qfill_column_face, "fill-column-face"); DEFSYM (Qfill_column_indicator, "fill-column-indicator");
/* Name and number of the face used to highlight escape glyphs. */ /* Name and number of the face used to highlight escape glyphs. */
DEFSYM (Qescape_glyph, "escape-glyph"); DEFSYM (Qescape_glyph, "escape-glyph");
...@@ -33414,25 +33416,26 @@ either `relative' or `visual'. */); ...@@ -33414,25 +33416,26 @@ either `relative' or `visual'. */);
DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen");
Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); Fmake_variable_buffer_local (Qdisplay_line_numbers_widen);
DEFVAR_LISP ("display-fill-column-indicator", Vdisplay_fill_column_indicator, DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator,
doc: /* Non-nil means display the fill column indicator. */); doc: /* Non-nil means display the fill column indicator. */);
Vdisplay_fill_column_indicator = Qnil; Vdisplay_fill_column_indicator = false;
DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator"); DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator");
Fmake_variable_buffer_local (Qdisplay_fill_column_indicator); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator);
DEFVAR_LISP ("display-fill-column-indicator-column", Vdisplay_fill_column_indicator_column, DEFVAR_LISP ("display-fill-column-indicator-column", Vdisplay_fill_column_indicator_column,
doc: /* Column for indicator when `display-fill-column-indicator' is non-nil. doc: /* Column for indicator when `display-fill-column-indicator'
The default value is t which means that the indicator will use the `fill-column' variable. is non-nil. The default value is t which means that the indicator
If a numeric value is set, the indicator will be drawn in that column will use the `fill-column' variable. If it is set to an integer the
independently of the `fill-column' value. */); indicator will be drawn in that column. */);
Vdisplay_fill_column_indicator_column = Qt; Vdisplay_fill_column_indicator_column = Qt;
DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column"); DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column");
Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column);
DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character, DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character,
doc: /* Character to draw the indicator when `display-fill-column-indicator' is non-nil. doc: /* Character to draw the indicator when
The default is U+2502 but a good alternative is (ascii 124) if `display-fill-column-indicator' is non-nil. The default is U+2502 but
the font in fill-column-face does not support Unicode characters. */); a good alternative is (ascii 124) if the font in fill-column-indicator
face does not support Unicode characters. */);
Vdisplay_fill_column_indicator_character = Qnil; Vdisplay_fill_column_indicator_character = Qnil;
DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character"); DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character");
Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment