Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
can you add swiper-the-thing-with-same-fontface #288
Swiper works line-wise, can't change that. So the thing could be in two places on a single line, with two different faces. That's one problem.
Additionally, faces apply to each character separately. Thing-at-point can have a different face for every single char. Suppose we restrict ourselves to only the cases where each entire match has face
One more thing, the faces don't get assigned if the buffer is huge. See the code of
Have a look at this code that's supposed to work, if we accept the above assumptions/restrictions:
(defvar swiper-like-this-face nil) (defun swiper-like-this (&optional initial-input) "`isearch' with an overview using `ivy'. When non-nil, INITIAL-INPUT is the initial search pattern." (interactive) (swiper--init) (setq swiper-like-this-face (plist-get (text-properties-at (point)) 'face)) (let ((candidates (swiper--candidates)) (preselect (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (minibuffer-allow-text-properties t)) (unwind-protect (ivy-read "Swiper: " candidates :initial-input initial-input :keymap swiper-map :preselect preselect :require-match t :update-fn #'swiper--update-input-ivy :unwind #'swiper--cleanup :action #'swiper--action :re-builder #'swiper--re-builder :matcher #'swiper--like-this-matcher :history 'swiper-history :caller 'swiper) (when (null ivy-exit) (goto-char swiper--opoint))))) (defun swiper--like-this-matcher (regexp candidates) "Return REGEXP-matching CANDIDATES. Skip some dotfiles unless `ivy-text' requires them." (cl-remove-if-not (lambda (x) (and (string-match regexp x) (let ((s (match-string 0 x)) (i 0)) (while (and (< i (length s)) (text-property-any i (1+ i) 'face swiper-like-this-face s)) (cl-incf i)) (eq i (length s))))) candidates))
If you like the code, I'll integrate it.