diff --git a/src/character.c b/src/character.c index c8ffa2b..6e7f55a 100644 --- a/src/character.c +++ b/src/character.c @@ -1145,4 +1145,15 @@ All Unicode characters have one of the following values (symbol): See The Unicode Standard for the meaning of those values. */); /* The correct char-table is setup in characters.el. */ Vunicode_category_table = Qnil; + + DEFVAR_LISP ("word-wrap-chars", Vword_wrap_chars, + doc: /* A char-table for characters at which word-wrap occurs. +Such characters have value t in this table. +By default these are the whitespace characters. */); + Vword_wrap_chars = Fmake_char_table (Qnil, Qnil); + Fset_char_table_range (Vword_wrap_chars, make_number (9), Qt); + Fset_char_table_range (Vword_wrap_chars, make_number (32), Qt); + Fset_char_table_range (Vword_wrap_chars, + Fcons (make_number (8192), + make_number (8203)), Qt); } diff --git a/src/xdisp.c b/src/xdisp.c index 7e47c06..7152220 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -348,20 +348,23 @@ static Lisp_Object list_of_error; #endif /* HAVE_WINDOW_SYSTEM */ /* Test if the display element loaded in IT, or the underlying buffer - or string character, is a space or a TAB character. This is used - to determine where word wrapping can occur. */ + or string character, belongs to the word-wrap-chars char-table. + This is used to determine where word wrapping can occur. */ #define IT_DISPLAYING_WHITESPACE(it) \ - ((it->what == IT_CHARACTER && (it->c == ' ' || it->c == '\t')) \ + ((it->what == IT_CHARACTER \ + && !NILP (CHAR_TABLE_REF (Vword_wrap_chars, it->c))) \ || ((STRINGP (it->string) \ - && (SREF (it->string, IT_STRING_BYTEPOS (*it)) == ' ' \ - || SREF (it->string, IT_STRING_BYTEPOS (*it)) == '\t')) \ - || (it->s \ - && (it->s[IT_BYTEPOS (*it)] == ' ' \ - || it->s[IT_BYTEPOS (*it)] == '\t')) \ + && !NILP (CHAR_TABLE_REF \ + (Vword_wrap_chars, STRING_CHAR \ + (SDATA (it->string) + IT_STRING_BYTEPOS (*it))))) \ + || (it->s && !NILP (CHAR_TABLE_REF \ + (Vword_wrap_chars, \ + STRING_CHAR(it->s + IT_BYTEPOS (*it))))) \ || (IT_BYTEPOS (*it) < ZV_BYTE \ - && (*BYTE_POS_ADDR (IT_BYTEPOS (*it)) == ' ' \ - || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \ + && !NILP (CHAR_TABLE_REF \ + (Vword_wrap_chars, \ + (FETCH_CHAR(IT_BYTEPOS (*it)))))))) \ /* True means print newline to stdout before next mini-buffer message. */