(require 'fill-new) (require 'cl-lib) (defun do-replace-string (from to) (interactive "sFrom: \nsTo: ") (save-excursion (let ((hits 0) (end (if mark-active (region-end) (point-max))) ) (while (search-forward from (point-max) t) ; NOERROR (cl-incf hits) (replace-match to) ) (message "Replaced %s hits." hits) )) ) (defun prepare-wiki-article-for-print () (interactive) (do-replace-string "From Wikipedia, the free encyclopedia" "") (do-replace-string "Jump to: navigation, search" "") (do-replace-string "\\[edit\\]" "") (fill-buffer) )