I wish to remove selection programatically, what is the proper way of doing this? Specifically I wish to write a function to make swiper search in buffer with selected text, but it needs to remove selection before open swiper window. Here's the function
(defun sandric/swiper-or-region (beg end) "Swiper region or 'empty string' if none highlighted." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list nil nil))) (if (and beg end) (progn (keyboard-quit) (swiper (buffer-substring-no-properties beg end))) (swiper)))
As you can see there's a
(keyboard-quit) call before swiper command to open swiper buffer, but with that it simply discards swiper buffer as if ESC was called already after swiper buffer appeared. So I need to find a better way.