From c70681004f18d20c81a9720aaf083712b9887602 Mon Sep 17 00:00:00 2001 From: James Nguyen Date: Sun, 5 Nov 2017 09:22:10 -0800 Subject: [PATCH] Add evil-occur --- evil-collection.el | 11 +++++++- evil-occur.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 evil-occur.el diff --git a/evil-collection.el b/evil-collection.el index 10911c1..5b0a904 100644 --- a/evil-collection.el +++ b/evil-collection.el @@ -46,7 +46,16 @@ (evil-edebug-set-keys)) (with-eval-after-load 'ibuffer (require 'evil-ibuffer) - (evil-ibuffer-set-keys))) + (evil-ibuffer-set-keys)) + + (if (<= emacs-major-version 25) + (progn + (require 'evil-occur) + (evil-occur-set-keys)) + (with-eval-after-load 'replace + (require 'evil-occur) + (evil-occur-set-keys))) + ) ;;;###autoload (defun evil-collection-extra-modes-init () diff --git a/evil-occur.el b/evil-occur.el new file mode 100644 index 0000000..22e523d --- /dev/null +++ b/evil-occur.el @@ -0,0 +1,64 @@ +;;; evil-occur.el --- Evil integration for occur. -*- lexical-binding: t -*- + +;; Copyright (C) 2017 James Nguyen + +;; Author: James Nguyen +;; Maintainer: James Nguyen +;; URL: https://github.com/jojojames/evil-collection +;; Version: 0.0.1 +;; Package-Requires: ((emacs "25.1")) +;; Keywords: evil, occur, emacs +;; HomePage: https://github.com/jojojames/evil-collection + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; Evil integration for `occur'. + +;;; Code: +(require 'evil-collection-util) + +(when (> emacs-major-version 25) + (require 'replace)) + +(defun evil-occur-set-keys () + (setq evil-emacs-state-modes + (remove 'occur-mode evil-emacs-state-modes)) + + (evil-define-key 'normal occur-mode-map + ;; Like `wdired-mode'. + "\C-x\C-q" 'occur-edit-mode + + [mouse-2] 'occur-mode-mouse-goto + "\C-c\C-c" 'occur-mode-goto-occurrence + "\C-m" 'occur-mode-goto-occurrence + "o" 'occur-mode-goto-occurrence-other-window + "\C-o" 'occur-mode-display-occurrence + "\C-j" 'occur-next + "\C-k" 'occur-prev + "r" 'occur-rename-buffer + "c" 'clone-buffer + "\C-c\C-f" 'next-error-follow-minor-mode) + + (evil-define-key 'normal occur-edit-mode-map + ;; Like `wdired-mode'. + "\C-x\C-q" 'occur-cease-edit + + [mouse-2] 'occur-mode-mouse-goto + "\C-c\C-c" 'occur-cease-edit + "\C-o" 'occur-mode-display-occurrence + "\C-c\C-f" 'next-error-follow-minor-mode)) + +(provide 'evil-occur) +;;; evil-occur.el ends here