diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/shortdoc.el | 9 | ||||
| -rw-r--r-- | lisp/subr.el | 26 |
2 files changed, 34 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index 70583e08dbd..af15d15523d 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el | |||
| @@ -385,8 +385,15 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'), | |||
| 385 | :eval (reverse "foo")) | 385 | :eval (reverse "foo")) |
| 386 | (substring-no-properties | 386 | (substring-no-properties |
| 387 | :eval (substring-no-properties (propertize "foobar" 'face 'bold) 0 3)) | 387 | :eval (substring-no-properties (propertize "foobar" 'face 'bold) 0 3)) |
| 388 | (string-common-prefix | ||
| 389 | :eval (string-common-prefix '("foobar" "foozot")) | ||
| 390 | :eval (string-common-prefix '("foobar" "foozot" "gazonk")) | ||
| 391 | :eval (string-common-prefix nil)) | ||
| 388 | (try-completion | 392 | (try-completion |
| 389 | :eval (try-completion "foo" '("foobar" "foozot" "gazonk"))) | 393 | :eval (try-completion "f" '("foobar" "foozot" "gazonk")) |
| 394 | :eval (try-completion "f" '("foo")) | ||
| 395 | :eval (try-completion "foo" '("foo")) | ||
| 396 | :eval (try-completion "foo" nil)) | ||
| 390 | "Unicode Strings" | 397 | "Unicode Strings" |
| 391 | (string-glyph-split | 398 | (string-glyph-split |
| 392 | :eval (string-glyph-split "Hello, πΌπ»π§πΌβπ€βπ§π»")) | 399 | :eval (string-glyph-split "Hello, πΌπ»π§πΌβπ€βπ§π»")) |
diff --git a/lisp/subr.el b/lisp/subr.el index d307a07f05b..a5191ba74f3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -6129,6 +6129,32 @@ attention to letter-case differences." | |||
| 6129 | (eq t (compare-strings suffix nil nil | 6129 | (eq t (compare-strings suffix nil nil |
| 6130 | string start-pos nil ignore-case))))) | 6130 | string start-pos nil ignore-case))))) |
| 6131 | 6131 | ||
| 6132 | (defun string-common-prefix (strings &optional ignore-case) | ||
| 6133 | "Return the longest common prefix from a collection of STRINGS. | ||
| 6134 | |||
| 6135 | Return \"\" if there is no common prefix or if STRINGS is nil. | ||
| 6136 | If STRINGS contains exactly one string, return that string. | ||
| 6137 | |||
| 6138 | If IGNORE-CASE is non-nil, letter case is ignored when matching the | ||
| 6139 | substrings, but no guarantee is made about the letter-case of the return | ||
| 6140 | value, except that it comes from one of the members of STRINGS. | ||
| 6141 | |||
| 6142 | STRINGS may be a list of strings or any other collection type supported | ||
| 6143 | by `try-completion' and `all-completions' (which see). To find the | ||
| 6144 | common prefix of a subset of STRINGS (filtered by string prefix, regular | ||
| 6145 | expression, or predicate function), use `all-completions' to perform the | ||
| 6146 | filtering and pass the result to `string-common-prefix' as STRINGS." | ||
| 6147 | ;; Note that `try-completion' is not affected by `completion-styles'. | ||
| 6148 | (let* ((completion-ignore-case ignore-case) | ||
| 6149 | (completion-regexp-list nil) | ||
| 6150 | (prefix (try-completion "" strings))) | ||
| 6151 | (if (stringp prefix) | ||
| 6152 | prefix | ||
| 6153 | ;; nil means there was no match. | ||
| 6154 | ;; t means that the "" argument was an exact match. | ||
| 6155 | ;; We always return a string, so we treat both cases the same. | ||
| 6156 | ""))) | ||
| 6157 | |||
| 6132 | (defun bidi-string-mark-left-to-right (str) | 6158 | (defun bidi-string-mark-left-to-right (str) |
| 6133 | "Return a string that can be safely inserted in left-to-right text. | 6159 | "Return a string that can be safely inserted in left-to-right text. |
| 6134 | 6160 | ||