[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7785463c8e 1/5: Add new bidi-string-strip-control-characters func
From: |
Lars Ingebrigtsen |
Subject: |
master 7785463c8e 1/5: Add new bidi-string-strip-control-characters function |
Date: |
Thu, 20 Jan 2022 02:38:31 -0500 (EST) |
branch: master
commit 7785463c8edbd83e0a7a4c2fe5c233949aa570f2
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add new bidi-string-strip-control-characters function
* lisp/international/characters.el
(bidi-string-strip-control-characters): New function.
---
etc/NEWS | 4 ++++
lisp/international/characters.el | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 47dbfba9c0..ac3b1dccf9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -960,6 +960,10 @@ The input must be encoded text.
* Lisp Changes in Emacs 29.1
+** New function 'bidi-string-strip-control-characters'.
+This utility function is meant for displaying strings when it's
+essential that there's no bidirectional context.
+
---
** The Gnus range functions have been moved to a new library, range.el.
All the old names have been made obsolete.
diff --git a/lisp/international/characters.el b/lisp/international/characters.el
index ce23e995c1..63ac455ea6 100644
--- a/lisp/international/characters.el
+++ b/lisp/international/characters.el
@@ -1541,6 +1541,12 @@ Setup `char-width-table' appropriate for non-CJK
language environment."
#x2069) ; ?\N{pop directional isolate}
"List of bidirectional control characters.")
+(defun bidi-string-strip-control-characters (string)
+ "Strip bidi control characters from STRING and return the result."
+ (apply #'string (seq-filter (lambda (char)
+ (not (memq char bidi-control-characters)))
+ string)))
+
(defun update-glyphless-char-display (&optional variable value)
"Make the setting of `glyphless-char-display-control' take effect.
This function updates the char-table `glyphless-char-display',