• 1 Post
  • 4 Comments
Joined 1 year ago
cake
Cake day: October 5th, 2023

help-circle




  • Wow TIL about the occur behavior with prefix arg.

    I usually call my own wrapper command that runs occur for the selected region (instead of limiting to region) or the symbol at point (the most common case when programming). Thanks to your video I added prefix arg support:

    (defun hoagie-occur-sexp-or-region ()
      "Run occur for the sexp at point, or the active region.
    By default, occur _limits the search to the region_ if it is active."
      (interactive)
      (occur (if (use-region-p)
                 (buffer-substring-no-properties (region-beginning)
                                                 (region-end))
               (thing-at-point 'sexp t))
             (when current-prefix-arg
    	       (prefix-numeric-value current-prefix-arg))))
    

    Thank you!!!