I made a function to filter unimportant lines from a CSS file I copied. I only want lines with the words "color" and "background" to remain in my buffer after the point the function is run. When I run the function it moves point to the next valid match but doesn't kill any lines. I want to kill all lines forward of point that don't match. I would run the command until the end of the buffer is reached if there is no convenient test to determine when the end of the buffer is reached. I'm new to Emacs LISP. How can I fix the function to kill the non-matching lines?
(defun my-color-filter () (interactive) (while (not (re-search-forward "^.*\\(?:color\\|background\\).*$" nil t)) (beginning-of-line) (kill-line)) )