How to apply an elisp function to a specific file, which is not in an open buffer?
Eg (my/apply delete-duplicate-lines "~/tmp")
I think you want to do
(with-current-buffer (find-file-noselect "~/tmp")
(delete-duplicate-lines (point-min) (point-max))
(save-buffer))
If you want more information on how to programmatically operate on buffer contents read this section of the manual
If you want also to cleanup the buffer etc, you could use
(let ((file "~/tmp"))
(with-temp-file file
(insert-file-contents file)
(delete-duplicate-lines (point-min) (point-max))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With