From 0d88e93bdfd4859238e6b114eb24585aaef6560d Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 31 Jan 2023 13:43:53 +0100 Subject: compat-27: Mark compat--dired-get-marked-files as obsolete See https://github.com/magit/magit/pull/4867 --- NEWS.org | 1 + compat-27.el | 5 +- compat-macs.el | 2 +- compat-tests.el | 5 -- compat.texi | 190 +++++++++++++++++++++++++++----------------------------- 5 files changed, 96 insertions(+), 107 deletions(-) diff --git a/NEWS.org b/NEWS.org index c114b3b..04ae9cb 100644 --- a/NEWS.org +++ b/NEWS.org @@ -3,6 +3,7 @@ * Development - compat-26: Add ~make-temp-file~ with optional argument TEXT. +- compat-27: Mark ~compat-call dired-get-marked-files~ as obsolete. - compat-29: Add ~funcall-with-delayed-message~ and ~with-delayed-message~. - compat-29: Add ~ert-with-temp-file~ and ~ert-with-temp-directory~. - compat-29: Add ~set-transient-map~ with optional arguments MESSAGE and TIMEOUT. diff --git a/compat-27.el b/compat-27.el index 5d23529..2be27a6 100644 --- a/compat-27.el +++ b/compat-27.el @@ -566,9 +566,10 @@ The return value is a string (or nil in case we can’t find it)." ;;;; Defined in dired.el -(compat-defun dired-get-marked-files ;; +(compat-defun dired-get-marked-files (&optional localp arg filter distinguish-one-marked error) - "Handle optional argument ERROR." + "Obsolete function." + :obsolete "The compatibility function has been made obsolete." :feature dired :extended t (let ((result (dired-get-marked-files localp arg filter distinguish-one-marked))) diff --git a/compat-macs.el b/compat-macs.el index 4b2368b..25b1088 100644 --- a/compat-macs.el +++ b/compat-macs.el @@ -137,7 +137,7 @@ REST are attributes and the function BODY." (list def)) ,@(when obsolete `((make-obsolete - ',name ,(if (stringp obsolete) obsolete "No substitute") + ',defname ,(if (stringp obsolete) obsolete "No substitute") ,compat-macs--version)))))))) (defmacro compat-guard (cond &rest rest) diff --git a/compat-tests.el b/compat-tests.el index 2e2d0d2..7cd67d0 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -2713,11 +2713,6 @@ )) (should-not (string-match-p regexp-unmatchable str)))) -(declare-function dired-get-marked-files "dired") -(ert-deftest dired-get-marked-files () - (require 'dired) - (should-error (compat-call dired-get-marked-files nil nil nil nil t))) - (ert-deftest use-region () (with-temp-buffer (insert "abc\ndef\n") diff --git a/compat.texi b/compat.texi index b5fd2dc..b2f4878 100644 --- a/compat.texi +++ b/compat.texi @@ -1361,6 +1361,97 @@ This function creates an empty file named @var{filename}. As function signals an error. @end defun +@defun text-property-search-forward prop &optional value predicate not-current +Search for the next region that has text property @var{prop} set to +@var{value} according to @var{predicate}. + +This function is modeled after @code{search-forward} and friends in +that it moves point, but it returns a structure that describes the +match instead of returning it in @code{match-beginning} and friends. + +If the text property can't be found, the function returns @code{nil}. +If it's found, point is placed at the end of the region that has this +text property match, and a @code{prop-match} structure is returned. + +@var{predicate} can either be @code{t} (which is a synonym for +@code{equal}), @code{nil} (which means ``not equal''), or a predicate +that will be called with two parameters: The first is @var{value}, and +the second is the value of the text property we're inspecting. + +If @var{not-current}, if point is in a region where we have a match, +then skip past that and find the next instance instead. + +The @code{prop-match} structure has the following accessors: +@code{prop-match-beginning} (the start of the match), +@code{prop-match-end} (the end of the match), and +@code{prop-match-value} (the value of @var{property} at the start of +the match). + +In the examples below, imagine that you're in a buffer that looks like +this: + +@example +This is a bold and here's bolditalic and this is the end. +@end example + +That is, the ``bold'' words are the @code{bold} face, and the +``italic'' word is in the @code{italic} face. + +With point at the start: + +@lisp +(while (setq match (text-property-search-forward 'face 'bold t)) + (push (buffer-substring (prop-match-beginning match) + (prop-match-end match)) + words)) +@end lisp + +This will pick out all the words that use the @code{bold} face. + +@lisp +(while (setq match (text-property-search-forward 'face nil t)) + (push (buffer-substring (prop-match-beginning match) + (prop-match-end match)) + words)) +@end lisp + +This will pick out all the bits that have no face properties, which +will result in the list @samp{("This is a " "and here's " "and this is +the end")} (only reversed, since we used @code{push}). + +@lisp +(while (setq match (text-property-search-forward 'face nil nil)) + (push (buffer-substring (prop-match-beginning match) + (prop-match-end match)) + words)) +@end lisp + +This will pick out all the regions where @code{face} is set to +something, but this is split up into where the properties change, so +the result here will be @samp{("bold" "bold" "italic")}. + +For a more realistic example where you might use this, consider that +you have a buffer where certain sections represent URLs, and these are +tagged with @code{shr-url}. + +@lisp +(while (setq match (text-property-search-forward 'shr-url nil nil)) + (push (prop-match-value match) urls)) +@end lisp + +This will give you a list of all those URLs. + +@xref{elisp,,,Property Search}. +@end defun + +@defun text-property-search-backward prop &optional value predicate not-current +This is just like @code{text-property-search-forward}, but searches +backward instead. Point is placed at the beginning of the matched +region instead of the end, though. + +@xref{elisp,,,Property Search}. +@end defun + @subsection Extended Definitions These functions must be called explicitly via @code{compat-call}, since their calling convention or behavior was extended in Emacs 27.1: @@ -1483,105 +1574,6 @@ This compatibility version adds support to handle the optional second (@var{remote}) argument. @end defun -@defun compat-call@ dired-get-marked-files &optional localp arg filter distinguish-one-marked error -Return a list of file names that are @emph{marked} in a Dired buffer. - -This compatibility version handles the optional fifth (@var{error}) -argument, which signals an error if the list of found files is empty. -@code{error} can be a string with the error message. -@end defun - -@defun text-property-search-forward prop &optional value predicate not-current -Search for the next region that has text property @var{prop} set to -@var{value} according to @var{predicate}. - -This function is modeled after @code{search-forward} and friends in -that it moves point, but it returns a structure that describes the -match instead of returning it in @code{match-beginning} and friends. - -If the text property can't be found, the function returns @code{nil}. -If it's found, point is placed at the end of the region that has this -text property match, and a @code{prop-match} structure is returned. - -@var{predicate} can either be @code{t} (which is a synonym for -@code{equal}), @code{nil} (which means ``not equal''), or a predicate -that will be called with two parameters: The first is @var{value}, and -the second is the value of the text property we're inspecting. - -If @var{not-current}, if point is in a region where we have a match, -then skip past that and find the next instance instead. - -The @code{prop-match} structure has the following accessors: -@code{prop-match-beginning} (the start of the match), -@code{prop-match-end} (the end of the match), and -@code{prop-match-value} (the value of @var{property} at the start of -the match). - -In the examples below, imagine that you're in a buffer that looks like -this: - -@example -This is a bold and here's bolditalic and this is the end. -@end example - -That is, the ``bold'' words are the @code{bold} face, and the -``italic'' word is in the @code{italic} face. - -With point at the start: - -@lisp -(while (setq match (text-property-search-forward 'face 'bold t)) - (push (buffer-substring (prop-match-beginning match) - (prop-match-end match)) - words)) -@end lisp - -This will pick out all the words that use the @code{bold} face. - -@lisp -(while (setq match (text-property-search-forward 'face nil t)) - (push (buffer-substring (prop-match-beginning match) - (prop-match-end match)) - words)) -@end lisp - -This will pick out all the bits that have no face properties, which -will result in the list @samp{("This is a " "and here's " "and this is -the end")} (only reversed, since we used @code{push}). - -@lisp -(while (setq match (text-property-search-forward 'face nil nil)) - (push (buffer-substring (prop-match-beginning match) - (prop-match-end match)) - words)) -@end lisp - -This will pick out all the regions where @code{face} is set to -something, but this is split up into where the properties change, so -the result here will be @samp{("bold" "bold" "italic")}. - -For a more realistic example where you might use this, consider that -you have a buffer where certain sections represent URLs, and these are -tagged with @code{shr-url}. - -@lisp -(while (setq match (text-property-search-forward 'shr-url nil nil)) - (push (prop-match-value match) urls)) -@end lisp - -This will give you a list of all those URLs. - -@xref{elisp,,,Property Search}. -@end defun - -@defun text-property-search-backward prop &optional value predicate not-current -This is just like @code{text-property-search-forward}, but searches -backward instead. Point is placed at the beginning of the matched -region instead of the end, though. - -@xref{elisp,,,Property Search}. -@end defun - @subsection Missing Definitions Compat does not provide support for the following Lisp features implemented in 27.1: -- cgit v1.0