emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c3ac2cb 3/3: Add a new face for non-breaking hyphen


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master c3ac2cb 3/3: Add a new face for non-breaking hyphen characters
Date: Thu, 28 Apr 2016 16:10:00 +0000

branch: master
commit c3ac2cbf73516d2414c845087cac8fc7ec1ce5d7
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 doc/emacs/display.texi |    5 ++++-
 etc/NEWS               |    3 +++
 lisp/faces.el          |   14 +++++++++++---
 src/xdisp.c            |   28 +++++++++++++++++-----------
 4 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 8039291..89f5bec 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -657,6 +657,9 @@ The face for displaying control characters and escape 
sequences
 @item nobreak-space
 The face for displaying no-break space characters (@pxref{Text
 Display}).
address@hidden nobreak-hyphen
+The face for displaying no-break hyphen characters (@pxref{Text
+Display}).
 @end table
 
   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
 specially: it displays @code{U+00A0} (no-break space) with the
 @code{nobreak-space} face, and it displays @code{U+00AD} (soft
 hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking
-hyphen) with the @code{escape-glyph} face.  To disable this, change
+hyphen) with the @code{nobreak-hyphen} face.  To disable this, change
 the variable @code{nobreak-char-display} to @code{nil}.  If you give
 this variable a address@hidden and address@hidden value, Emacs instead
 displays such characters as a highlighted backslash followed by a
diff --git a/etc/NEWS b/etc/NEWS
index da68ed5..c7bc34f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -56,6 +56,9 @@ affected by this, as SGI stopped supporting IRIX in December 
2013.
 
 * Changes in Emacs 25.2
 
+** Non-breaking hypens are now displayed with the `nobreak-hyphen'
+face instead of the `escape-glyph' face.
+
 ---
 ** `C-x h' (`mark-whole-buffer') will now avoid marking the prompt
 part of minibuffers.
diff --git a/lisp/faces.el b/lisp/faces.el
index c9cc611..552a7be 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."
   :version "22.1")
 
 (defface nobreak-space
-  '((((class color) (min-colors 88)) :inherit escape-glyph :underline t)
-    (((class color) (min-colors 8)) :background "magenta")
-    (t :inverse-video t))
+  '((((background dark)) :foreground "cyan")
+    (((type pc)) :foreground "magenta")
+    (t :foreground "brown"))
   "Face for displaying nobreak space."
   :group 'basic-faces
   :version "22.1")
 
+(defface nobreak-hyphen
+  '((((background dark)) :foreground "cyan")
+    (((type pc)) :foreground "magenta")
+    (t :foreground "brown"))
+  "Face for displaying nobreak hyphens."
+  :group 'basic-faces
+  :version "25.2")
+
 (defgroup mode-line-faces nil
   "Faces used in the mode line."
   :group 'mode-line
diff --git a/src/xdisp.c b/src/xdisp.c
index 4f33c0d..d0ff952 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7080,6 +7080,19 @@ get_next_display_element (struct it *it)
                  goto display_control;
                }
 
+             /* Handle non-ascii hyphens in the mode where it only
+                gets highlighting.  */
+
+             if (nonascii_hyphen_p && EQ (Vnobreak_char_display, Qt))
+               {
+                 /* Merge `nobreak-space' into the current face.  */
+                 face_id = merge_faces (it->f, Qnobreak_hyphen, 0,
+                                        it->face_id);
+                 XSETINT (it->ctl_chars[0], '-');
+                 ctl_len = 1;
+                 goto display_control;
+               }
+
              /* Handle sequences that start with the "escape glyph".  */
 
              /* the default escape glyph is \.  */
@@ -7096,15 +7109,6 @@ get_next_display_element (struct it *it)
                         ? merge_faces (it->f, Qt, lface_id, it->face_id)
                         : merge_escape_glyph_face (it));
 
-             /* Draw non-ASCII hyphen with just highlighting: */
-
-             if (nonascii_hyphen_p && EQ (Vnobreak_char_display, Qt))
-               {
-                 XSETINT (it->ctl_chars[0], '-');
-                 ctl_len = 1;
-                 goto display_control;
-               }
-
              /* Draw non-ASCII space/hyphen with escape glyph: */
 
              if (nonascii_space_p || nonascii_hyphen_p)
@@ -31198,8 +31202,10 @@ They are still logged to the *Messages* buffer.  */);
   /* Name and number of the face used to highlight escape glyphs.  */
   DEFSYM (Qescape_glyph, "escape-glyph");
 
-  /* Name and number of the face used to highlight non-breaking spaces.  */
+  /* Name and number of the face used to highlight non-breaking
+     spaces/hyphens.  */
   DEFSYM (Qnobreak_space, "nobreak-space");
+  DEFSYM (Qnobreak_hyphen, "nobreak-hyphen");
 
   /* The symbol 'image' which is the car of the lists used to represent
      images in Lisp.  Also a tool bar style.  */
@@ -31311,7 +31317,7 @@ The face used for trailing whitespace is 
`trailing-whitespace'.  */);
     doc: /* Control highlighting of non-ASCII space and hyphen chars.
 If the value is t, Emacs highlights non-ASCII chars which have the
 same appearance as an ASCII space or hyphen, using the `nobreak-space'
-or `escape-glyph' face respectively.
+or `nobreak-hyphen' face respectively.
 
 U+00A0 (no-break space), U+00AD (soft hyphen), U+2010 (hyphen), and
 U+2011 (non-breaking hyphen) are affected.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]