Giter Club home page Giter Club logo

anzu's Introduction

anzu.el

melpa badge melpa stable badge circleci badge

Introduction

anzu.el is an Emacs port of anzu.vim. anzu.el provides a minor mode which displays current match and total matches information in the mode-line in various search modes.

Screenshot

Screencast of anzu.gif

Requirements

  • Emacs 24 or higher
  • cl-lib 0.5 or higher (you don't need to install cl-lib if you use Emacs 24.3 or higher)

Installation

You can install anzu.el from MELPA with package.el

 M-x package-install anzu

Basic Usage

global-anzu-mode

Enable global anzu mode:

(global-anzu-mode +1)
anzu-mode

Enable anzu minor mode:

(anzu-mode +1)
anzu-query-replace

Same as query-replace except anzu information in mode-line

anzu-query-replace-regexp

Same as query-replace-regexp except anzu information in mode-line

Add following S-exp in your configuration if you want to use anzu's replace commands by default.

(global-set-key [remap query-replace] 'anzu-query-replace)
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)

Screencast of anzu-query-replace-at-cursor-thing

anzu-query-replace-at-cursor

Same as anzu-query-replace except from-string is symbol at cursor

anzu-query-replace-at-cursor-thing

Same as anzu-query-replace-at-cursor except replaced region is specified by anzu-replace-at-cursor-thing.

anzu-replace-at-cursor-thing

Same as anzu-query-replace-at-cursor-thing except not query. This command is useful in refactoring such as changing variable name in the function.

Screencast of anzu-replace-at-cursor-thing

anzu-isearch-query-replace

Anzu version of isearch-query-replace

anzu-isearch-query-replace-regexp

Anzu version of isearch-query-replace-regexp

Customization

anzu-mode-line

Face of mode-line anzu information

anzu-mode-line-no-match

Face of mode-line at no matching case

anzu-replace-highlight

Face of from-string of replacement

anzu-replace-to

Face of to-string of replacement

anzu-mode-line-update-function

Function which constructs mode-line string. anzu.el puts its output to mode-line. It is called at searching, inputting replaced word, replacing. This must be non-nil.

The function takes 2 integer arguments, current position and total match number. You can get current-state from anzu--state('search, 'replace-query, replace).

(defun my/anzu-update-func (here total)
  (when anzu--state
    (let ((status (cl-case anzu--state
                    (search (format "<%d/%d>" here total))
                    (replace-query (format "(%d Replaces)" total))
                    (replace (format "<%d/%d>" here total)))))
      (propertize status 'face 'anzu-mode-line))))

(custom-set-variables
 '(anzu-mode-line-update-function #'my/anzu-update-func))
anzu-cons-mode-line-p(Default is t)

Set nil if you want to display anzu information at any position in mode-line. anzu.el cons search information head of mode-line as default.

For example, show search information tail of minor-mode-alist

(setq anzu-cons-mode-line-p nil)
(setcar (cdr (assq 'isearch-mode minor-mode-alist))
        '(:eval (anzu--update-mode-line)))
Screenshot

anzu-any-position

anzu-mode-lighter

Mode name in mode-line. Default is Anzu.

anzu-input-idle-delay(Default is 0.05)

Delay second of updating mode-line information when you input from-string

anzu-regexp-search-commands

Commands which have regexp input. If the last command is a member of this list, anzu.el treats input as regular expression.

The default value is '(isearch-forward-regexp isearch-backward-regexp).

anzu-use-migemo(Default is nil)

Set to t if you use migemo.

anzu-search-threshold(Default is nil)

Threshold of searched words. If there are searched word more than this value, anzu.el stops to search and display total number like 1000+(as default). If this value is nil, anzu.el counts all words.

anzu-threshold

anzu-replace-threshold(Default is nil)

Threshold of replacement overlay. If this value is nil,

anzu-minimum-input-length(Default is 1)

Minimum input length to enable anzu. This parameter is useful for migemo users. Searching 1 or 2 characters with migemo is too heavy if buffer is so large. Please set 3 or higher if you frequently edit such file.

anzu-deactivate-region(Default is nil)

Deactivate region at anzu replace command if this value is non-nil. It is hard to see with anzu replace command when region is active.

anzu-replace-at-cursor-thing(Default is 'defun)

Thing at point of anzu-query-replace-at-cursor-thing. This parameter is same as thing-at-point.

anzu-replace-to-string-separator(Default is "")

Separator of to string.

Sample Configuration

(require 'anzu)
(global-anzu-mode +1)

(set-face-attribute 'anzu-mode-line nil
                    :foreground "yellow" :weight 'bold)

(custom-set-variables
 '(anzu-mode-lighter "")
 '(anzu-deactivate-region t)
 '(anzu-search-threshold 1000)
 '(anzu-replace-threshold 50)
 '(anzu-replace-to-string-separator " => "))

(define-key isearch-mode-map [remap isearch-query-replace]  #'anzu-isearch-query-replace)
(define-key isearch-mode-map [remap isearch-query-replace-regexp] #'anzu-isearch-query-replace-regexp)

anzu's People

Contributors

syohex avatar gonewest818 avatar tarsius avatar kosh04 avatar bbatsov avatar cedricporter avatar kiwanami avatar swsnr avatar purcell avatar akicho8 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.