• sebhoagie@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    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!!!

  • cosmologica101@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Also a thank you from my side. At the moment I am scanning an org table with over 350 rows and looking for doubles. Next I have to reference the doubles to the first of the doubles. And I discovered thanks to this magnificent tutorial that I can edit all doubles in one place, the occur buffer. And add the references through the edit mode of the occur buffer. Wow… this is really great.