Tags: patch X-Debbugs-Cc: Stefan Monnier After evaluating (add-hook 'occur-hook 'occur-rename-buffer) then selecting a region, and running 'M-x occur' with any string in the active region, signals the error: (wrong-type-argument bufferp #) It seems the attached patch is the right way to fix this. Also Cc:ing Stefan with a question about occur--garbage-collect-revert-args: trying to revert the Occur buffer created from an active region removes the source buffer name from the Occur buffer name. For example, (after applying the attached patch) 'M-x occur' on the active region in *scratch* creates the buffer *Occur: *scratch**. But reverting the Occur buffer with 'g' removes the *scratch* buffer name, and renames the Occur buffer to *Occur: *. This is because of two lines in occur-1: (occur--garbage-collect-revert-args) (setq occur-revert-arguments (list regexp nlines bufs)) where occur--garbage-collect-revert-args deletes the overlay with the buffer name *scratch*, and later occur-rename-buffer can't get the original buffer name from occur-revert-arguments. And I don't know how to fix this.