aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-04-28 18:09:10 +0200
committerLars Ingebrigtsen2016-04-28 18:09:10 +0200
commitc3ac2cbf73516d2414c845087cac8fc7ec1ce5d7 (patch)
tree6767ba0ab44954d0b8363bf6024993d48d758232
parent214f85a0a68b96a552ca605d601b33f6eef5c4ca (diff)
downloademacs-c3ac2cbf73516d2414c845087cac8fc7ec1ce5d7.tar.gz
emacs-c3ac2cbf73516d2414c845087cac8fc7ec1ce5d7.zip
Add a new face for non-breaking hyphen characters
* doc/emacs/display.texi (Standard Faces): Mention nobreak-hyphen. (Text Display): Ditto. * lisp/faces.el (nobreak-hyphen): New face (bug#12048). * src/xdisp.c (get_next_display_element): Use it instead of the escape-glyph face. * src/xdisp.c (syms_of_xdisp): New symbil Qnobreak_hyphen.
-rw-r--r--doc/emacs/display.texi5
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/faces.el14
-rw-r--r--src/xdisp.c28
4 files changed, 35 insertions, 15 deletions
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 8039291298c..89f5bec3639 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -657,6 +657,9 @@ The face for displaying control characters and escape sequences
657@item nobreak-space 657@item nobreak-space
658The face for displaying no-break space characters (@pxref{Text 658The face for displaying no-break space characters (@pxref{Text
659Display}). 659Display}).
660@item nobreak-hyphen
661The face for displaying no-break hyphen characters (@pxref{Text
662Display}).
660@end table 663@end table
661 664
662 The following faces control the appearance of parts of the Emacs 665 The following faces control the appearance of parts of the Emacs
@@ -1481,7 +1484,7 @@ characters. To deal with this problem, Emacs displays such characters
1481specially: it displays @code{U+00A0} (no-break space) with the 1484specially: it displays @code{U+00A0} (no-break space) with the
1482@code{nobreak-space} face, and it displays @code{U+00AD} (soft 1485@code{nobreak-space} face, and it displays @code{U+00AD} (soft
1483hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking 1486hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking
1484hyphen) with the @code{escape-glyph} face. To disable this, change 1487hyphen) with the @code{nobreak-hyphen} face. To disable this, change
1485the variable @code{nobreak-char-display} to @code{nil}. If you give 1488the variable @code{nobreak-char-display} to @code{nil}. If you give
1486this variable a non-@code{nil} and non-@code{t} value, Emacs instead 1489this variable a non-@code{nil} and non-@code{t} value, Emacs instead
1487displays such characters as a highlighted backslash followed by a 1490displays such characters as a highlighted backslash followed by a
diff --git a/etc/NEWS b/etc/NEWS
index da68ed597db..c7bc34fe0e3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -56,6 +56,9 @@ affected by this, as SGI stopped supporting IRIX in December 2013.
56 56
57* Changes in Emacs 25.2 57* Changes in Emacs 25.2
58 58
59** Non-breaking hypens are now displayed with the `nobreak-hyphen'
60face instead of the `escape-glyph' face.
61
59--- 62---
60** `C-x h' (`mark-whole-buffer') will now avoid marking the prompt 63** `C-x h' (`mark-whole-buffer') will now avoid marking the prompt
61part of minibuffers. 64part of minibuffers.
diff --git a/lisp/faces.el b/lisp/faces.el
index c9cc611a97a..552a7be9c93 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2428,13 +2428,21 @@ If you set `term-file-prefix' to nil, this function does nothing."
2428 :version "22.1") 2428 :version "22.1")
2429 2429
2430(defface nobreak-space 2430(defface nobreak-space
2431 '((((class color) (min-colors 88)) :inherit escape-glyph :underline t) 2431 '((((background dark)) :foreground "cyan")
2432 (((class color) (min-colors 8)) :background "magenta") 2432 (((type pc)) :foreground "magenta")
2433 (t :inverse-video t)) 2433 (t :foreground "brown"))
2434 "Face for displaying nobreak space." 2434 "Face for displaying nobreak space."
2435 :group 'basic-faces 2435 :group 'basic-faces
2436 :version "22.1") 2436 :version "22.1")
2437 2437
2438(defface nobreak-hyphen
2439 '((((background dark)) :foreground "cyan")
2440 (((type pc)) :foreground "magenta")
2441 (t :foreground "brown"))
2442 "Face for displaying nobreak hyphens."
2443 :group 'basic-faces
2444 :version "25.2")
2445
2438(defgroup mode-line-faces nil 2446(defgroup mode-line-faces nil
2439 "Faces used in the mode line." 2447 "Faces used in the mode line."
2440 :group 'mode-line 2448 :group 'mode-line
diff --git a/src/xdisp.c b/src/xdisp.c
index 4f33c0d518a..d0ff95257ce 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7080,6 +7080,19 @@ get_next_display_element (struct it *it)
7080 goto display_control; 7080 goto display_control;
7081 } 7081 }
7082 7082
7083 /* Handle non-ascii hyphens in the mode where it only
7084 gets highlighting. */
7085
7086 if (nonascii_hyphen_p && EQ (Vnobreak_char_display, Qt))
7087 {
7088 /* Merge `nobreak-space' into the current face. */
7089 face_id = merge_faces (it->f, Qnobreak_hyphen, 0,
7090 it->face_id);
7091 XSETINT (it->ctl_chars[0], '-');
7092 ctl_len = 1;
7093 goto display_control;
7094 }
7095
7083 /* Handle sequences that start with the "escape glyph". */ 7096 /* Handle sequences that start with the "escape glyph". */
7084 7097
7085 /* the default escape glyph is \. */ 7098 /* the default escape glyph is \. */
@@ -7096,15 +7109,6 @@ get_next_display_element (struct it *it)
7096 ? merge_faces (it->f, Qt, lface_id, it->face_id) 7109 ? merge_faces (it->f, Qt, lface_id, it->face_id)
7097 : merge_escape_glyph_face (it)); 7110 : merge_escape_glyph_face (it));
7098 7111
7099 /* Draw non-ASCII hyphen with just highlighting: */
7100
7101 if (nonascii_hyphen_p && EQ (Vnobreak_char_display, Qt))
7102 {
7103 XSETINT (it->ctl_chars[0], '-');
7104 ctl_len = 1;
7105 goto display_control;
7106 }
7107
7108 /* Draw non-ASCII space/hyphen with escape glyph: */ 7112 /* Draw non-ASCII space/hyphen with escape glyph: */
7109 7113
7110 if (nonascii_space_p || nonascii_hyphen_p) 7114 if (nonascii_space_p || nonascii_hyphen_p)
@@ -31198,8 +31202,10 @@ They are still logged to the *Messages* buffer. */);
31198 /* Name and number of the face used to highlight escape glyphs. */ 31202 /* Name and number of the face used to highlight escape glyphs. */
31199 DEFSYM (Qescape_glyph, "escape-glyph"); 31203 DEFSYM (Qescape_glyph, "escape-glyph");
31200 31204
31201 /* Name and number of the face used to highlight non-breaking spaces. */ 31205 /* Name and number of the face used to highlight non-breaking
31206 spaces/hyphens. */
31202 DEFSYM (Qnobreak_space, "nobreak-space"); 31207 DEFSYM (Qnobreak_space, "nobreak-space");
31208 DEFSYM (Qnobreak_hyphen, "nobreak-hyphen");
31203 31209
31204 /* The symbol 'image' which is the car of the lists used to represent 31210 /* The symbol 'image' which is the car of the lists used to represent
31205 images in Lisp. Also a tool bar style. */ 31211 images in Lisp. Also a tool bar style. */
@@ -31311,7 +31317,7 @@ The face used for trailing whitespace is `trailing-whitespace'. */);
31311 doc: /* Control highlighting of non-ASCII space and hyphen chars. 31317 doc: /* Control highlighting of non-ASCII space and hyphen chars.
31312If the value is t, Emacs highlights non-ASCII chars which have the 31318If the value is t, Emacs highlights non-ASCII chars which have the
31313same appearance as an ASCII space or hyphen, using the `nobreak-space' 31319same appearance as an ASCII space or hyphen, using the `nobreak-space'
31314or `escape-glyph' face respectively. 31320or `nobreak-hyphen' face respectively.
31315 31321
31316U+00A0 (no-break space), U+00AD (soft hyphen), U+2010 (hyphen), and 31322U+00A0 (no-break space), U+00AD (soft hyphen), U+2010 (hyphen), and
31317U+2011 (non-breaking hyphen) are affected. 31323U+2011 (non-breaking hyphen) are affected.