[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 8c66839789 1/4: compat-28: Add make-separator-li
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 8c66839789 1/4: compat-28: Add make-separator-line |
Date: |
Mon, 9 Jan 2023 09:57:27 -0500 (EST) |
branch: externals/compat
commit 8c66839789e2de1ddcd9abd323dcfe4433a3fd84
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
compat-28: Add make-separator-line
---
compat-28.el | 9 +++++++++
compat-tests.el | 6 ++++++
compat.texi | 7 +++++--
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/compat-28.el b/compat-28.el
index a39f148909..feffa1e6ff 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -279,6 +279,15 @@ and BLUE, is normalized to have its value in [0,65535]."
(<= 0 b) (<= b 65535))
(list r g b))))))))
+;;;; Defined in simple.el
+
+(compat-defun make-separator-line (&optional length) ;; <OK>
+ "Make a string appropriate for usage as a visual separator line.
+If LENGTH is nil, use the window width."
+ (concat (propertize (make-string (or length (1- (window-width))) ?-)
+ 'face 'separator-line)
+ "\n"))
+
;;;; Defined in subr.el
;;* INCOMPLETE FEATURE: Should handle multibyte regular expressions
diff --git a/compat-tests.el b/compat-tests.el
index 6f4d2dc929..e1f2aea15c 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -60,6 +60,12 @@
(setq list (funcall sym list "first" 1 #'string=))
(should (eq (compat-call plist-get list "first" #'string=) 1))))
+(ert-deftest make-separator-line ()
+ (should-equal (length (make-separator-line 10)) 11)
+ (should (string-suffix-p "\n" (make-separator-line 10)))
+ (should (string-suffix-p "\n" (make-separator-line)))
+ (should-equal (replace-regexp-in-string "[^\n]" "" (make-separator-line))
"\n"))
+
(ert-deftest pos-bol ()
(with-temp-buffer
(insert (propertize "one" 'field 1)
diff --git a/compat.texi b/compat.texi
index c0cb17bc9d..6d3a45e105 100644
--- a/compat.texi
+++ b/compat.texi
@@ -1494,6 +1494,11 @@ This function ignores any @var{arguments} and returns
@code{t}.
@xref{Calling Functions,,,elisp}.
@end defun
+@defun make-separator-line &optional LENGTH
+Make a string appropriate for usage as a visual separator line.
+If LENGTH is nil, use the window width.
+@end defun
+
@c copied from lispref/text.texi
@defun insert-into-buffer to-buffer &optional start end
This is like @code{insert-buffer-substring}, but works in the opposite
@@ -1993,8 +1998,6 @@ The function @code{mail-header-parse-addresses-lax}.
@item
The function @code{mail-header-parse-address-lax}.
@item
-The function @code{make-separator-line}.
-@item
The function @code{num-processors}.
@item
The function @code{object-intervals}.