Is there a way to do this for both non-Elisp and Elisp? For Elisp, the only thing I can think of is to create a new Dired buffer from a new list of files, but is there a better way?
Note: I want to do this without external dependency.
Mark files (e.g. with m, but there are lots of marking functions), and then remove them with k.
Edit: The scenario in question appears to be a virtual dired buffer (or similar) using a custom source of file listings, and the problem is how, after modifications to the initial dired contents, to refresh the dired buffer without also reverting to the original contents (i.e. how to retain the modifications, even after reverting the dired buffer).
dired-revert (which re-runs the command to generate the original list of files) does remember a bunch of things already, but not killed lines (and one can easily argue that remembering killed lines is a bad idea), but you could provide a custom
revert-buffer-function which did remember which lines had been killed.
I suspect if you're creating a dired buffer with custom contents, it's up to you to handle the
revert-buffer case with similar custom logic.
dired-narrow may be a good place to look, both for a way to filter dired content interactively and for exploring a method for implementing this in elisp. To do this, it seems that dired-narrow adds the invisible property to lines for files that don't match the search criteria and then deletes these lines.