commit be127caa5e0716f0e0985e3613764e2e89d2d9e9 parent 12fb8fa4669d254650066dc495273a26373c6f36 Author: Vincent Demeester <vincent@sbr.pm> Date: Wed, 19 Aug 2020 10:13:18 +0200 tools/emacs: configure replace/occur … and add a way to visit url in buffer Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | tools/emacs/config/config-navigating.el | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git a/tools/emacs/config/config-navigating.el b/tools/emacs/config/config-navigating.el @@ -28,6 +28,51 @@ ;; focus the Line and also works as a variant of C-l. :bind ("C-c L" . vde/scroll-centre-cursor-mode)) +(use-package replace + :config + (setq list-matching-lines-jump-to-current-line t) + ;; See my "Modus themes" for these inherited faces + (setq list-matching-lines-buffer-name-face + '(:inherit modus-theme-intense-neutral :weight bold)) + (setq list-matching-lines-current-line-face + '(:inherit modus-theme-special-mild)) + + (defun vde/occur-url () + "Produce list with all URLs in the current buffer." + (interactive) + (let ((urls browse-url-button-regexp)) + (occur urls "\\&"))) + + (defun vde/occur-browse-url-in-buffer () + "Run `eww' on a URL from the buffer using completion. +Also see `vde/occur-url'." + (interactive) + (let ((matches nil)) + (save-excursion + (goto-char (point-min)) + (while (search-forward-regexp browse-url-button-regexp nil t) + (push (match-string-no-properties 0) matches))) + (icomplete-vertical-do + (:height (/ (frame-height) 4) :separator 'dotted-line) + (eww + (completing-read "Browse URL: " matches nil t))))) + + (defun vde/occur-visit-or-list-urls (&optional arg) + "Wrap `vde/occur-visit-or-list-urls' and `vde/occur-url'. +Meant to economise on key bindings." + (interactive "P") + (if arg + (vde/occur-url) + (vde/occur-browse-url-in-buffer))) + + :hook ((occur-mode-hook . hl-line-mode) + (occur-mode-hook . (lambda () + (toggle-truncate-lines t)))) + :bind (("M-s u" . vde/occur-visit-or-list-urls) + ("M-s M-o" . multi-occur) + :map occur-mode-map + ("t" . toggle-truncate-lines))) + (use-package avy :disabled :bind (("C-c j" . avy-goto-word-1)