diff options
| author | Chong Yidong | 2011-10-18 17:07:56 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-10-18 17:07:56 -0400 |
| commit | 4e948d153a13d2ee9e84b8db9a7dd2477460196e (patch) | |
| tree | 1281df8dd694c617d388d298f22cc4494d5a92a5 /src | |
| parent | 0ffe10653bb4366a03ce79fde9847ae810bc78d4 (diff) | |
| download | emacs-4e948d153a13d2ee9e84b8db9a7dd2477460196e.tar.gz emacs-4e948d153a13d2ee9e84b8db9a7dd2477460196e.zip | |
Have nobreak-char-display handle U+2010 and U+2011.
See discussion at
http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00747.html
* src/xdisp.c (get_next_display_element): Handle U+2010 and U+2011
with nobreak-char-display too.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 70 |
2 files changed, 43 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d21e6383764..ce049ebfc84 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-10-18 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (get_next_display_element): Handle U+2010 and U+2011 | ||
| 4 | with nobreak-char-display too. | ||
| 5 | |||
| 1 | 2011-10-18 Eli Zaretskii <eliz@gnu.org> | 6 | 2011-10-18 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | Fix part 3 of bug#9771. | 8 | Fix part 3 of bug#9771. |
diff --git a/src/xdisp.c b/src/xdisp.c index 43907ccc03a..75763616f72 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6371,8 +6371,8 @@ get_next_display_element (struct it *it) | |||
| 6371 | { | 6371 | { |
| 6372 | Lisp_Object dv; | 6372 | Lisp_Object dv; |
| 6373 | struct charset *unibyte = CHARSET_FROM_ID (charset_unibyte); | 6373 | struct charset *unibyte = CHARSET_FROM_ID (charset_unibyte); |
| 6374 | enum { char_is_other = 0, char_is_nbsp, char_is_soft_hyphen } | 6374 | int nonascii_space_p = 0; |
| 6375 | nbsp_or_shy = char_is_other; | 6375 | int nonascii_hyphen_p = 0; |
| 6376 | int c = it->c; /* This is the character to display. */ | 6376 | int c = it->c; /* This is the character to display. */ |
| 6377 | 6377 | ||
| 6378 | if (! it->multibyte_p && ! ASCII_CHAR_P (c)) | 6378 | if (! it->multibyte_p && ! ASCII_CHAR_P (c)) |
| @@ -6424,10 +6424,15 @@ get_next_display_element (struct it *it) | |||
| 6424 | goto get_next; | 6424 | goto get_next; |
| 6425 | } | 6425 | } |
| 6426 | 6426 | ||
| 6427 | /* If `nobreak-char-display' is non-nil, we display | ||
| 6428 | non-ASCII spaces and hyphens specially. */ | ||
| 6427 | if (! ASCII_CHAR_P (c) && ! NILP (Vnobreak_char_display)) | 6429 | if (! ASCII_CHAR_P (c) && ! NILP (Vnobreak_char_display)) |
| 6428 | nbsp_or_shy = (c == 0xA0 ? char_is_nbsp | 6430 | { |
| 6429 | : c == 0xAD ? char_is_soft_hyphen | 6431 | if (c == 0xA0) |
| 6430 | : char_is_other); | 6432 | nonascii_space_p = 1; |
| 6433 | else if (c == 0xAD || c == 0x2010 || c == 0x2011) | ||
| 6434 | nonascii_hyphen_p = 1; | ||
| 6435 | } | ||
| 6431 | 6436 | ||
| 6432 | /* Translate control characters into `\003' or `^C' form. | 6437 | /* Translate control characters into `\003' or `^C' form. |
| 6433 | Control characters coming from a display table entry are | 6438 | Control characters coming from a display table entry are |
| @@ -6435,7 +6440,8 @@ get_next_display_element (struct it *it) | |||
| 6435 | the translation. This could easily be changed but I | 6440 | the translation. This could easily be changed but I |
| 6436 | don't believe that it is worth doing. | 6441 | don't believe that it is worth doing. |
| 6437 | 6442 | ||
| 6438 | NBSP and SOFT-HYPEN are property translated too. | 6443 | The characters handled by `nobreak-char-display' must be |
| 6444 | translated too. | ||
| 6439 | 6445 | ||
| 6440 | Non-printable characters and raw-byte characters are also | 6446 | Non-printable characters and raw-byte characters are also |
| 6441 | translated to octal form. */ | 6447 | translated to octal form. */ |
| @@ -6446,14 +6452,15 @@ get_next_display_element (struct it *it) | |||
| 6446 | && it->glyph_row | 6452 | && it->glyph_row |
| 6447 | && (it->glyph_row->mode_line_p || it->avoid_cursor_p)) | 6453 | && (it->glyph_row->mode_line_p || it->avoid_cursor_p)) |
| 6448 | || (c != '\n' && c != '\t')) | 6454 | || (c != '\n' && c != '\t')) |
| 6449 | : (nbsp_or_shy | 6455 | : (nonascii_space_p |
| 6456 | || nonascii_hyphen_p | ||
| 6450 | || CHAR_BYTE8_P (c) | 6457 | || CHAR_BYTE8_P (c) |
| 6451 | || ! CHAR_PRINTABLE_P (c)))) | 6458 | || ! CHAR_PRINTABLE_P (c)))) |
| 6452 | { | 6459 | { |
| 6453 | /* C is a control character, NBSP, SOFT-HYPEN, raw-byte, | 6460 | /* C is a control character, non-ASCII space/hyphen, |
| 6454 | or a non-printable character which must be displayed | 6461 | raw-byte, or a non-printable character which must be |
| 6455 | either as '\003' or as `^C' where the '\\' and '^' | 6462 | displayed either as '\003' or as `^C' where the '\\' |
| 6456 | can be defined in the display table. Fill | 6463 | and '^' can be defined in the display table. Fill |
| 6457 | IT->ctl_chars with glyphs for what we have to | 6464 | IT->ctl_chars with glyphs for what we have to |
| 6458 | display. Then, set IT->dpvec to these glyphs. */ | 6465 | display. Then, set IT->dpvec to these glyphs. */ |
| 6459 | Lisp_Object gc; | 6466 | Lisp_Object gc; |
| @@ -6502,17 +6509,14 @@ get_next_display_element (struct it *it) | |||
| 6502 | goto display_control; | 6509 | goto display_control; |
| 6503 | } | 6510 | } |
| 6504 | 6511 | ||
| 6505 | /* Handle non-break space in the mode where it only gets | 6512 | /* Handle non-ascii space in the mode where it only gets |
| 6506 | highlighting. */ | 6513 | highlighting. */ |
| 6507 | 6514 | ||
| 6508 | if (EQ (Vnobreak_char_display, Qt) | 6515 | if (nonascii_space_p && EQ (Vnobreak_char_display, Qt)) |
| 6509 | && nbsp_or_shy == char_is_nbsp) | ||
| 6510 | { | 6516 | { |
| 6511 | /* Merge the no-break-space face into the current face. */ | 6517 | /* Merge `nobreak-space' into the current face. */ |
| 6512 | face_id = merge_faces (it->f, Qnobreak_space, 0, | 6518 | face_id = merge_faces (it->f, Qnobreak_space, 0, |
| 6513 | it->face_id); | 6519 | it->face_id); |
| 6514 | |||
| 6515 | c = ' '; | ||
| 6516 | XSETINT (it->ctl_chars[0], ' '); | 6520 | XSETINT (it->ctl_chars[0], ' '); |
| 6517 | ctl_len = 1; | 6521 | ctl_len = 1; |
| 6518 | goto display_control; | 6522 | goto display_control; |
| @@ -6552,25 +6556,21 @@ get_next_display_element (struct it *it) | |||
| 6552 | last_escape_glyph_merged_face_id = face_id; | 6556 | last_escape_glyph_merged_face_id = face_id; |
| 6553 | } | 6557 | } |
| 6554 | 6558 | ||
| 6555 | /* Handle soft hyphens in the mode where they only get | 6559 | /* Draw non-ASCII hyphen with just highlighting: */ |
| 6556 | highlighting. */ | ||
| 6557 | 6560 | ||
| 6558 | if (EQ (Vnobreak_char_display, Qt) | 6561 | if (nonascii_hyphen_p && EQ (Vnobreak_char_display, Qt)) |
| 6559 | && nbsp_or_shy == char_is_soft_hyphen) | ||
| 6560 | { | 6562 | { |
| 6561 | XSETINT (it->ctl_chars[0], '-'); | 6563 | XSETINT (it->ctl_chars[0], '-'); |
| 6562 | ctl_len = 1; | 6564 | ctl_len = 1; |
| 6563 | goto display_control; | 6565 | goto display_control; |
| 6564 | } | 6566 | } |
| 6565 | 6567 | ||
| 6566 | /* Handle non-break space and soft hyphen | 6568 | /* Draw non-ASCII space/hyphen with escape glyph: */ |
| 6567 | with the escape glyph. */ | ||
| 6568 | 6569 | ||
| 6569 | if (nbsp_or_shy) | 6570 | if (nonascii_space_p || nonascii_hyphen_p) |
| 6570 | { | 6571 | { |
| 6571 | XSETINT (it->ctl_chars[0], escape_glyph); | 6572 | XSETINT (it->ctl_chars[0], escape_glyph); |
| 6572 | c = (nbsp_or_shy == char_is_nbsp ? ' ' : '-'); | 6573 | XSETINT (it->ctl_chars[1], nonascii_space_p ? ' ' : '-'); |
| 6573 | XSETINT (it->ctl_chars[1], c); | ||
| 6574 | ctl_len = 2; | 6574 | ctl_len = 2; |
| 6575 | goto display_control; | 6575 | goto display_control; |
| 6576 | } | 6576 | } |
| @@ -28001,12 +28001,18 @@ The face used for trailing whitespace is `trailing-whitespace'. */); | |||
| 28001 | Vshow_trailing_whitespace = Qnil; | 28001 | Vshow_trailing_whitespace = Qnil; |
| 28002 | 28002 | ||
| 28003 | DEFVAR_LISP ("nobreak-char-display", Vnobreak_char_display, | 28003 | DEFVAR_LISP ("nobreak-char-display", Vnobreak_char_display, |
| 28004 | doc: /* *Control highlighting of nobreak space and soft hyphen. | 28004 | doc: /* Control highlighting of non-ASCII space and hyphen chars. |
| 28005 | A value of t means highlight the character itself (for nobreak space, | 28005 | If the value is t, Emacs highlights non-ASCII chars which have the |
| 28006 | use face `nobreak-space'). | 28006 | same appearance as an ASCII space or hyphen, using the `nobreak-space' |
| 28007 | A value of nil means no highlighting. | 28007 | or `escape-glyph' face respectively. |
| 28008 | Other values mean display the escape glyph followed by an ordinary | 28008 | |
| 28009 | space or ordinary hyphen. */); | 28009 | U+00A0 (no-break space), U+00AD (soft hyphen), U+2010 (hyphen), and |
| 28010 | U+2011 (non-breaking hyphen) are affected. | ||
| 28011 | |||
| 28012 | Any other non-nil value means to display these characters as a escape | ||
| 28013 | glyph followed by an ordinary space or hyphen. | ||
| 28014 | |||
| 28015 | A value of nil means no special handling of these characters. */); | ||
| 28010 | Vnobreak_char_display = Qt; | 28016 | Vnobreak_char_display = Qt; |
| 28011 | 28017 | ||
| 28012 | DEFVAR_LISP ("void-text-area-pointer", Vvoid_text_area_pointer, | 28018 | DEFVAR_LISP ("void-text-area-pointer", Vvoid_text_area_pointer, |