diff options
| author | Jimmy Aguilar Mena | 2019-04-05 12:37:59 +0200 |
|---|---|---|
| committer | Jimmy Aguilar Mena | 2019-05-05 16:27:37 +0200 |
| commit | 491e145f96aa0278d0a4cf0dc4c1e75550f67d25 (patch) | |
| tree | 1e5770017d8de139c950b545da90c0b1e00240f8 | |
| parent | 18ea7605c06791641a465cd209a3de760d560863 (diff) | |
| download | emacs-491e145f96aa0278d0a4cf0dc4c1e75550f67d25.tar.gz emacs-491e145f96aa0278d0a4cf0dc4c1e75550f67d25.zip | |
display-fill-column-indicator interface corrections
*lisp/display-fill-column-indicator.el: Fixed character selection for
the indicator based in the current faces. Extended condition to set
display-fill-column-indicator-character in graphical displays.
*src/xdisp.c: Fixed some long lines.
| -rw-r--r-- | lisp/cus-start.el | 5 | ||||
| -rw-r--r-- | lisp/display-fill-column-indicator.el | 18 | ||||
| -rw-r--r-- | src/xdisp.c | 62 |
3 files changed, 51 insertions, 34 deletions
diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 3f58eac63bc..b935776a2df 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el | |||
| @@ -649,6 +649,11 @@ since it could result in memory overflow and make Emacs crash." | |||
| 649 | :value nil)) | 649 | :value nil)) |
| 650 | "26.1") | 650 | "26.1") |
| 651 | 651 | ||
| 652 | (display-fill-column-indicator display-fill-column-indicator | ||
| 653 | (choice | ||
| 654 | (const :tag "Off (nil)" :value nil) | ||
| 655 | (const :tag "On (t)" :value t)) | ||
| 656 | "27.1") | ||
| 652 | (display-fill-column-indicator-column display-fill-column-indicator | 657 | (display-fill-column-indicator-column display-fill-column-indicator |
| 653 | integer "27.1") | 658 | integer "27.1") |
| 654 | (display-fill-column-indicator-character display-fill-column-indicator | 659 | (display-fill-column-indicator-character display-fill-column-indicator |
diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el index 7c1df531df1..f6b7352c21b 100644 --- a/lisp/display-fill-column-indicator.el +++ b/lisp/display-fill-column-indicator.el | |||
| @@ -24,10 +24,9 @@ | |||
| 24 | 24 | ||
| 25 | ;; Provides a minor mode interface for `display-fill-column-indicator'. | 25 | ;; Provides a minor mode interface for `display-fill-column-indicator'. |
| 26 | ;; | 26 | ;; |
| 27 | ;; Toggle display of line numbers with M-x | 27 | ;; Toggle display of the column indicator with M-x |
| 28 | ;; display-fill-column-indicator-mode. To enable line numbering in | 28 | ;; display-fill-column-indicator-mode. To enable the indicator in |
| 29 | ;; all buffers, use M-x global-display-fill-column-indicator-mode. To | 29 | ;; all buffers, use M-x global-display-fill-column-indicator-mode. |
| 30 | ;; change the default line column | ||
| 31 | 30 | ||
| 32 | 31 | ||
| 33 | ;; NOTE: Customization variables for | 32 | ;; NOTE: Customization variables for |
| @@ -38,7 +37,7 @@ | |||
| 38 | ;;; Code: | 37 | ;;; Code: |
| 39 | 38 | ||
| 40 | (defgroup display-fill-column-indicator nil | 39 | (defgroup display-fill-column-indicator nil |
| 41 | "Display line numbers in the buffer." | 40 | "Display a fill column indicator in th buffer." |
| 42 | :group 'convenience | 41 | :group 'convenience |
| 43 | :group 'display) | 42 | :group 'display) |
| 44 | 43 | ||
| @@ -48,15 +47,18 @@ | |||
| 48 | "Toggle display fill column indicator. | 47 | "Toggle display fill column indicator. |
| 49 | This uses `display-fill-column-indicator' internally. | 48 | This uses `display-fill-column-indicator' internally. |
| 50 | 49 | ||
| 51 | To change the position of the line displayed by default, | 50 | To change the position of the column displayed by default, |
| 52 | customize `display-fill-column-indicator-column' you can change the | 51 | customize `display-fill-column-indicator-column' you can change the |
| 53 | character for the line setting `display-fill-column-indicator-character'." | 52 | character for the indicator setting `display-fill-column-indicator-character'." |
| 54 | :lighter nil | 53 | :lighter nil |
| 55 | (if display-fill-column-indicator-mode | 54 | (if display-fill-column-indicator-mode |
| 56 | (progn | 55 | (progn |
| 57 | (setq display-fill-column-indicator t) | 56 | (setq display-fill-column-indicator t) |
| 58 | (unless display-fill-column-indicator-character | 57 | (unless display-fill-column-indicator-character |
| 59 | (if (char-displayable-p ?\u2502) | 58 | (if (and (char-displayable-p ?\u2502) |
| 59 | (or (not (display-graphic-p)) | ||
| 60 | (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0) | ||
| 61 | (face-font 'default)))) | ||
| 60 | (setq display-fill-column-indicator-character ?\u2502) | 62 | (setq display-fill-column-indicator-character ?\u2502) |
| 61 | (setq display-fill-column-indicator-character ?|)))) | 63 | (setq display-fill-column-indicator-character ?|)))) |
| 62 | (setq display-fill-column-indicator nil))) | 64 | (setq display-fill-column-indicator nil))) |
diff --git a/src/xdisp.c b/src/xdisp.c index 25ef98b49cf..31bb83c4181 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -20183,19 +20183,23 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 20183 | XFIXNAT (Vdisplay_fill_column_indicator_column); | 20183 | XFIXNAT (Vdisplay_fill_column_indicator_column); |
| 20184 | 20184 | ||
| 20185 | struct font *font = | 20185 | struct font *font = |
| 20186 | default_face->font ? default_face->font : FRAME_FONT (it->f); | 20186 | default_face->font ? |
| 20187 | default_face->font : FRAME_FONT (it->f); | ||
| 20187 | const int char_width = | 20188 | const int char_width = |
| 20188 | font->average_width ? font->average_width : font->space_width; | 20189 | font->average_width ? |
| 20190 | font->average_width : font->space_width; | ||
| 20189 | 20191 | ||
| 20190 | const int column_x = | 20192 | const int column_x = |
| 20191 | char_width * fill_column_indicator_column + it->lnum_pixel_width; | 20193 | char_width * fill_column_indicator_column + |
| 20194 | it->lnum_pixel_width; | ||
| 20192 | 20195 | ||
| 20193 | if (it->current_x == column_x) | 20196 | if (it->current_x == column_x) |
| 20194 | { | 20197 | { |
| 20195 | it->c = it->char_to_display = | 20198 | it->c = it->char_to_display = |
| 20196 | XFIXNAT (Vdisplay_fill_column_indicator_character); | 20199 | XFIXNAT (Vdisplay_fill_column_indicator_character); |
| 20197 | it->face_id = | 20200 | it->face_id = |
| 20198 | merge_faces (it->w, Qfill_column_face, 0, DEFAULT_FACE_ID); | 20201 | merge_faces (it->w, Qfill_column_face, |
| 20202 | 0, DEFAULT_FACE_ID); | ||
| 20199 | face = FACE_FROM_ID(it->f, it->face_id); | 20203 | face = FACE_FROM_ID(it->f, it->face_id); |
| 20200 | goto produce_glyphs; | 20204 | goto produce_glyphs; |
| 20201 | } | 20205 | } |
| @@ -20444,10 +20448,12 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20444 | struct font *font = | 20448 | struct font *font = |
| 20445 | default_face->font ? default_face->font : FRAME_FONT (f); | 20449 | default_face->font ? default_face->font : FRAME_FONT (f); |
| 20446 | const int char_width = | 20450 | const int char_width = |
| 20447 | font->average_width ? font->average_width : font->space_width; | 20451 | font->average_width ? |
| 20452 | font->average_width : font->space_width; | ||
| 20448 | 20453 | ||
| 20449 | const int column_x = char_width * fill_column_indicator_column + | 20454 | const int column_x = |
| 20450 | it->lnum_pixel_width; | 20455 | char_width * fill_column_indicator_column + |
| 20456 | it->lnum_pixel_width; | ||
| 20451 | 20457 | ||
| 20452 | if ((it->current_x <= column_x) | 20458 | if ((it->current_x <= column_x) |
| 20453 | && (column_x <= it->last_visible_x)) | 20459 | && (column_x <= it->last_visible_x)) |
| @@ -20459,39 +20465,43 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20459 | const bool saved_box_start = it->start_of_box_run_p; | 20465 | const bool saved_box_start = it->start_of_box_run_p; |
| 20460 | Lisp_Object save_object = it->object; | 20466 | Lisp_Object save_object = it->object; |
| 20461 | 20467 | ||
| 20462 | /* The stretch width needs to considet the latter added glyph */ | 20468 | /* The stretch width needs to considet the latter |
| 20463 | const int stretch_width = column_x - it->current_x - char_width; | 20469 | added glyph */ |
| 20470 | const int stretch_width = | ||
| 20471 | column_x - it->current_x - char_width; | ||
| 20464 | 20472 | ||
| 20465 | memset (&it->position, 0, sizeof it->position); | 20473 | memset (&it->position, 0, sizeof it->position); |
| 20466 | it->avoid_cursor_p = true; | 20474 | it->avoid_cursor_p = true; |
| 20467 | it->object = Qnil; | 20475 | it->object = Qnil; |
| 20468 | 20476 | ||
| 20469 | /* Only generate a stretch glysph if there is distance between | 20477 | /* Only generate a stretch glysph if there is distance |
| 20470 | current_x and and the indicator position */ | 20478 | between current_x and and the indicator position */ |
| 20471 | if (stretch_width > 0) | 20479 | if (stretch_width > 0) |
| 20472 | { | 20480 | { |
| 20473 | int stretch_ascent = (((it->ascent + it->descent) | 20481 | int stretch_ascent = (((it->ascent + it->descent) |
| 20474 | * FONT_BASE (font)) / FONT_HEIGHT (font)); | 20482 | * FONT_BASE (font)) / FONT_HEIGHT (font)); |
| 20475 | append_stretch_glyph (it, Qnil, stretch_width, | 20483 | append_stretch_glyph (it, Qnil, stretch_width, |
| 20476 | it->ascent + it->descent, stretch_ascent); | 20484 | it->ascent + it->descent, |
| 20477 | } | 20485 | stretch_ascent); |
| 20478 | 20486 | } | |
| 20479 | /* Generate the glysph indicator only if append_space_for_newline | 20487 | |
| 20480 | didn't already. */ | 20488 | /* Generate the glysph indicator only if |
| 20489 | append_space_for_newline didn't already. */ | ||
| 20481 | if (it->current_x < column_x) | 20490 | if (it->current_x < column_x) |
| 20482 | { | 20491 | { |
| 20483 | it->char_to_display = | 20492 | it->char_to_display = |
| 20484 | XFIXNAT (Vdisplay_fill_column_indicator_character); | 20493 | XFIXNAT (Vdisplay_fill_column_indicator_character); |
| 20485 | it->face_id = | 20494 | it->face_id = |
| 20486 | merge_faces (it->w, Qfill_column_face, 0, DEFAULT_FACE_ID); | 20495 | merge_faces (it->w, Qfill_column_face, |
| 20496 | 0, DEFAULT_FACE_ID); | ||
| 20487 | PRODUCE_GLYPHS (it); | 20497 | PRODUCE_GLYPHS (it); |
| 20488 | } | 20498 | } |
| 20489 | 20499 | ||
| 20490 | /* Restore the face after the indicator was generated */ | 20500 | /* Restore the face after the indicator was generated */ |
| 20491 | it->face_id = saved_face_id; | 20501 | it->face_id = saved_face_id; |
| 20492 | 20502 | ||
| 20493 | /* If there is space after the indicator generate an extra | 20503 | /* If there is space after the indicator generate an |
| 20494 | empty glysph to restore the face. */ | 20504 | extra empty glysph to restore the face. */ |
| 20495 | it->char_to_display = ' '; | 20505 | it->char_to_display = ' '; |
| 20496 | PRODUCE_GLYPHS (it); | 20506 | PRODUCE_GLYPHS (it); |
| 20497 | 20507 | ||
| @@ -20630,8 +20640,8 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20630 | { | 20640 | { |
| 20631 | int fill_column_indicator_column = -1; | 20641 | int fill_column_indicator_column = -1; |
| 20632 | 20642 | ||
| 20633 | /* Vdisplay_fill_column_indicator_column accepts the special value t | 20643 | /* Vdisplay_fill_column_indicator_column accepts the special |
| 20634 | to use the default fill-column variable. */ | 20644 | value t to use the default fill-column variable. */ |
| 20635 | if (EQ (Vdisplay_fill_column_indicator_column, Qt) | 20645 | if (EQ (Vdisplay_fill_column_indicator_column, Qt) |
| 20636 | && FIXNATP (BVAR (current_buffer, fill_column))) | 20646 | && FIXNATP (BVAR (current_buffer, fill_column))) |
| 20637 | fill_column_indicator_column = | 20647 | fill_column_indicator_column = |