Skip to content

Instantly share code, notes, and snippets.

@knollet
Created November 3, 2023 15:07
Show Gist options
  • Save knollet/16927be87e51e07ef2ce964be9d02603 to your computer and use it in GitHub Desktop.
Save knollet/16927be87e51e07ef2ce964be9d02603 to your computer and use it in GitHub Desktop.
(defun buffer-minus (subtrahend)
"This function takes the name of a buffer,
and removes every line in the current buffer present in the given one.
The lines are removed with `delete-matching-lines' which uses the given string as a regex
but it is good enough..."
(interactive "*b")
(let ((sub-list
(with-current-buffer subtrahend
(string-split (buffer-string) "\n" t "[\t ]+"))))
(mapc (lambda (x)
(goto-char (point-min))
(delete-matching-lines x))
sub-list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment