From 3acc40be3a0076fed1ddfc76c04eaf46b88c9fd2 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 25 Feb 2015 23:04:38 -0500 Subject: Add Oleh Krehel's variant of occur --- lisp/init-editing.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lisp') diff --git a/lisp/init-editing.el b/lisp/init-editing.el index d8a4381..6e66b9d 100644 --- a/lisp/init-editing.el +++ b/lisp/init-editing.el @@ -135,6 +135,18 @@ and '<<<' mark the bounds of the narrowed region. (call-interactively 'goto-line)) (linum-mode -1))) +;; Modified from http://oremacs.com/2015/01/26/occur-dwim/. +(defun km/occur () + "Call `occur' with active region or symbol at point." + (interactive) + (push (if (use-region-p) + (buffer-substring-no-properties + (region-beginning) + (region-end)) + (thing-at-point 'symbol)) + regexp-history) + (call-interactively 'occur)) + (global-set-key (kbd "C-x \\") 'align-regexp) (global-set-key (kbd "C-;") 'er/expand-region) @@ -155,6 +167,8 @@ and '<<<' mark the bounds of the narrowed region. (define-key narrow-map "c" 'km/narrow-to-comment-heading) +;; Override default `occur'. +(define-key search-map "o" 'km/occur) (define-key search-map "s" 'query-replace) (define-key search-map "S" 'replace-string) (define-key search-map "r" 'query-replace-regexp) -- cgit v1.2.3