diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-17 23:49:05 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-17 23:52:49 +0100 |
| commit | 12e2d82a5a469aabadb1082678f7a33539779d8b (patch) | |
| tree | 9d76ea346e2ab673c355516535d4570822415d04 | |
| parent | 64dc62259f1adc6ae70a38f7a874cee48dfa3626 (diff) | |
compat-29: Add delete-line
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-29.el | 28 | ||||
| -rw-r--r-- | compat-tests.el | 7 | ||||
| -rw-r--r-- | compat.texi | 5 |
4 files changed, 29 insertions, 12 deletions
@@ -11,6 +11,7 @@ - compat-29: Add ~plist-get~ generalized variable. - compat-29: Add ~plistp~. - compat-29: Add ~list-of-strings-p~. +- compat-29: Add ~delete-line~. * Release of "Compat" Version 29.1.2.0 diff --git a/compat-29.el b/compat-29.el index e84c628..9373c0c 100644 --- a/compat-29.el +++ b/compat-29.el @@ -84,18 +84,6 @@ Unibyte strings are converted to multibyte for comparison." (declare (pure t) (side-effect-free t)) (eq t (compare-strings string1 0 nil string2 0 nil t))) -(compat-defun list-of-strings-p (object) ;; <compat-tests:lists-of-strings-p> - "Return t if OBJECT is nil or a list of strings." - (declare (pure t) (side-effect-free t)) - (while (and (consp object) (stringp (car object))) - (setq object (cdr object))) - (null object)) - -(compat-defun plistp (object) ;; <compat-tests:plistp> - "Non-nil if and only if OBJECT is a valid plist." - (let ((len (proper-list-p object))) - (and len (zerop (% len 2))))) - (compat-defun plist-get (plist prop &optional predicate) ;; <compat-tests:plist-get> "Handle optional argument PREDICATE." :explicit t @@ -183,6 +171,22 @@ This function does not move point. Also see `line-end-position'." ;;;; Defined in subr.el +(compat-defun list-of-strings-p (object) ;; <compat-tests:lists-of-strings-p> + "Return t if OBJECT is nil or a list of strings." + (declare (pure t) (side-effect-free t)) + (while (and (consp object) (stringp (car object))) + (setq object (cdr object))) + (null object)) + +(compat-defun plistp (object) ;; <compat-tests:plistp> + "Non-nil if and only if OBJECT is a valid plist." + (let ((len (proper-list-p object))) + (and len (zerop (% len 2))))) + +(compat-defun delete-line () ;; <compat-tests:delete-line> + "Delete the current line." + (delete-region (pos-bol) (pos-bol 2))) + (compat-defmacro with-memoization (place &rest code) ;; <compat-tests:with-memoization> "Return the value of CODE and stash it in PLACE. If PLACE's value is non-nil, then don't bother evaluating CODE diff --git a/compat-tests.el b/compat-tests.el index a15f3f5..1b61570 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -906,6 +906,13 @@ (should (string-prefix-p "compat" (symbol-name (gensym "compat")))) (should-equal gensym-counter (+ orig 3)))) +(ert-deftest delete-line () + (with-temp-buffer + (insert "first\nsecond\nthird\n") + (goto-char 7) + (delete-line) + (should (equal (buffer-string) "first\nthird\n")))) + (ert-deftest list-of-strings-p () (should-not (list-of-strings-p 1)) (should (list-of-strings-p nil)) diff --git a/compat.texi b/compat.texi index 6aec7f4..bb86925 100644 --- a/compat.texi +++ b/compat.texi @@ -2013,6 +2013,11 @@ that there will be the need for changes, so use these functions with care. @c based on lisp/subr.el +@defun delete-line +Delete the current line. +@end defun + +@c based on lisp/subr.el @defun list-of-strings-p object Return @code{t} if @var{object} is @code{nil} or a list of strings. @end defun |
