Rework everything

This commit is contained in:
altffour 2019-11-22 15:03:35 +03:00
parent 09be216577
commit 6c7ca778c7
No known key found for this signature in database
GPG Key ID: 96E22EFCFC1F2140
113 changed files with 47261 additions and 456 deletions

View File

@ -1,6 +0,0 @@
#!/bin/bash
if synclient -l | grep "TouchpadOff .*=.*0" ; then
synclient TouchpadOff=1 ;
else
synclient TouchpadOff=0 ;
fi

104
.zshrc
View File

@ -1,104 +0,0 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="agnoster"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#
TERM=xterm-256color
# Add git tab completion support.
autoload -Uz compinit && compinit

View File

@ -1,49 +1,45 @@
!! Colorscheme
! special
*.foreground: #93a1a1
*.background: #141c21
*.cursorColor: #afbfbf
*.foreground: #C5C8C6
*.background: #1D1F21
.cursorColor: #afbfbf
! black
*.color0: #263640
*.color8: #4a697d
*.color0: #1d1f21
*.color8: #969896
! red
*.color1: #d12f2c
*.color9: #fa3935
*.color1: #cc342b
*.color9: #cc342b
! green
*.color2: #819400
*.color10: #a4bd00
*.color2: #198844
*.color10: #19884
! yellow
*.color3: #b08500
*.color11: #d9a400
*.color3: #fba922
*.color11: #fba922
! blue
*.color4: #2587cc
*.color12: #2ca2f5
*.color4: #3971ed
*.color12: #3971ed
! magenta
*.color5: #696ebf
*.color13: #8086e8
*.color5: #a36ac7
*.color13: #a36ac7
! cyan
*.color6: #289c93
*.color14: #33c5ba
*.color6: #3971ed
*.color14: #3971ed
! white
*.color7: #bfbaac
*.color15: #fdf6e3
*.color7: #c5c8c6
*.color15: #ffffff
!! URxvt Appearance
URxvt.font: xft:Iosevka Term:style=medium:size=13
URxvt.boldFont: xft:Iosevka Term:style=bold:size=13
URxvt.italicFont: xft:Iosevka Term:style=italic:size=13
URxvt.boldItalicFont: xft:Iosevka Term:style=medium:size=13
URxvt.font: xft:FiraCode Nerd Font:size=13
URxvt.transparent: true
URxvt.shading: 20
URxvt.letterSpace: 0
URxvt.lineSpace: 0

BIN
bg.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 KiB

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Clean the directory from files.
rm -rf .config
rm -rf .emacs.d
rm -rf .Xresources
rm -f .

View File

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Install packages.
./install_packages.sh
# Load store(configuration files).
./load_store.sh

130
emacs/.emacs.d/config.el Normal file
View File

@ -0,0 +1,130 @@
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(load-file (concat user-emacs-directory "scripts/typing_speed.el"))
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(set-window-scroll-bars (minibuffer-window) nil nil)
(setq frame-title-format '((:eval (projectile-project-name))))
(defun apply-theme ()
"Make frames just slightly transparent."
(interactive)
(load-theme 'monokai t))
(use-package monokai-theme
:config
(apply-theme))
(setq ;; foreground and background
monokai-foreground "#ABB2BF"
monokai-background "#282C34"
;; highlights and comments
monokai-comments "#F8F8F0"
monokai-emphasis "#282C34"
monokai-highlight "#FFB269"
monokai-highlight-alt "#1B1D1E"
monokai-highlight-line "#1B1D1E"
monokai-line-number "#F8F8F0"
;; colours
monokai-blue "#61AFEF"
monokai-cyan "#56B6C2"
monokai-green "#98C379"
monokai-gray "#3E4451"
monokai-violet "#C678DD"
monokai-red "#E06C75"
monokai-orange "#D19A66"
monokai-yellow "#E5C07B")
(setq monokai-height-minus-1 0.8
monokai-height-plus-1 1.1
monokai-height-plus-2 1.15
monokai-height-plus-3 1.2
monokai-height-plus-4 1.3)
(use-package powerline)
(powerline-default-theme)
(setq org-ellipsis "")
(setq gc-cons-threshold 20000000)
(add-hook 'prog-mode-hook 'subword-mode)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(add-hook 'before-save-hook
(lambda ()
(when buffer-file-name
(let ((dir (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p dir)) y-or-n-p (format "Directory %s does not exist, Create it?" dir))
(make-directory dir t ))))))
(setq require-final-newline t)
(setq-default dired-listing-switches "-alh")
(global-auto-revert-mode t)
(setq mouse-yank-at-point 1)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(show-paren-mode 1)
(global-display-line-numbers-mode)
(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms `((".*", temporary-file-directory t)))
(use-package evil)
(evil-mode t)
(use-package ag)
(use-package company)
(add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "M-/") 'company-complete-common)
(use-package flycheck)
(use-package magit
:bind ("C-x g" . magit-status))
(use-package projectile)
(use-package undo-tree)
(use-package paredit)
(use-package rainbow-delimiters)
(setq-default tab-width 4)
(use-package subword
:config (global-subword-mode 1))
(setq-default c-basic-offset 4)
(setq lispy-mode-hooks
'(emacs-lisp-hook lisp-mode-hook))
(dolist (hook lispy-mode-hooks)
(add-hook hook (lambda()
(setq show-paren-style 'expression)
(paredit-mode)
(rainbow-delimeters-mode))))
(setq org-src-tab-acts-natively t)
(add-hook 'sh-mode-hook
(lambda ()
(setq sh-basic-offset 4
sh-indentation 4)))
(use-package speed-type)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2019-11-22T13:10:03+0300 using RSA

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
(1 (org . [(20191118) ( ) "Outline-based notes management and organizer" tar])
(org-plus-contrib . [(20191118) ( ) "Outline-based notes management and organizer" tar]))

View File

@ -0,0 +1,84 @@
;;; bind-key-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "bind-key" "bind-key.el" (0 0 0 0))
;;; Generated autoloads from bind-key.el
(autoload 'bind-key "bind-key" "\
Bind KEY-NAME to COMMAND in KEYMAP (`global-map' if not passed).
KEY-NAME may be a vector, in which case it is passed straight to
`define-key'. Or it may be a string to be interpreted as
spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of
`edmacro-mode' for details.
COMMAND must be an interactive function or lambda form.
KEYMAP, if present, should be a keymap and not a quoted symbol.
For example:
(bind-key \"M-h\" #'some-interactive-function my-mode-map)
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
Emacs can evaluate this form at any time that it does redisplay
or operates on menu data structures, so you should write it so it
can safely be called at any time.
\(fn KEY-NAME COMMAND &optional KEYMAP PREDICATE)" nil t)
(autoload 'unbind-key "bind-key" "\
Unbind the given KEY-NAME, within the KEYMAP (if specified).
See `bind-key' for more details.
\(fn KEY-NAME &optional KEYMAP)" nil t)
(autoload 'bind-key* "bind-key" "\
Similar to `bind-key', but overrides any mode-specific bindings.
\(fn KEY-NAME COMMAND &optional PREDICATE)" nil t)
(autoload 'bind-keys "bind-key" "\
Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted).
\(fn &rest ARGS)" nil t)
(autoload 'bind-keys* "bind-key" "\
\(fn &rest ARGS)" nil t)
(autoload 'describe-personal-keybindings "bind-key" "\
Display all the personal keybindings defined by `bind-key'.
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "bind-key" '("compare-keybindings" "get-binding-description" "bind-key" "personal-keybindings" "override-global-m")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; bind-key-autoloads.el ends here

View File

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "bind-key" "20191110.416" "A simple way to manage personal keybindings" 'nil :commit "df2528cd5116cdf2885f6f497511bf0946fe0825" :keywords '("keys" "keybinding" "config" "dotemacs") :authors '(("John Wiegley" . "johnw@newartisans.com")) :maintainer '("John Wiegley" . "johnw@newartisans.com") :url "https://github.com/jwiegley/use-package")

View File

@ -0,0 +1,455 @@
;;; bind-key.el --- A simple way to manage personal keybindings
;; Copyright (c) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 16 Jun 2012
;; Modified: 29 Nov 2017
;; Version: 2.4
;; Package-Version: 20191110.416
;; Keywords: keys keybinding config dotemacs
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 gnu emacs; see the file copying. if not, write to the
;; free software foundation, inc., 59 temple place - suite 330,
;; boston, ma 02111-1307, usa.
;;; Commentary:
;; If you have lots of keybindings set in your .emacs file, it can be hard to
;; know which ones you haven't set yet, and which may now be overriding some
;; new default in a new emacs version. This module aims to solve that
;; problem.
;;
;; Bind keys as follows in your .emacs:
;;
;; (require 'bind-key)
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command)
;;
;; If the keybinding argument is a vector, it is passed straight to
;; `define-key', so remapping a key with `[remap COMMAND]' works as
;; expected:
;;
;; (bind-key [remap original-ctrl-c-x-command] 'my-ctrl-c-x-command)
;;
;; If you want the keybinding to override all minor modes that may also bind
;; the same key, use the `bind-key*' form:
;;
;; (bind-key* "<C-return>" 'other-window)
;;
;; If you want to rebind a key only in a particular keymap, use:
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command some-other-mode-map)
;;
;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;
;; (unbind-key "C-c x" some-other-mode-map)
;;
;; To bind multiple keys at once, or set up a prefix map, a `bind-keys' macro
;; is provided. It accepts keyword arguments, please see its documentation
;; for a detailed description.
;;
;; To add keys into a specific map, use :map argument
;;
;; (bind-keys :map dired-mode-map
;; ("o" . dired-omit-mode)
;; ("a" . some-custom-dired-function))
;;
;; To set up a prefix map, use `:prefix-map' and `:prefix' arguments (both are
;; required)
;;
;; (bind-keys :prefix-map my-customize-prefix-map
;; :prefix "C-c c"
;; ("f" . customize-face)
;; ("v" . customize-variable))
;;
;; You can combine all the keywords together. Additionally,
;; `:prefix-docstring' can be specified to set documentation of created
;; `:prefix-map' variable.
;;
;; To bind multiple keys in a `bind-key*' way (to be sure that your bindings
;; will not be overridden by other modes), you may use `bind-keys*' macro:
;;
;; (bind-keys*
;; ("C-o" . other-window)
;; ("C-M-n" . forward-page)
;; ("C-M-p" . backward-page))
;;
;; After Emacs loads, you can see a summary of all your personal keybindings
;; currently in effect with this command:
;;
;; M-x describe-personal-keybindings
;;
;; This display will tell you if you've overridden a default keybinding, and
;; what the default was. Also, it will tell you if the key was rebound after
;; your binding it with `bind-key', and what it was rebound it to.
;;; Code:
(require 'cl-lib)
(require 'easy-mmode)
(defgroup bind-key nil
"A simple way to manage personal keybindings"
:group 'emacs)
(defcustom bind-key-column-widths '(18 . 40)
"Width of columns in `describe-personal-keybindings'."
:type '(cons integer integer)
:group 'bind-key)
(defcustom bind-key-segregation-regexp
"\\`\\(\\(C-[chx] \\|M-[gso] \\)\\([CM]-\\)?\\|.+-\\)"
"Regular expression used to divide key sets in the output from
\\[describe-personal-keybindings]."
:type 'regexp
:group 'bind-key)
(defcustom bind-key-describe-special-forms nil
"If non-nil, extract docstrings from lambdas, closures and keymaps if possible."
:type 'boolean
:group 'bind-key)
;; Create override-global-mode to force key remappings
(defvar override-global-map (make-keymap)
"override-global-mode keymap")
(define-minor-mode override-global-mode
"A minor mode so that keymap settings override other modes."
t "")
;; the keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
(add-to-list 'emulation-mode-map-alists
`((override-global-mode . ,override-global-map)))
(defvar personal-keybindings nil
"List of bindings performed by `bind-key'.
Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
;;;###autoload
(defmacro bind-key (key-name command &optional keymap predicate)
"Bind KEY-NAME to COMMAND in KEYMAP (`global-map' if not passed).
KEY-NAME may be a vector, in which case it is passed straight to
`define-key'. Or it may be a string to be interpreted as
spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of
`edmacro-mode' for details.
COMMAND must be an interactive function or lambda form.
KEYMAP, if present, should be a keymap and not a quoted symbol.
For example:
(bind-key \"M-h\" #'some-interactive-function my-mode-map)
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
Emacs can evaluate this form at any time that it does redisplay
or operates on menu data structures, so you should write it so it
can safely be called at any time."
(let ((namevar (make-symbol "name"))
(keyvar (make-symbol "key"))
(kdescvar (make-symbol "kdesc"))
(bindingvar (make-symbol "binding")))
`(let* ((,namevar ,key-name)
(,keyvar (if (vectorp ,namevar) ,namevar
(read-kbd-macro ,namevar)))
(,kdescvar (cons (if (stringp ,namevar) ,namevar
(key-description ,namevar))
(quote ,keymap)))
(,bindingvar (lookup-key (or ,keymap global-map) ,keyvar)))
(let ((entry (assoc ,kdescvar personal-keybindings))
(details (list ,command
(unless (numberp ,bindingvar)
,bindingvar))))
(if entry
(setcdr entry details)
(add-to-list 'personal-keybindings (cons ,kdescvar details))))
,(if predicate
`(define-key (or ,keymap global-map) ,keyvar
'(menu-item "" nil :filter (lambda (&optional _)
(when ,predicate
,command))))
`(define-key (or ,keymap global-map) ,keyvar ,command)))))
;;;###autoload
(defmacro unbind-key (key-name &optional keymap)
"Unbind the given KEY-NAME, within the KEYMAP (if specified).
See `bind-key' for more details."
`(progn
(bind-key ,key-name nil ,keymap)
(setq personal-keybindings
(cl-delete-if #'(lambda (k)
,(if keymap
`(and (consp (car k))
(string= (caar k) ,key-name)
(eq (cdar k) ',keymap))
`(and (stringp (car k))
(string= (car k) ,key-name))))
personal-keybindings))))
;;;###autoload
(defmacro bind-key* (key-name command &optional predicate)
"Similar to `bind-key', but overrides any mode-specific bindings."
`(bind-key ,key-name ,command override-global-map ,predicate))
(defun bind-keys-form (args keymap)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(let (map
doc
prefix-map
prefix
filter
menu-name
pkg)
;; Process any initial keyword arguments
(let ((cont t))
(while (and cont args)
(if (cond ((and (eq :map (car args))
(not prefix-map))
(setq map (cadr args)))
((eq :prefix-docstring (car args))
(setq doc (cadr args)))
((and (eq :prefix-map (car args))
(not (memq map '(global-map
override-global-map))))
(setq prefix-map (cadr args)))
((eq :prefix (car args))
(setq prefix (cadr args)))
((eq :filter (car args))
(setq filter (cadr args)) t)
((eq :menu-name (car args))
(setq menu-name (cadr args)))
((eq :package (car args))
(setq pkg (cadr args))))
(setq args (cddr args))
(setq cont nil))))
(when (or (and prefix-map (not prefix))
(and prefix (not prefix-map)))
(error "Both :prefix-map and :prefix must be supplied"))
(when (and menu-name (not prefix))
(error "If :menu-name is supplied, :prefix must be too"))
(unless map (setq map keymap))
;; Process key binding arguments
(let (first next)
(while args
(if (keywordp (car args))
(progn
(setq next args)
(setq args nil))
(if first
(nconc first (list (car args)))
(setq first (list (car args))))
(setq args (cdr args))))
(cl-flet
((wrap (map bindings)
(if (and map pkg (not (memq map '(global-map
override-global-map))))
`((if (boundp ',map)
,(macroexp-progn bindings)
(eval-after-load
,(if (symbolp pkg) `',pkg pkg)
',(macroexp-progn bindings))))
bindings)))
(append
(when prefix-map
`((defvar ,prefix-map)
,@(when doc `((put ',prefix-map 'variable-documentation ,doc)))
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
(wrap map
(cl-mapcan
(lambda (form)
(let ((fun (and (cdr form) (list 'function (cdr form)))))
(if prefix-map
`((bind-key ,(car form) ,fun ,prefix-map ,filter))
(if (and map (not (eq map 'global-map)))
`((bind-key ,(car form) ,fun ,map ,filter))
`((bind-key ,(car form) ,fun nil ,filter))))))
first))
(when next
(bind-keys-form (if pkg
(cons :package (cons pkg next))
next) map)))))))
;;;###autoload
(defmacro bind-keys (&rest args)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(macroexp-progn (bind-keys-form args nil)))
;;;###autoload
(defmacro bind-keys* (&rest args)
(macroexp-progn (bind-keys-form args 'override-global-map)))
(defun get-binding-description (elem)
(cond
((listp elem)
(cond
((memq (car elem) '(lambda function))
(if (and bind-key-describe-special-forms
(stringp (nth 2 elem)))
(nth 2 elem)
"#<lambda>"))
((eq 'closure (car elem))
(if (and bind-key-describe-special-forms
(stringp (nth 3 elem)))
(nth 3 elem)
"#<closure>"))
((eq 'keymap (car elem))
"#<keymap>")
(t
elem)))
;; must be a symbol, non-symbol keymap case covered above
((and bind-key-describe-special-forms (keymapp elem))
(let ((doc (get elem 'variable-documentation)))
(if (stringp doc) doc elem)))
((symbolp elem)
elem)
(t
"#<byte-compiled lambda>")))
(defun compare-keybindings (l r)
(let* ((regex bind-key-segregation-regexp)
(lgroup (and (string-match regex (caar l))
(match-string 0 (caar l))))
(rgroup (and (string-match regex (caar r))
(match-string 0 (caar r))))
(lkeymap (cdar l))
(rkeymap (cdar r)))
(cond
((and (null lkeymap) rkeymap)
(cons t t))
((and lkeymap (null rkeymap))
(cons nil t))
((and lkeymap rkeymap
(not (string= (symbol-name lkeymap) (symbol-name rkeymap))))
(cons (string< (symbol-name lkeymap) (symbol-name rkeymap)) t))
((and (null lgroup) rgroup)
(cons t t))
((and lgroup (null rgroup))
(cons nil t))
((and lgroup rgroup)
(if (string= lgroup rgroup)
(cons (string< (caar l) (caar r)) nil)
(cons (string< lgroup rgroup) t)))
(t
(cons (string< (caar l) (caar r)) nil)))))
;;;###autoload
(defun describe-personal-keybindings ()
"Display all the personal keybindings defined by `bind-key'."
(interactive)
(with-output-to-temp-buffer "*Personal Keybindings*"
(princ (format (concat "Key name%s Command%s Comments\n%s %s "
"---------------------\n")
(make-string (- (car bind-key-column-widths) 9) ? )
(make-string (- (cdr bind-key-column-widths) 8) ? )
(make-string (1- (car bind-key-column-widths)) ?-)
(make-string (1- (cdr bind-key-column-widths)) ?-)))
(let (last-binding)
(dolist (binding
(setq personal-keybindings
(sort personal-keybindings
(lambda (l r)
(car (compare-keybindings l r))))))
(if (not (eq (cdar last-binding) (cdar binding)))
(princ (format "\n\n%s: %s\n%s\n\n"
(cdar binding) (caar binding)
(make-string (+ 21 (car bind-key-column-widths)
(cdr bind-key-column-widths)) ?-)))
(if (and last-binding
(cdr (compare-keybindings last-binding binding)))
(princ "\n")))
(let* ((key-name (caar binding))
(at-present (lookup-key (or (symbol-value (cdar binding))
(current-global-map))
(read-kbd-macro key-name)))
(command (nth 1 binding))
(was-command (nth 2 binding))
(command-desc (get-binding-description command))
(was-command-desc (and was-command
(get-binding-description was-command)))
(at-present-desc (get-binding-description at-present))
)
(let ((line
(format
(format "%%-%ds%%-%ds%%s\n" (car bind-key-column-widths)
(cdr bind-key-column-widths))
key-name (format "`%s\'" command-desc)
(if (string= command-desc at-present-desc)
(if (or (null was-command)
(string= command-desc was-command-desc))
""
(format "was `%s\'" was-command-desc))
(format "[now: `%s\']" at-present)))))
(princ (if (string-match "[ \t]+\n" line)
(replace-match "\n" t t line)
line))))
(setq last-binding binding)))))
(provide 'bind-key)
;; Local Variables:
;; outline-regexp: ";;;\\(;* [^\s\t\n]\\|###autoload\\)\\|("
;; indent-tabs-mode: nil
;; End:
;;; bind-key.el ends here

Binary file not shown.

View File

@ -0,0 +1 @@
akham@brains.7633:1574418732

View File

@ -0,0 +1,18 @@
This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir, Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "q" exits, "H" lists all Info commands, "d" returns here,
"h" gives a primer for first-timers,
"mEmacs<Return>" visits the Emacs manual, etc.
In Emacs, you can click mouse button 2 on a menu item or cross reference
to select it.
* Menu:
Emacs
* Evil: (evil). Extensible vi layer for Emacs.

View File

@ -0,0 +1,15 @@
;;; evil-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; evil-autoloads.el ends here

View File

@ -0,0 +1,168 @@
;;; evil-command-window.el --- Evil command line window implementation
;; Author: Emanuel Evans <emanuel.evans at gmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This provides an implementation of the vim command line window for
;; editing and repeating past ex commands and searches.
;;; Code:
(require 'evil-vars)
(require 'evil-common)
(require 'evil-search)
(require 'evil-ex)
(defvar evil-search-module)
(define-derived-mode evil-command-window-mode fundamental-mode "Evil-cmd"
"Major mode for the Evil command line window."
(auto-fill-mode 0)
(setq-local after-change-functions (cons 'evil-command-window-draw-prefix
after-change-functions)))
(defun evil-command-window (hist cmd-key execute-fn)
"Open a command line window for HIST with CMD-KEY and EXECUTE-FN.
HIST should be a list of commands. CMD-KEY should be the string of
the key whose history is being shown (one of \":\", \"/\", or
\"?\"). EXECUTE-FN should be a function of one argument to
execute on the result that the user selects."
(when (eq major-mode 'evil-command-window-mode)
(user-error "Cannot recursively open command line window"))
(dolist (win (window-list))
(when (equal (buffer-name (window-buffer win))
"*Command Line*")
(kill-buffer (window-buffer win))
(delete-window win)))
(split-window nil
(unless (zerop evil-command-window-height)
evil-command-window-height)
'above)
(setq evil-command-window-current-buffer (current-buffer))
(ignore-errors (kill-buffer "*Command Line*"))
(switch-to-buffer "*Command Line*")
(setq-local evil-command-window-execute-fn execute-fn)
(setq-local evil-command-window-cmd-key cmd-key)
(evil-command-window-mode)
(evil-command-window-insert-commands hist))
(defun evil-command-window-ex (&optional current-command)
"Open a command line window for editing and executing ex commands.
If CURRENT-COMMAND is present, it will be inserted under the
cursor as the current command to be edited."
(interactive)
(evil-command-window (cons (or current-command "") evil-ex-history)
":"
'evil-command-window-ex-execute))
(defun evil-command-window-execute ()
"Execute the command under the cursor in the appropriate buffer.
The local var `evil-command-window-execute-fn' determines which
function to execute."
(interactive)
(let ((result (buffer-substring (line-beginning-position)
(line-end-position)))
(execute-fn evil-command-window-execute-fn)
(command-window (get-buffer-window)))
(select-window (previous-window))
(unless (equal evil-command-window-current-buffer (current-buffer))
(user-error "Originating buffer is no longer active"))
(kill-buffer "*Command Line*")
(delete-window command-window)
(funcall execute-fn result)
(setq evil-command-window-current-buffer nil)))
(defun evil-command-window-ex-execute (result)
"Execute RESULT as an ex command in the appropriate buffer."
(unless (string-match-p "^ *$" result)
(unless (equal result (car evil-ex-history))
(setq evil-ex-history (cons result evil-ex-history)))
(let ((evil-ex-current-buffer evil-command-window-current-buffer))
(evil-ex-execute result))))
(defun evil-command-window-search-forward ()
"Open a command line window for forward searches."
(interactive)
(evil-command-window (cons ""
(if (eq evil-search-module 'evil-search)
evil-ex-search-history
evil-search-forward-history))
"/"
(lambda (result)
(evil-command-window-search-execute result t))))
(defun evil-command-window-search-backward ()
"Open a command line window for backward searches."
(interactive)
(evil-command-window (cons ""
(if (eq evil-search-module 'evil-search)
evil-ex-search-history
evil-search-backward-history))
"?"
(lambda (result)
(evil-command-window-search-execute result nil))))
(defun evil-command-window-search-execute (result forward)
"Search for RESULT using FORWARD to determine direction."
(unless (zerop (length result))
(if (eq evil-search-module 'evil-search)
(progn
(setq evil-ex-search-pattern (evil-ex-make-search-pattern result)
evil-ex-search-direction (if forward 'forward 'backward))
(unless (equal result (car-safe evil-ex-search-history))
(push result evil-ex-search-history))
(evil-ex-search))
(if forward
(unless (equal result (car-safe evil-search-forward-history))
(push result evil-search-forward-history))
(unless (equal result (car-safe evil-search-backward-history))
(push result evil-search-backward-history)))
(evil-search result forward evil-regexp-search))))
(defun evil-command-window-draw-prefix (&rest ignored)
"Display `evil-command-window-cmd-key' as a prefix to the current line.
Parameters passed in through IGNORED are ignored."
(let ((prefix (propertize evil-command-window-cmd-key
'font-lock-face 'minibuffer-prompt)))
(set-text-properties (line-beginning-position) (line-beginning-position 2)
(list 'line-prefix prefix))))
(defun evil-command-window-insert-commands (hist)
"Insert the commands in HIST."
(let ((inhibit-modification-hooks t))
(mapc #'(lambda (cmd) (insert cmd) (newline)) hist)
(reverse-region (point-min) (point-max)))
(let ((prefix (propertize evil-command-window-cmd-key
'font-lock-face 'minibuffer-prompt)))
(set-text-properties (point-min) (point-max) (list 'line-prefix prefix)))
(goto-char (point-max))
(when (and (bolp) (not (bobp))) (backward-char))
(evil-adjust-cursor))
(provide 'evil-command-window)
;;; evil-command-window.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
;;; evil-development.el --- Useful features for Evil developers
;; Author: Justin Burkett <justin at burkett dot cc>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;;; Teach imenu about evil macros
(with-eval-after-load 'lisp-mode
(when (boundp 'lisp-imenu-generic-expression)
(dolist (macro '("interactive-code"
"type"
"text-object"
"motion"
"command"
"operator"))
(let ((macro-name (format "evil-%s" macro)))
(unless (assoc macro-name lisp-imenu-generic-expression)
(push (list
macro-name
(format "^\\s-*(evil-define-%s\\s-+\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)"
macro)
1)
lisp-imenu-generic-expression))))))
(provide 'evil-development)
;;; evil-development.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,531 @@
;;; evil-integration.el --- Integrate Evil with other modules
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This provides evil integration for various emacs modes.
;; Additional keybindings (or default state) should go into evil-keybindings.el.
;;; Code:
(require 'evil-maps)
(require 'evil-core)
(require 'evil-macros)
(require 'evil-types)
(require 'evil-repeat)
;;; Evilize some commands
;; unbound keys should be ignored
(evil-declare-ignore-repeat 'undefined)
(mapc #'(lambda (cmd)
(evil-set-command-property cmd :keep-visual t)
(evil-declare-not-repeat cmd))
'(digit-argument
negative-argument
universal-argument
universal-argument-minus
universal-argument-more
universal-argument-other-key))
(mapc #'evil-declare-not-repeat
'(what-cursor-position))
(mapc #'evil-declare-change-repeat
'(dabbrev-expand
hippie-expand
quoted-insert))
(mapc #'evil-declare-abort-repeat
'(balance-windows
eval-expression
execute-extended-command
exit-minibuffer
compile
delete-window
delete-other-windows
find-file-at-point
ffap-other-window
recompile
redo
save-buffer
split-window
split-window-horizontally
split-window-vertically
undo
undo-tree-redo
undo-tree-undo))
(evil-set-type #'previous-line 'line)
(evil-set-type #'next-line 'line)
(dolist (cmd '(keyboard-quit keyboard-escape-quit))
(evil-set-command-property cmd :suppress-operator t))
;;; Mouse
(evil-declare-insert-at-point-repeat 'mouse-yank-primary)
(evil-declare-insert-at-point-repeat 'mouse-yank-secondary)
;;; key-binding
;; Calling `keyboard-quit' should cancel repeat
(defadvice keyboard-quit (before evil activate)
(when (fboundp 'evil-repeat-abort)
(evil-repeat-abort)))
(eval-after-load 'wdired
'(progn
(add-hook 'wdired-mode-hook #'evil-change-to-initial-state)
(defadvice wdired-change-to-dired-mode (after evil activate)
(evil-change-to-initial-state nil t))))
;;; Parentheses
(defadvice show-paren-function (around evil disable)
"Match parentheses in Normal state."
(if (if (memq 'not evil-highlight-closing-paren-at-point-states)
(memq evil-state evil-highlight-closing-paren-at-point-states)
(not (memq evil-state evil-highlight-closing-paren-at-point-states)))
ad-do-it
(let ((pos (point)) syntax narrow)
(setq pos
(catch 'end
(dotimes (var (1+ (* 2 evil-show-paren-range)))
(if (zerop (mod var 2))
(setq pos (+ pos var))
(setq pos (- pos var)))
(setq syntax (syntax-class (syntax-after pos)))
(cond
((eq syntax 4)
(setq narrow pos)
(throw 'end pos))
((eq syntax 5)
(throw 'end (1+ pos)))))))
(if pos
(save-excursion
(goto-char pos)
(save-restriction
(when narrow
(narrow-to-region narrow (point-max)))
ad-do-it))
;; prevent the preceding pair from being highlighted
(dolist (ov '(show-paren--overlay
show-paren--overlay-1
show-paren-overlay
show-paren-overlay-1))
(let ((ov (and (boundp ov) (symbol-value ov))))
(when (overlayp ov) (delete-overlay ov))))))))
;;; Undo tree
(when (and (require 'undo-tree nil t)
(fboundp 'global-undo-tree-mode))
(global-undo-tree-mode 1))
(eval-after-load 'undo-tree
'(with-no-warnings
(defun evil-turn-on-undo-tree-mode ()
"Enable `undo-tree-mode' if evil is enabled.
This function enables `undo-tree-mode' when Evil is activated in
some buffer, but only if `global-undo-tree-mode' is also
activated."
(when (and (boundp 'global-undo-tree-mode)
global-undo-tree-mode)
(turn-on-undo-tree-mode)))
(add-hook 'evil-local-mode-hook #'evil-turn-on-undo-tree-mode)
(defadvice undo-tree-visualize (after evil activate)
"Initialize Evil in the visualization buffer."
(when evil-local-mode
(evil-initialize-state)))
(when (fboundp 'undo-tree-visualize)
(evil-ex-define-cmd "undol[ist]" 'undo-tree-visualize)
(evil-ex-define-cmd "ul" 'undo-tree-visualize))
(when (boundp 'undo-tree-visualizer-mode-map)
(define-key undo-tree-visualizer-mode-map
[remap evil-backward-char] 'undo-tree-visualize-switch-branch-left)
(define-key undo-tree-visualizer-mode-map
[remap evil-forward-char] 'undo-tree-visualize-switch-branch-right)
(define-key undo-tree-visualizer-mode-map
[remap evil-next-line] 'undo-tree-visualize-redo)
(define-key undo-tree-visualizer-mode-map
[remap evil-previous-line] 'undo-tree-visualize-undo)
(define-key undo-tree-visualizer-mode-map
[remap evil-ret] 'undo-tree-visualizer-set))
(when (boundp 'undo-tree-visualizer-selection-mode-map)
(define-key undo-tree-visualizer-selection-mode-map
[remap evil-backward-char] 'undo-tree-visualizer-select-left)
(define-key undo-tree-visualizer-selection-mode-map
[remap evil-forward-char] 'undo-tree-visualizer-select-right)
(define-key undo-tree-visualizer-selection-mode-map
[remap evil-next-line] 'undo-tree-visualizer-select-next)
(define-key undo-tree-visualizer-selection-mode-map
[remap evil-previous-line] 'undo-tree-visualizer-select-previous)
(define-key undo-tree-visualizer-selection-mode-map
[remap evil-ret] 'undo-tree-visualizer-set))))
;;; Auto-complete
(eval-after-load 'auto-complete
'(progn
(evil-add-command-properties 'auto-complete :repeat 'evil-ac-repeat)
(evil-add-command-properties 'ac-complete :repeat 'evil-ac-repeat)
(evil-add-command-properties 'ac-expand :repeat 'evil-ac-repeat)
(evil-add-command-properties 'ac-next :repeat 'ignore)
(evil-add-command-properties 'ac-previous :repeat 'ignore)
(defvar evil-ac-prefix-len nil
"The length of the prefix of the current item to be completed.")
(defvar ac-prefix)
(defun evil-ac-repeat (flag)
"Record the changes for auto-completion."
(cond
((eq flag 'pre)
(setq evil-ac-prefix-len (length ac-prefix))
(evil-repeat-start-record-changes))
((eq flag 'post)
;; Add change to remove the prefix
(evil-repeat-record-change (- evil-ac-prefix-len)
""
evil-ac-prefix-len)
;; Add change to insert the full completed text
(evil-repeat-record-change
(- evil-ac-prefix-len)
(buffer-substring-no-properties (- evil-repeat-pos
evil-ac-prefix-len)
(point))
0)
;; Finish repeation
(evil-repeat-finish-record-changes))))))
;;; Company
(eval-after-load 'company
'(progn
(mapc #'evil-declare-change-repeat
'(company-complete-mouse
company-complete-number
company-complete-selection
company-complete-common))
(mapc #'evil-declare-ignore-repeat
'(company-abort
company-select-next
company-select-previous
company-select-next-or-abort
company-select-previous-or-abort
company-select-mouse
company-show-doc-buffer
company-show-location
company-search-candidates
company-filter-candidates))))
;; Eval last sexp
(cond
((version< emacs-version "25")
(defadvice preceding-sexp (around evil activate)
"In normal-state or motion-state, last sexp ends at point."
(if (and (not evil-move-beyond-eol)
(or (evil-normal-state-p) (evil-motion-state-p)))
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
ad-do-it)
ad-do-it))
(defadvice pp-last-sexp (around evil activate)
"In normal-state or motion-state, last sexp ends at point."
(if (and (not evil-move-beyond-eol)
(or (evil-normal-state-p) (evil-motion-state-p)))
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
ad-do-it)
ad-do-it)))
(t
(defun evil--preceding-sexp (command &rest args)
"In normal-state or motion-state, last sexp ends at point."
(if (and (not evil-move-beyond-eol)
(or (evil-normal-state-p) (evil-motion-state-p)))
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
(apply command args))
(apply command args)))
(advice-add 'elisp--preceding-sexp :around 'evil--preceding-sexp '((name . evil)))
(advice-add 'pp-last-sexp :around 'evil--preceding-sexp '((name . evil)))))
;; Show key
(defadvice quail-show-key (around evil activate)
"Temporarily go to Emacs state"
(evil-with-state emacs ad-do-it))
(defadvice describe-char (around evil activate)
"Temporarily go to Emacs state"
(evil-with-state emacs ad-do-it))
;; ace-jump-mode
(declare-function 'ace-jump-char-mode "ace-jump-mode")
(declare-function 'ace-jump-word-mode "ace-jump-mode")
(declare-function 'ace-jump-line-mode "ace-jump-mode")
(defvar evil-ace-jump-active nil)
(defmacro evil-enclose-ace-jump-for-motion (&rest body)
"Enclose ace-jump to make it suitable for motions.
This includes restricting `ace-jump-mode' to the current window
in visual and operator state, deactivating visual updates, saving
the mark and entering `recursive-edit'."
(declare (indent defun)
(debug t))
`(let ((old-mark (mark))
(ace-jump-mode-scope
(if (and (not (memq evil-state '(visual operator)))
(boundp 'ace-jump-mode-scope))
ace-jump-mode-scope
'window)))
(remove-hook 'pre-command-hook #'evil-visual-pre-command t)
(remove-hook 'post-command-hook #'evil-visual-post-command t)
(unwind-protect
(let ((evil-ace-jump-active 'prepare))
(add-hook 'ace-jump-mode-end-hook
#'evil-ace-jump-exit-recursive-edit)
,@body
(when evil-ace-jump-active
(setq evil-ace-jump-active t)
(recursive-edit)))
(remove-hook 'post-command-hook
#'evil-ace-jump-exit-recursive-edit)
(remove-hook 'ace-jump-mode-end-hook
#'evil-ace-jump-exit-recursive-edit)
(if (evil-visual-state-p)
(progn
(add-hook 'pre-command-hook #'evil-visual-pre-command nil t)
(add-hook 'post-command-hook #'evil-visual-post-command nil t)
(set-mark old-mark))
(push-mark old-mark)))))
(eval-after-load 'ace-jump-mode
`(defadvice ace-jump-done (after evil activate)
(when evil-ace-jump-active
(add-hook 'post-command-hook #'evil-ace-jump-exit-recursive-edit))))
(defun evil-ace-jump-exit-recursive-edit ()
"Exit a recursive edit caused by an evil jump."
(cond
((eq evil-ace-jump-active 'prepare)
(setq evil-ace-jump-active nil))
(evil-ace-jump-active
(remove-hook 'post-command-hook #'evil-ace-jump-exit-recursive-edit)
(exit-recursive-edit))))
(evil-define-motion evil-ace-jump-char-mode (count)
"Jump visually directly to a char using ace-jump."
:type inclusive
(evil-without-repeat
(let ((pnt (point))
(buf (current-buffer)))
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-char-mode))
;; if we jump backwards, motion type is exclusive, analogously
;; to `evil-find-char-backward'
(when (and (equal buf (current-buffer))
(< (point) pnt))
(setq evil-this-type
(cond
((eq evil-this-type 'exclusive) 'inclusive)
((eq evil-this-type 'inclusive) 'exclusive)))))))
(evil-define-motion evil-ace-jump-char-to-mode (count)
"Jump visually to the char in front of a char using ace-jump."
:type inclusive
(evil-without-repeat
(let ((pnt (point))
(buf (current-buffer)))
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-char-mode))
(if (and (equal buf (current-buffer))
(< (point) pnt))
(progn
(or (eobp) (forward-char))
(setq evil-this-type
(cond
((eq evil-this-type 'exclusive) 'inclusive)
((eq evil-this-type 'inclusive) 'exclusive))))
(backward-char)))))
(evil-define-motion evil-ace-jump-line-mode (count)
"Jump visually to the beginning of a line using ace-jump."
:type line
:repeat abort
(evil-without-repeat
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-line-mode))))
(evil-define-motion evil-ace-jump-word-mode (count)
"Jump visually to the beginning of a word using ace-jump."
:type exclusive
:repeat abort
(evil-without-repeat
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-word-mode))))
(define-key evil-motion-state-map [remap ace-jump-char-mode] #'evil-ace-jump-char-mode)
(define-key evil-motion-state-map [remap ace-jump-line-mode] #'evil-ace-jump-line-mode)
(define-key evil-motion-state-map [remap ace-jump-word-mode] #'evil-ace-jump-word-mode)
;;; avy
(declare-function 'avy-goto-word-or-subword-1 "avy")
(declare-function 'avy-goto-line "avy")
(declare-function 'avy-goto-char "avy")
(declare-function 'avy-goto-char-2 "avy")
(declare-function 'avy-goto-char-2-above "avy")
(declare-function 'avy-goto-char-2-below "avy")
(declare-function 'avy-goto-char-in-line "avy")
(declare-function 'avy-goto-word-0 "avy")
(declare-function 'avy-goto-word-1 "avy")
(declare-function 'avy-goto-word-1-above "avy")
(declare-function 'avy-goto-word-1-below "avy")
(declare-function 'avy-goto-subword-0 "avy")
(declare-function 'avy-goto-subword-1 "avy")
(declare-function 'avy-goto-char-timer "avy")
(defmacro evil-enclose-avy-for-motion (&rest body)
"Enclose avy to make it suitable for motions.
Based on `evil-enclose-ace-jump-for-motion'."
(declare (indent defun)
(debug t))
`(let ((avy-all-windows
(if (and (not (memq evil-state '(visual operator)))
(boundp 'avy-all-windows))
avy-all-windows
nil)))
,@body))
(defmacro evil-define-avy-motion (command type)
(declare (indent defun)
(debug t))
(let ((name (intern (format "evil-%s" command))))
`(evil-define-motion ,name (_count)
,(format "Evil motion for `%s'." command)
:type ,type
:jump t
:repeat abort
(evil-without-repeat
(evil-enclose-avy-for-motion
(call-interactively ',command))))))
;; define evil-avy-* motion commands for avy-* commands
(evil-define-avy-motion avy-goto-char inclusive)
(evil-define-avy-motion avy-goto-char-2 inclusive)
(evil-define-avy-motion avy-goto-char-2-above inclusive)
(evil-define-avy-motion avy-goto-char-2-below inclusive)
(evil-define-avy-motion avy-goto-char-in-line inclusive)
(evil-define-avy-motion avy-goto-char-timer inclusive)
(evil-define-avy-motion avy-goto-line line)
(evil-define-avy-motion avy-goto-line-above line)
(evil-define-avy-motion avy-goto-line-below line)
(evil-define-avy-motion avy-goto-subword-0 exclusive)
(evil-define-avy-motion avy-goto-subword-1 exclusive)
(evil-define-avy-motion avy-goto-symbol-1 exclusive)
(evil-define-avy-motion avy-goto-symbol-1-above exclusive)
(evil-define-avy-motion avy-goto-symbol-1-below exclusive)
(evil-define-avy-motion avy-goto-word-0 exclusive)
(evil-define-avy-motion avy-goto-word-1 exclusive)
(evil-define-avy-motion avy-goto-word-1-above exclusive)
(evil-define-avy-motion avy-goto-word-1-below exclusive)
(evil-define-avy-motion avy-goto-word-or-subword-1 exclusive)
;; remap avy-* commands to evil-avy-* commands
(dolist (command '(avy-goto-char
avy-goto-char-2
avy-goto-char-2-above
avy-goto-char-2-below
avy-goto-char-in-line
avy-goto-char-timer
avy-goto-line
avy-goto-line-above
avy-goto-line-below
avy-goto-subword-0
avy-goto-subword-1
avy-goto-symbol-1
avy-goto-symbol-1-above
avy-goto-symbol-1-below
avy-goto-word-0
avy-goto-word-1
avy-goto-word-1-above
avy-goto-word-1-below
avy-goto-word-or-subword-1))
(define-key evil-motion-state-map
(vector 'remap command) (intern-soft (format "evil-%s" command))))
;;; nXhtml/mumamo
;; ensure that mumamo does not toggle evil through its globalized mode
(eval-after-load 'mumamo
'(with-no-warnings
(push 'evil-mode-cmhh mumamo-change-major-mode-no-nos)))
;; visual-line-mode integration
(when evil-respect-visual-line-mode
(evil-define-command evil-digit-argument-or-evil-beginning-of-visual-line ()
:digit-argument-redirection evil-beginning-of-visual-line
:keep-visual t
:repeat nil
(interactive)
(cond
(current-prefix-arg
(setq this-command #'digit-argument)
(call-interactively #'digit-argument))
(t
(let ((target (or (command-remapping #'evil-beginning-of-visual-line)
#'evil-beginning-of-visual-line)))
(setq this-command 'evil-beginning-of-visual-line)
(call-interactively 'evil-beginning-of-visual-line)))))
(evil-define-minor-mode-key 'motion 'visual-line-mode
"j" 'evil-next-visual-line
"gj" 'evil-next-line
"k" 'evil-previous-visual-line
"gk" 'evil-previous-line
"0" 'evil-digit-argument-or-evil-beginning-of-visual-line
"g0" 'evil-beginning-of-line
"$" 'evil-end-of-visual-line
"g$" 'evil-end-of-line
"V" 'evil-visual-screen-line))
;;; abbrev.el
(when evil-want-abbrev-expand-on-insert-exit
(eval-after-load 'abbrev
'(add-hook 'evil-insert-state-exit-hook 'expand-abbrev)))
;;; ElDoc
(eval-after-load 'eldoc
'(when (fboundp 'eldoc-add-command-completions)
(eldoc-add-command-completions "evil-window-")))
(provide 'evil-integration)
;;; evil-integration.el ends here

View File

@ -0,0 +1,318 @@
;;; evil-jumps.el --- Jump list implementation
;; Author: Bailey Ling <bling at live.ca>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'cl-lib)
(require 'evil-core)
(require 'evil-states)
;;; Code:
(defgroup evil-jumps nil
"Evil jump list configuration options."
:prefix "evil-jumps"
:group 'evil)
(defcustom evil-jumps-cross-buffers t
"When non-nil, the jump commands can cross borders between buffers, otherwise the jump commands act only within the current buffer."
:type 'boolean
:group 'evil-jumps)
(defcustom evil-jumps-max-length 100
"The maximum number of jumps to keep track of."
:type 'integer
:group 'evil-jumps)
(defcustom evil-jumps-pre-jump-hook nil
"Hooks to run just before jumping to a location in the jump list."
:type 'hook
:group 'evil-jumps)
(defcustom evil-jumps-post-jump-hook nil
"Hooks to run just after jumping to a location in the jump list."
:type 'hook
:group 'evil-jumps)
(defcustom evil-jumps-ignored-file-patterns '("COMMIT_EDITMSG$" "TAGS$")
"A list of pattern regexps to match on the file path to exclude from being included in the jump list."
:type '(repeat string)
:group 'evil-jumps)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar savehist-additional-variables)
(defvar evil--jumps-jumping nil)
(eval-when-compile (defvar evil--jumps-debug nil))
(defvar evil--jumps-buffer-targets "\\*\\(new\\|scratch\\)\\*"
"Regexp to match against `buffer-name' to determine whether it's a valid jump target.")
(defvar evil--jumps-window-jumps (make-hash-table)
"Hashtable which stores all jumps on a per window basis.")
(defvar evil-jumps-history nil
"History of `evil-mode' jumps that are persisted with `savehist'.")
(cl-defstruct evil-jumps-struct
ring
(idx -1))
(defmacro evil--jumps-message (format &rest args)
(when evil--jumps-debug
`(with-current-buffer (get-buffer-create "*evil-jumps*")
(goto-char (point-max))
(insert (apply #'format ,format ',args) "\n"))))
(defun evil--jumps-get-current (&optional window)
(unless window
(setq window (frame-selected-window)))
(let* ((jump-struct (gethash window evil--jumps-window-jumps)))
(unless jump-struct
(setq jump-struct (make-evil-jumps-struct))
(puthash window jump-struct evil--jumps-window-jumps))
jump-struct))
(defun evil--jumps-get-jumps (struct)
(let ((ring (evil-jumps-struct-ring struct)))
(unless ring
(setq ring (make-ring evil-jumps-max-length))
(setf (evil-jumps-struct-ring struct) ring))
ring))
(defun evil--jumps-get-window-jump-list ()
(let ((struct (evil--jumps-get-current)))
(evil--jumps-get-jumps struct)))
(defun evil--jumps-savehist-load ()
(add-to-list 'savehist-additional-variables 'evil-jumps-history)
(let ((ring (make-ring evil-jumps-max-length)))
(cl-loop for jump in (reverse evil-jumps-history)
do (ring-insert ring jump))
(setf (evil-jumps-struct-ring (evil--jumps-get-current)) ring))
(add-hook 'savehist-save-hook #'evil--jumps-savehist-sync)
(remove-hook 'savehist-mode-hook #'evil--jumps-savehist-load))
(defun evil--jumps-savehist-sync ()
"Updates the printable value of window jumps for `savehist'."
(setq evil-jumps-history
(cl-remove-if-not #'identity
(mapcar #'(lambda (jump)
(let* ((mark (car jump))
(pos (if (markerp mark)
(marker-position mark)
mark))
(file-name (cadr jump)))
(if (and (not (file-remote-p file-name))
(file-exists-p file-name)
pos)
(list pos file-name)
nil)))
(ring-elements (evil--jumps-get-window-jump-list))))))
(defun evil--jumps-jump (idx shift)
(let ((target-list (evil--jumps-get-window-jump-list)))
(evil--jumps-message "jumping from %s by %s" idx shift)
(evil--jumps-message "target list = %s" target-list)
(setq idx (+ idx shift))
(let* ((current-file-name (or (buffer-file-name) (buffer-name)))
(size (ring-length target-list)))
(unless evil-jumps-cross-buffers
;; skip jump marks pointing to other buffers
(while (and (< idx size) (>= idx 0)
(not (string= current-file-name
(let* ((place (ring-ref target-list idx))
(pos (car place)))
(cadr place)))))
(setq idx (+ idx shift))))
(when (and (< idx size) (>= idx 0))
;; actual jump
(run-hooks 'evil-jumps-pre-jump-hook)
(let* ((place (ring-ref target-list idx))
(pos (car place))
(file-name (cadr place)))
(setq evil--jumps-jumping t)
(if (string-match-p evil--jumps-buffer-targets file-name)
(switch-to-buffer file-name)
(find-file file-name))
(setq evil--jumps-jumping nil)
(goto-char pos)
(setf (evil-jumps-struct-idx (evil--jumps-get-current)) idx)
(run-hooks 'evil-jumps-post-jump-hook))))))
(defun evil--jumps-push ()
"Pushes the current cursor/file position to the jump list."
(let ((target-list (evil--jumps-get-window-jump-list)))
(let ((file-name (buffer-file-name))
(buffer-name (buffer-name))
(current-pos (point-marker))
(first-pos nil)
(first-file-name nil)
(excluded nil))
(when (and (not file-name)
(string-match-p evil--jumps-buffer-targets buffer-name))
(setq file-name buffer-name))
(when file-name
(dolist (pattern evil-jumps-ignored-file-patterns)
(when (string-match-p pattern file-name)
(setq excluded t)))
(unless excluded
(unless (ring-empty-p target-list)
(setq first-pos (car (ring-ref target-list 0)))
(setq first-file-name (car (cdr (ring-ref target-list 0)))))
(unless (and (equal first-pos current-pos)
(equal first-file-name file-name))
(evil--jumps-message "pushing %s on %s" current-pos file-name)
(ring-insert target-list `(,current-pos ,file-name))))))
(evil--jumps-message "%s %s"
(selected-window)
(and (not (ring-empty-p target-list))
(ring-ref target-list 0)))))
(evil-define-command evil-show-jumps ()
"Display the contents of the jump list."
:repeat nil
(evil-with-view-list
:name "evil-jumps"
:mode "Evil Jump List"
:format [("Jump" 5 nil)
("Marker" 8 nil)
("File/text" 1000 t)]
:entries (let* ((jumps (evil--jumps-savehist-sync))
(count 0))
(cl-loop for jump in jumps
collect `(nil [,(number-to-string (cl-incf count))
,(number-to-string (car jump))
(,(cadr jump))])))
:select-action #'evil--show-jumps-select-action))
(defun evil--show-jumps-select-action (jump)
(let ((position (string-to-number (elt jump 1)))
(file (car (elt jump 2))))
(kill-buffer)
(switch-to-buffer (find-file file))
(goto-char position)))
(defun evil-set-jump (&optional pos)
"Set jump point at POS.
POS defaults to point."
(unless (or (region-active-p) (evil-visual-state-p))
(push-mark pos t))
(unless evil--jumps-jumping
;; clear out intermediary jumps when a new one is set
(let* ((struct (evil--jumps-get-current))
(target-list (evil--jumps-get-jumps struct))
(idx (evil-jumps-struct-idx struct)))
(cl-loop repeat idx
do (ring-remove target-list))
(setf (evil-jumps-struct-idx struct) -1))
(save-excursion
(when pos
(goto-char pos))
(evil--jumps-push))))
(defun evil--jump-backward (count)
(let ((count (or count 1)))
(evil-motion-loop (nil count)
(let* ((struct (evil--jumps-get-current))
(idx (evil-jumps-struct-idx struct)))
(evil--jumps-message "jumping back %s" idx)
(when (= idx -1)
(setq idx 0)
(setf (evil-jumps-struct-idx struct) 0)
(evil--jumps-push))
(evil--jumps-jump idx 1)))))
(defun evil--jump-forward (count)
(let ((count (or count 1)))
(evil-motion-loop (nil count)
(let* ((struct (evil--jumps-get-current))
(idx (evil-jumps-struct-idx struct)))
(when (= idx -1)
(setq idx 0)
(setf (evil-jumps-struct-idx struct) 0)
(evil--jumps-push))
(evil--jumps-jump idx -1)))))
(defun evil--jumps-window-configuration-hook (&rest args)
(let* ((window-list (window-list-1 nil nil t))
(existing-window (selected-window))
(new-window (previous-window)))
(when (and (not (eq existing-window new-window))
(> (length window-list) 1))
(let* ((target-jump-struct (evil--jumps-get-current new-window))
(target-jump-count (ring-length (evil--jumps-get-jumps target-jump-struct))))
(if (not (ring-empty-p (evil--jumps-get-jumps target-jump-struct)))
(evil--jumps-message "target window %s already has %s jumps" new-window target-jump-count)
(evil--jumps-message "new target window detected; copying %s to %s" existing-window new-window)
(let* ((source-jump-struct (evil--jumps-get-current existing-window))
(source-list (evil--jumps-get-jumps source-jump-struct)))
(when (= (ring-length (evil--jumps-get-jumps target-jump-struct)) 0)
(setf (evil-jumps-struct-idx target-jump-struct) (evil-jumps-struct-idx source-jump-struct))
(setf (evil-jumps-struct-ring target-jump-struct) (ring-copy source-list)))))))
;; delete obsolete windows
(maphash (lambda (key val)
(unless (member key window-list)
(evil--jumps-message "removing %s" key)
(remhash key evil--jumps-window-jumps)))
evil--jumps-window-jumps)))
(defun evil--jump-hook (&optional command)
"Set jump point if COMMAND has a non-nil :jump property."
(setq command (or command this-command))
(when (evil-get-command-property command :jump)
(evil-set-jump)))
(defadvice switch-to-buffer (before evil-jumps activate)
(evil-set-jump))
(defadvice split-window-internal (before evil-jumps activate)
(evil-set-jump))
(eval-after-load 'etags
'(defadvice find-tag-noselect (before evil-jumps activate)
(evil-set-jump)))
(if (bound-and-true-p savehist-loaded)
(evil--jumps-savehist-load)
(add-hook 'savehist-mode-hook #'evil--jumps-savehist-load))
(add-hook 'evil-local-mode-hook
(lambda ()
(if evil-local-mode
(progn
(add-hook 'pre-command-hook #'evil--jump-hook nil t)
(add-hook 'next-error-hook #'evil-set-jump nil t)
(add-hook 'window-configuration-change-hook #'evil--jumps-window-configuration-hook nil t))
(progn
(remove-hook 'pre-command-hook #'evil--jump-hook t)
(remove-hook 'next-error-hook #'evil-set-jump t)
(remove-hook 'window-configuration-change-hook #'evil--jumps-window-configuration-hook t)))))
(provide 'evil-jumps)
;;; evil-jumps.el ends here

View File

@ -0,0 +1,124 @@
;;; evil-keybindings.el --- Add some Evil keybindings to other modules
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This provides a set of keybindings for other emacs modes. This also includes
;; setting up the initial evil state of those other modes.
;;; Code:
(require 'evil-maps)
(require 'evil-core)
(require 'evil-macros)
(require 'evil-types)
(require 'evil-repeat)
;; etags-select
;; FIXME: probably etags-select should be recomended in docs
(eval-after-load 'etags-select
'(progn
(define-key evil-motion-state-map "g]" 'etags-select-find-tag-at-point)))
;;; Buffer-menu
(evil-add-hjkl-bindings Buffer-menu-mode-map 'motion)
;; dictionary.el
(evil-add-hjkl-bindings dictionary-mode-map 'motion
"?" 'dictionary-help ; "h"
"C-o" 'dictionary-previous) ; "l"
;;; Dired
(eval-after-load 'dired
'(progn
;; use the standard Dired bindings as a base
(defvar dired-mode-map)
(evil-make-overriding-map dired-mode-map 'normal)
(evil-add-hjkl-bindings dired-mode-map 'normal
"J" 'dired-goto-file ; "j"
"K" 'dired-do-kill-lines ; "k"
"r" 'dired-do-redisplay ; "l"
;; ":d", ":v", ":s", ":e"
";" (lookup-key dired-mode-map ":"))))
;;; ERT
(evil-add-hjkl-bindings ert-results-mode-map 'motion)
;;; Info
(evil-add-hjkl-bindings Info-mode-map 'motion
"0" 'evil-digit-argument-or-evil-beginning-of-line
(kbd "\M-h") 'Info-help ; "h"
"\C-t" 'Info-history-back ; "l"
"\C-o" 'Info-history-back
" " 'Info-scroll-up
"\C-]" 'Info-follow-nearest-node
(kbd "DEL") 'Info-scroll-down)
;;; Speedbar
(evil-add-hjkl-bindings speedbar-key-map 'motion
"h" 'backward-char
"j" 'speedbar-next
"k" 'speedbar-prev
"l" 'forward-char
"i" 'speedbar-item-info
"r" 'speedbar-refresh
"u" 'speedbar-up-directory
"o" 'speedbar-toggle-line-expansion
(kbd "RET") 'speedbar-edit-line)
;; Ibuffer
(eval-after-load 'ibuffer
'(progn
(defvar ibuffer-mode-map)
(evil-make-overriding-map ibuffer-mode-map 'normal)
(evil-define-key 'normal ibuffer-mode-map
"j" 'evil-next-line
"k" 'evil-previous-line
"RET" 'ibuffer-visit-buffer)))
;;; ag.el
(eval-after-load 'ag
'(progn
(defvar ag-mode-map)
(add-to-list 'evil-motion-state-modes 'ag-mode)
(evil-add-hjkl-bindings ag-mode-map 'motion)))
;;; ELP
(eval-after-load 'elp
'(defadvice elp-results (after evil activate)
(evil-motion-state)))
(provide 'evil-keybindings)
;;; evil-keybindings.el ends here

View File

@ -0,0 +1,781 @@
;;; evil-macros.el --- Macros
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-common)
(require 'evil-states)
(require 'evil-repeat)
;;; Code:
(declare-function evil-ex-p "evil-ex")
;; set some error codes
(put 'beginning-of-line 'error-conditions '(beginning-of-line error))
(put 'beginning-of-line 'error-message "Beginning of line")
(put 'end-of-line 'error-conditions '(end-of-line error))
(put 'end-of-line 'error-message "End of line")
(defun evil-motion-range (motion &optional count type)
"Execute a motion and return the buffer positions.
The return value is a list (BEG END TYPE)."
(let ((opoint (point))
(omark (mark t))
(omactive (and (boundp 'mark-active) mark-active))
(obuffer (current-buffer))
(evil-motion-marker (move-marker (make-marker) (point)))
range)
(evil-with-transient-mark-mode
(evil-narrow-to-field
(unwind-protect
(let ((current-prefix-arg count)
;; Store type in global variable `evil-this-type'.
;; If necessary, motions can change their type
;; during execution by setting this variable.
(evil-this-type
(or type (evil-type motion 'exclusive))))
(condition-case err
(let ((repeat-type (evil-repeat-type motion t)))
(if (functionp repeat-type)
(funcall repeat-type 'pre))
(unless (with-local-quit
(setq range (call-interactively motion))
t)
(evil-repeat-abort)
(setq quit-flag t))
(if (functionp repeat-type)
(funcall repeat-type 'post)))
(error (prog1 nil
(evil-repeat-abort)
;; some operators depend on succeeding
;; motions, in particular for
;; `evil-forward-char' (e.g., used by
;; `evil-substitute'), therefore we let
;; end-of-line and end-of-buffer pass
(if (not (memq (car err) '(end-of-line end-of-buffer)))
(signal (car err) (cdr err))
(message (error-message-string err))))))
(cond
;; the motion returned a range
((evil-range-p range))
;; the motion made a Visual selection
((evil-visual-state-p)
(setq range (evil-visual-range)))
;; the motion made an active region
((region-active-p)
(setq range (evil-range (region-beginning)
(region-end)
evil-this-type)))
;; default: range from previous position to current
(t
(setq range (evil-expand-range
(evil-normalize evil-motion-marker
(point)
evil-this-type)))))
(unless (or (null type) (eq (evil-type range) type))
(evil-set-type range type)
(evil-expand-range range))
(evil-set-range-properties range nil)
range)
;; restore point and mark like `save-excursion',
;; but only if the motion hasn't disabled the operator
(unless evil-inhibit-operator
(set-buffer obuffer)
(evil-move-mark omark)
(goto-char opoint))
;; delete marker so it doesn't slow down editing
(move-marker evil-motion-marker nil))))))
(defmacro evil-define-motion (motion args &rest body)
"Define an motion command MOTION.
\(fn MOTION (COUNT ARGS...) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(doc-string 3)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
[&optional ("interactive" [&rest form])]
def-body)))
(let (arg doc interactive key keys type)
(when args
(setq args `(&optional ,@(delq '&optional args))
;; the count is either numerical or nil
interactive '("<c>")))
;; collect docstring
(when (and (> (length body) 1)
(or (eq (car-safe (car-safe body)) 'format)
(stringp (car-safe body))))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :repeat 'motion))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body)
keys (plist-put keys key arg)))
;; collect `interactive' specification
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (cdr (pop body))))
;; macro expansion
`(progn
;; refresh echo area in Eldoc mode
(when ',motion
(eval-after-load 'eldoc
'(and (fboundp 'eldoc-add-command)
(eldoc-add-command ',motion))))
(evil-define-command ,motion (,@args)
,@(when doc `(,doc)) ; avoid nil before `interactive'
,@keys
:keep-visual t
(interactive ,@interactive)
,@body))))
(defmacro evil-narrow-to-line (&rest body)
"Narrow BODY to the current line.
BODY will signal the errors 'beginning-of-line or 'end-of-line
upon reaching the beginning or end of the current line.
\(fn [[KEY VAL]...] BODY...)"
(declare (indent defun)
(debug t))
`(let* ((range (evil-expand (point) (point) 'line))
(beg (evil-range-beginning range))
(end (evil-range-end range))
(min (point-min))
(max (point-max)))
(when (save-excursion (goto-char end) (bolp))
(setq end (max beg (1- end))))
;; don't include the newline in Normal state
(when (and (not evil-move-beyond-eol)
(not (evil-visual-state-p))
(not (evil-operator-state-p)))
(setq end (max beg (1- end))))
(evil-with-restriction beg end
(evil-signal-without-movement
(condition-case err
(progn ,@body)
(beginning-of-buffer
(if (= beg min)
(signal (car err) (cdr err))
(signal 'beginning-of-line nil)))
(end-of-buffer
(if (= end max)
(signal (car err) (cdr err))
(signal 'end-of-line nil))))))))
;; we don't want line boundaries to trigger the debugger
;; when `debug-on-error' is t
(add-to-list 'debug-ignored-errors "^Beginning of line$")
(add-to-list 'debug-ignored-errors "^End of line$")
(defun evil-eobp (&optional pos)
"Whether point is at end-of-buffer with regard to end-of-line."
(save-excursion
(when pos (goto-char pos))
(cond
((eobp))
;; the rest only pertains to Normal state
((not (evil-normal-state-p))
nil)
;; at the end of the last line
((eolp)
(forward-char)
(eobp))
;; at the last character of the last line
(t
(forward-char)
(cond
((eobp))
((eolp)
(forward-char)
(eobp)))))))
(defun evil-move-beginning (count forward &optional backward)
"Move to the beginning of the COUNT next object.
If COUNT is negative, move to the COUNT previous object.
FORWARD is a function which moves to the end of the object, and
BACKWARD is a function which moves to the beginning.
If one is unspecified, the other is used with a negative argument."
(let* ((count (or count 1))
(backward (or backward
#'(lambda (count)
(funcall forward (- count)))))
(forward (or forward
#'(lambda (count)
(funcall backward (- count)))))
(opoint (point)))
(cond
((< count 0)
(when (bobp)
(signal 'beginning-of-buffer nil))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall backward 1))
(unless (zerop count)
(goto-char (point-min)))))
((> count 0)
(when (evil-eobp)
(signal 'end-of-buffer nil))
;; Do we need to move past the current object?
(when (<= (save-excursion
(funcall forward 1)
(funcall backward 1)
(point))
opoint)
(setq count (1+ count)))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall forward 1))
(if (zerop count)
;; go back to beginning of object
(funcall backward 1)
(goto-char (point-max)))))
(t
count))))
(defun evil-move-end (count forward &optional backward inclusive)
"Move to the end of the COUNT next object.
If COUNT is negative, move to the COUNT previous object.
FORWARD is a function which moves to the end of the object, and
BACKWARD is a function which moves to the beginning.
If one is unspecified, the other is used with a negative argument.
If INCLUSIVE is non-nil, then point is placed at the last character
of the object; otherwise it is placed at the end of the object."
(let* ((count (or count 1))
(backward (or backward
#'(lambda (count)
(funcall forward (- count)))))
(forward (or forward
#'(lambda (count)
(funcall backward (- count)))))
(opoint (point)))
(cond
((< count 0)
(when (bobp)
(signal 'beginning-of-buffer nil))
;; Do we need to move past the current object?
(when (>= (save-excursion
(funcall backward 1)
(funcall forward 1)
(point))
(if inclusive
(1+ opoint)
opoint))
(setq count (1- count)))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall backward 1))
(if (not (zerop count))
(goto-char (point-min))
;; go to end of object
(funcall forward 1)
(when inclusive
(unless (bobp) (backward-char)))
(when (or (evil-normal-state-p)
(evil-motion-state-p))
(evil-adjust-cursor)))))
((> count 0)
(when (evil-eobp)
(signal 'end-of-buffer nil))
(when inclusive
(forward-char))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall forward 1))
(if (not (zerop count))
(goto-char (point-max))
(when inclusive
(unless (bobp) (backward-char)))
(when (or (evil-normal-state-p)
(evil-motion-state-p))
(evil-adjust-cursor)))))
(t
count))))
(defun evil-text-object-make-linewise (range)
"Turn the text object selection RANGE to linewise.
The selection is adjusted in a sensible way so that the selected
lines match the user intent. In particular, whitespace-only parts
at the first and last lines are omitted. This function returns
the new range."
;; Bug #607
;; If new type is linewise and the selection of the
;; first line consists of whitespace only, the
;; beginning is moved to the start of the next line. If
;; the selections of the last line consists of
;; whitespace only, the end is moved to the end of the
;; previous line.
(if (eq (evil-type range) 'line)
range
(let ((expanded (plist-get (evil-range-properties range) :expanded))
(newrange (evil-expand-range range t)))
(save-excursion
;; skip whitespace at the beginning
(goto-char (evil-range-beginning newrange))
(skip-chars-forward " \t")
(when (and (not (bolp)) (eolp))
(evil-set-range-beginning newrange (1+ (point))))
;; skip whitepsace at the end
(goto-char (evil-range-end newrange))
(skip-chars-backward " \t")
(when (and (not (eolp)) (bolp))
(evil-set-range-end newrange (1- (point))))
;; only modify range if result is not empty
(if (> (evil-range-beginning newrange)
(evil-range-end newrange))
range
(unless expanded
(evil-contract-range newrange))
newrange)))))
(defmacro evil-define-text-object (object args &rest body)
"Define a text object command OBJECT.
BODY should return a range (BEG END) to the right of point
if COUNT is positive, and to the left of it if negative.
\(fn OBJECT (COUNT) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(doc-string 3)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
def-body)))
(let* ((args (delq '&optional args))
(count (or (pop args) 'count))
(args (when args `(&optional ,@args)))
(interactive '((interactive "<c><v>")))
arg doc key keys)
;; collect docstring
(when (stringp (car-safe body))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :extend-selection t))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body)
keys (plist-put keys key arg)))
;; interactive
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (list (pop body))))
;; macro expansion
`(evil-define-motion ,object (,count ,@args)
,@(when doc `(,doc))
,@keys
,@interactive
(setq ,count (or ,count 1))
(when (/= ,count 0)
(let ((type (evil-type ',object evil-visual-char))
(extend (and (evil-visual-state-p)
(evil-get-command-property
',object :extend-selection
',(plist-get keys :extend-selection))))
(dir evil-visual-direction)
mark point range selection)
(cond
;; Visual state: extend the current selection
((and (evil-visual-state-p)
(called-interactively-p 'any))
;; if we are at the beginning of the Visual selection,
;; go to the left (negative COUNT); if at the end,
;; go to the right (positive COUNT)
(setq dir evil-visual-direction
,count (* ,count dir))
(setq range (progn ,@body))
(when (evil-range-p range)
(setq range (evil-expand-range range))
(evil-set-type range (evil-type range type))
(setq range (evil-contract-range range))
;; the beginning is mark and the end is point
;; unless the selection goes the other way
(setq mark (evil-range-beginning range)
point (evil-range-end range)
type (evil-type
(if evil-text-object-change-visual-type
range
(evil-visual-range))))
(when (and (eq type 'line)
(not (eq type (evil-type range))))
(let ((newrange (evil-text-object-make-linewise range)))
(setq mark (evil-range-beginning newrange)
point (evil-range-end newrange))))
(when (< dir 0)
(evil-swap mark point))
;; select the union
(evil-visual-make-selection mark point type)))
;; not Visual state: return a pair of buffer positions
(t
(setq range (progn ,@body))
(unless (evil-range-p range)
(setq ,count (- ,count)
range (progn ,@body)))
(when (evil-range-p range)
(setq selection (evil-range (point) (point) type))
(if extend
(setq range (evil-range-union range selection))
(evil-set-type range (evil-type range type)))
;; possibly convert to linewise
(when (eq evil-this-type-modified 'line)
(setq range (evil-text-object-make-linewise range)))
(evil-set-range-properties range nil)
range))))))))
(defmacro evil-define-operator (operator args &rest body)
"Define an operator command OPERATOR.
\(fn OPERATOR (BEG END ARGS...) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(doc-string 3)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
[&optional ("interactive" [&rest form])]
def-body)))
(let* ((args (delq '&optional args))
(interactive (if (> (length args) 2) '("<R>") '("<r>")))
(args (if (> (length args) 2)
`(,(nth 0 args) ,(nth 1 args)
&optional ,@(nthcdr 2 args))
args))
arg doc key keys visual)
;; collect docstring
(when (and (> (length body) 1)
(or (eq (car-safe (car-safe body)) 'format)
(stringp (car-safe body))))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :move-point t))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body))
(cond
((eq key :keep-visual)
(setq visual arg))
(t
(setq keys (plist-put keys key arg)))))
;; collect `interactive' specification
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (cdr-safe (pop body))))
;; transform extended interactive specs
(setq interactive (apply #'evil-interactive-form interactive))
(setq keys (evil-concat-plists keys (cdr-safe interactive))
interactive (car-safe interactive))
;; macro expansion
`(evil-define-command ,operator ,args
,@(when doc `(,doc))
,@keys
:keep-visual t
:suppress-operator t
(interactive
(let* ((evil-operator-range-motion
(when (evil-has-command-property-p ',operator :motion)
;; :motion nil is equivalent to :motion undefined
(or (evil-get-command-property ',operator :motion)
#'undefined)))
(evil-operator-range-type
(evil-get-command-property ',operator :type))
(orig (point))
evil-operator-range-beginning
evil-operator-range-end
evil-inhibit-operator)
(setq evil-inhibit-operator-value nil
evil-this-operator this-command)
(prog1 ,interactive
(setq orig (point)
evil-inhibit-operator-value evil-inhibit-operator)
(if ,visual
(when (evil-visual-state-p)
(evil-visual-expand-region))
(when (or (evil-visual-state-p) (region-active-p))
(setq deactivate-mark t)))
(cond
((evil-visual-state-p)
(evil-visual-rotate 'upper-left))
((evil-get-command-property ',operator :move-point)
(goto-char (or evil-operator-range-beginning orig)))
(t
(goto-char orig))))))
(unwind-protect
(let ((evil-inhibit-operator evil-inhibit-operator-value))
(unless (and evil-inhibit-operator
(called-interactively-p 'any))
,@body))
(setq evil-inhibit-operator-value nil)))))
;; this is used in the `interactive' specification of an operator command
(defun evil-operator-range (&optional return-type)
"Read a motion from the keyboard and return its buffer positions.
The return value is a list (BEG END), or (BEG END TYPE) if
RETURN-TYPE is non-nil."
(let* ((evil-ex-p (and (not (minibufferp)) (evil-ex-p)))
(motion (or evil-operator-range-motion
(when evil-ex-p 'evil-line)))
(type evil-operator-range-type)
(range (evil-range (point) (point)))
command count modifier)
(setq evil-this-type-modified nil)
(evil-save-echo-area
(cond
;; Ex mode
((and evil-ex-p evil-ex-range)
(setq range evil-ex-range))
;; Visual selection
((and (not evil-ex-p) (evil-visual-state-p))
(setq range (evil-visual-range)))
;; active region
((and (not evil-ex-p) (region-active-p))
(setq range (evil-range (region-beginning)
(region-end)
(or evil-this-type 'exclusive))))
(t
;; motion
(evil-save-state
(unless motion
(evil-change-state 'operator)
;; Make linewise operator shortcuts. E.g., "d" yields the
;; shortcut "dd", and "g?" yields shortcuts "g??" and "g?g?".
(let ((keys (nth 2 (evil-extract-count (this-command-keys)))))
(setq keys (listify-key-sequence keys))
(dotimes (var (length keys))
(define-key evil-operator-shortcut-map
(vconcat (nthcdr var keys)) 'evil-line-or-visual-line)))
;; read motion from keyboard
(setq command (evil-read-motion motion)
motion (nth 0 command)
count (nth 1 command)
type (or type (nth 2 command))))
(cond
((eq motion #'undefined)
(setq range (if return-type '(nil nil nil) '(nil nil))
motion nil))
((or (null motion) ; keyboard-quit
(evil-get-command-property motion :suppress-operator))
(when (fboundp 'evil-repeat-abort)
(evil-repeat-abort))
(setq quit-flag t
motion nil))
(evil-repeat-count
(setq count evil-repeat-count
;; only the first operator's count is overwritten
evil-repeat-count nil))
((or count current-prefix-arg)
;; multiply operator count and motion count together
(setq count
(* (prefix-numeric-value count)
(prefix-numeric-value current-prefix-arg)))))
(when motion
(let ((evil-state 'operator)
mark-active)
;; calculate motion range
(setq range (evil-motion-range
motion
count
type))))
;; update global variables
(setq evil-this-motion motion
evil-this-motion-count count
type (evil-type range type)
evil-this-type type))))
(when (evil-range-p range)
(unless (or (null type) (eq (evil-type range) type))
(evil-contract-range range)
(evil-set-type range type)
(evil-expand-range range))
(evil-set-range-properties range nil)
(unless return-type
(evil-set-type range nil))
(setq evil-operator-range-beginning (evil-range-beginning range)
evil-operator-range-end (evil-range-end range)
evil-operator-range-type (evil-type range)))
range)))
(defmacro evil-define-type (type doc &rest body)
"Define type TYPE.
DOC is a general description and shows up in all docstrings.
It is followed by a list of keywords and functions:
:expand FUNC Expansion function. This function should accept
two positions in the current buffer, BEG and END,
and return a pair of expanded buffer positions.
:contract FUNC The opposite of :expand, optional.
:one-to-one BOOL Whether expansion is one-to-one. This means that
:expand followed by :contract always returns the
original range.
:normalize FUNC Normalization function, optional. This function should
accept two unexpanded positions and adjust them before
expansion. May be used to deal with buffer boundaries.
:string FUNC Description function. This takes two buffer positions
and returns a human-readable string, for example,
\"2 lines\".
If further keywords and functions are specified, they are assumed to
be transformations on buffer positions, like :expand and :contract.
\(fn TYPE DOC [[KEY FUNC]...])"
(declare (indent defun)
(doc-string 2)
(debug (&define name
[&optional stringp]
[&rest [keywordp function-form]])))
(let (args defun-forms func key name plist string sym val)
;; standard values
(setq plist (plist-put plist :one-to-one t))
;; keywords
(while (keywordp (car-safe body))
(setq key (pop body)
val (pop body))
(if (plist-member plist key) ; not a function
(setq plist (plist-put plist key val))
(setq func val
sym (intern (replace-regexp-in-string
"^:" "" (symbol-name key)))
name (intern (format "evil-%s-%s" type sym))
args (car (cdr-safe func))
string (car (cdr (cdr-safe func)))
string (if (stringp string)
(format "%s\n\n" string) "")
plist (plist-put plist key `',name))
(add-to-list
'defun-forms
(cond
((eq key :string)
`(defun ,name (beg end &rest properties)
,(format "Return size of %s from BEG to END \
with PROPERTIES.\n\n%s%s" type string doc)
(let ((beg (evil-normalize-position beg))
(end (evil-normalize-position end))
(type ',type)
plist range)
(when (and beg end)
(save-excursion
(evil-sort beg end)
(unless (plist-get properties :expanded)
(setq range (apply #'evil-expand
beg end type properties)
beg (evil-range-beginning range)
end (evil-range-end range)
type (evil-type range type)
plist (evil-range-properties range))
(setq properties
(evil-concat-plists properties plist)))
(or (apply #',func beg end
(when ,(> (length args) 2)
properties))
""))))))
(t
`(defun ,name (beg end &rest properties)
,(format "Perform %s transformation on %s from BEG to END \
with PROPERTIES.\n\n%s%s" sym type string doc)
(let ((beg (evil-normalize-position beg))
(end (evil-normalize-position end))
(type ',type)
plist range)
(when (and beg end)
(save-excursion
(evil-sort beg end)
(when (memq ,key '(:expand :contract))
(setq properties
(plist-put properties
:expanded
,(eq key :expand))))
(setq range (or (apply #',func beg end
(when ,(> (length args) 2)
properties))
(apply #'evil-range
beg end type properties))
beg (evil-range-beginning range)
end (evil-range-end range)
type (evil-type range type)
plist (evil-range-properties range))
(setq properties
(evil-concat-plists properties plist))
(apply #'evil-range beg end type properties)))))))
t)))
;; :one-to-one requires both or neither of :expand and :contract
(when (plist-get plist :expand)
(setq plist (plist-put plist :one-to-one
(and (plist-get plist :contract)
(plist-get plist :one-to-one)))))
`(progn
(evil-put-property 'evil-type-properties ',type ,@plist)
,@defun-forms
',type)))
(defmacro evil-define-interactive-code (code &rest body)
"Define an interactive code.
PROMPT, if given, is the remainder of the interactive string
up to the next newline. Command properties may be specified
via KEY-VALUE pairs. BODY should evaluate to a list of values.
\(fn CODE (PROMPT) [[KEY VALUE]...] BODY...)"
(declare (indent defun))
(let* ((args (when (and (> (length body) 1)
(listp (car-safe body)))
(pop body)))
(doc (when (stringp (car-safe body)) (pop body)))
func properties)
(while (keywordp (car-safe body))
(setq properties
(append properties (list (pop body) (pop body)))))
(cond
(args
(setq func `(lambda ,args
,@(when doc `(,doc))
,@body)))
((> (length body) 1)
(setq func `(progn ,@body)))
(t
(setq func (car body))))
`(eval-and-compile
(let* ((code ,code)
(entry (assoc code evil-interactive-alist))
(value (cons ',func ',properties)))
(if entry
(setcdr entry value)
(push (cons code value) evil-interactive-alist))
code))))
;;; Highlighting
(when (fboundp 'font-lock-add-keywords)
(font-lock-add-keywords
'emacs-lisp-mode
;; Match all `evil-define-' forms except `evil-define-key'.
;; (In the interests of speed, this expression is incomplete
;; and does not match all three-letter words.)
'(("(\\(evil-\\(?:ex-\\)?define-\
\\(?:[^ k][^ e][^ y]\\|[-[:word:]]\\{4,\\}\\)\\)\
\\>[ \f\t\n\r\v]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face nil t))
("(\\(evil-\\(?:delay\\|narrow\\|signal\\|save\\|with\\(?:out\\)?\\)\
\\(?:-[-[:word:]]+\\)?\\)\\>\[ \f\t\n\r\v]+"
1 font-lock-keyword-face)
("(\\(evil-\\(?:[-[:word:]]\\)*loop\\)\\>[ \f\t\n\r\v]+"
1 font-lock-keyword-face))))
(provide 'evil-macros)
;;; evil-macros.el ends here

View File

@ -0,0 +1,572 @@
;;; evil-maps.el --- Default keymaps
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-states)
(require 'evil-ex)
(require 'evil-commands)
(require 'evil-command-window)
(require 'evil-common)
;;; Code:
;;; Normal state
(define-key evil-normal-state-map "a" 'evil-append)
(define-key evil-normal-state-map "A" 'evil-append-line)
(define-key evil-normal-state-map "c" 'evil-change)
(define-key evil-normal-state-map "C" 'evil-change-line)
(define-key evil-normal-state-map "d" 'evil-delete)
(define-key evil-normal-state-map "D" 'evil-delete-line)
(define-key evil-normal-state-map "i" 'evil-insert)
(define-key evil-normal-state-map (kbd "<insert>") 'evil-insert)
(define-key evil-normal-state-map (kbd "<insertchar>") 'evil-insert)
(define-key evil-normal-state-map "I" 'evil-insert-line)
(define-key evil-normal-state-map "J" 'evil-join)
(define-key evil-normal-state-map "m" 'evil-set-marker)
(define-key evil-normal-state-map "o" 'evil-open-below)
(define-key evil-normal-state-map "O" 'evil-open-above)
(define-key evil-normal-state-map "p" 'evil-paste-after)
(define-key evil-normal-state-map "P" 'evil-paste-before)
(define-key evil-normal-state-map "q" 'evil-record-macro)
(define-key evil-normal-state-map "r" 'evil-replace)
(define-key evil-normal-state-map "R" 'evil-replace-state)
(define-key evil-normal-state-map "s" 'evil-substitute)
(define-key evil-normal-state-map "S" 'evil-change-whole-line)
(define-key evil-normal-state-map "x" 'evil-delete-char)
(define-key evil-normal-state-map "X" 'evil-delete-backward-char)
(define-key evil-normal-state-map [deletechar] 'evil-delete-char)
(define-key evil-normal-state-map "y" 'evil-yank)
(define-key evil-normal-state-map "Y" 'evil-yank-line)
(define-key evil-normal-state-map "&" 'evil-ex-repeat-substitute)
(define-key evil-normal-state-map "g&" 'evil-ex-repeat-global-substitute)
(define-key evil-normal-state-map "g8" 'what-cursor-position)
(define-key evil-normal-state-map "ga" 'what-cursor-position)
(define-key evil-normal-state-map "gi" 'evil-insert-resume)
(define-key evil-normal-state-map "gJ" 'evil-join-whitespace)
(define-key evil-normal-state-map "gq" 'evil-fill-and-move)
(define-key evil-normal-state-map "gw" 'evil-fill)
(define-key evil-normal-state-map "gu" 'evil-downcase)
(define-key evil-normal-state-map "gU" 'evil-upcase)
(define-key evil-normal-state-map "gf" 'find-file-at-point)
(define-key evil-normal-state-map "gF" 'evil-find-file-at-point-with-line)
(define-key evil-normal-state-map "gx" 'browse-url-at-point)
(define-key evil-normal-state-map "g?" 'evil-rot13)
(define-key evil-normal-state-map "g~" 'evil-invert-case)
(define-key evil-normal-state-map "zo" 'evil-open-fold)
(define-key evil-normal-state-map "zO" 'evil-open-fold-rec)
(define-key evil-normal-state-map "zc" 'evil-close-fold)
(define-key evil-normal-state-map "za" 'evil-toggle-fold)
(define-key evil-normal-state-map "zr" 'evil-open-folds)
(define-key evil-normal-state-map "zm" 'evil-close-folds)
(define-key evil-normal-state-map "z=" 'ispell-word)
(define-key evil-normal-state-map "\C-n" 'evil-paste-pop-next)
(define-key evil-normal-state-map "\C-p" 'evil-paste-pop)
(define-key evil-normal-state-map "\C-t" 'pop-tag-mark)
(define-key evil-normal-state-map (kbd "C-.") 'evil-repeat-pop)
(define-key evil-normal-state-map (kbd "M-.") 'evil-repeat-pop-next)
(define-key evil-normal-state-map "." 'evil-repeat)
(define-key evil-normal-state-map "@" 'evil-execute-macro)
(define-key evil-normal-state-map "\"" 'evil-use-register)
(define-key evil-normal-state-map "~" 'evil-invert-char)
(define-key evil-normal-state-map "=" 'evil-indent)
(define-key evil-normal-state-map "<" 'evil-shift-left)
(define-key evil-normal-state-map ">" 'evil-shift-right)
(define-key evil-normal-state-map "ZZ" 'evil-save-modified-and-close)
(define-key evil-normal-state-map "ZQ" 'evil-quit)
(define-key evil-normal-state-map (kbd "DEL") 'evil-backward-char)
(define-key evil-normal-state-map [escape] 'evil-force-normal-state)
(define-key evil-normal-state-map [remap cua-paste-pop] 'evil-paste-pop)
(define-key evil-normal-state-map [remap yank-pop] 'evil-paste-pop)
(when (featurep 'tab-bar)
(define-key evil-normal-state-map "gt" 'tab-bar-switch-to-next-tab)
(define-key evil-normal-state-map "gT" 'tab-bar-switch-to-prev-tab))
;; go to last change
(define-key evil-normal-state-map "g;" 'goto-last-change)
(define-key evil-normal-state-map "g," 'goto-last-change-reverse)
;; undo
(define-key evil-normal-state-map "u" 'undo)
(define-key evil-normal-state-map "\C-r" 'redo)
;; window commands
(define-prefix-command 'evil-window-map)
(define-key evil-window-map "b" 'evil-window-bottom-right)
(define-key evil-window-map "c" 'evil-window-delete)
(define-key evil-window-map "h" 'evil-window-left)
(define-key evil-window-map "H" 'evil-window-move-far-left)
(define-key evil-window-map "j" 'evil-window-down)
(define-key evil-window-map "J" 'evil-window-move-very-bottom)
(define-key evil-window-map "k" 'evil-window-up)
(define-key evil-window-map "K" 'evil-window-move-very-top)
(define-key evil-window-map "l" 'evil-window-right)
(define-key evil-window-map "L" 'evil-window-move-far-right)
(define-key evil-window-map "n" 'evil-window-new)
(define-key evil-window-map "o" 'delete-other-windows)
(define-key evil-window-map "p" 'evil-window-mru)
(define-key evil-window-map "q" 'evil-quit)
(define-key evil-window-map "r" 'evil-window-rotate-downwards)
(define-key evil-window-map "R" 'evil-window-rotate-upwards)
(define-key evil-window-map "s" 'evil-window-split)
(define-key evil-window-map "S" 'evil-window-split)
(define-key evil-window-map "t" 'evil-window-top-left)
(define-key evil-window-map "v" 'evil-window-vsplit)
(define-key evil-window-map "w" 'evil-window-next)
(define-key evil-window-map "W" 'evil-window-prev)
(define-key evil-window-map "+" 'evil-window-increase-height)
(define-key evil-window-map "-" 'evil-window-decrease-height)
(define-key evil-window-map "_" 'evil-window-set-height)
(define-key evil-window-map "<" 'evil-window-decrease-width)
(define-key evil-window-map ">" 'evil-window-increase-width)
(define-key evil-window-map "=" 'balance-windows)
(define-key evil-window-map "|" 'evil-window-set-width)
(define-key evil-window-map "\C-b" 'evil-window-bottom-right)
(define-key evil-window-map "\C-c" 'evil-window-delete)
(define-key evil-window-map (kbd "C-S-h") 'evil-window-move-far-left)
(define-key evil-window-map (kbd "C-S-j") 'evil-window-move-very-bottom)
(define-key evil-window-map (kbd "C-S-k") 'evil-window-move-very-top)
(define-key evil-window-map (kbd "C-S-l") 'evil-window-move-far-right)
(define-key evil-window-map "\C-n" 'evil-window-new)
(define-key evil-window-map "\C-o" 'delete-other-windows)
(define-key evil-window-map "\C-p" 'evil-window-mru)
(define-key evil-window-map "\C-r" 'evil-window-rotate-downwards)
(define-key evil-window-map (kbd "C-S-r") 'evil-window-rotate-upwards)
(define-key evil-window-map "\C-s" 'evil-window-split)
(define-key evil-window-map (kbd "C-S-s") 'evil-window-split)
(define-key evil-window-map "\C-t" 'evil-window-top-left)
(define-key evil-window-map "\C-v" 'evil-window-vsplit)
(define-key evil-window-map "\C-w" 'evil-window-next)
(define-key evil-window-map (kbd "C-S-W") 'evil-window-prev)
(define-key evil-window-map "\C-_" 'evil-window-set-height)
(define-key evil-window-map "\C-f" 'ffap-other-window)
;;; Motion state
;; "0" is a special command when called first
(evil-redirect-digit-argument evil-motion-state-map "0" 'evil-beginning-of-line)
(define-key evil-motion-state-map "1" 'digit-argument)
(define-key evil-motion-state-map "2" 'digit-argument)
(define-key evil-motion-state-map "3" 'digit-argument)
(define-key evil-motion-state-map "4" 'digit-argument)
(define-key evil-motion-state-map "5" 'digit-argument)
(define-key evil-motion-state-map "6" 'digit-argument)
(define-key evil-motion-state-map "7" 'digit-argument)
(define-key evil-motion-state-map "8" 'digit-argument)
(define-key evil-motion-state-map "9" 'digit-argument)
(define-key evil-motion-state-map "b" 'evil-backward-word-begin)
(define-key evil-motion-state-map "B" 'evil-backward-WORD-begin)
(define-key evil-motion-state-map "e" 'evil-forward-word-end)
(define-key evil-motion-state-map "E" 'evil-forward-WORD-end)
(define-key evil-motion-state-map "f" 'evil-find-char)
(define-key evil-motion-state-map "F" 'evil-find-char-backward)
(define-key evil-motion-state-map "G" 'evil-goto-line)
(define-key evil-motion-state-map "h" 'evil-backward-char)
(define-key evil-motion-state-map "H" 'evil-window-top)
(define-key evil-motion-state-map "j" 'evil-next-line)
(define-key evil-motion-state-map "k" 'evil-previous-line)
(define-key evil-motion-state-map "l" 'evil-forward-char)
(define-key evil-motion-state-map " " 'evil-forward-char)
(define-key evil-motion-state-map "K" 'evil-lookup)
(define-key evil-motion-state-map "L" 'evil-window-bottom)
(define-key evil-motion-state-map "M" 'evil-window-middle)
(define-key evil-motion-state-map "n" 'evil-search-next)
(define-key evil-motion-state-map "N" 'evil-search-previous)
(define-key evil-motion-state-map "t" 'evil-find-char-to)
(define-key evil-motion-state-map "T" 'evil-find-char-to-backward)
(define-key evil-motion-state-map "w" 'evil-forward-word-begin)
(define-key evil-motion-state-map "W" 'evil-forward-WORD-begin)
(define-key evil-motion-state-map "y" 'evil-yank)
(define-key evil-motion-state-map "Y" 'evil-yank-line)
(define-key evil-motion-state-map "gd" 'evil-goto-definition)
(define-key evil-motion-state-map "ge" 'evil-backward-word-end)
(define-key evil-motion-state-map "gE" 'evil-backward-WORD-end)
(define-key evil-motion-state-map "gg" 'evil-goto-first-line)
(define-key evil-motion-state-map "gj" 'evil-next-visual-line)
(define-key evil-motion-state-map "gk" 'evil-previous-visual-line)
(define-key evil-motion-state-map "g0" 'evil-beginning-of-visual-line)
(define-key evil-motion-state-map "g_" 'evil-last-non-blank)
(define-key evil-motion-state-map "g^" 'evil-first-non-blank-of-visual-line)
(define-key evil-motion-state-map "gm" 'evil-middle-of-visual-line)
(define-key evil-motion-state-map "g$" 'evil-end-of-visual-line)
(define-key evil-motion-state-map "g\C-]" 'evil-jump-to-tag)
(define-key evil-motion-state-map "{" 'evil-backward-paragraph)
(define-key evil-motion-state-map "}" 'evil-forward-paragraph)
(define-key evil-motion-state-map "#" 'evil-search-word-backward)
(define-key evil-motion-state-map "g#" 'evil-search-unbounded-word-backward)
(define-key evil-motion-state-map "$" 'evil-end-of-line)
(define-key evil-motion-state-map "%" 'evil-jump-item)
(define-key evil-motion-state-map "`" 'evil-goto-mark)
(define-key evil-motion-state-map "'" 'evil-goto-mark-line)
(define-key evil-motion-state-map "(" 'evil-backward-sentence-begin)
(define-key evil-motion-state-map ")" 'evil-forward-sentence-begin)
(define-key evil-motion-state-map "]]" 'evil-forward-section-begin)
(define-key evil-motion-state-map "][" 'evil-forward-section-end)
(define-key evil-motion-state-map "[[" 'evil-backward-section-begin)
(define-key evil-motion-state-map "[]" 'evil-backward-section-end)
(define-key evil-motion-state-map "[(" 'evil-previous-open-paren)
(define-key evil-motion-state-map "])" 'evil-next-close-paren)
(define-key evil-motion-state-map "[{" 'evil-previous-open-brace)
(define-key evil-motion-state-map "]}" 'evil-next-close-brace)
(define-key evil-motion-state-map "]s" 'evil-next-flyspell-error)
(define-key evil-motion-state-map "[s" 'evil-prev-flyspell-error)
(define-key evil-motion-state-map "*" 'evil-search-word-forward)
(define-key evil-motion-state-map "g*" 'evil-search-unbounded-word-forward)
(define-key evil-motion-state-map "," 'evil-repeat-find-char-reverse)
(define-key evil-motion-state-map "/" 'evil-search-forward)
(define-key evil-motion-state-map ";" 'evil-repeat-find-char)
(define-key evil-motion-state-map "?" 'evil-search-backward)
(define-key evil-motion-state-map "|" 'evil-goto-column)
(define-key evil-motion-state-map "^" 'evil-first-non-blank)
(define-key evil-motion-state-map "+" 'evil-next-line-first-non-blank)
(define-key evil-motion-state-map "_" 'evil-next-line-1-first-non-blank)
(define-key evil-motion-state-map "-" 'evil-previous-line-first-non-blank)
(define-key evil-motion-state-map "\C-w" 'evil-window-map)
(define-key evil-motion-state-map (kbd "C-6") 'evil-switch-to-windows-last-buffer)
(define-key evil-motion-state-map "\C-]" 'evil-jump-to-tag)
(define-key evil-motion-state-map (kbd "C-b") 'evil-scroll-page-up)
(define-key evil-motion-state-map (kbd "C-e") 'evil-scroll-line-down)
(define-key evil-motion-state-map (kbd "C-f") 'evil-scroll-page-down)
(define-key evil-motion-state-map (kbd "C-o") 'evil-jump-backward)
(define-key evil-motion-state-map (kbd "C-y") 'evil-scroll-line-up)
(define-key evil-motion-state-map (kbd "RET") 'evil-ret)
(define-key evil-motion-state-map "\\" 'evil-execute-in-emacs-state)
(define-key evil-motion-state-map "z^" 'evil-scroll-top-line-to-bottom)
(define-key evil-motion-state-map "z+" 'evil-scroll-bottom-line-to-top)
(define-key evil-motion-state-map "zt" 'evil-scroll-line-to-top)
;; TODO: z RET has an advanced form taking an count before the RET
;; but this requires again a special state with a single command
;; bound to RET
(define-key evil-motion-state-map (vconcat "z" [return]) "zt^")
(define-key evil-motion-state-map (kbd "z RET") (vconcat "z" [return]))
(define-key evil-motion-state-map "zz" 'evil-scroll-line-to-center)
(define-key evil-motion-state-map "z." "zz^")
(define-key evil-motion-state-map "zb" 'evil-scroll-line-to-bottom)
(define-key evil-motion-state-map "z-" "zb^")
(define-key evil-motion-state-map "v" 'evil-visual-char)
(define-key evil-motion-state-map "V" 'evil-visual-line)
(define-key evil-motion-state-map "\C-v" 'evil-visual-block)
(define-key evil-motion-state-map "gv" 'evil-visual-restore)
(define-key evil-motion-state-map (kbd "C-^") 'evil-buffer)
(define-key evil-motion-state-map [left] 'evil-backward-char)
(define-key evil-motion-state-map [right] 'evil-forward-char)
(define-key evil-motion-state-map [up] 'evil-previous-line)
(define-key evil-motion-state-map [down] 'evil-next-line)
(define-key evil-motion-state-map "zl" 'evil-scroll-column-right)
(define-key evil-motion-state-map [?z right] "zl")
(define-key evil-motion-state-map "zh" 'evil-scroll-column-left)
(define-key evil-motion-state-map [?z left] "zh")
(define-key evil-motion-state-map "zL" 'evil-scroll-right)
(define-key evil-motion-state-map "zH" 'evil-scroll-left)
(define-key evil-motion-state-map
(read-kbd-macro evil-toggle-key) 'evil-emacs-state)
;; text objects
(define-key evil-outer-text-objects-map "w" 'evil-a-word)
(define-key evil-outer-text-objects-map "W" 'evil-a-WORD)
(define-key evil-outer-text-objects-map "s" 'evil-a-sentence)
(define-key evil-outer-text-objects-map "p" 'evil-a-paragraph)
(define-key evil-outer-text-objects-map "b" 'evil-a-paren)
(define-key evil-outer-text-objects-map "(" 'evil-a-paren)
(define-key evil-outer-text-objects-map ")" 'evil-a-paren)
(define-key evil-outer-text-objects-map "[" 'evil-a-bracket)
(define-key evil-outer-text-objects-map "]" 'evil-a-bracket)
(define-key evil-outer-text-objects-map "B" 'evil-a-curly)
(define-key evil-outer-text-objects-map "{" 'evil-a-curly)
(define-key evil-outer-text-objects-map "}" 'evil-a-curly)
(define-key evil-outer-text-objects-map "<" 'evil-an-angle)
(define-key evil-outer-text-objects-map ">" 'evil-an-angle)
(define-key evil-outer-text-objects-map "'" 'evil-a-single-quote)
(define-key evil-outer-text-objects-map "\"" 'evil-a-double-quote)
(define-key evil-outer-text-objects-map "`" 'evil-a-back-quote)
(define-key evil-outer-text-objects-map "t" 'evil-a-tag)
(define-key evil-outer-text-objects-map "o" 'evil-a-symbol)
(define-key evil-inner-text-objects-map "w" 'evil-inner-word)
(define-key evil-inner-text-objects-map "W" 'evil-inner-WORD)
(define-key evil-inner-text-objects-map "s" 'evil-inner-sentence)
(define-key evil-inner-text-objects-map "p" 'evil-inner-paragraph)
(define-key evil-inner-text-objects-map "b" 'evil-inner-paren)
(define-key evil-inner-text-objects-map "(" 'evil-inner-paren)
(define-key evil-inner-text-objects-map ")" 'evil-inner-paren)
(define-key evil-inner-text-objects-map "[" 'evil-inner-bracket)
(define-key evil-inner-text-objects-map "]" 'evil-inner-bracket)
(define-key evil-inner-text-objects-map "B" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "{" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "}" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "<" 'evil-inner-angle)
(define-key evil-inner-text-objects-map ">" 'evil-inner-angle)
(define-key evil-inner-text-objects-map "'" 'evil-inner-single-quote)
(define-key evil-inner-text-objects-map "\"" 'evil-inner-double-quote)
(define-key evil-inner-text-objects-map "`" 'evil-inner-back-quote)
(define-key evil-inner-text-objects-map "t" 'evil-inner-tag)
(define-key evil-inner-text-objects-map "o" 'evil-inner-symbol)
(define-key evil-motion-state-map "gn" 'evil-next-match)
(define-key evil-motion-state-map "gN" 'evil-previous-match)
(when evil-want-C-i-jump
(define-key evil-motion-state-map (kbd "C-i") 'evil-jump-forward))
(when evil-want-C-u-scroll
(define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up))
(when evil-want-C-d-scroll
(define-key evil-motion-state-map (kbd "C-d") 'evil-scroll-down))
;;; Visual state
(define-key evil-visual-state-map "A" 'evil-append)
(define-key evil-visual-state-map "I" 'evil-insert)
(define-key evil-visual-state-map "o" 'exchange-point-and-mark)
(define-key evil-visual-state-map "O" 'evil-visual-exchange-corners)
(define-key evil-visual-state-map "R" 'evil-change)
(define-key evil-visual-state-map "u" 'evil-downcase)
(define-key evil-visual-state-map "U" 'evil-upcase)
(define-key evil-visual-state-map "z=" 'ispell-word)
(define-key evil-visual-state-map "a" evil-outer-text-objects-map)
(define-key evil-visual-state-map "i" evil-inner-text-objects-map)
(define-key evil-visual-state-map (kbd "<insert>") 'undefined)
(define-key evil-visual-state-map (kbd "<insertchar>") 'undefined)
(define-key evil-visual-state-map [remap evil-repeat] 'undefined)
(define-key evil-visual-state-map [escape] 'evil-exit-visual-state)
;;; Operator-Pending state
(define-key evil-operator-state-map "a" evil-outer-text-objects-map)
(define-key evil-operator-state-map "i" evil-inner-text-objects-map)
;; (define-key evil-operator-state-map [escape] 'keyboard-quit)
;;; Insert state
(defvar evil-insert-state-bindings
`(("\C-v" . quoted-insert)
("\C-k" . evil-insert-digraph)
("\C-o" . evil-execute-in-normal-state)
("\C-r" . evil-paste-from-register)
("\C-y" . evil-copy-from-above)
("\C-e" . evil-copy-from-below)
("\C-n" . evil-complete-next)
("\C-p" . evil-complete-previous)
("\C-x\C-n" . evil-complete-next-line)
("\C-x\C-p" . evil-complete-previous-line)
("\C-t" . evil-shift-right-line)
("\C-d" . evil-shift-left-line)
("\C-a" . evil-paste-last-insertion)
([remap delete-backward-char] . evil-delete-backward-char-and-join)
,(if evil-want-C-w-delete
'("\C-w" . evil-delete-backward-word)
'("\C-w" . evil-window-map))
([mouse-2] . mouse-yank-primary))
"Evil's bindings for insert state (for
`evil-insert-state-map'), excluding <delete>, <escape>, and
`evil-toggle-key'.")
(defun evil-update-insert-state-bindings (&optional _option-name remove force)
"Update bindings in `evil-insert-state-map'.
If no arguments are given add the bindings specified in
`evil-insert-state-bindings'. If REMOVE is non nil, remove only
these bindings. Unless FORCE is non nil, this will not
overwriting existing bindings, which means bindings will not be
added if one already exists for a key and only default bindings
are removed.
Note that <delete>, <escape> and `evil-toggle-key' are not
included in `evil-insert-state-bindings' by default."
(interactive)
(dolist (binding evil-insert-state-bindings)
(cond
((and remove
(or force
;; Only remove if the default binding has not changed
(eq (evil-lookup-key evil-insert-state-map (car binding))
(cdr binding))))
(define-key evil-insert-state-map (car binding) nil))
((and (null remove)
(or force
;; Check to see that nothing is bound here before adding
(not (evil-lookup-key evil-insert-state-map (car binding)))))
(define-key evil-insert-state-map (car binding) (cdr binding))))))
(define-key evil-insert-state-map [delete] 'delete-char)
(define-key evil-insert-state-map [escape] 'evil-normal-state)
(define-key evil-insert-state-map
(read-kbd-macro evil-toggle-key) 'evil-emacs-state)
;;; Replace state
(define-key evil-replace-state-map (kbd "DEL") 'evil-replace-backspace)
(define-key evil-replace-state-map [escape] 'evil-normal-state)
;;; Emacs state
(define-key evil-emacs-state-map
(read-kbd-macro evil-toggle-key) 'evil-exit-emacs-state)
(when evil-want-C-w-in-emacs-state
(define-key evil-emacs-state-map "\C-w" 'evil-window-map))
;;; Mouse
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region)
(define-key evil-visual-state-map [mouse-2] 'evil-exit-visual-and-repeat)
(define-key evil-normal-state-map [mouse-2] 'mouse-yank-primary)
;; Ex
(define-key evil-motion-state-map ":" 'evil-ex)
(define-key evil-motion-state-map "!" 'evil-shell-command)
(evil-ex-define-cmd "e[dit]" 'evil-edit)
(evil-ex-define-cmd "w[rite]" 'evil-write)
(evil-ex-define-cmd "wa[ll]" 'evil-write-all)
(evil-ex-define-cmd "sav[eas]" 'evil-save)
(evil-ex-define-cmd "r[ead]" 'evil-read)
(evil-ex-define-cmd "b[uffer]" 'evil-buffer)
(evil-ex-define-cmd "bn[ext]" 'evil-next-buffer)
(evil-ex-define-cmd "bp[revious]" 'evil-prev-buffer)
(evil-ex-define-cmd "bN[ext]" "bprevious")
(evil-ex-define-cmd "sb[uffer]" 'evil-split-buffer)
(evil-ex-define-cmd "sbn[ext]" 'evil-split-next-buffer)
(evil-ex-define-cmd "sbp[revious]" 'evil-split-prev-buffer)
(evil-ex-define-cmd "sbN[ext]" "sbprevious")
(evil-ex-define-cmd "buffers" 'buffer-menu)
(evil-ex-define-cmd "files" 'evil-show-files)
(evil-ex-define-cmd "ls" "buffers")
(evil-ex-define-cmd "c[hange]" 'evil-change)
(evil-ex-define-cmd "co[py]" 'evil-copy)
(evil-ex-define-cmd "t" "copy")
(evil-ex-define-cmd "m[ove]" 'evil-move)
(evil-ex-define-cmd "d[elete]" 'evil-ex-delete)
(evil-ex-define-cmd "y[ank]" 'evil-ex-yank)
(evil-ex-define-cmd "go[to]" 'evil-goto-char)
(evil-ex-define-cmd "j[oin]" 'evil-ex-join)
(evil-ex-define-cmd "le[ft]" 'evil-align-left)
(evil-ex-define-cmd "ri[ght]" 'evil-align-right)
(evil-ex-define-cmd "ce[nter]" 'evil-align-center)
(evil-ex-define-cmd "sp[lit]" 'evil-window-split)
(evil-ex-define-cmd "vs[plit]" 'evil-window-vsplit)
(evil-ex-define-cmd "new" 'evil-window-new)
(evil-ex-define-cmd "ene[w]" 'evil-buffer-new)
(evil-ex-define-cmd "vne[w]" 'evil-window-vnew)
(evil-ex-define-cmd "clo[se]" 'evil-window-delete)
(evil-ex-define-cmd "on[ly]" 'delete-other-windows)
(evil-ex-define-cmd "q[uit]" 'evil-quit)
(evil-ex-define-cmd "wq" 'evil-save-and-close)
(evil-ex-define-cmd "quita[ll]" 'evil-quit-all)
(evil-ex-define-cmd "qa[ll]" "quitall")
(evil-ex-define-cmd "cq[uit]" 'evil-quit-all-with-error-code)
(evil-ex-define-cmd "wqa[ll]" 'evil-save-and-quit)
(evil-ex-define-cmd "xa[ll]" "wqall")
(evil-ex-define-cmd "x[it]" 'evil-save-modified-and-close)
(evil-ex-define-cmd "exi[t]" 'evil-save-modified-and-close)
(evil-ex-define-cmd "bd[elete]" 'evil-delete-buffer)
(evil-ex-define-cmd "bw[ipeout]" 'evil-delete-buffer)
(evil-ex-define-cmd "g[lobal]" 'evil-ex-global)
(evil-ex-define-cmd "v[global]" 'evil-ex-global-inverted)
(evil-ex-define-cmd "norm[al]" 'evil-ex-normal)
(evil-ex-define-cmd "s[ubstitute]" 'evil-ex-substitute)
(evil-ex-define-cmd "&" 'evil-ex-repeat-substitute)
(evil-ex-define-cmd "&&" 'evil-ex-repeat-substitute-with-flags)
(evil-ex-define-cmd "~" 'evil-ex-repeat-substitute-with-search)
(evil-ex-define-cmd "~&" 'evil-ex-repeat-substitute-with-search-and-flags)
(evil-ex-define-cmd "registers" 'evil-show-registers)
(evil-ex-define-cmd "marks" 'evil-show-marks)
(evil-ex-define-cmd "delm[arks]" 'evil-delete-marks)
(evil-ex-define-cmd "ju[mps]" 'evil-show-jumps)
(evil-ex-define-cmd "noh[lsearch]" 'evil-ex-nohighlight)
(evil-ex-define-cmd "f[ile]" 'evil-show-file-info)
(evil-ex-define-cmd "<" 'evil-shift-left)
(evil-ex-define-cmd ">" 'evil-shift-right)
(evil-ex-define-cmd "=" 'evil-ex-line-number)
(evil-ex-define-cmd "!" 'evil-shell-command)
(evil-ex-define-cmd "@:" 'evil-ex-repeat)
(evil-ex-define-cmd "mak[e]" 'evil-make)
(evil-ex-define-cmd "cc" 'evil-goto-error)
(evil-ex-define-cmd "cfir[st]" 'first-error)
(evil-ex-define-cmd "cr[ewind]" 'first-error)
(evil-ex-define-cmd "cn[ext]" 'next-error)
(evil-ex-define-cmd "cp[revious]" 'previous-error)
(evil-ex-define-cmd "set-initial-state" 'evil-ex-set-initial-state)
(evil-ex-define-cmd "show-digraphs" 'evil-ex-show-digraphs)
(evil-ex-define-cmd "sor[t]" 'evil-ex-sort)
(evil-ex-define-cmd "res[ize]" 'evil-ex-resize)
(when (featurep 'tab-bar)
(evil-ex-define-cmd "tabnew" 'tab-bar-new-tab)
(evil-ex-define-cmd "tabn[ext]" 'tab-bar-switch-to-next-tab)
(evil-ex-define-cmd "tabp[revious]" 'tab-bar-switch-to-prev-tab))
;; search command line
(define-key evil-ex-search-keymap "\d" #'evil-ex-delete-backward-char)
(define-key evil-ex-search-keymap "\C-r" 'evil-paste-from-register)
(define-key evil-ex-search-keymap "\C-n" 'next-history-element)
(define-key evil-ex-search-keymap "\C-p" 'previous-history-element)
;; ex command line
(define-key evil-ex-completion-map "\d" #'evil-ex-delete-backward-char)
(define-key evil-ex-completion-map "\t" #'evil-ex-completion)
(define-key evil-ex-completion-map [tab] #'evil-ex-completion)
(define-key evil-ex-completion-map [remap completion-at-point] #'evil-ex-completion)
(define-key evil-ex-completion-map "\C-a" 'evil-ex-completion)
(define-key evil-ex-completion-map "\C-b" 'move-beginning-of-line)
(define-key evil-ex-completion-map "\C-c" 'abort-recursive-edit)
(define-key evil-ex-completion-map "\C-d" 'evil-ex-completion)
(define-key evil-ex-completion-map "\C-g" 'abort-recursive-edit)
(define-key evil-ex-completion-map "\C-k" 'evil-insert-digraph)
(define-key evil-ex-completion-map "\C-l" 'evil-ex-completion)
(define-key evil-ex-completion-map "\C-p" #'previous-complete-history-element)
(define-key evil-ex-completion-map "\C-r" 'evil-paste-from-register)
(define-key evil-ex-completion-map "\C-n" #'next-complete-history-element)
(define-key evil-ex-completion-map "\C-u" 'evil-delete-whole-line)
(define-key evil-ex-completion-map "\C-v" #'quoted-insert)
(define-key evil-ex-completion-map "\C-w" 'backward-kill-word)
(define-key evil-ex-completion-map [escape] 'abort-recursive-edit)
(define-key evil-ex-completion-map [S-left] 'backward-word)
(define-key evil-ex-completion-map [S-right] 'forward-word)
(define-key evil-ex-completion-map [up] 'previous-complete-history-element)
(define-key evil-ex-completion-map [down] 'next-complete-history-element)
(define-key evil-ex-completion-map [prior] 'previous-history-element)
(define-key evil-ex-completion-map [next] 'next-history-element)
(define-key evil-ex-completion-map [return] 'exit-minibuffer)
(define-key evil-ex-completion-map (kbd "RET") 'exit-minibuffer)
;; evil-read-key
(define-key evil-read-key-map (kbd "ESC") #'keyboard-quit)
(define-key evil-read-key-map (kbd "C-]") #'keyboard-quit)
(define-key evil-read-key-map (kbd "C-g") #'keyboard-quit)
(define-key evil-read-key-map (kbd "C-q") #'evil-read-quoted-char)
(define-key evil-read-key-map (kbd "C-v") #'evil-read-quoted-char)
(define-key evil-read-key-map (kbd "C-k") #'evil-read-digraph-char)
(define-key evil-read-key-map "\r" "\n")
;; command line window
(evil-define-key 'normal
evil-command-window-mode-map (kbd "RET") 'evil-command-window-execute)
(evil-define-key 'insert
evil-command-window-mode-map (kbd "RET") 'evil-command-window-execute)
(provide 'evil-maps)
;;; evil-maps.el ends here

View File

@ -0,0 +1,8 @@
(define-package "evil" "20191121.752" "Extensible Vi layer for Emacs."
'((emacs "24.1")
(undo-tree "0.6.3")
(goto-chg "1.6")
(cl-lib "0.5")))
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@ -0,0 +1,639 @@
;;; evil-repeat.el --- Repeat system
;; Author: Frank Fischer <frank.fischer at mathematik.tu-chemnitz.de>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A repeat begins when leaving Normal state; it ends when re-entering
;; Normal state. The diagram below shows possible routes between
;; Normal state (N), Insert state (I), Visual state (V),
;; Operator-Pending state (O) and Replace state (R). (Emacs state
;; is an exception: nothing is repeated in that state.)
;; ___
;; / \
;; | R |
;; \___/
;; ^ |
;; | |
;; ___ |___V ___
;; / \ <------- / \ -------> / \
;; | V | | N | | O |
;; \___/ -------> \___/ <------- \___/
;; | | ^ |
;; | | | |
;; | V___| |
;; | / \ |
;; +--------> | I | <--------+
;; \___/
;;
;; The recording of a repeat is started in one of two cases: Either a
;; command is about being executed (in pre-command-hook) or normal
;; state is exited. The recording is stopped whenever a command has
;; being completed and evil is in normal state afterwards. Therefore,
;; a non-inserting command in normal-state is recorded as a single
;; repeat unit. In contrast, if the command leaves normal state and
;; starts insert-state, all commands that are executed until
;; insert-state is left and normal state is reactivated are recorded
;; together in one repeat unit. In other words, a repeat unit consists
;; of all commands that are executed starting and ending in normal
;; state.
;;
;; Not all commands are recorded. There are several commands that are
;; completely ignored and other commands that even abort the currently
;; active recording, e.g., commands that change the current buffer.
;;
;; During recording the repeat information is appended to the variable
;; `evil-repeat-info', which is cleared when the recording
;; starts. This accumulated repeat information is put into the
;; `evil-repeat-ring' when the recording is finished. The dot command,
;; `\[evil-repeat]' (`evil-repeat') replays the most recent entry in
;; the ring, preceeding repeats can be replayed using
;; `\[evil-repeat-pop]' (`evil-repeat-pop').
;;
;; Repeat information can be stored in almost arbitrary form. How the
;; repeat information for each single command is recored is determined
;; by the :repeat property of the command. This property has the
;; following interpretation:
;;
;; t record commands by storing the key-sequence that invoked it
;; nil ignore this command completely
;; ignore synonym to nil
;; motion command is recorded by storing the key-sequence but only in
;; insert state, otherwise it is ignored.
;; abort stop recording of repeat information immediately
;; change record commands by storing buffer changes
;; SYMBOL if SYMBOL is contained as key in `evil-repeat-types'
;; call the corresponding (function-)value, otherwise
;; call the function associated with SYMBOL. In both
;; cases the function should take exactly one argument
;; which is either 'pre or 'post depending on whether
;; the function is called before or after the execution
;; of the command.
;;
;; Therefore, using a certain SYMBOL one can write specific repeation
;; functions for each command.
;;
;; Each value of ring `evil-repeat-info', i.e., each single repeat
;; information must be one of the following two possibilities:
;; If element is a sequence, it is regarded as a key-sequence to
;; be repeated. Otherwise the element must be a list
;; (FUNCTION PARAMS ...) which will be called using
;; (apply FUNCTION PARAMS) whenever this repeat is being executed.
;;
;; A user supplied repeat function can use the functions
;; `evil-record-repeat' to append further repeat-information of the
;; form described above to `evil-repeat-info'. See the implementation
;; of `evil-repeat-keystrokes' and `evil-repeat-changes' for examples.
;; Those functions are called in different situations before and after
;; the execution of a command. Each function should take one argument
;; which can be either 'pre, 'post, 'pre-operator or 'post-operator
;; specifying when the repeat function has been called. If the command
;; is a usual command the function is called with 'pre before the
;; command is executed and with 'post after the command has been
;; executed.
;;
;; The repeat information is executed with `evil-execute-repeat-info',
;; which passes key-sequence elements to `execute-kbd-macro' and
;; executes other elements as defined above. A special version is
;; `evil-execute-repeat-info-with-count'. This function works as
;; `evil-execute-repeat-info', but replaces the count of the first
;; command. This is done by parsing the key-sequence, ignoring all
;; calls to `digit-prefix-argument' and `negative-argument', and
;; prepending the count as a string to the vector of the remaining
;; key-sequence.
(require 'evil-states)
;;; Code:
(declare-function evil-visual-state-p "evil-visual")
(declare-function evil-visual-range "evil-visual")
(declare-function evil-visual-char "evil-visual")
(declare-function evil-visual-line "evil-visual")
(declare-function evil-visual-block "evil-visual")
(defmacro evil-without-repeat (&rest body)
(declare (indent defun)
(debug t))
`(let ((pre-command-hook (remq 'evil-repeat-pre-hook pre-command-hook))
(post-command-hook (remq 'evil-repeat-post-hook post-command-hook)))
,@body
(evil-repeat-abort)))
(defsubst evil-repeat-recording-p ()
"Returns non-nil iff a recording is in progress."
(eq evil-recording-repeat t))
(defun evil-repeat-start ()
"Start recording a new repeat into `evil-repeat-info'."
(evil-repeat-reset t)
(evil-repeat-record-buffer)
(when (evil-visual-state-p)
(let* ((range (evil-visual-range))
(beg (evil-range-beginning range))
(end (1- (evil-range-end range)))
(nfwdlines (evil-count-lines beg end)))
(evil-repeat-record
(cond
((eq evil-visual-selection 'char)
(list #'evil-repeat-visual-char
nfwdlines
(- end
(if (zerop nfwdlines)
beg
(save-excursion
(goto-char end)
(line-beginning-position))))))
((eq evil-visual-selection 'line)
(list #'evil-repeat-visual-line nfwdlines))
((eq evil-visual-selection 'block)
(list #'evil-repeat-visual-block
nfwdlines
(abs (- (evil-column beg) (evil-column end))))))))))
(defun evil-repeat-stop ()
"Stop recording a repeat.
Update `evil-repeat-ring' with the accumulated changes
in `evil-repeat-info' and clear variables."
(unwind-protect
(when (evil-repeat-recording-p)
(setq evil-repeat-info
(evil-normalize-repeat-info evil-repeat-info))
(when (and evil-repeat-info evil-repeat-ring)
(ring-insert evil-repeat-ring evil-repeat-info)))
(evil-repeat-reset nil)))
(defun evil-repeat-abort ()
"Abort current repeation."
(evil-repeat-reset 'abort))
(defun evil-repeat-reset (flag)
"Clear all repeat recording variables.
Set `evil-recording-repeat' to FLAG."
(setq evil-recording-repeat flag
evil-repeat-info nil
evil-repeat-buffer nil))
(defsubst evil-repeat-record-position (&optional pos)
"Set `evil-repeat-pos' to POS or point."
(setq evil-repeat-pos (or pos (point))))
(defun evil-repeat-record-buffer ()
"Set `evil-repeat-buffer' to the current buffer."
(unless (minibufferp)
(setq evil-repeat-buffer (current-buffer))))
(defmacro evil-save-repeat-info (&rest body)
"Execute BODY, protecting the values of repeat variables."
(declare (indent defun)
(debug t))
`(let (evil-repeat-ring
evil-recording-repeat
evil-recording-current-command
evil-repeat-info
evil-repeat-changes
evil-repeat-pos
evil-repeat-keys
evil-repeat-buffer
this-command
last-command)
,@body))
(defun evil-repeat-different-buffer-p (&optional strict)
"Whether the buffer has changed in a repeat.
If STRICT is non-nil, returns t if the previous buffer
is unknown; otherwise returns t only if the previous
buffer is known and different from the current buffer."
(and (or (buffer-live-p evil-repeat-buffer) strict)
(not (minibufferp))
(not (eq (current-buffer) evil-repeat-buffer))))
(defun evil-repeat-type (command &optional default)
"Return the :repeat property of COMMAND.
If COMMAND doesn't have this property, return DEFAULT."
(when (functionp command) ; ignore keyboard macros
(let* ((type (evil-get-command-property command :repeat default))
(repeat-type (assq type evil-repeat-types)))
(if repeat-type (cdr repeat-type) type))))
(defun evil-repeat-force-abort-p (repeat-type)
"Returns non-nil iff the current command should abort the recording of repeat information."
(or (evil-repeat-different-buffer-p) ; ... buffer changed
(eq repeat-type 'abort) ; ... explicitely forced
(eq evil-recording-repeat 'abort) ; ... already aborted
(evil-emacs-state-p) ; ... in Emacs state
(and (evil-mouse-events-p (this-command-keys)) ; ... mouse events
(eq repeat-type nil))
(minibufferp))) ; ... minibuffer activated
(defun evil-repeat-record (info)
"Add INFO to the end of `evil-repeat-info'."
(when (evil-repeat-recording-p)
(setq evil-repeat-info (nconc evil-repeat-info (list info)))))
;; called from `evil-normal-state-exit-hook'
(defun evil-repeat-start-hook ()
"Record a new repeat when exiting Normal state.
Does not record in Emacs state or if the current command
has :repeat nil."
(when (and (eq (evil-repeat-type this-command t) t)
(not (evil-emacs-state-p)))
(evil-repeat-start)))
;; called from `pre-command-hook'
(defun evil-repeat-pre-hook ()
"Prepare the current command for recording the repeation."
(when evil-local-mode
(let ((repeat-type (evil-repeat-type this-command t)))
(cond
;; abort the repeat
((evil-repeat-force-abort-p repeat-type)
;; We mark the current record as being aborted, because there
;; may be further pre-hooks following before the post-hook is
;; called.
(evil-repeat-abort))
;; ignore those commands completely
((or (null repeat-type)
(evil-mouse-events-p (this-command-keys))))
;; record command
(t
;; In normal-state or visual state, each command is a single
;; repeation, therefore start a new repeation.
(when (or (evil-normal-state-p)
(evil-visual-state-p))
(evil-repeat-start))
(setq evil-recording-current-command t)
(funcall repeat-type 'pre))))))
(put 'evil-repeat-pre-hook 'permanent-local-hook t)
;; called from `post-command-hook'
(defun evil-repeat-post-hook ()
"Finish recording of repeat-information for the current-command."
(when (and evil-local-mode evil-recording-repeat)
(let ((repeat-type (evil-repeat-type this-command t)))
(cond
;; abort the repeat
((evil-repeat-force-abort-p repeat-type)
;; The command has been aborted but is complete, so just reset
;; the recording state.
(evil-repeat-reset nil))
;; ignore if command should not be recorded or the current
;; command is not being recorded
((or (null repeat-type)
(not evil-recording-current-command)))
;; record command
(t
(funcall repeat-type 'post)
;; In normal state, the repeat sequence is complete, so record it.
(when (evil-normal-state-p)
(evil-repeat-stop)))))
;; done with recording the current command
(setq evil-recording-current-command nil)))
(put 'evil-repeat-post-hook 'permanent-local-hook t)
(defun evil-clear-command-keys ()
"Clear `this-command-keys' and all information about the current command keys.
Calling this function prevents further recording of the keys that
invoked the current command"
(clear-this-command-keys t)
(setq evil-repeat-keys ""))
(defun evil-this-command-keys (&optional post-cmd)
"Version of `this-command-keys' with finer control over prefix args."
(let ((arg (if post-cmd current-prefix-arg prefix-arg)))
(vconcat
(when (and (numberp arg)
;; Only add prefix if no repeat info recorded yet
(null evil-repeat-info))
(string-to-vector (number-to-string arg)))
(this-single-command-keys))))
(defun evil-repeat-keystrokes (flag)
"Repeation recording function for commands that are repeated by keystrokes."
(cond
((eq flag 'pre)
(when evil-this-register
(evil-repeat-record
`(set evil-this-register ,evil-this-register)))
(setq evil-repeat-keys (evil-this-command-keys)))
((eq flag 'post)
(evil-repeat-record (if (zerop (length (evil-this-command-keys t)))
evil-repeat-keys
(evil-this-command-keys t)))
;; erase commands keys to prevent double recording
(evil-clear-command-keys))))
(defun evil-repeat-motion (flag)
"Repeation for motions. Motions are recorded by keystroke but only in insert state."
(when (memq evil-state '(insert replace))
(evil-repeat-keystrokes flag)))
(defun evil-repeat-changes (flag)
"Repeation recording function for commands that are repeated by buffer changes."
(cond
((eq flag 'pre)
(add-hook 'after-change-functions #'evil-repeat-change-hook nil t)
(evil-repeat-start-record-changes))
((eq flag 'post)
(remove-hook 'after-change-functions #'evil-repeat-change-hook t)
(evil-repeat-finish-record-changes))))
;; called from the `after-change-functions' hook
(defun evil-repeat-change-hook (beg end length)
"Record change information for current command."
(let ((repeat-type (evil-repeat-type this-command t)))
(when (and (evil-repeat-recording-p)
(eq repeat-type 'evil-repeat-changes)
(not (evil-emacs-state-p))
(not (evil-repeat-different-buffer-p t))
evil-state)
(unless (evil-repeat-recording-p)
(evil-repeat-start))
(evil-repeat-record-change (- beg evil-repeat-pos)
(buffer-substring beg end)
length))))
(put 'evil-repeat-change-hook 'permanent-local-hook t)
(defun evil-repeat-record-change (relpos ins ndel)
"Record the current buffer changes during a repeat.
If CHANGE is specified, it is added to `evil-repeat-changes'."
(when (evil-repeat-recording-p)
(setq evil-repeat-changes
(nconc evil-repeat-changes (list (list relpos ins ndel))))))
(defun evil-repeat-start-record-changes ()
"Starts the recording of a new set of buffer changes."
(setq evil-repeat-changes nil)
(evil-repeat-record-position))
(defun evil-repeat-finish-record-changes ()
"Finishes the recording of buffer changes and records them as repeat."
(when (evil-repeat-recording-p)
(evil-repeat-record `(evil-execute-change
,evil-repeat-changes
,(- (point) evil-repeat-pos)))
(setq evil-repeat-changes nil)))
(defun evil-repeat-insert-at-point (flag)
"Repeation recording function for commands that insert text in region.
This records text insertion when a command inserts some text in a
buffer between (point) and (mark)."
(cond
((eq flag 'pre)
(add-hook 'after-change-functions #'evil-repeat-insert-at-point-hook nil t))
((eq flag 'post)
(remove-hook 'after-change-functions #'evil-repeat-insert-at-point-hook t))))
(defun evil-repeat-insert-at-point-hook (beg end length)
(let ((repeat-type (evil-repeat-type this-command t)))
(when (and (evil-repeat-recording-p)
(eq repeat-type 'evil-repeat-insert-at-point)
(not (evil-emacs-state-p))
(not (evil-repeat-different-buffer-p t))
evil-state)
(setq evil-repeat-pos beg)
(evil-repeat-record (list 'insert (buffer-substring beg end))))))
(put 'evil-repeat-insert-at-point-hook 'permanent-local-hook t)
(defun evil-normalize-repeat-info (repeat-info)
"Concatenate consecutive arrays in REPEAT-INFO.
Returns a single array."
(let* ((result (cons nil nil))
(result-last result)
cur cur-last)
(dolist (rep repeat-info)
(cond
((null rep))
((arrayp rep)
(setq rep (listify-key-sequence rep))
(cond
(cur
(setcdr cur-last (cons rep nil))
(setq cur-last (cdr cur-last)))
(t
(setq cur (cons rep nil))
(setq cur-last cur))))
(t
(when cur
(setcdr result-last (cons (apply #'vconcat cur) nil))
(setq result-last (cdr result-last))
(setq cur nil))
(setcdr result-last (cons rep nil))
(setq result-last (cdr result-last)))))
(when cur
(setcdr result-last (cons (apply #'vconcat cur) nil)))
(cdr result)))
(defun evil-repeat-visual-char (nfwdlines nfwdchars)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-char)
(when (> nfwdlines 0)
(forward-line nfwdlines))
(forward-char nfwdchars))
(defun evil-repeat-visual-line (nfwdlines)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-line)
(forward-line nfwdlines))
(defun evil-repeat-visual-block (nfwdlines nfwdchars)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-block)
(let ((col (current-column)))
(forward-line nfwdlines)
(move-to-column (+ col nfwdchars) t)))
(defun evil-execute-change (changes rel-point)
"Executes as list of changes.
CHANGES is a list of triples (REL-BEG INSERT-TEXT NDEL).
REL-BEG is the relative position (to point) where the change
takes place. INSERT-TEXT is the text to be inserted at that
position and NDEL the number of characters to be deleted at that
position before insertion.
REL-POINT is the relative position to point before the changed
where point should be placed after all changes."
(evil-save-repeat-info
(let ((point (point)))
(dolist (change changes)
(goto-char (+ point (nth 0 change)))
(delete-char (nth 2 change))
(insert (nth 1 change)))
(goto-char (+ point rel-point)))))
(defun evil-execute-repeat-info (repeat-info)
"Executes a repeat-information REPEAT-INFO."
(evil-save-repeat-info
(dolist (rep repeat-info)
(cond
((or (arrayp rep) (stringp rep))
(let ((input-method current-input-method)
(evil-input-method nil))
(deactivate-input-method)
(unwind-protect
(execute-kbd-macro rep)
(activate-input-method input-method))))
((consp rep)
(when (and (= 3 (length rep))
(eq (nth 0 rep) 'set)
(eq (nth 1 rep) 'evil-this-register)
(>= (nth 2 rep) ?0)
(< (nth 2 rep) ?9))
(setcar (nthcdr 2 rep) (1+ (nth 2 rep))))
(apply (car rep) (cdr rep)))
(t
(error "Unexpected repeat-info: %S" rep))))))
;; TODO: currently we prepend the replacing count before the
;; key-sequence that calls the command. Can we use direct
;; modification of prefix-arg instead? Does it work in
;; conjunction with `execute-kbd-macro'?
(defun evil-execute-repeat-info-with-count (count repeat-info)
"Repeat the repeat-information REPEAT-INFO with the count of
the first command replaced by COUNT. The count is replaced if
and only if COUNT is non-nil."
(evil-save-repeat-info
(cond
;; do nothing (zero repeating)
((and count (zerop count)))
;; replace count
(count
(let ((evil-repeat-count count)
done)
(while (and repeat-info
(arrayp (car repeat-info))
(not done))
(let* ((count-and-cmd (evil-extract-count (pop repeat-info))))
(push (vconcat (number-to-string count)
(nth 2 count-and-cmd)
(nth 3 count-and-cmd))
repeat-info)
(setq done t)))
(evil-execute-repeat-info repeat-info)))
;; repeat with original count
(t
(evil-execute-repeat-info repeat-info)))))
(evil-define-command evil-repeat (count &optional save-point)
"Repeat the last editing command with count replaced by COUNT.
If SAVE-POINT is non-nil, do not move point."
:repeat ignore
:suppress-operator t
(interactive (list current-prefix-arg
(not evil-repeat-move-cursor)))
(cond
((null evil-repeat-ring)
(error "Already executing repeat"))
(save-point
(save-excursion
(evil-repeat count)))
(t
(unwind-protect
(let ((confirm-kill-emacs t)
(kill-buffer-hook
(cons #'(lambda ()
(user-error "Cannot delete buffer in repeat command"))
kill-buffer-hook))
(undo-pointer buffer-undo-list))
(evil-with-single-undo
(setq evil-last-repeat (list (point) count undo-pointer))
(evil-execute-repeat-info-with-count
count (ring-ref evil-repeat-ring 0))))
(evil-normal-state)))))
;; TODO: the same issue concering disabled undos as for `evil-paste-pop'
(evil-define-command evil-repeat-pop (count &optional save-point)
"Replace the just repeated command with a previously executed command.
Only allowed after `evil-repeat', `evil-repeat-pop' or
`evil-repeat-pop-next'. Uses the same repeat count that
was used for the first repeat.
The COUNT argument inserts the COUNT-th previous kill.
If COUNT is negative, this is a more recent kill."
:repeat nil
:suppress-operator t
(interactive (list (prefix-numeric-value current-prefix-arg)
(not evil-repeat-move-cursor)))
(cond
((not (and (eq last-command #'evil-repeat)
evil-last-repeat))
(user-error "Previous command was not evil-repeat: %s" last-command))
(save-point
(save-excursion
(evil-repeat-pop count)))
(t
(unless (eq buffer-undo-list (nth 2 evil-last-repeat))
(evil-undo-pop))
(goto-char (car evil-last-repeat))
;; rotate the repeat-ring
(while (> count 0)
(when evil-repeat-ring
(ring-insert-at-beginning evil-repeat-ring
(ring-remove evil-repeat-ring 0)))
(setq count (1- count)))
(while (< count 0)
(when evil-repeat-ring
(ring-insert evil-repeat-ring
(ring-remove evil-repeat-ring)))
(setq count (1+ count)))
(setq this-command #'evil-repeat)
(evil-repeat (cadr evil-last-repeat)))))
(evil-define-command evil-repeat-pop-next (count &optional save-point)
"Same as `evil-repeat-pop', but with negative COUNT."
:repeat nil
:suppress-operator t
(interactive (list (prefix-numeric-value current-prefix-arg)
(not evil-repeat-move-cursor)))
(evil-repeat-pop (- count) save-point))
(defadvice read-key-sequence (before evil activate)
"Record `this-command-keys' before it is reset."
(when (and (evil-repeat-recording-p)
evil-recording-current-command)
(let ((repeat-type (evil-repeat-type this-command t)))
(if (functionp repeat-type)
(funcall repeat-type 'post)))))
(provide 'evil-repeat)
;;; evil-repeat.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,907 @@
;;; evil-states.el --- States
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-core)
;;; Code:
;;; Normal state
(evil-define-state normal
"Normal state.
AKA \"Command\" state."
:tag " <N> "
:enable (motion)
:exit-hook (evil-repeat-start-hook)
(cond
((evil-normal-state-p)
(overwrite-mode -1)
(add-hook 'post-command-hook #'evil-normal-post-command nil t))
(t
(remove-hook 'post-command-hook #'evil-normal-post-command t))))
(defun evil-normal-post-command (&optional command)
"Reset command loop variables in Normal state.
Also prevent point from reaching the end of the line.
If the region is activated, enter Visual state."
(unless (or (evil-initializing-p)
(null this-command))
(setq command (or command this-command))
(when (evil-normal-state-p)
(setq evil-this-type nil
evil-this-operator nil
evil-this-motion nil
evil-this-motion-count nil
evil-inhibit-operator nil
evil-inhibit-operator-value nil)
(unless (memq command '(evil-use-register
digit-argument
negative-argument
universal-argument
universal-argument-minus
universal-argument-more
universal-argument-other-key))
(setq evil-this-register nil))
(evil-adjust-cursor))))
(put 'evil-normal-post-command 'permanent-local-hook t)
;;; Insert state
(defun evil-maybe-remove-spaces (&optional do-remove)
"Remove space from newly opened empty line.
This function removes (indentation) spaces that have been
inserted by opening a new empty line. The behavior depends on the
variable `evil-maybe-remove-spaces'. If this variable is nil the
function does nothing. Otherwise the behavior depends on
DO-REMOVE. If DO-REMOVE is non-nil the spaces are
removed. Otherwise `evil-maybe-remove-spaces' is set to nil
unless the last command opened yet another new line.
This function should be added as a post-command-hook to track
commands opening a new line."
(cond
((not evil-maybe-remove-spaces)
(remove-hook 'post-command-hook #'evil-maybe-remove-spaces))
(do-remove
(when (save-excursion
(beginning-of-line)
(looking-at "^\\s-*$"))
(delete-region (line-beginning-position)
(line-end-position)))
(setq evil-maybe-remove-spaces nil)
(remove-hook 'post-command-hook #'evil-maybe-remove-spaces))
((not (memq this-command
'(evil-open-above
evil-open-below
evil-append
evil-append-line
newline
newline-and-indent
indent-and-newline)))
(setq evil-maybe-remove-spaces nil)
(remove-hook 'post-command-hook #'evil-maybe-remove-spaces))))
(evil-define-state insert
"Insert state."
:tag " <I> "
:cursor (bar . 2)
:message "-- INSERT --"
:entry-hook (evil-start-track-last-insertion)
:exit-hook (evil-cleanup-insert-state evil-stop-track-last-insertion)
:input-method t
(cond
((evil-insert-state-p)
(add-hook 'post-command-hook #'evil-maybe-remove-spaces)
(add-hook 'pre-command-hook #'evil-insert-repeat-hook)
(setq evil-maybe-remove-spaces t)
(unless (eq evil-want-fine-undo t)
(evil-start-undo-step)))
(t
(remove-hook 'post-command-hook #'evil-maybe-remove-spaces)
(remove-hook 'pre-command-hook #'evil-insert-repeat-hook)
(evil-maybe-remove-spaces t)
(setq evil-insert-repeat-info evil-repeat-info)
(evil-set-marker ?^ nil t)
(unless (eq evil-want-fine-undo t)
(evil-end-undo-step))
(when (or (evil-normal-state-p evil-next-state)
(evil-motion-state-p evil-next-state))
(evil-move-cursor-back
(and (eolp) (not evil-move-beyond-eol)))))))
(defun evil-insert-repeat-hook ()
"Record insertion keys in `evil-insert-repeat-info'."
(setq evil-insert-repeat-info (last evil-repeat-info))
(remove-hook 'pre-command-hook #'evil-insert-repeat-hook))
(put 'evil-insert-repeat-hook 'permanent-local-hook t)
(defun evil-cleanup-insert-state ()
"Called when Insert state is about to be exited.
Handles the repeat-count of the insertion command."
(when evil-insert-count
(dotimes (i (1- evil-insert-count))
(when evil-insert-lines
(evil-insert-newline-below)
(when evil-auto-indent
(indent-according-to-mode)))
(when (fboundp 'evil-execute-repeat-info)
(evil-execute-repeat-info
(cdr evil-insert-repeat-info)))))
(when evil-insert-vcount
(let ((buffer-invisibility-spec buffer-invisibility-spec))
;; make all lines hidden by hideshow temporarily visible
(when (listp buffer-invisibility-spec)
(setq buffer-invisibility-spec
(evil-filter-list
#'(lambda (x)
(or (eq x 'hs)
(eq (car-safe x) 'hs)))
buffer-invisibility-spec)))
(let ((line (nth 0 evil-insert-vcount))
(col (nth 1 evil-insert-vcount))
(vcount (nth 2 evil-insert-vcount)))
(save-excursion
(dotimes (v (1- vcount))
(goto-char (point-min))
(forward-line (+ line v))
(when (or (not evil-insert-skip-empty-lines)
(not (integerp col))
(save-excursion
(evil-move-end-of-line)
(>= (current-column) col)))
(if (integerp col)
(move-to-column col t)
(funcall col))
(dotimes (i (or evil-insert-count 1))
(when (fboundp 'evil-execute-repeat-info)
(evil-execute-repeat-info
(cdr evil-insert-repeat-info)))))))))))
;;; Visual state
;; Visual selections are implemented in terms of types, and are
;; compatible with the Emacs region. This is achieved by "translating"
;; the region to the selected text right before a command is executed.
;; If the command is a motion, the translation is postponed until a
;; non-motion command is invoked (distinguished by the :keep-visual
;; command property).
;;
;; Visual state activates the region, enabling Transient Mark mode if
;; not already enabled. This is only temporay: if Transient Mark mode
;; was disabled before entering Visual state, it is disabled when
;; exiting Visual state. This allows Visual state to harness the
;; "transient" behavior of many commands without overriding the user's
;; preferences in other states.
(defmacro evil-define-visual-selection (selection doc &rest body)
"Define a Visual selection SELECTION.
Creates a command evil-visual-SELECTION for enabling the selection.
DOC is the function's documentation string. The following keywords
may be specified in BODY:
:message STRING Status message when enabling the selection.
:type TYPE Type to use (defaults to SELECTION).
Following the keywords is optional code which is executed each time
the selection is enabled.
\(fn SELECTION DOC [[KEY VAL]...] BODY...)"
(declare (indent defun)
(doc-string 2)
(debug (&define name stringp
[&rest keywordp sexp]
def-body)))
(let* ((name (intern (format "evil-visual-%s" selection)))
(message (intern (format "%s-message" name)))
(type selection)
arg key string)
;; collect keywords
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body))
(cond
((eq key :message)
(setq string arg))
((eq key :type)
(setq type arg))))
;; macro expansion
`(progn
(add-to-list 'evil-visual-alist (cons ',selection ',name))
(defvar ,name ',type ,(format "*%s" doc))
(defvar ,message ,string ,doc)
(evil-define-command ,name (&optional mark point type message)
,@(when doc `(,doc))
:keep-visual t
:repeat nil
(interactive
(list nil nil
(if (and (evil-visual-state-p)
(eq evil-visual-selection ',selection))
'exit ,name) t))
(if (eq type 'exit)
(evil-exit-visual-state)
(setq type (or type ,name)
evil-visual-selection ',selection)
(evil-visual-make-region mark point type message)
,@body))
',selection)))
(evil-define-visual-selection char
"Characterwise selection."
:type inclusive
:message "-- VISUAL --")
(evil-define-visual-selection line
"Linewise selection."
:message "-- VISUAL LINE --")
(evil-define-visual-selection screen-line
"Linewise selection in `visual-line-mode'."
:message "-- SCREEN LINE --")
(evil-define-visual-selection block
"Blockwise selection."
:message "-- VISUAL BLOCK --"
(evil-transient-mark -1)
;; refresh the :corner property
(setq evil-visual-properties
(plist-put evil-visual-properties :corner
(evil-visual-block-corner 'upper-left))))
(evil-define-state visual
"Visual state."
:tag " <V> "
:enable (motion normal)
:message 'evil-visual-message
(cond
((evil-visual-state-p)
(evil-save-transient-mark-mode)
(setq select-active-regions nil)
(cond
((region-active-p)
(if (< (evil-visual-direction) 0)
(evil-visual-select (region-beginning) (region-end)
evil-visual-char
(evil-visual-direction))
(evil-visual-make-selection (mark t) (point)
evil-visual-char))
(evil-visual-highlight))
(t
(evil-visual-make-region (point) (point) evil-visual-char)))
(add-hook 'pre-command-hook #'evil-visual-pre-command nil t)
(add-hook 'post-command-hook #'evil-visual-post-command nil t)
(add-hook 'deactivate-mark-hook #'evil-visual-deactivate-hook nil t))
(t
;; Postpone deactivation of region if next state is Insert.
;; This gives certain insertion commands (auto-pairing characters,
;; for example) an opportunity to access the region.
(if (and (eq evil-next-state 'insert)
(eq evil-visual-selection 'char))
(add-hook 'evil-normal-state-entry-hook
#'evil-visual-deactivate-hook nil t)
(evil-visual-deactivate-hook))
(setq evil-visual-region-expanded nil)
(remove-hook 'pre-command-hook #'evil-visual-pre-command t)
(remove-hook 'post-command-hook #'evil-visual-post-command t)
(remove-hook 'deactivate-mark-hook #'evil-visual-deactivate-hook t)
(evil-visual-highlight -1))))
(defun evil-visual-pre-command (&optional command)
"Run before each COMMAND in Visual state.
Expand the region to the selection unless COMMAND is a motion."
(when (evil-visual-state-p)
(setq command (or command this-command))
(when evil-visual-x-select-timer
(cancel-timer evil-visual-x-select-timer))
(unless (evil-get-command-property command :keep-visual)
(evil-visual-update-x-selection)
(evil-visual-expand-region
;; exclude final newline from linewise selection
;; unless the command has real need of it
(and (eq (evil-visual-type) 'line)
(evil-get-command-property command :exclude-newline))))))
(put 'evil-visual-pre-command 'permanent-local-hook t)
(defun evil-visual-post-command (&optional command)
"Run after each COMMAND in Visual state.
If COMMAND is a motion, refresh the selection;
otherwise exit Visual state."
(when (evil-visual-state-p)
(setq command (or command this-command))
(if (or quit-flag
(eq command #'keyboard-quit)
;; Is `mark-active' nil for an unexpanded region?
deactivate-mark
(and (not evil-visual-region-expanded)
(not (region-active-p))
(not (eq evil-visual-selection 'block))))
(progn
(evil-exit-visual-state)
(evil-adjust-cursor))
(if evil-visual-region-expanded
(evil-visual-contract-region)
(evil-visual-refresh))
(setq evil-visual-x-select-timer
(run-with-idle-timer evil-visual-x-select-timeout nil
#'evil-visual-update-x-selection
(current-buffer)))
(evil-visual-highlight))))
(put 'evil-visual-post-command 'permanent-local-hook t)
(defun evil-visual-update-x-selection (&optional buffer)
"Update the X selection with the current visual region."
(let ((buf (or buffer (current-buffer))))
(when (buffer-live-p buf)
(with-current-buffer buf
(when (and (evil-visual-state-p)
(display-selections-p)
(not (eq evil-visual-selection 'block)))
(evil-set-selection 'PRIMARY (buffer-substring-no-properties
evil-visual-beginning
evil-visual-end)))))))
(defun evil-visual-activate-hook (&optional command)
"Enable Visual state if the region is activated."
(unless (evil-visual-state-p)
(evil-delay nil
;; the activation may only be momentary, so re-check
;; in `post-command-hook' before entering Visual state
'(unless (or (evil-visual-state-p)
(evil-insert-state-p)
(evil-emacs-state-p))
(when (and (region-active-p)
(not deactivate-mark))
(evil-visual-state)))
'post-command-hook nil t
"evil-activate-visual-state")))
(put 'evil-visual-activate-hook 'permanent-local-hook t)
(defun evil-visual-deactivate-hook (&optional command)
"Deactivate the region and restore Transient Mark mode."
(setq command (or command this-command))
(remove-hook 'deactivate-mark-hook
#'evil-visual-deactivate-hook t)
(remove-hook 'evil-normal-state-entry-hook
#'evil-visual-deactivate-hook t)
(cond
((and (evil-visual-state-p) command
(not (evil-get-command-property command :keep-visual)))
(setq evil-visual-region-expanded nil)
(evil-exit-visual-state))
((not (evil-visual-state-p))
(evil-active-region -1)
(evil-restore-transient-mark-mode))))
(put 'evil-visual-deactivate-hook 'permanent-local-hook t)
(evil-define-command evil-exit-visual-state (&optional later buffer)
"Exit from Visual state to the previous state.
If LATER is non-nil, exit after the current command."
:keep-visual t
:repeat abort
(with-current-buffer (or buffer (current-buffer))
(when (evil-visual-state-p)
(if later
(setq deactivate-mark t)
(when evil-visual-region-expanded
(evil-visual-contract-region))
(evil-change-to-previous-state)))))
(defun evil-visual-message (&optional selection)
"Create an echo area message for SELECTION.
SELECTION is a kind of selection as defined by
`evil-define-visual-selection', such as `char', `line'
or `block'."
(let (message)
(setq selection (or selection evil-visual-selection))
(when selection
(setq message
(symbol-value (intern (format "evil-visual-%s-message"
selection))))
(cond
((functionp message)
(funcall message))
((stringp message)
(evil-echo "%s" message))))))
(defun evil-visual-select (beg end &optional type dir message)
"Create a Visual selection of type TYPE from BEG to END.
Point and mark are positioned so that the resulting selection
has the specified boundaries. If DIR is negative, point precedes mark,
otherwise it succedes it. To specify point and mark directly,
use `evil-visual-make-selection'."
(let* ((range (evil-contract beg end type))
(mark (evil-range-beginning range))
(point (evil-range-end range))
(dir (or dir 1)))
(when (< dir 0)
(evil-swap mark point))
(evil-visual-make-selection mark point type message)))
(defun evil-visual-make-selection (mark point &optional type message)
"Create a Visual selection with point at POINT and mark at MARK.
The boundaries of the selection are inferred from these
and the current TYPE. To specify the boundaries and infer
mark and point, use `evil-visual-select' instead."
(let* ((selection (evil-visual-selection-for-type type))
(func (evil-visual-selection-function selection))
(prev (and (evil-visual-state-p) evil-visual-selection))
(mark (evil-normalize-position mark))
(point (evil-normalize-position point))
(state evil-state))
(unless (evil-visual-state-p)
(evil-visual-state))
(setq evil-visual-selection selection)
(funcall func mark point type
;; signal a message when changing the selection
(when (or (not (evil-visual-state-p state))
(not (eq selection prev)))
message))))
(defun evil-visual-make-region (mark point &optional type message)
"Create an active region from MARK to POINT.
If TYPE is given, also set the Visual type.
If MESSAGE is given, display it in the echo area."
(interactive)
(let* ((point (evil-normalize-position
(or point (point))))
(mark (evil-normalize-position
(or mark
(when (or (evil-visual-state-p)
(region-active-p))
(mark t))
point))))
(unless (evil-visual-state-p)
(evil-visual-state))
(evil-active-region 1)
(setq evil-visual-region-expanded nil)
(evil-visual-refresh mark point type)
(cond
((null evil-echo-state))
((stringp message)
(evil-echo "%s" message))
(message
(cond
((stringp evil-visual-state-message)
(evil-echo "%s" evil-visual-state-message))
((functionp evil-visual-state-message)
(funcall evil-visual-state-message)))))))
(defun evil-visual-expand-region (&optional exclude-newline)
"Expand the region to the Visual selection.
If EXCLUDE-NEWLINE is non-nil and the selection ends with a newline,
exclude that newline from the region."
(when (and (evil-visual-state-p)
(not evil-visual-region-expanded))
(let ((mark evil-visual-beginning)
(point evil-visual-end))
(when (< evil-visual-direction 0)
(evil-swap mark point))
(setq evil-visual-region-expanded t)
(evil-visual-refresh mark point)
(when (and exclude-newline
(save-excursion
(goto-char evil-visual-end)
(and (bolp) (not (bobp)))))
(if (< evil-visual-direction 0)
(evil-move-mark (max point (1- (mark))))
(goto-char (max mark (1- (point)))))))))
(defun evil-visual-contract-region ()
"The inverse of `evil-visual-expand-region'.
Create a Visual selection that expands to the current region."
(evil-visual-refresh)
(setq evil-visual-region-expanded nil)
(evil-visual-refresh evil-visual-mark evil-visual-point))
(defun evil-visual-refresh (&optional mark point type &rest properties)
"Refresh point, mark and Visual variables.
Refreshes `evil-visual-beginning', `evil-visual-end',
`evil-visual-mark', `evil-visual-point', `evil-visual-selection',
`evil-visual-direction', `evil-visual-properties' and `evil-this-type'."
(let* ((point (or point (point)))
(mark (or mark (mark t) point))
(dir (evil-visual-direction))
(type (or type (evil-visual-type evil-visual-selection)
(evil-visual-type)))
range)
(evil-move-mark mark)
(goto-char point)
(setq evil-visual-beginning
(or evil-visual-beginning
(let ((marker (make-marker)))
(move-marker marker (min point mark))))
evil-visual-end
(or evil-visual-end
(let ((marker (make-marker)))
(set-marker-insertion-type marker t)
(move-marker marker (max point mark))))
evil-visual-mark
(or evil-visual-mark
(let ((marker (make-marker)))
(move-marker marker mark)))
evil-visual-point
(or evil-visual-point
(let ((marker (make-marker)))
(move-marker marker point))))
(setq evil-visual-properties
(evil-concat-plists evil-visual-properties properties))
(cond
(evil-visual-region-expanded
(setq type (or (evil-visual-type) type))
(move-marker evil-visual-beginning (min point mark))
(move-marker evil-visual-end (max point mark))
;; if the type is one-to-one, we can safely refresh
;; the unexpanded positions as well
(when (evil-type-property type :one-to-one)
(setq range (apply #'evil-contract point mark type
evil-visual-properties)
mark (evil-range-beginning range)
point (evil-range-end range))
(when (< dir 0)
(evil-swap mark point))
(move-marker evil-visual-mark mark)
(move-marker evil-visual-point point)))
(t
(setq range (apply #'evil-expand point mark type
evil-visual-properties)
type (evil-type range type))
(move-marker evil-visual-beginning (evil-range-beginning range))
(move-marker evil-visual-end (evil-range-end range))
(move-marker evil-visual-mark mark)
(move-marker evil-visual-point point)))
(setq evil-visual-direction dir
evil-this-type type)))
(defun evil-visual-highlight (&optional arg)
"Highlight Visual selection, depending on the Visual type.
With negative ARG, disable highlighting."
(cond
((and (numberp arg) (< arg 1))
(when evil-visual-overlay
(delete-overlay evil-visual-overlay)
(setq evil-visual-overlay nil))
(when evil-visual-block-overlays
(mapc #'delete-overlay evil-visual-block-overlays)
(setq evil-visual-block-overlays nil)))
((eq evil-visual-selection 'block)
(when evil-visual-overlay
(evil-visual-highlight -1))
(evil-visual-highlight-block
evil-visual-beginning
evil-visual-end))
(t
(when evil-visual-block-overlays
(evil-visual-highlight -1))
(if evil-visual-overlay
(move-overlay evil-visual-overlay
evil-visual-beginning evil-visual-end)
(setq evil-visual-overlay
(make-overlay evil-visual-beginning evil-visual-end)))
(overlay-put evil-visual-overlay 'face 'region)
(overlay-put evil-visual-overlay 'priority 99))))
(defun evil-visual-highlight-block (beg end &optional overlays)
"Highlight rectangular region from BEG to END.
Do this by putting an overlay on each line within the rectangle.
Each overlay extends across all the columns of the rectangle.
Reuse overlays where possible to prevent flicker."
(let* ((point (point))
(mark (or (mark t) point))
(overlays (or overlays 'evil-visual-block-overlays))
(old (symbol-value overlays))
(eol-col (and (memq this-command '(next-line previous-line))
(numberp temporary-goal-column)
(1+ (min (round temporary-goal-column)
(1- most-positive-fixnum)))))
beg-col end-col new nlines overlay window-beg window-end)
(save-excursion
;; calculate the rectangular region represented by BEG and END,
;; but put BEG in the upper-left corner and END in the
;; lower-right if not already there
(setq beg-col (evil-column beg)
end-col (evil-column end))
(when (>= beg-col end-col)
(if (= beg-col end-col)
(setq end-col (1+ end-col))
(evil-sort beg-col end-col))
(setq beg (save-excursion
(goto-char beg)
(evil-move-to-column beg-col))
end (save-excursion
(goto-char end)
(evil-move-to-column end-col 1))))
;; update end column with eol-col (extension to eol).
(when (and eol-col (> eol-col end-col))
(setq end-col eol-col))
;; force a redisplay so we can do reliable window
;; BEG/END calculations
(sit-for 0)
(setq window-beg (max (window-start) beg)
window-end (min (window-end) (1+ end))
nlines (count-lines window-beg
(min window-end (point-max))))
;; iterate over those lines of the rectangle which are
;; visible in the currently selected window
(goto-char window-beg)
(dotimes (i nlines)
(let (before after row-beg row-end)
;; beginning of row
(evil-move-to-column beg-col)
(when (< (current-column) beg-col)
;; prepend overlay with virtual spaces if unable to
;; move directly to the first column
(setq before
(propertize
(make-string
(- beg-col (current-column)) ?\s)
'face
(or (get-text-property (1- (point)) 'face)
'default))))
(setq row-beg (point))
;; end of row
(evil-move-to-column end-col)
(when (and (not (eolp))
(< (current-column) end-col))
;; append overlay with virtual spaces if unable to
;; move directly to the last column
(setq after
(propertize
(make-string
(if (= (point) row-beg)
(- end-col beg-col)
(- end-col (current-column)))
?\s) 'face 'region))
;; place cursor on one of the virtual spaces
(if (= point row-beg)
(put-text-property
0 (min (length after) 1)
'cursor t after)
(put-text-property
(max 0 (1- (length after))) (length after)
'cursor t after)))
(setq row-end (min (point) (line-end-position)))
;; trim old leading overlays
(while (and old
(setq overlay (car old))
(< (overlay-start overlay) row-beg)
(/= (overlay-end overlay) row-end))
(delete-overlay overlay)
(setq old (cdr old)))
;; reuse an overlay if possible, otherwise create one
(cond
((and old (setq overlay (car old))
(or (= (overlay-start overlay) row-beg)
(= (overlay-end overlay) row-end)))
(move-overlay overlay row-beg row-end)
(overlay-put overlay 'before-string before)
(overlay-put overlay 'after-string after)
(setq new (cons overlay new)
old (cdr old)))
(t
(setq overlay (make-overlay row-beg row-end))
(overlay-put overlay 'before-string before)
(overlay-put overlay 'after-string after)
(setq new (cons overlay new)))))
(forward-line 1))
;; display overlays
(dolist (overlay new)
(overlay-put overlay 'face 'region)
(overlay-put overlay 'priority 99))
;; trim old overlays
(dolist (overlay old)
(delete-overlay overlay))
(set overlays (nreverse new)))))
(defun evil-visual-range ()
"Return the Visual selection as a range.
This is a list (BEG END TYPE PROPERTIES...), where BEG is the
beginning of the selection, END is the end of the selection,
TYPE is the selection's type, and PROPERTIES is a property list
of miscellaneous selection attributes."
(apply #'evil-range
evil-visual-beginning evil-visual-end
(evil-visual-type)
:expanded t
evil-visual-properties))
(defun evil-visual-direction ()
"Return direction of Visual selection.
The direction is -1 if point precedes mark and 1 otherwise.
See also the variable `evil-visual-direction', which holds
the direction of the last selection."
(let* ((point (point))
(mark (or (mark t) point)))
(if (< point mark) -1 1)))
(defun evil-visual-type (&optional selection)
"Return the type of the Visual selection.
If SELECTION is specified, return the type of that instead."
(if (and (null selection) (evil-visual-state-p))
(or evil-this-type (evil-visual-type evil-visual-selection))
(setq selection (or selection evil-visual-selection))
(symbol-value (cdr-safe (assq selection evil-visual-alist)))))
(defun evil-visual-goto-end ()
"Go to the last line of the Visual selection.
This position may differ from `evil-visual-end' depending on
the selection type, and is contained in the selection."
(let ((range (evil-contract-range (evil-visual-range))))
(goto-char (evil-range-end range))))
(defun evil-visual-alist ()
"Return an association list from types to selection symbols."
(mapcar #'(lambda (e)
(cons (symbol-value (cdr-safe e)) (cdr-safe e)))
evil-visual-alist))
(defun evil-visual-selection-function (selection)
"Return a selection function for TYPE.
Default to `evil-visual-make-region'."
(or (cdr-safe (assq selection evil-visual-alist))
;; generic selection function
'evil-visual-make-region))
(defun evil-visual-selection-for-type (type)
"Return a Visual selection for TYPE."
(catch 'done
(dolist (selection evil-visual-alist)
(when (eq (symbol-value (cdr selection)) type)
(throw 'done (car selection))))))
(defun evil-visual-block-corner (&optional corner point mark)
"Block corner corresponding to POINT, with MARK in opposite corner.
Depending on POINT and MARK, the return value is `upper-left',
`upper-right', `lower-left' or `lower-right':
upper-left +---+ upper-right
| |
lower-left +---+ lower-right
One-column or one-row blocks are ambiguous. In such cases,
the horizontal or vertical component of CORNER is used.
CORNER defaults to `upper-left'."
(let* ((point (or point (point)))
(mark (or mark (mark t)))
(corner (symbol-name
(or corner
(and (overlayp evil-visual-overlay)
(overlay-get evil-visual-overlay
:corner))
'upper-left)))
(point-col (evil-column point))
(mark-col (evil-column mark))
horizontal vertical)
(cond
((= point-col mark-col)
(setq horizontal
(or (and (string-match "left\\|right" corner)
(match-string 0 corner))
"left")))
((< point-col mark-col)
(setq horizontal "left"))
((> point-col mark-col)
(setq horizontal "right")))
(cond
((= (line-number-at-pos point)
(line-number-at-pos mark))
(setq vertical
(or (and (string-match "upper\\|lower" corner)
(match-string 0 corner))
"upper")))
((< point mark)
(setq vertical "upper"))
((> point mark)
(setq vertical "lower")))
(intern (format "%s-%s" vertical horizontal))))
;;; Operator-Pending state
(evil-define-state operator
"Operator-Pending state."
:tag " <O> "
:cursor evil-half-cursor
:enable (evil-operator-shortcut-map operator motion normal))
(evil-define-keymap evil-operator-shortcut-map
"Keymap for Operator-Pending shortcuts like \"dd\" and \"gqq\"."
:local t
(setq evil-operator-shortcut-map (make-sparse-keymap))
(evil-initialize-local-keymaps))
;; the half-height "Operator-Pending cursor" cannot be specified
;; as a static `cursor-type' value, since its height depends on
;; the current font size
(defun evil-half-cursor ()
"Change cursor to a half-height box.
\(This is really just a thick horizontal bar.)"
(let ((height (/ (window-pixel-height) (* (window-height) 2))))
(setq cursor-type (cons 'hbar height))))
;;; Replace state
(evil-define-state replace
"Replace state."
:tag " <R> "
:cursor hbar
:message "-- REPLACE --"
:input-method t
(cond
((evil-replace-state-p)
(overwrite-mode 1)
(add-hook 'pre-command-hook #'evil-replace-pre-command nil t)
(unless (eq evil-want-fine-undo t)
(evil-start-undo-step)))
(t
(overwrite-mode -1)
(remove-hook 'pre-command-hook #'evil-replace-pre-command t)
(unless (eq evil-want-fine-undo t)
(evil-end-undo-step))
(evil-move-cursor-back)))
(setq evil-replace-alist nil))
(defun evil-replace-pre-command ()
"Remember the character under point."
(when (evil-replace-state-p)
(unless (assq (point) evil-replace-alist)
(add-to-list 'evil-replace-alist
(cons (point)
(unless (eolp)
(char-after)))))))
(put 'evil-replace-pre-command 'permanent-local-hook t)
(defun evil-replace-backspace ()
"Restore character under cursor."
(interactive)
(let (char)
(backward-char)
(when (assq (point) evil-replace-alist)
(setq char (cdr (assq (point) evil-replace-alist)))
(save-excursion
(delete-char 1)
(when char
(insert char))))))
;;; Motion state
(evil-define-state motion
"Motion state."
:tag " <M> "
:suppress-keymap t)
;;; Emacs state
(evil-define-state emacs
"Emacs state."
:tag " <E> "
:message "-- EMACS --"
:input-method t
:intercept-esc nil)
(provide 'evil-states)
;;; evil-states.el ends here

View File

@ -0,0 +1,454 @@
;;; evil-types.el --- Type system
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.2.14
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A type defines a transformation on a pair of buffer positions.
;; Types are used by Visual state (character/line/block selection)
;; and Operator-Pending state (character/line/block motions).
;;
;; The basic transformation is "expansion". For example, the `line'
;; type "expands" a pair of positions to whole lines by moving the
;; first position to the beginning of the line and the last position
;; to the end of the line. That expanded selection is what the rest
;; of Emacs sees and acts on.
;;
;; An optional transformation is "contraction", which is the opposite
;; of expansion. If the transformation is one-to-one, expansion
;; followed by contraction always returns the original range.
;; (The `line' type is not one-to-one, as it may expand multiple
;; positions to the same lines.)
;;
;; Another optional transformation is "normalization", which takes
;; two unexpanded positions and adjusts them before expansion.
;; This is useful for cleaning up "invalid" positions.
;;
;; Types are defined at the end of this file using the macro
;; `evil-define-type'.
(require 'evil-common)
(require 'evil-macros)
;;; Code:
;;; Type definitions
(evil-define-type exclusive
"Return the positions unchanged, with some exceptions.
If the end position is at the beginning of a line, then:
* If the beginning position is at or before the first non-blank
character on the line, return `line' (expanded).
* Otherwise, move the end position to the end of the previous
line and return `inclusive' (expanded)."
:normalize (lambda (beg end)
(cond
((progn
(goto-char end)
(and (/= beg end) (bolp)))
(setq end (max beg (1- end)))
(cond
((progn
(goto-char beg)
(looking-back "^[ \f\t\v]*" (line-beginning-position)))
(evil-expand beg end 'line))
(t
(unless evil-cross-lines
(setq end (max beg (1- end))))
(evil-expand beg end 'inclusive))))
(t
(evil-range beg end))))
:string (lambda (beg end)
(let ((width (- end beg)))
(format "%s character%s" width
(if (= width 1) "" "s")))))
(evil-define-type inclusive
"Include the character under point.
If the end position is at the beginning of a line or the end of a
line and `evil-want-visual-char-semi-exclusive', then:
* If in visual state return `exclusive' (expanded)."
:expand (lambda (beg end)
(if (and evil-want-visual-char-semi-exclusive
(evil-visual-state-p)
(< beg end)
(save-excursion
(goto-char end)
(or (bolp) (eolp))))
(evil-range beg end 'exclusive)
(evil-range beg (1+ end))))
:contract (lambda (beg end)
(evil-range beg (max beg (1- end))))
:normalize (lambda (beg end)
(goto-char end)
(when (eq (char-after) ?\n)
(setq end (max beg (1- end))))
(evil-range beg end))
:string (lambda (beg end)
(let ((width (- end beg)))
(format "%s character%s" width
(if (= width 1) "" "s")))))
(evil-define-type line
"Include whole lines."
:one-to-one nil
:expand (lambda (beg end)
(evil-range
(progn
(goto-char beg)
(min (line-beginning-position)
(progn
;; move to beginning of line as displayed
(evil-move-beginning-of-line)
(line-beginning-position))))
(progn
(goto-char end)
(max (line-beginning-position 2)
(progn
;; move to end of line as displayed
(evil-move-end-of-line)
(line-beginning-position 2))))))
:contract (lambda (beg end)
(evil-range beg (max beg (1- end))))
:string (lambda (beg end)
(let ((height (count-lines beg end)))
(format "%s line%s" height
(if (= height 1) "" "s")))))
(evil-define-type screen-line
"Include whole lines, being aware of `visual-line-mode'
when `evil-respect-visual-line-mode' is non-nil."
:one-to-one nil
:expand (lambda (beg end)
(if (or (not evil-respect-visual-line-mode)
(not visual-line-mode))
(evil-line-expand beg end)
(evil-range
(progn
(goto-char beg)
(save-excursion
(beginning-of-visual-line)))
(progn
(goto-char end)
(save-excursion
;; `beginning-of-visual-line' reverts to the beginning of the
;; last visual line if the end of the last line is the end of
;; the buffer. This would prevent selecting the last screen
;; line.
(if (= (line-beginning-position 2) (point-max))
(point-max)
(beginning-of-visual-line 2)))))))
:contract (lambda (beg end)
(evil-range beg (max beg (1- end))))
:string (lambda (beg end)
(let ((height (count-screen-lines beg end)))
(format "%s screen line%s" height
(if (= height 1) "" "s")))))
(evil-define-type block
"Like `inclusive', but for rectangles:
the last column is included."
:expand (lambda (beg end &rest properties)
(let ((beg-col (evil-column beg))
(end-col (evil-column end))
(corner (plist-get properties :corner)))
;; Since blocks are implemented as a pair of buffer
;; positions, expansion is restricted to what the buffer
;; allows. In the case of a one-column block, there are
;; two ways to expand it (either move the upper corner
;; beyond the lower corner, or the lower beyond the
;; upper), so try out both possibilities when
;; encountering the end of the line.
(cond
((= beg-col end-col)
(goto-char end)
(cond
((eolp)
(goto-char beg)
(if (eolp)
(evil-range beg end)
(evil-range (1+ beg) end)))
((memq corner '(lower-right upper-right right))
(evil-range (1+ beg) end))
(t
(evil-range beg (1+ end)))))
((< beg-col end-col)
(goto-char end)
(if (eolp)
(evil-range beg end)
(evil-range beg (1+ end))))
(t
(goto-char beg)
(if (eolp)
(evil-range beg end)
(evil-range (1+ beg) end))))))
:contract (lambda (beg end)
(let ((beg-col (evil-column beg))
(end-col (evil-column end)))
(if (> beg-col end-col)
(evil-range (1- beg) end)
(evil-range beg (max beg (1- end))))))
:string (lambda (beg end)
(let ((height (count-lines
beg
(progn
(goto-char end)
(if (and (bolp) (not (eobp)))
(1+ end)
end))))
(width (abs (- (evil-column beg)
(evil-column end)))))
(format "%s row%s and %s column%s"
height
(if (= height 1) "" "s")
width
(if (= width 1) "" "s"))))
:rotate (lambda (beg end &rest properties)
"Rotate block according to :corner property.
:corner can be one of `upper-left',``upper-right', `lower-left'
and `lower-right'."
(let ((left (evil-column beg))
(right (evil-column end))
(corner (or (plist-get properties :corner)
'upper-left)))
(evil-sort left right)
(goto-char beg)
(if (memq corner '(upper-right lower-left))
(move-to-column right)
(move-to-column left))
(setq beg (point))
(goto-char end)
(if (memq corner '(upper-right lower-left))
(move-to-column left)
(move-to-column right))
(setq end (point))
(setq properties (plist-put properties
:corner corner))
(apply #'evil-range beg end properties))))
(evil-define-type rectangle
"Like `exclusive', but for rectangles:
the last column is excluded."
:expand (lambda (beg end)
;; select at least one column
(if (= (evil-column beg) (evil-column end))
(evil-expand beg end 'block)
(evil-range beg end 'block))))
;;; Standard interactive codes
(evil-define-interactive-code "*"
"Signal error if the buffer is read-only."
(when buffer-read-only
(signal 'buffer-read-only nil)))
(evil-define-interactive-code "b" (prompt)
"Name of existing buffer."
(list (read-buffer prompt (current-buffer) t)))
(evil-define-interactive-code "c"
"Read character."
(list (read-char)))
(evil-define-interactive-code "p"
"Prefix argument converted to number."
(list (prefix-numeric-value current-prefix-arg)))
(evil-define-interactive-code "P"
"Prefix argument in raw form."
(list current-prefix-arg))
;;; Custom interactive codes
(evil-define-interactive-code "<c>"
"Count."
(list (when current-prefix-arg
(prefix-numeric-value
current-prefix-arg))))
(evil-define-interactive-code "<vc>"
"Count, but only in visual state.
This should be used by an operator taking a count. In normal
state the count should not be handled by the operator but by the
motion that defines the operator's range. In visual state the
range is specified by the visual region and the count is not used
at all. Thus in the case the operator may use the count
directly."
(list (when (and (evil-visual-state-p) current-prefix-arg)
(prefix-numeric-value
current-prefix-arg))))
(evil-define-interactive-code "<C>"
"Character read through `evil-read-key'."
(list
(if (evil-operator-state-p)
(evil-without-restriction (evil-read-key))
(evil-read-key))))
(evil-define-interactive-code "<r>"
"Untyped motion range (BEG END)."
(evil-operator-range))
(evil-define-interactive-code "<R>"
"Typed motion range (BEG END TYPE)."
(evil-operator-range t))
(evil-define-interactive-code "<v>"
"Typed motion range of visual range(BEG END TYPE).
If visual state is inactive then those values are nil."
(if (evil-visual-state-p)
(let ((range (evil-visual-range)))
(list (car range)
(cadr range)
(evil-type range)))
(list nil nil nil)))
(evil-define-interactive-code "<x>"
"Current register."
(list evil-this-register))
(evil-define-interactive-code "<y>"
"Current yank-handler."
(list (evil-yank-handler)))
(evil-define-interactive-code "<a>"
"Ex argument."
:ex-arg t
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<f>"
"Ex file argument."
:ex-arg file
(list (when (evil-ex-p) (evil-ex-file-arg))))
(evil-define-interactive-code "<b>"
"Ex buffer argument."
:ex-arg buffer
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<sh>"
"Ex shell command argument."
:ex-arg shell
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<fsh>"
"Ex file or shell command argument."
:ex-arg file-or-shell
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<sym>"
"Ex symbolic argument."
:ex-arg sym
(list (when (and (evil-ex-p) evil-ex-argument)
(intern evil-ex-argument))))
(evil-define-interactive-code "<addr>"
"Ex line number."
(list
(and (evil-ex-p)
(let ((expr (evil-ex-parse evil-ex-argument)))
(if (eq (car expr) 'evil-goto-line)
(save-excursion
(goto-char evil-ex-point)
(eval (cadr expr)))
(user-error "Invalid address"))))))
(evil-define-interactive-code "<!>"
"Ex bang argument."
:ex-bang t
(list (when (evil-ex-p) evil-ex-bang)))
(evil-define-interactive-code "</>"
"Ex delimited argument."
(when (evil-ex-p)
(evil-delimited-arguments evil-ex-argument)))
(evil-define-interactive-code "<g/>"
"Ex global argument."
(when (evil-ex-p)
(evil-ex-parse-global evil-ex-argument)))
(evil-define-interactive-code "<s/>"
"Ex substitution argument."
:ex-arg substitution
(when (evil-ex-p)
(evil-ex-get-substitute-info evil-ex-argument t)))
(evil-define-interactive-code "<xc/>"
"Ex register and count argument, both optional.
Can be used for commands such as :delete [REGISTER] [COUNT] where the
command can be called with either zero, one or two arguments. When the
argument is one, if it's numeric it's treated as a COUNT, otherwise -
REGISTER"
(when (evil-ex-p)
(evil-ex-get-optional-register-and-count evil-ex-argument)))
(defun evil-ex-get-optional-register-and-count (string)
"Parse STRING as an ex arg with both optional REGISTER and COUNT.
Returns a list (REGISTER COUNT)."
(let* ((split-args (split-string (or string "")))
(arg-count (length split-args))
(arg0 (car split-args))
(arg1 (cadr split-args))
(number-regex "^-?[1-9][0-9]*$")
(register nil)
(count nil))
(cond
;; :command REGISTER or :command COUNT
((= arg-count 1)
(if (string-match-p number-regex arg0)
(setq count arg0)
(setq register arg0)))
;; :command REGISTER COUNT
((eq arg-count 2)
(setq register arg0
count arg1))
;; more than 2 args aren't allowed
((> arg-count 2)
(user-error "Invalid use")))
;; if register is given, check it's valid
(when register
(unless (= (length register) 1)
(user-error "Invalid register"))
(setq register (string-to-char register)))
;; if count is given, check it's valid
(when count
(unless (string-match-p number-regex count)
(user-error "Invalid count"))
(setq count (string-to-number count))
(unless (> count 0)
(user-error "Invalid count")))
(list register count)))
(provide 'evil-types)
;;; evil-types.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
;;; evil.el --- extensible vi layer
;; The following list of authors was kept up to date until the beginning of
;; 2017, when evil moved under new maintainers. For authors since then, please
;; consult the git logs.
;; Alessandro Piras <laynor at gmail.com>
;; Alexander Baier <alexander.baier at mailbox.org>
;; Antono Vasiljev <antono.vasiljev at gmail.com>
;; Bailey Ling <bling at live.ca>
;; Barry O'Reilly <gundaetiapo at gmail.com>
;; Christoph Lange <langec at web.de>
;; Daniel Reiter <danieltreiter at gmail.com>
;; Eivind Fonn <evfonn at gmail.com>
;; Emanuel Evans <emanuel.evans at gmail.com>
;; Eric Siegel <siegel.eric at gmail.com>
;; Eugene Yaremenko <w3techplayground at gmail.com>
;; Frank Fischer <frank-fischer at shadow-soft.de>
;; Frank Terbeck <ft at bewatermyfriend.org>
;; Gordon Gustafson <gordon3.14 at gmail.com>
;; Herbert Jones <jones.herbert at gmail.com>
;; Jonas Bernoulli <jonas at bernoul.li>
;; Jonathan Claggett <jclaggett at lonocloud.com>
;; José A. Romero L. <escherdragon at gmail.com>
;; Justin Burkett <justin at burkett.cc>
;; Lars Andersen <expez at expez.com>
;; Lintaro Ina <tarao.gnn at gmail.com>
;; Lukasz Wrzosek <wrzoski at mail.com>
;; Marian Schubert <maio at netsafe.cz>
;; Matthew Malcomson <>
;; Michael Markert <markert.michael at googlemail.com>
;; Mike Gerwitz <mikegerwitz at gnu.org>
;; Nikolai Weibull <now at bitwi.se>
;; phaebz <phaebz at gmail.com>
;; ralesi <scio62 at gmail.com>
;; Rodrigo Setti <rodrigosetti at gmail.com>
;; Sanel Zukan <sanelz at gmail.com>
;; Sarah Brofeldt <sarah at thinkmonster.(none)>
;; Simon Hafner <hafnersimon at gmail.com>
;; Stefan Wehr <mail at stefanwehr.de>
;; Sune Simonsen <sune.simonsen at jayway.com>
;; Thomas Hisch <thomas at opentech.at>
;; Tim Harper <timcharper at gmail.com>
;; Tom Willemse <tom at ryuslash.org>
;; Trevor Murphy <trevor.m.murphy at gmail.com>
;; Ulrich Müller <ulm at gentoo.org>
;; Vasilij Schneidermann <v.schneidermann at gmail.com>
;; Vegard Øye <vegard_oye at hotmail.com>
;; Winfred Lu <winfred.lu at gmail.com>
;; Wolfgang Jenkner <wjenkner at inode.at>
;; Xiao Hanyu <xiaohanyu1988 at gmail.com>
;; York Zhao <yzhao at telecor.com>
;; Maintainers: The emacs-evil team. <https://github.com/orgs/emacs-evil/people>
;; To get in touch, please use the bug tracker or the
;; mailing list (see below).
;; Created: 2011-03-01
;; Version: 1.2.14
;; Keywords: emulation, vim
;; URL: https://github.com/emacs-evil/evil
;; Repository: https://github.com/emacs-evil/evil.git
;; EmacsWiki: http://www.emacswiki.org/emacs/Evil
;; Bug tracker: https://github.com/emacs-evil/evil/issues
;; If you have bug reports, suggestions or patches, please
;; create an issue at the bug tracker (open for everyone).
;; Other discussions (tips, extensions) go to the mailing list.
;; Mailing list: <implementations-list at lists.ourproject.org>
;; Subscribe: http://tinyurl.com/implementations-list
;; Newsgroup: nntp://news.gmane.org/gmane.emacs.vim-emulation
;; Archives: http://dir.gmane.org/gmane.emacs.vim-emulation
;; You don't have to subscribe to post; we usually reply
;; within a few days and CC our replies back to you.
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Evil is an extensible vi layer for Emacs. It emulates the main
;; features of Vim, and provides facilities for writing custom
;; extensions.
;;
;; Evil lives in a Git repository. To obtain Evil, do
;;
;; git clone git://github.com/emacs-evil/evil.git
;;
;; Move Evil to ~/.emacs.d/evil (or somewhere else in the `load-path').
;; Then add the following lines to ~/.emacs:
;;
;; (add-to-list 'load-path "~/.emacs.d/evil")
;; (require 'evil)
;; (evil-mode 1)
;;
;; Evil requires undo-tree.el for linear undo and undo branches:
;;
;; http://www.emacswiki.org/emacs/UndoTree
;;
;; Otherwise, Evil uses regular Emacs undo.
;;
;; Evil requires `goto-last-change' and `goto-last-change-reverse'
;; function for the corresponding motions g; g, as well as the
;; last-change-register `.'. One package providing these functions is
;; goto-chg.el:
;;
;; http://www.emacswiki.org/emacs/GotoChg
;;
;; Without this package the corresponding motions will raise an error.
;;; Code:
(require 'evil-vars)
(require 'evil-common)
(require 'evil-core)
(require 'evil-states)
(require 'evil-repeat)
(require 'evil-macros)
(require 'evil-search)
(require 'evil-ex)
(require 'evil-digraphs)
(require 'evil-types)
(require 'evil-commands)
(require 'evil-jumps)
(require 'evil-maps)
(when evil-want-integration
(require 'evil-integration))
(when evil-want-keybinding
(require 'evil-keybindings))
(run-hooks 'evil-after-load-hook)
(provide 'evil)
;;; evil.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,484 @@
This is fdl-1.3.info, produced by makeinfo version 6.5 from
fdl-1.3.texi.
Version 1.3, 3 November 2008
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or
noncommercially. Secondarily, this License preserves for the
author and publisher a way to get credit for their work, while not
being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense.
It complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for
free software, because free software needs free documentation: a
free program should come with manuals providing the same freedoms
that the software does. But this License is not limited to
software manuals; it can be used for any textual work, regardless
of subject matter or whether it is published as a printed book. We
recommend this License principally for works whose purpose is
instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium,
that contains a notice placed by the copyright holder saying it can
be distributed under the terms of this License. Such a notice
grants a world-wide, royalty-free license, unlimited in duration,
to use that work under the conditions stated herein. The
"Document", below, refers to any such manual or work. Any member
of the public is a licensee, and is addressed as "you". You accept
the license if you copy, modify or distribute the work in a way
requiring permission under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could
fall directly within that overall subject. (Thus, if the Document
is in part a textbook of mathematics, a Secondary Section may not
explain any mathematics.) The relationship could be a matter of
historical connection with the subject or with related matters, or
of legal, commercial, philosophical, ethical or political position
regarding them.
The "Invariant Sections" are certain Secondary Sections whose
titles are designated, as being those of Invariant Sections, in the
notice that says that the Document is released under this License.
If a section does not fit the above definition of Secondary then it
is not allowed to be designated as Invariant. The Document may
contain zero Invariant Sections. If the Document does not identify
any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are
listed, as Front-Cover Texts or Back-Cover Texts, in the notice
that says that the Document is released under this License. A
Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed
of pixels) generic paint programs or (for drawings) some widely
available drawing editor, and that is suitable for input to text
formatters or for automatic translation to a variety of formats
suitable for input to text formatters. A copy made in an otherwise
Transparent file format whose markup, or absence of markup, has
been arranged to thwart or discourage subsequent modification by
readers is not Transparent. An image format is not Transparent if
used for any substantial amount of text. A copy that is not
"Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format,
SGML or XML using a publicly available DTD, and standard-conforming
simple HTML, PostScript or PDF designed for human modification.
Examples of transparent image formats include PNG, XCF and JPG.
Opaque formats include proprietary formats that can be read and
edited only by proprietary word processors, SGML or XML for which
the DTD and/or processing tools are not generally available, and
the machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the
material this License requires to appear in the title page. For
works in formats which do not have any title page as such, "Title
Page" means the text near the most prominent appearance of the
work's title, preceding the beginning of the body of the text.
The "publisher" means any person or entity that distributes copies
of the Document to the public.
A section "Entitled XYZ" means a named subunit of the Document
whose title either is precisely XYZ or contains XYZ in parentheses
following text that translates XYZ in another language. (Here XYZ
stands for a specific section name mentioned below, such as
"Acknowledgements", "Dedications", "Endorsements", or "History".)
To "Preserve the Title" of such a section when you modify the
Document means that it remains a section "Entitled XYZ" according
to this definition.
The Document may include Warranty Disclaimers next to the notice
which states that this License applies to the Document. These
Warranty Disclaimers are considered to be included by reference in
this License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and
has no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License
applies to the Document are reproduced in all copies, and that you
add no other conditions whatsoever to those of this License. You
may not use technical measures to obstruct or control the reading
or further copying of the copies you make or distribute. However,
you may accept compensation in exchange for copies. If you
distribute a large enough number of copies you must also follow the
conditions in section 3.
You may also lend copies, under the same conditions stated above,
and you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly
have printed covers) of the Document, numbering more than 100, and
the Document's license notice requires Cover Texts, you must
enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and
Back-Cover Texts on the back cover. Both covers must also clearly
and legibly identify you as the publisher of these copies. The
front cover must present the full title with all words of the title
equally prominent and visible. You may add other material on the
covers in addition. Copying with changes limited to the covers, as
long as they preserve the title of the Document and satisfy these
conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto
adjacent pages.
If you publish or distribute Opaque copies of the Document
numbering more than 100, you must either include a machine-readable
Transparent copy along with each Opaque copy, or state in or with
each Opaque copy a computer-network location from which the general
network-using public has access to download using public-standard
network protocols a complete Transparent copy of the Document, free
of added material. If you use the latter option, you must take
reasonably prudent steps, when you begin distribution of Opaque
copies in quantity, to ensure that this Transparent copy will
remain thus accessible at the stated location until at least one
year after the last time you distribute an Opaque copy (directly or
through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of
the Document well before redistributing any large number of copies,
to give them a chance to provide you with an updated version of the
Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document
under the conditions of sections 2 and 3 above, provided that you
release the Modified Version under precisely this License, with the
Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever
possesses a copy of it. In addition, you must do these things in
the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title
distinct from that of the Document, and from those of previous
versions (which should, if there were any, be listed in the
History section of the Document). You may use the same title
as a previous version if the original publisher of that
version gives permission.
B. List on the Title Page, as authors, one or more persons or
entities responsible for authorship of the modifications in
the Modified Version, together with at least five of the
principal authors of the Document (all of its principal
authors, if it has fewer than five), unless they release you
from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license
notice giving the public permission to use the Modified
Version under the terms of this License, in the form shown in
the Addendum below.
G. Preserve in that license notice the full lists of Invariant
Sections and required Cover Texts given in the Document's
license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title,
and add to it an item stating at least the title, year, new
authors, and publisher of the Modified Version as given on the
Title Page. If there is no section Entitled "History" in the
Document, create one stating the title, year, authors, and
publisher of the Document as given on its Title Page, then add
an item describing the Modified Version as stated in the
previous sentence.
J. Preserve the network location, if any, given in the Document
for public access to a Transparent copy of the Document, and
likewise the network locations given in the Document for
previous versions it was based on. These may be placed in the
"History" section. You may omit a network location for a work
that was published at least four years before the Document
itself, or if the original publisher of the version it refers
to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section
all the substance and tone of each of the contributor
acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered
in their text and in their titles. Section numbers or the
equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled
"Endorsements" or to conflict in title with any Invariant
Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no
material copied from the Document, you may at your option designate
some or all of these sections as invariant. To do this, add their
titles to the list of Invariant Sections in the Modified Version's
license notice. These titles must be distinct from any other
section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text
has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text,
and a passage of up to 25 words as a Back-Cover Text, to the end of
the list of Cover Texts in the Modified Version. Only one passage
of Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document
already includes a cover text for the same cover, previously added
by you or by arrangement made by the same entity you are acting on
behalf of, you may not add another; but you may replace the old
one, on explicit permission from the previous publisher that added
the old one.
The author(s) and publisher(s) of the Document do not by this
License give permission to use their names for publicity for or to
assert or imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under
this License, under the terms defined in section 4 above for
modified versions, provided that you include in the combination all
of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your
combined work in its license notice, and that you preserve all
their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name
but different contents, make the title of each such section unique
by adding at the end of it, in parentheses, the name of the
original author or publisher of that section if known, or else a
unique number. Make the same adjustment to the section titles in
the list of Invariant Sections in the license notice of the
combined work.
In the combination, you must combine any sections Entitled
"History" in the various original documents, forming one section
Entitled "History"; likewise combine any sections Entitled
"Acknowledgements", and any sections Entitled "Dedications". You
must delete all sections Entitled "Endorsements."
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the
rules of this License for verbatim copying of each of the documents
in all other respects.
You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert
a copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that
document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other
separate and independent documents or works, in or on a volume of a
storage or distribution medium, is called an "aggregate" if the
copyright resulting from the compilation is not used to limit the
legal rights of the compilation's users beyond what the individual
works permit. When the Document is included in an aggregate, this
License does not apply to the other works in the aggregate which
are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half
of the entire aggregate, the Document's Cover Texts may be placed
on covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic
form. Otherwise they must appear on printed covers that bracket
the whole aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section
4. Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also
include the original English version of this License and the
original versions of those notices and disclaimers. In case of a
disagreement between the translation and the original version of
this License or a notice or disclaimer, the original version will
prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to
Preserve its Title (section 1) will typically require changing the
actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void,
and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the
copyright holder fails to notify you of the violation by some
reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from
that copyright holder, and you cure the violation prior to 30 days
after your receipt of the notice.
Termination of your rights under this section does not terminate
the licenses of parties who have received copies or rights from you
under this License. If your rights have been terminated and not
permanently reinstated, receipt of a copy of some or all of the
same material does not give you any rights to use it.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of
the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
<http://www.gnu.org/copyleft/>.
Each version of the License is given a distinguishing version
number. If the Document specifies that a particular numbered
version of this License "or any later version" applies to it, you
have the option of following the terms and conditions either of
that specified version or of any later version that has been
published (not as a draft) by the Free Software Foundation. If the
Document does not specify a version number of this License, you may
choose any version ever published (not as a draft) by the Free
Software Foundation. If the Document specifies that a proxy can
decide which future versions of this License can be used, that
proxy's public statement of acceptance of a version permanently
authorizes you to choose that version for the Document.
11. RELICENSING
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server.
A "Massive Multiauthor Collaboration" (or "MMC") contained in the
site means any set of copyrightable works thus published on the MMC
site.
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
"Incorporate" means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this
License somewhere other than this MMC, and subsequently
incorporated in whole or in part into the MMC, (1) had no cover
texts or invariant sections, and (2) were thus incorporated prior
to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the
site under CC-BY-SA on the same site at any time before August 1,
2009, provided the MMC is eligible for relicensing.
ADDENDUM: How to use this License for your documents
====================================================
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and license
notices just after the title page:
Copyright (C) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with
the Front-Cover Texts being LIST, and with the Back-Cover Texts
being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.

Tag Table:

End Tag Table

View File

@ -0,0 +1,7 @@
This is macros.info, produced by makeinfo version 6.5 from macros.texi.

Tag Table:

End Tag Table

View File

@ -0,0 +1,8 @@
This is version.info, produced by makeinfo version 6.5 from
version.texi.

Tag Table:

End Tag Table

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,55 @@
;;; goto-chg-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "goto-chg" "goto-chg.el" (0 0 0 0))
;;; Generated autoloads from goto-chg.el
(autoload 'goto-last-change "goto-chg" "\
Go to the point where the last edit was made in the current buffer.
Repeat the command to go to the second last edit, etc.
To go back to more recent edit, the reverse of this command, use \\[goto-last-change-reverse]
or precede this command with \\[universal-argument] - (minus).
It does not go to the same point twice even if there has been many edits
there. I call the minimal distance between distinguishable edits \"span\".
Set variable `glc-default-span' to control how close is \"the same point\".
Default span is 8.
The span can be changed temporarily with \\[universal-argument] right before \\[goto-last-change]:
\\[universal-argument] <NUMBER> set current span to that number,
\\[universal-argument] (no number) multiplies span by 4, starting with default.
The so set span remains until it is changed again with \\[universal-argument], or the consecutive
repetition of this command is ended by any other command.
When span is zero (i.e. \\[universal-argument] 0) subsequent \\[goto-last-change] visits each and
every point of edit and a message shows what change was made there.
In this case it may go to the same point twice.
This command uses undo information. If undo is disabled, so is this command.
At times, when undo information becomes too large, the oldest information is
discarded. See variable `undo-limit'.
\(fn ARG)" t nil)
(autoload 'goto-last-change-reverse "goto-chg" "\
Go back to more recent changes after \\[goto-last-change] have been used.
See `goto-last-change' for use of prefix argument.
\(fn ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "goto-chg" '("glc-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; goto-chg-autoloads.el ends here

View File

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "goto-chg" "20190110.2114" "goto last change" '((undo-tree "0.1.3")) :commit "1829a13026c597e358f716d2c7793202458120b5" :keywords '("convenience" "matching") :authors '(("David Andersson <l.david.andersson(at)sverige.nu>")) :maintainer '("Vasilij Schneidermann" . "v.schneidermann@gmail.com") :url "https://github.com/emacs-evil/goto-chg")

View File

@ -0,0 +1,361 @@
;;; goto-chg.el --- goto last change
;;--------------------------------------------------------------------
;;
;; Copyright (C) 2002-2008,2013 David Andersson
;;
;; 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 2 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, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301 USA
;;
;;-------------------------------------------------------------------
;;
;; Author: David Andersson <l.david.andersson(at)sverige.nu>
;; Maintainer: Vasilij Schneidermann <v.schneidermann@gmail.com>
;; Created: 16 May 2002
;; Version: 1.7.3
;; Package-Version: 20190110.2114
;; Package-Requires: ((undo-tree "0.1.3"))
;; Keywords: convenience, matching
;; URL: https://github.com/emacs-evil/goto-chg
;;
;;; Commentary:
;;
;; Goto Last Change
;;
;; Goto the point of the most recent edit in the buffer.
;; When repeated, goto the second most recent edit, etc.
;; Negative argument, C-u -, for reverse direction.
;; Works by looking into buffer-undo-list to find points of edit.
;;
;; You would probably like to bind this command to a key.
;; For example in your ~/.emacs:
;;
;; (require 'goto-chg)
;;
;; (global-set-key [(control ?.)] 'goto-last-change)
;; (global-set-key [(control ?,)] 'goto-last-change-reverse)
;;
;; Works with emacs-19.29, 19.31, 20.3, 20.7, 21.1, 21.4, 22.1 and 23.1
;; Works with XEmacs-20.4 and 21.4 (but see todo about `last-command' below)
;;
;;--------------------------------------------------------------------
;; History
;;
;; Ver 1.7.3 2019-01-07 Vasilij Schneidermann
;; Fix errors when used with persistent undo
;; Ver 1.7.2 2018-01-05 Vasilij Schneidermann
;; Fix byte-compiler warnings again
;; Ver 1.7.1 2017-12-31 Vasilij Schneidermann
;; Fix byte-compiler warnings
;; Ver 1.7 2017-09-17 Vasilij Schneidermann
;; Make it work with undo-tree-mode (see
;; <https://github.com/martinp26/goto-chg>)
;; Ver 1.6 2013-12-12 David Andersson
;; Add keywords; Cleanup comments
;; Ver 1.5 2013-12-11 David Andersson
;; Autoload and document `goto-last-change-reverse'
;; Ver 1.4 2008-09-20 David Andersson
;; Improved property change description; Update comments.
;; Ver 1.3 2007-03-14 David Andersson
;; Added `goto-last-change-reverse'
;; Ver 1.2 2003-04-06 David Andersson
;; Don't let repeating error depthen glc-probe-depth.
;; Ver 1.1 2003-04-06 David Andersson
;; Zero arg describe changes. Negative arg go back.
;; Autoload. Remove message using nil in stead of an empty string.
;; Ver 1.0 2002-05-18 David Andersson
;; Initial version
;;
;;--------------------------------------------------------------------
;;
;;todo: Rename "goto-chg.el" -> "gotochange.el" or "goto-chgs" ?
;;todo: Rename function goto-last-change -> goto-last-edit ?
;;todo: Rename adjective "-last-" -> "-latest-" or "-most-recent-" ?
;;todo: There are some, maybe useful, funcs for region undo
;; in simple.el in emacs 20. Take a look.
;;todo: Add functionality to visit changed point in text order, not only in
;; chronological order. (Naa, highlight-changes-mode does that).
;;todo: Inverse indication that a change has been saved or not
;;todo: Highlight the range of text involved in the last change?
;;todo: See session-jump-to-last-change in session.el?
;;todo: Unhide invisible text (e.g. outline mode) like isearch do.
;;todo: XEmacs sets last-command to `t' after an error, so you cannot reverse
;; after "No furter change info". Should we bother?
;;todo: Try distinguish "No further change info" (end of truncated undo list)
;; and "No further changes" (end of a complete undo list).
;;
;;--------------------------------------------------------------------
;;; Code:
(require 'undo-tree)
(defvar glc-default-span 8 "*goto-last-change don't visit the same point twice. glc-default-span tells how far around a visited point not to visit again.")
(defvar glc-current-span 8 "Internal for goto-last-change.\nA copy of glc-default-span or the ARG passed to goto-last-change.")
(defvar glc-probe-depth 0 "Internal for goto-last-change.\nIt is non-zero between successive goto-last-change.")
(defvar glc-direction 1 "Direction goto-last-change moves towards.")
;;todo: Find begin and end of line, then use it somewhere
(defun glc-center-ellipsis (str maxlen &optional ellipsis)
"Truncate STRING in the middle to length MAXLEN.
If STRING is max MAXLEN just return the string.
Optional third argument is the replacement, which defaults to \"...\"."
(if (<= (length str) maxlen)
str
;; else
(let* ((lipsis (or ellipsis "..."))
(i (/ (- maxlen (length lipsis)) 2)))
(concat (substring str 0 i)
lipsis
(substring str (- i))))))
(defun glc-adjust-pos2 (pos p1 p2 adj)
;; Helper function to glc-adjust-pos
;; p1, p2: interval where an edit occured
;; adj: amount of text added (positive) or removed (negativ) by the edit
;; Return pos if well before p1, or pos+adj if well after p2, or nil if too close
(cond ((<= pos (- p1 glc-current-span))
pos)
((> pos (+ p2 glc-current-span))
(+ pos adj))
((zerop glc-current-span)
p1)
(t
nil)))
(defun glc-adjust-pos (pos e)
"Given POS, a buffer position before the edit E, compute and return
the \"same\" buffer position after E happened.
Exception: return nil if POS is closer than `glc-current-span' to the edit E.
\nInsertion edits before POS returns a larger value.
Deletion edits before POS returns a smaller value.
\nThe edit E is an entry from the `buffer-undo-list'. See for details."
(cond ((atom e) ; nil==cmd boundary, or, num==changed pos
pos)
((numberp (car e)) ; (beg . end)==insertion
(glc-adjust-pos2 pos (car e) (car e) (- (cdr e) (car e))))
((stringp (car e)) ; (string . pos)==deletion
(glc-adjust-pos2 pos (abs (cdr e)) (+ (abs (cdr e)) (length (car e))) (- (length (car e)))))
((null (car e)) ; (nil prop val beg . end)==prop change
(glc-adjust-pos2 pos (nth 3 e) (nthcdr 4 e) 0))
(t ; (marker . dist)==marker moved
pos)))
;; If recursive in stead of iterative (while), it tends to fill the call stack.
;; (Isn't it tail optimized?)
(defun glc-adjust-list (r)
"R is list of edit entries in chronological order.
Pick the point of the first edit entry and update that point with
the second, third, etc, edit entries. Return the final updated point,
or nil if the point was closer than `glc-current-span' to some edit in R.
\nR is basically a reversed slice from the buffer-undo-list."
(if r
;; Get pos
(let ((pos (glc-get-pos (car r))))
(setq r (cdr r))
;; Walk back in reverse list
(while (and r pos)
(setq pos (glc-adjust-pos pos (car r))
r (cdr r)))
pos)
;; else
nil))
(defun glc-get-pos (e)
"If E represents an edit, return a position value in E, the position
where the edit took place. Return nil if E represents no real change.
\nE is an entry in the buffer-undo-list."
(cond ((numberp e) e) ; num==changed position
((atom e) nil) ; nil==command boundary
((numberp (car e)) (cdr e)) ; (beg . end)==insertion
((stringp (car e)) (abs (cdr e))) ; (string . pos)==deletion
((null (car e)) (nthcdr 4 e)) ; (nil ...)==text property change
((atom (car e)) nil) ; (t ...)==file modification time
(t nil))) ; (marker ...)==marker moved
(defun glc-get-descript (e &optional n)
"If E represents an edit, return a short string describing E.
Return nil if E represents no real change.
\nE is an entry in the buffer-undo-list."
(let ((nn (or (format "T-%d: " n) "")))
(cond ((numberp e) "New position") ; num==changed position
((atom e) nil) ; nil==command boundary
((numberp (car e)) ; (beg . end)==insertion
(if (and n (< n 2))
(format "%sInserted %d chars \"%s\"" nn (- (cdr e) (car e))
(glc-center-ellipsis (buffer-substring (car e) (cdr e)) 60))
;; else
;; An older insert. The inserted text cannot easily be computed.
;; Just show the char count.
(format "%sInserted %d chars" nn (- (cdr e) (car e)))))
((stringp (car e)) ; (string . pos)==deletion
(format "%sDeleted \"%s\"" nn (glc-center-ellipsis (car e) 60)))
((null (car e)) ; (nil ...)==text property change
(format "%sProperty change" nn))
((atom (car e)) nil) ; (t ...)==file modification time
(t nil)))) ; (marker ...)==marker moved
(defun glc-is-positionable (e)
"Return non-nil if E is an insertion, deletion or text property change.
\nE is an entry in the buffer-undo-list."
(and (not (numberp e)) (glc-get-pos e)))
(defun glc-is-filetime (e)
"Return t if E indicates a buffer became \"modified\",
that is, it was previously saved or unchanged. Nil otherwise."
(and (listp e) (eq (car e) t)))
;;;###autoload
(defun goto-last-change (arg)
"Go to the point where the last edit was made in the current buffer.
Repeat the command to go to the second last edit, etc.
\nTo go back to more recent edit, the reverse of this command, use \\[goto-last-change-reverse]
or precede this command with \\[universal-argument] - (minus).
\nIt does not go to the same point twice even if there has been many edits
there. I call the minimal distance between distinguishable edits \"span\".
Set variable `glc-default-span' to control how close is \"the same point\".
Default span is 8.
The span can be changed temporarily with \\[universal-argument] right before \\[goto-last-change]:
\\[universal-argument] <NUMBER> set current span to that number,
\\[universal-argument] (no number) multiplies span by 4, starting with default.
The so set span remains until it is changed again with \\[universal-argument], or the consecutive
repetition of this command is ended by any other command.
\nWhen span is zero (i.e. \\[universal-argument] 0) subsequent \\[goto-last-change] visits each and
every point of edit and a message shows what change was made there.
In this case it may go to the same point twice.
\nThis command uses undo information. If undo is disabled, so is this command.
At times, when undo information becomes too large, the oldest information is
discarded. See variable `undo-limit'."
(interactive "P")
(cond ((not (eq this-command last-command))
;; Start a glc sequence
;; Don't go to current point if last command was an obvious edit
;; (yank or self-insert, but not kill-region). Makes it easier to
;; jump back and forth when copying seleced lines.
(setq glc-probe-depth (if (memq last-command '(yank self-insert-command)) 1 0)
glc-direction 1
glc-current-span glc-default-span)
(if (< (prefix-numeric-value arg) 0)
(error "Negative arg: Cannot reverse as the first operation"))))
(cond ((and (null buffer-undo-list) (null buffer-undo-tree))
(error "Buffer has not been changed"))
((eq buffer-undo-list t)
(error "No change info (undo is disabled)")))
(cond ((numberp arg) ; Numeric arg sets span
(setq glc-current-span (abs arg)))
((consp arg) ; C-u's multiply previous span by 4
(setq glc-current-span (* (abs (car arg)) glc-default-span))
(message "Current span is %d chars" glc-current-span))) ;todo: keep message with "waiting" and "is saved"
(cond ((< (prefix-numeric-value arg) 0)
(setq glc-direction -1))
(t
(setq glc-direction 1)))
(let (rev ; Reversed (and filtered) undo list
pos ; The pos we look for, nil until found
(n 0) ; Steps in undo list (length of 'rev')
(l buffer-undo-list)
(passed-save-entry (not (buffer-modified-p)))
(new-probe-depth glc-probe-depth)
(undo-tree-p (bound-and-true-p undo-tree-mode))
glc-seen-canary)
;; Walk back and forth in the buffer-undo-list, each time one step deeper,
;; until we can walk back the whole list with a 'pos' that is not coming
;; too close to another edit.
(while (null pos)
(setq new-probe-depth (+ new-probe-depth glc-direction))
(if (< glc-direction 0)
(setq rev ()
n 0
l buffer-undo-list
passed-save-entry (not (buffer-modified-p))))
(if (< new-probe-depth 1)
(error "No later change info"))
(if (> n 150)
(message "working..."))
;; Walk forward in buffer-undo-list, glc-probe-depth steps.
;; Build reverse list along the way
(if (not undo-tree-p)
(while (< n new-probe-depth)
(cond ((null l)
;(setq this-command t) ; Disrupt repeat sequence
(error "No further change info"))
((glc-is-positionable (car l))
(setq n (1+ n)
rev (cons (car l) rev)))
((or passed-save-entry (glc-is-filetime (car l)))
(setq passed-save-entry t)))
(setq l (cdr l)))
(undo-list-transfer-to-tree)
(when (not glc-seen-canary)
(while (and (not (null l)) (not glc-seen-canary) (< n new-probe-depth))
(cond ((eq 'undo-tree-canary (car l)) ; used by buffer-undo-tree
(message "Canary found...")
(setq l (undo-tree-current buffer-undo-tree)
glc-seen-canary t))
((glc-is-positionable (car l))
(setq n (1+ n)
rev (cons (car l) rev)))
((or passed-save-entry (glc-is-filetime (car l)))
(setq passed-save-entry t)))
(when (not glc-seen-canary)
(setq l (cdr l)))))
(when glc-seen-canary
(while (and (< n new-probe-depth) (undo-tree-node-p l))
(cond ((null l)
;(setq this-command t) ; Disrupt repeat sequence
(error "No further change info"))
((glc-is-positionable (car (undo-tree-node-undo l)))
(setq n (1+ n)
rev (cons (car (undo-tree-node-undo l)) rev)))
((or passed-save-entry (glc-is-filetime (car (undo-tree-node-undo l))))
(setq passed-save-entry t)))
(setq l (undo-tree-node-previous l))))
(when (null l)
(error "No further change info")))
;; Walk back in reverse list, from older to newer edits.
;; Adjusting pos along the way.
(setq pos (glc-adjust-list rev)))
;; Found a place not previously visited, in 'pos'.
;; (An error have been issued if nothing (more) found.)
(if (> n 150)
(message nil)) ; remove message "working..."
(if (and (= glc-current-span 0) (glc-get-descript (car rev) n))
(message "%s" (glc-get-descript (car rev) n))
;; else
(if passed-save-entry
(message "(This change is saved)")))
(setq glc-probe-depth new-probe-depth)
(goto-char pos)))
;;;###autoload
(defun goto-last-change-reverse (arg)
"Go back to more recent changes after \\[goto-last-change] have been used.
See `goto-last-change' for use of prefix argument."
(interactive "P")
;; Negate arg, all kinds
(cond ((eq arg nil) (setq arg '-))
((eq arg '-) (setq arg nil))
((listp arg) (setq arg (list (- (car arg)))))
(t (setq arg (- arg))))
;; Make 'goto-last-change-reverse' look like 'goto-last-change'
(cond ((eq last-command this-command)
(setq last-command 'goto-last-change)))
(setq this-command 'goto-last-change)
;; Call 'goto-last-change' to do the job
(goto-last-change arg))
(provide 'goto-chg)
;;; goto-chg.el ends here

View File

@ -0,0 +1,24 @@
;;; monokai-theme-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "monokai-theme" "monokai-theme.el" (0 0 0 0))
;;; Generated autoloads from monokai-theme.el
(when (and (boundp 'custom-theme-load-path) load-file-name) (add-to-list 'custom-theme-load-path (file-name-as-directory (file-name-directory load-file-name))))
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "monokai-theme" '("monokai")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; monokai-theme-autoloads.el ends here

View File

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "monokai-theme" "20190801.1701" "A fruity color theme for Emacs." 'nil :commit "e407f51d34b0c30cfe9d815f80a0c3539b998b08" :authors '(("Kelvin Smith" . "oneKelvinSmith@gmail.com")) :maintainer '("Kelvin Smith" . "oneKelvinSmith@gmail.com") :url "http://github.com/oneKelvinSmith/monokai-emacs")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
;;; powerline-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "powerline" "powerline.el" (0 0 0 0))
;;; Generated autoloads from powerline.el
(autoload 'powerline-hud "powerline" "\
Return an XPM of relative buffer location using FACE1 and FACE2 of optional WIDTH.
\(fn FACE1 FACE2 &optional WIDTH)" nil nil)
(autoload 'powerline-mouse "powerline" "\
Return mouse handler for CLICK-GROUP given CLICK-TYPE and STRING.
\(fn CLICK-GROUP CLICK-TYPE STRING)" nil nil)
(autoload 'powerline-concat "powerline" "\
Concatonate STRINGS and pad sides by spaces.
\(fn &rest STRINGS)" nil nil)
(autoload 'defpowerline "powerline" "\
Create function NAME by wrapping BODY with powerline padding an propetization.
\(fn NAME BODY)" nil t)
(autoload 'powerline-raw "powerline" "\
Render STR as mode-line data using FACE and optionally PAD import on left (l) or right (r).
\(fn STR &optional FACE PAD)" nil nil)
(autoload 'powerline-fill "powerline" "\
Return empty space using FACE and leaving RESERVE space on the right.
\(fn FACE RESERVE)" nil nil)
(autoload 'powerline-major-mode "powerline")
(autoload 'powerline-minor-modes "powerline")
(autoload 'powerline-narrow "powerline")
(autoload 'powerline-vc "powerline")
(autoload 'powerline-encoding "powerline")
(autoload 'powerline-buffer-size "powerline")
(autoload 'powerline-buffer-id "powerline")
(autoload 'powerline-process "powerline")
(autoload 'powerline-selected-window-active "powerline")
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "powerline" '("pl/" "powerline-")))
;;;***
;;;### (autoloads nil "powerline-separators" "powerline-separators.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from powerline-separators.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "powerline-separators" '("powerline-image-apple-rgb" "pl/")))
;;;***
;;;### (autoloads nil "powerline-themes" "powerline-themes.el" (0
;;;;;; 0 0 0))
;;; Generated autoloads from powerline-themes.el
(autoload 'powerline-default-theme "powerline-themes" "\
Setup the default mode-line.
\(fn)" t nil)
(autoload 'powerline-center-theme "powerline-themes" "\
Setup a mode-line with major and minor modes centered.
\(fn)" t nil)
(autoload 'powerline-vim-theme "powerline-themes" "\
Setup a Vim-like mode-line.
\(fn)" t nil)
(autoload 'powerline-nano-theme "powerline-themes" "\
Setup a nano-like mode-line.
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "powerline-themes" '("powerline-")))
;;;***
;;;### (autoloads nil nil ("powerline-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; powerline-autoloads.el ends here

View File

@ -0,0 +1,12 @@
(define-package "powerline" "20190323.213" "Rewrite of Powerline"
'((cl-lib "0.2"))
:keywords
'("mode-line")
:authors
'(("Donald Ephraim Curtis" . "dcurtis@milkbox.net"))
:maintainer
'("Donald Ephraim Curtis" . "dcurtis@milkbox.net")
:url "http://github.com/milkypostman/powerline/")
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@ -0,0 +1,635 @@
;;; powerline-separators.el --- Separators for Powerline
;; Copyright (C) 2012-2013 Donald Ephraim Curtis
;; Copyright (C) 2013 Jason Milkins
;; Copyright (C) 2012 Nicolas Rougier
;; This file 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, or (at your option)
;; any later version.
;; This file 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Separators for Powerline.
;; Included separators: alternate, arrow, arrow-fade, bar, box, brace, butt,
;; chamfer, contour, curve, rounded, roundstub, slant, wave, zigzag, and nil.
;;
;;; Code:
(require 'cl-lib)
(require 'color)
(defvar powerline-image-apple-rgb
(and (eq (window-system) 'ns)
ns-use-srgb-colorspace
(< 11
(string-to-number
(and (string-match "darwin\\([0-9]+\\)" system-configuration)
(match-string-no-properties 1 system-configuration)))))
"Boolean variable to determine whether to use Apple RGB colorspace to render images.
t on macOS 10.7+ and `ns-use-srgb-colorspace' is t, nil otherwise.
This variable is automatically set, there's no need to modify it.")
(defun pl/interpolate (color1 color2)
"Interpolate between COLOR1 and COLOR2.
COLOR1 and COLOR2 must be supplied as hex strings with a leading #."
(let* ((c1 (color-name-to-rgb color1))
(c2 (color-name-to-rgb color2))
(red (/ (+ (nth 0 c1) (nth 0 c2)) 2))
(green (/ (+ (nth 1 c1) (nth 1 c2)) 2))
(blue (/ (+ (nth 2 c1) (nth 2 c2)) 2)))
(color-rgb-to-hex red green blue)))
(defun pl/color-xyz-to-apple-rgb (X Y Z)
"Convert CIE X Y Z colors to Apple RGB color space."
(let ((r (+ (* 3.2404542 X) (* -1.5371385 Y) (* -0.4985314 Z)))
(g (+ (* -0.9692660 X) (* 1.8760108 Y) (* 0.0415560 Z)))
(b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z))))
(list (expt r (/ 1.8)) (expt g (/ 1.8)) (expt b (/ 1.8)))))
(defun pl/color-srgb-to-apple-rgb (red green blue)
"Convert RED GREEN BLUE colors from sRGB color space to Apple RGB.
RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive."
(apply 'pl/color-xyz-to-apple-rgb (color-srgb-to-xyz red green blue)))
(defun pl/hex-color (color)
"Get the hexadecimal value of COLOR."
(when color
(let ((srgb-color (color-name-to-rgb color)))
(if powerline-image-apple-rgb
(apply 'color-rgb-to-hex (apply 'pl/color-srgb-to-apple-rgb srgb-color))
(apply 'color-rgb-to-hex srgb-color)))))
(defun pl/pattern (lst)
"Turn LST into an infinite pattern."
(when lst
(let ((pattern (cl-copy-list lst)))
(setcdr (last pattern) pattern))))
(defun pl/pattern-to-string (pattern)
"Convert a PATTERN into a string that can be used in an XPM."
(concat "\"" (mapconcat 'number-to-string pattern "") "\","))
(defun pl/reverse-pattern (pattern)
"Reverse each line in PATTERN."
(mapcar 'reverse pattern))
(defun pl/row-pattern (fill total &optional fade)
"Make a list that has FILL 0s out of TOTAL 1s with FADE 2s to the right of the fill."
(unless fade
(setq fade 0))
(let ((fill (min fill total))
(fade (min fade (max (- total fill) 0))))
(append (make-list fill 0)
(make-list fade 2)
(make-list (- total fill fade) 1))))
(defun pl/pattern-bindings-body (patterns height-exp pattern-height-sym
second-pattern-height-sym)
"Create let-var bindings and a function body from PATTERNS.
The `car' and `cdr' parts of the result can be passed to the
function `pl/wrap-defun' as its `let-vars' and `body' arguments,
respectively. HEIGHT-EXP is an expression calculating the image
height and it should contain a free variable `height'.
PATTERN-HEIGHT-SYM and SECOND-PATTERN-HEIGHT-SYM are symbols used
for let-var binding variables."
(let* ((pattern (pl/pattern (mapcar 'pl/pattern-to-string (car patterns))))
(header (mapcar 'pl/pattern-to-string (nth 1 patterns)))
(footer (mapcar 'pl/pattern-to-string (nth 2 patterns)))
(second-pattern (pl/pattern (mapcar 'pl/pattern-to-string (nth 3 patterns))))
(center (mapcar 'pl/pattern-to-string (nth 4 patterns)))
(reserve (+ (length header) (length footer) (length center))))
(when pattern
(cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0))
(,second-pattern-height-sym (/ ,pattern-height-sym 2))
(,pattern-height-sym ,(if second-pattern `(ceiling ,pattern-height-sym 2) `,pattern-height-sym)))
(list (when header `(mapconcat 'identity ',header ""))
`(mapconcat 'identity
(cl-subseq ',pattern 0 ,pattern-height-sym) "")
(when center `(mapconcat 'identity ',center ""))
(when second-pattern
`(mapconcat 'identity
(cl-subseq ',second-pattern
0 ,second-pattern-height-sym) ""))
(when footer `(mapconcat 'identity ',footer "")))))))
(defun pl/pattern-defun (name dir width &rest patterns)
"Create a powerline function of NAME in DIR with WIDTH for PATTERNS.
PATTERNS is of the form (PATTERN HEADER FOOTER SECOND-PATTERN CENTER
PATTERN-2X HEADER-2X FOOTER-2X SECOND-PATTERN-2X CENTER-2X).
PATTERN is required, all other components are optional.
The first 5 components are for the standard resolution image.
The remaining ones are for the high resolution image where both
width and height are doubled. If PATTERN-2X is nil or not given,
then the remaining components are ignored and the standard
resolution image with magnification and interpolation will be
used in high resolution environments
All generated functions generate the form:
HEADER
PATTERN ...
CENTER
SECOND-PATTERN ...
FOOTER
PATTERN and SECOND-PATTERN repeat infinitely to fill the space needed to generate a full height XPM.
PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the form ((COLOR ...) (COLOR ...) ...).
COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is the
destination color, and 2 is the interpolated color between 0 and 1."
(when (eq dir 'right)
(setq patterns (mapcar 'pl/reverse-pattern patterns)))
(let ((bindings-body (pl/pattern-bindings-body patterns
'height
'pattern-height
'second-pattern-height))
(bindings-body-2x (pl/pattern-bindings-body (nthcdr 5 patterns)
'(* height 2)
'pattern-height-2x
'second-pattern-height-2x)))
(pl/wrap-defun name dir width
(append (car bindings-body) (car bindings-body-2x))
(cdr bindings-body) (cdr bindings-body-2x))))
(defun pl/background-color (face)
(face-attribute face
(if (face-attribute face :inverse-video nil 'default)
:foreground
:background)
nil
'default))
(defun pl/wrap-defun (name dir width let-vars body &optional body-2x)
"Generate a powerline function of NAME in DIR with WIDTH using LET-VARS and BODY."
(let* ((src-face (if (eq dir 'left) 'face1 'face2))
(dst-face (if (eq dir 'left) 'face2 'face1)))
`(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir)))
(face1 face2 &optional height)
(when window-system
(unless height (setq height (pl/separator-height)))
(let* ,(append `((color1 (when ,src-face
(pl/hex-color (pl/background-color ,src-face))))
(color2 (when ,dst-face
(pl/hex-color (pl/background-color ,dst-face))))
(colori (when (and color1 color2) (pl/interpolate color1 color2)))
(color1 (or color1 "None"))
(color2 (or color2 "None"))
(colori (or colori "None")))
let-vars)
(apply 'create-image
,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\","
,(replace-regexp-in-string "-" "_" name)
(symbol-name ',dir)
,width
height
color1
color2
colori))
body
'("};"))
'xpm t
:ascent 'center
:face (when (and face1 face2)
,dst-face)
,(and body-2x
`(and (featurep 'mac)
(list :data-2x
,(append `(concat (format "/* XPM */ static char * %s_%s_2x[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\","
,(replace-regexp-in-string "-" "_" name)
(symbol-name ',dir)
(* ,width 2)
(* height 2)
color1
color2
colori))
body-2x
'("};")))))))))))
(defmacro pl/alternate (dir)
"Generate an alternating pattern XPM function for DIR."
(pl/pattern-defun "alternate" dir 4
'((2 2 1 1)
(0 0 2 2))
nil nil nil nil
;; 2x
'((2 2 2 2 1 1 1 1)
(2 2 2 2 1 1 1 1)
(0 0 0 0 2 2 2 2)
(0 0 0 0 2 2 2 2))))
(defmacro pl/arrow (dir)
"Generate an arrow XPM function for DIR."
(let ((row-modifier (if (eq dir 'left) 'identity 'reverse)))
(pl/wrap-defun "arrow" dir 'middle-width
'((width (1- (/ height 2)))
(middle-width (1- (ceiling height 2))))
`((cl-loop for i from 0 to width
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width))))
(when (cl-oddp height)
(pl/pattern-to-string (make-list middle-width 0)))
(cl-loop for i from width downto 0
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width)))))
`((when (cl-evenp height)
(pl/pattern-to-string (make-list (* middle-width 2) 1)))
(cl-loop for i from 0 to (* middle-width 2)
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2)))))
(cl-loop for i from (* middle-width 2) downto 0
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2)))))
(when (cl-evenp height)
(pl/pattern-to-string (make-list (* middle-width 2) 1)))))))
(defmacro pl/arrow-fade (dir)
"Generate an arrow-fade XPM function for DIR."
(let* ((row-modifier (if (eq dir 'left) 'identity 'reverse)))
(pl/wrap-defun "arrow-fade" dir 'middle-width
'((width (1- (/ height 2)))
(middle-width (1+ (ceiling height 2))))
`((cl-loop for i from 0 to width
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2))))
(when (cl-oddp height)
(pl/pattern-to-string (,row-modifier (pl/row-pattern (1+ width) middle-width 2))))
(cl-loop for i from width downto 0
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2)))))
`((when (cl-evenp height)
(pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2)))))
(cl-loop for i from 0 to (* (- middle-width 2) 2)
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2)))))
(cl-loop for i from (* (- middle-width 2) 2) downto 0
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2)))))
(when (cl-evenp height)
(pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2)))))))))
(defmacro pl/bar (dir)
"Generate a bar XPM function for DIR."
(pl/pattern-defun "bar" dir 2
'((2 2))))
(defmacro pl/box (dir)
"Generate a box XPM function for DIR."
(pl/pattern-defun "box" dir 2
'((0 0)
(0 0)
(1 1)
(1 1))
nil nil nil nil
;; 2x
'((0 0 0 0)
(0 0 0 0)
(0 0 0 0)
(0 0 0 0)
(1 1 1 1)
(1 1 1 1)
(1 1 1 1)
(1 1 1 1))))
(defmacro pl/brace (dir)
"Generate a brace XPM function for DIR."
(pl/pattern-defun "brace" dir 4
'((0 1 1 1))
'((1 1 1 1)
(2 1 1 1))
'((2 1 1 1)
(1 1 1 1))
'((0 1 1 1))
'((0 2 1 1)
(0 2 1 1)
(0 0 2 1)
(0 0 0 0)
(0 0 2 1)
(0 2 1 1)
(0 2 1 1))
;; 2x
'((0 0 1 1 1 1 1 1))
'((1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(2 1 1 1 1 1 1 1)
(0 2 1 1 1 1 1 1))
'((0 2 1 1 1 1 1 1)
(2 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1))
'((0 0 1 1 1 1 1 1))
'((0 0 2 1 1 1 1 1)
(0 0 0 1 1 1 1 1)
(0 0 0 2 1 1 1 1)
(0 0 0 0 1 1 1 1)
(0 0 0 0 2 1 1 1)
(0 0 0 0 0 2 1 1)
(0 0 0 0 0 0 0 2)
(0 0 0 0 0 0 0 2)
(0 0 0 0 0 2 1 1)
(0 0 0 0 2 1 1 1)
(0 0 0 0 1 1 1 1)
(0 0 0 2 1 1 1 1)
(0 0 0 1 1 1 1 1)
(0 0 2 1 1 1 1 1))))
(defmacro pl/butt (dir)
"Generate a butt XPM function for DIR."
(pl/pattern-defun "butt" dir 3
'((0 0 0))
'((1 1 1)
(0 1 1)
(0 0 1))
'((0 0 1)
(0 1 1)
(1 1 1))
nil nil
;; 2x
'((0 0 0 0 0 0))
'((1 1 1 1 1 1)
(0 1 1 1 1 1)
(0 0 1 1 1 1)
(0 0 0 1 1 1)
(0 0 0 0 1 1)
(0 0 0 0 0 1))
'((0 0 0 0 0 1)
(0 0 0 0 1 1)
(0 0 0 1 1 1)
(0 0 1 1 1 1)
(0 1 1 1 1 1)
(1 1 1 1 1 1))))
(defmacro pl/chamfer (dir)
"Generate a chamfer XPM function for DIR."
(pl/pattern-defun "chamfer" dir 3
'((0 0 0))
'((1 1 1)
(0 1 1)
(0 0 1))
nil nil nil
;; 2x
'((0 0 0 0 0 0))
'((1 1 1 1 1 1)
(0 1 1 1 1 1)
(0 0 1 1 1 1)
(0 0 0 1 1 1)
(0 0 0 0 1 1)
(0 0 0 0 0 1))))
(defmacro pl/contour (dir)
"Generate a contour XPM function for DIR."
(pl/pattern-defun "contour" dir 10
'((0 0 0 0 0 1 1 1 1 1))
'((1 1 1 1 1 1 1 1 1 1)
(0 2 1 1 1 1 1 1 1 1)
(0 0 2 1 1 1 1 1 1 1)
(0 0 0 2 1 1 1 1 1 1)
(0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 2 1 1 1 1 1))
'((0 0 0 0 0 2 1 1 1 1)
(0 0 0 0 0 0 1 1 1 1)
(0 0 0 0 0 0 2 1 1 1)
(0 0 0 0 0 0 0 2 1 1)
(0 0 0 0 0 0 0 0 0 0))
nil nil
;; 2x
'((0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1))
'((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1))
'((0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))))
(defmacro pl/curve (dir)
"Generate a curve XPM function for DIR."
(pl/pattern-defun "curve" dir 4
'((0 0 0 0))
'((1 1 1 1)
(2 1 1 1)
(0 0 1 1)
(0 0 2 1)
(0 0 0 1)
(0 0 0 2))
'((0 0 0 2)
(0 0 0 1)
(0 0 2 1)
(0 0 1 1)
(2 1 1 1)
(1 1 1 1))
nil nil
;; 2x
'((0 0 0 0 0 0 0 0))
'((1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(0 0 1 1 1 1 1 1)
(0 0 0 2 1 1 1 1)
(0 0 0 0 2 1 1 1)
(0 0 0 0 0 2 1 1)
(0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 0 1))
'((0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 1 1)
(0 0 0 0 0 2 1 1)
(0 0 0 0 2 1 1 1)
(0 0 0 2 1 1 1 1)
(0 0 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1))))
(defmacro pl/rounded (dir)
"Generate a rounded XPM function for DIR."
(pl/pattern-defun "rounded" dir 6
'((0 0 0 0 0 0))
'((2 1 1 1 1 1)
(0 0 2 1 1 1)
(0 0 0 0 1 1)
(0 0 0 0 2 1)
(0 0 0 0 0 1)
(0 0 0 0 0 2))
nil nil nil
;; 2x
'((0 0 0 0 0 0 0 0 0 0 0 0))
'((1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 2 1 1 1 1 1 1 1 1 1)
(0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 0 0 2 1 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1 1)
(0 0 0 0 0 0 0 0 0 1 1 1)
(0 0 0 0 0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 0 0 0 0 2 1)
(0 0 0 0 0 0 0 0 0 0 0 1)
(0 0 0 0 0 0 0 0 0 0 0 1))))
(defmacro pl/roundstub (dir)
"Generate a roundstub XPM function for DIR."
(pl/pattern-defun "roundstub" dir 3
'((0 0 0))
'((1 1 1)
(0 0 1)
(0 0 2))
'((0 0 2)
(0 0 1)
(1 1 1))
nil nil
;; 2x
'((0 0 0 0 0 0))
'((1 1 1 1 1 1)
(2 1 1 1 1 1)
(0 0 0 2 1 1)
(0 0 0 0 1 1)
(0 0 0 0 0 1)
(0 0 0 0 0 1))
'((0 0 0 0 0 1)
(0 0 0 0 0 1)
(0 0 0 0 1 1)
(0 0 0 2 1 1)
(2 1 1 1 1 1)
(1 1 1 1 1 1))))
(defmacro pl/slant (dir)
"Generate a slant XPM function for DIR."
(let* ((row-modifier (if (eq dir 'left) 'identity 'reverse)))
(pl/wrap-defun "slant" dir 'width
'((width (1- (ceiling height 2))))
`((cl-loop for i from 0 to (1- height)
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) width)))))
`((cl-loop for i from 0 to (1- (* height 2))
concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) (* width 2)))))))))
(defmacro pl/wave (dir)
"Generate a wave XPM function for DIR."
(pl/pattern-defun "wave" dir 11
'((0 0 0 0 0 0 1 1 1 1 1))
'((2 1 1 1 1 1 1 1 1 1 1)
(0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 2 1 1 1 1 1 1 1)
(0 0 0 0 1 1 1 1 1 1 1)
(0 0 0 0 2 1 1 1 1 1 1)
(0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 2 1 1 1 1 1))
'((0 0 0 0 0 0 2 1 1 1 1)
(0 0 0 0 0 0 0 1 1 1 1)
(0 0 0 0 0 0 0 1 1 1 1)
(0 0 0 0 0 0 0 2 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1)
(0 0 0 0 0 0 0 0 2 1 1)
(0 0 0 0 0 0 0 0 0 0 2))
nil nil
;; 2x
'((0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1))
'((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1))
'((0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1)
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))))
(defmacro pl/zigzag (dir)
"Generate a zigzag pattern XPM function for DIR."
(pl/pattern-defun "zigzag" dir 3
'((1 1 1)
(0 1 1)
(0 0 1)
(0 0 0)
(0 0 1)
(0 1 1))
nil nil nil nil
;; 2x
'((1 1 1 1 1 1)
(0 1 1 1 1 1)
(0 0 1 1 1 1)
(0 0 0 1 1 1)
(0 0 0 0 1 1)
(0 0 0 0 0 1)
(0 0 0 0 0 0)
(0 0 0 0 0 1)
(0 0 0 0 1 1)
(0 0 0 1 1 1)
(0 0 1 1 1 1)
(0 1 1 1 1 1))))
(defmacro pl/nil (dir)
"Generate a XPM function that returns nil for DIR."
`(defun ,(intern (format "powerline-nil-%s" (symbol-name dir)))
(face1 face2 &optional height)
nil))
(defmacro pl/utf-8 (dir)
"Generate function that returns raw utf-8 symbols."
(let ((dir-name (symbol-name dir))
(src-face (if (eq dir 'left) 'face1 'face2))
(dst-face (if (eq dir 'left) 'face2 'face1)))
`(defun ,(intern (format "powerline-utf-8-%s" dir-name))
(face1 face2 &optional height)
(powerline-raw
(char-to-string ,(intern (format "powerline-utf-8-separator-%s"
dir-name)))
(list :foreground (pl/background-color ,src-face)
:background (pl/background-color ,dst-face)
:inverse-video nil)))))
(provide 'powerline-separators)
;;; powerline-separators.el ends here

View File

@ -0,0 +1,294 @@
;;; powerline-themes.el --- Themes for Powerline
;; Copyright (C) 2012-2013 Donald Ephraim Curtis
;; Copyright (C) 2013 Jason Milkins
;; Copyright (C) 2012 Nicolas Rougier
;; This file 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, or (at your option)
;; any later version.
;; This file 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Themes for Powerline.
;; Included themes: default, center, center-evil, vim, and nano.
;;
;;; Code:
(defcustom powerline-display-buffer-size t
"When non-nil, display the buffer size."
:group 'powerline
:type 'boolean)
(defcustom powerline-display-mule-info t
"When non-nil, display the mule info."
:group 'powerline
:type 'boolean)
(defcustom powerline-display-hud t
"When non-nil, display the hud."
:group 'powerline
:type 'boolean)
;;;###autoload
(defun powerline-default-theme ()
"Setup the default mode-line."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face0 (if active 'powerline-active0 'powerline-inactive0))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left (intern (format "powerline-%s-%s"
(powerline-current-separator)
(car powerline-default-separator-dir))))
(separator-right (intern (format "powerline-%s-%s"
(powerline-current-separator)
(cdr powerline-default-separator-dir))))
(lhs (list (powerline-raw "%*" face0 'l)
(when powerline-display-buffer-size
(powerline-buffer-size face0 'l))
(when powerline-display-mule-info
(powerline-raw mode-line-mule-info face0 'l))
(powerline-buffer-id `(mode-line-buffer-id ,face0) 'l)
(when (and (boundp 'which-func-mode) which-func-mode)
(powerline-raw which-func-format face0 'l))
(powerline-raw " " face0)
(funcall separator-left face0 face1)
(when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
(powerline-raw erc-modified-channels-object face1 'l))
(powerline-major-mode face1 'l)
(powerline-process face1)
(powerline-minor-modes face1 'l)
(powerline-narrow face1 'l)
(powerline-raw " " face1)
(funcall separator-left face1 face2)
(powerline-vc face2 'r)
(when (bound-and-true-p nyan-mode)
(powerline-raw (list (nyan-create)) face2 'l))))
(rhs (list (powerline-raw global-mode-string face2 'r)
(funcall separator-right face2 face1)
(unless window-system
(powerline-raw (char-to-string #xe0a1) face1 'l))
(powerline-raw "%4l" face1 'l)
(powerline-raw ":" face1 'l)
(powerline-raw "%3c" face1 'r)
(funcall separator-right face1 face0)
(powerline-raw " " face0)
(powerline-raw "%6p" face0 'r)
(when powerline-display-hud
(powerline-hud face0 face2))
(powerline-fill face0 0)
)))
(concat (powerline-render lhs)
(powerline-fill face2 (powerline-width rhs))
(powerline-render rhs)))))))
;;;###autoload
(defun powerline-center-theme ()
"Setup a mode-line with major and minor modes centered."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face0 (if active 'powerline-active0 'powerline-inactive0))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left (intern (format "powerline-%s-%s"
(powerline-current-separator)
(car powerline-default-separator-dir))))
(separator-right (intern (format "powerline-%s-%s"
(powerline-current-separator)
(cdr powerline-default-separator-dir))))
(lhs (list (powerline-raw "%*" face0 'l)
(when powerline-display-buffer-size
(powerline-buffer-size face0 'l))
(powerline-buffer-id `(mode-line-buffer-id ,face0) 'l)
(powerline-raw " " face0)
(funcall separator-left face0 face1)
(powerline-narrow face1 'l)
(powerline-vc face1)))
(rhs (list (powerline-raw global-mode-string face1 'r)
(powerline-raw "%4l" face1 'r)
(powerline-raw ":" face1)
(powerline-raw "%3c" face1 'r)
(funcall separator-right face1 face0)
(powerline-raw " " face0)
(powerline-raw "%6p" face0 'r)
(when powerline-display-hud
(powerline-hud face2 face1))
(powerline-fill face0 0)))
(center (list (powerline-raw " " face1)
(funcall separator-left face1 face2)
(when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
(powerline-raw erc-modified-channels-object face2 'l))
(powerline-major-mode face2 'l)
(powerline-process face2)
(powerline-raw " :" face2)
(powerline-minor-modes face2 'l)
(powerline-raw " " face2)
(funcall separator-right face2 face1))))
(concat (powerline-render lhs)
(powerline-fill-center face1 (/ (powerline-width center) 2.0))
(powerline-render center)
(powerline-fill face1 (powerline-width rhs))
(powerline-render rhs)))))))
(defun powerline-center-evil-theme ()
"Setup a mode-line with major, evil, and minor modes centered."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face0 (if active 'powerline-active0 'powerline-inactive0))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left (intern (format "powerline-%s-%s"
(powerline-current-separator)
(car powerline-default-separator-dir))))
(separator-right (intern (format "powerline-%s-%s"
(powerline-current-separator)
(cdr powerline-default-separator-dir))))
(lhs (list (powerline-raw "%*" face0 'l)
(when powerline-display-buffer-size
(powerline-buffer-size face0 'l))
(powerline-buffer-id `(mode-line-buffer-id ,face0) 'l)
(powerline-raw " " face0)
(funcall separator-left face0 face1)
(powerline-narrow face1 'l)
(powerline-vc face1)))
(rhs (list (powerline-raw global-mode-string face1 'r)
(powerline-raw "%4l" face1 'r)
(powerline-raw ":" face1)
(powerline-raw "%3c" face1 'r)
(funcall separator-right face1 face0)
(powerline-raw " " face0)
(powerline-raw "%6p" face0 'r)
(when powerline-display-hud
(powerline-hud face2 face1))))
(center (append (list (powerline-raw " " face1)
(funcall separator-left face1 face2)
(when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
(powerline-raw erc-modified-channels-object face2 'l))
(powerline-major-mode face2 'l)
(powerline-process face2)
(powerline-raw " " face2))
(if (split-string (format-mode-line minor-mode-alist))
(append (if evil-mode
(list (funcall separator-right face2 face1)
(powerline-raw evil-mode-line-tag face1 'l)
(powerline-raw " " face1)
(funcall separator-left face1 face2)))
(list (powerline-minor-modes face2 'l)
(powerline-raw " " face2)
(funcall separator-right face2 face1)))
(list (powerline-raw evil-mode-line-tag face2)
(funcall separator-right face2 face1))))))
(concat (powerline-render lhs)
(powerline-fill-center face1 (/ (powerline-width center) 2.0))
(powerline-render center)
(powerline-fill face1 (powerline-width rhs))
(powerline-render rhs)))))))
;;;###autoload
(defun powerline-vim-theme ()
"Setup a Vim-like mode-line."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face0 (if active 'powerline-active0 'powerline-inactive0))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left (intern (format "powerline-%s-%s"
(powerline-current-separator)
(car powerline-default-separator-dir))))
(separator-right (intern (format "powerline-%s-%s"
(powerline-current-separator)
(cdr powerline-default-separator-dir))))
(lhs (list (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l)
(powerline-raw "[" face0 'l)
(powerline-major-mode face0)
(powerline-process face0)
(powerline-raw "]" face0)
(when (buffer-modified-p)
(powerline-raw "[+]" face0))
(when buffer-read-only
(powerline-raw "[RO]" face0))
(powerline-raw "[%z]" face0)
;; (powerline-raw (concat "[" (mode-line-eol-desc) "]") face0)
(when (and (boundp 'which-func-mode) which-func-mode)
(powerline-raw which-func-format nil 'l))
(when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode)
(powerline-raw erc-modified-channels-object face1 'l))
(powerline-raw "[" face0 'l)
(powerline-minor-modes face0)
(powerline-raw "%n" face0)
(powerline-raw "]" face0)
(when (and vc-mode buffer-file-name)
(let ((backend (vc-backend buffer-file-name)))
(when backend
(concat (powerline-raw "[" face0 'l)
(powerline-raw (format "%s / %s" backend (vc-working-revision buffer-file-name backend)) face0)
(powerline-raw "]" face0)))))))
(rhs (list (powerline-raw '(10 "%i") face0)
(powerline-raw global-mode-string face0 'r)
(powerline-raw "%l," face0 'l)
(powerline-raw (format-mode-line '(10 "%c")) face0)
(powerline-raw (replace-regexp-in-string "%" "%%" (format-mode-line '(-3 "%p"))) face0 'r)
(powerline-fill face0 0))))
(concat (powerline-render lhs)
(powerline-fill face0 (powerline-width rhs))
(powerline-render rhs)))))))
;;;###autoload
(defun powerline-nano-theme ()
"Setup a nano-like mode-line."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(face0 (if active 'powerline-active0 'powerline-inactive0))
(lhs (list (powerline-raw (concat "GNU Emacs "
(number-to-string
emacs-major-version)
"."
(number-to-string
emacs-minor-version))
face0 'l)))
(rhs (list (if (buffer-modified-p) (powerline-raw "Modified" face0 'r))
(powerline-fill face0 0)))
(center (list (powerline-raw "%b" face0))))
(concat (powerline-render lhs)
(powerline-fill-center face0 (/ (powerline-width center) 2.0))
(powerline-render center)
(powerline-fill face0 (powerline-width rhs))
(powerline-render rhs)))))))
(provide 'powerline-themes)
;;; powerline-themes.el ends here

View File

@ -0,0 +1,617 @@
;;; powerline.el --- Rewrite of Powerline
;; Copyright (C) 2012-2013 Donald Ephraim Curtis
;; Copyright (C) 2013 Jason Milkins
;; Copyright (C) 2012 Nicolas Rougier
;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net>
;; URL: http://github.com/milkypostman/powerline/
;; Version: 2.4
;; Keywords: mode-line
;; Package-Requires: ((cl-lib "0.2"))
;; This file 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, or (at your option)
;; any later version.
;; This file 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Powerline is a library for customizing the mode-line that is based on the Vim
;; Powerline. A collection of predefined themes comes with the package.
;;
;;; Code:
(eval-and-compile (require 'powerline-themes))
(eval-and-compile (require 'powerline-separators))
(require 'cl-lib)
(defgroup powerline nil
"Powerline, a prettier mode line."
:group 'mode-line)
(defface powerline-active0 '((t (:inherit mode-line)))
"Powerline face 0."
:group 'powerline)
(defface powerline-active1 '((t (:background "grey17" :foreground "white" :inherit mode-line)))
"Powerline face 1."
:group 'powerline)
(defface powerline-active2 '((t (:background "grey40" :foreground "white" :inherit mode-line)))
"Powerline face 2."
:group 'powerline)
(defface powerline-inactive0
'((t (:inherit mode-line-inactive)))
"Powerline face 0."
:group 'powerline)
(defface powerline-inactive1
'((t (:background "grey11" :inherit mode-line-inactive)))
"Powerline face 1."
:group 'powerline)
(defface powerline-inactive2
'((t (:background "grey20" :inherit mode-line-inactive)))
"Powerline face 2."
:group 'powerline)
(defface mode-line-buffer-id-inactive
'((t (:inherit mode-line-buffer-id)))
"Powerline mode-line face"
:group 'powerline)
(defcustom powerline-default-separator 'arrow
"The separator to use for the default theme.
Valid Values: alternate, arrow, arrow-fade, bar, box, brace,
butt, chamfer, contour, curve, rounded, roundstub, wave, zigzag,
utf-8."
:group 'powerline
:type '(choice (const alternate)
(const arrow)
(const arrow-fade)
(const bar)
(const box)
(const brace)
(const butt)
(const chamfer)
(const contour)
(const curve)
(const rounded)
(const roundstub)
(const slant)
(const wave)
(const zigzag)
(const utf-8)
(const nil)))
(defcustom powerline-utf-8-separator-left #xe0b0
"The unicode character number for the left facing separator"
:group 'powerline
:type '(choice integer (const nil)))
(defcustom powerline-utf-8-separator-right #xe0b2
"The unicode character number for the right facing separator"
:group 'powerline
:type '(choice integer (const nil)))
(defcustom powerline-default-separator-dir '(left . right)
"The separator direction to use for the default theme.
CONS of the form (DIR . DIR) denoting the lean of the
separators for the left and right side of the powerline.
DIR must be one of: left, right"
:group 'powerline
:type '(cons (choice :tag "Left Hand Side" (const left) (const right))
(choice :tag "Right Hand Side" (const left) (const right))))
(defcustom powerline-height nil
"Override the mode-line height."
:group 'powerline
:type '(choice integer (const nil)))
(defcustom powerline-text-scale-factor nil
"Scale of mode-line font size to default text size.
Smaller mode-line fonts will be a float value less that 1.
Larger mode-line fonts require a float value greater than 1.
This is needed to make sure that text is properly aligned."
:group 'powerline
:type '(choice float integer (const nil)))
(defcustom powerline-buffer-size-suffix t
"Display the buffer size suffix."
:group 'powerline
:type 'boolean)
(defcustom powerline-gui-use-vcs-glyph nil
"Display a unicode character to represent a version control system. Not always supported in GUI."
:group 'powerline
:type 'boolean)
(defcustom powerline-narrowed-indicator "Narrow"
"A string to display in the mode-line when the buffer is narrowed."
:group 'powerline
:type 'string)
(defun pl/create-or-get-cache ()
"Return a frame-local hash table that acts as a memoization cache for powerline. Create one if the frame doesn't have one yet."
(let ((table (frame-parameter nil 'powerline-cache)))
(if (hash-table-p table) table (pl/reset-cache))))
(defun pl/reset-cache ()
"Reset and return the frame-local hash table used for a memoization cache."
(let ((table (make-hash-table :test 'equal)))
;; Store it as a frame-local variable
(modify-frame-parameters nil `((powerline-cache . ,table)))
table))
(defun powerline-current-separator ()
"Get the current default separator. Always returns utf-8 in non-gui mode."
(if window-system
powerline-default-separator
'utf-8))
;;
;; the frame-local powerline cache causes problems if included in a saved desktop,
;; so delete it before the desktop is saved.
;;
;; see https://github.com/milkypostman/powerline/issues/58
;;
;; It is better to put the following code into your init file for Emacs 24.4 or later.
;; (require 'frameset)
;; (push '(powerline-cache . :never) frameset-filter-alist)
;;
(defun powerline-delete-cache (&optional frame)
"Set the FRAME cache to nil."
(set-frame-parameter frame 'powerline-cache nil))
(defun powerline-desktop-save-delete-cache ()
"Set all caches to nil unless `frameset-filter-alist' has :never for powerline-cache."
(unless (and (boundp 'frameset-filter-alist)
(eq (cdr (assq 'powerline-cache frameset-filter-alist))
:never))
(dolist (fr (frame-list)) (powerline-delete-cache fr))))
(add-hook 'desktop-save-hook 'powerline-desktop-save-delete-cache)
;; from memoize.el @ http://nullprogram.com/blog/2010/07/26/
(defun pl/memoize (func)
"Memoize FUNC.
If argument is a symbol then install the memoized function over
the original function. Use frame-local memoization."
(cl-typecase func
(symbol (fset func (pl/memoize-wrap-frame-local (symbol-function func))) func)
(function (pl/memoize-wrap-frame-local func))))
(defun pl/memoize-wrap-frame-local (func)
"Return the memoized version of FUNC.
The memoization cache is frame-local."
(let ((funcid (cl-gensym)))
`(lambda (&rest args)
,(concat (documentation func) (format "\n(memoized function %s)" funcid))
(let* ((cache (pl/create-or-get-cache))
(key (cons ',funcid args))
(val (gethash key cache)))
(if val
val
(puthash key (apply ,func args) cache))))))
(defun pl/separator-height ()
"Get default height for rendering separators."
(or powerline-height (frame-char-height)))
(defun powerline-reset ()
"Reset memoized functions."
(interactive)
(pl/memoize (pl/alternate left))
(pl/memoize (pl/alternate right))
(pl/memoize (pl/arrow left))
(pl/memoize (pl/arrow right))
(pl/memoize (pl/arrow-fade left))
(pl/memoize (pl/arrow-fade right))
(pl/memoize (pl/bar left))
(pl/memoize (pl/bar right))
(pl/memoize (pl/box left))
(pl/memoize (pl/box right))
(pl/memoize (pl/brace left))
(pl/memoize (pl/brace right))
(pl/memoize (pl/butt left))
(pl/memoize (pl/butt right))
(pl/memoize (pl/chamfer left))
(pl/memoize (pl/chamfer right))
(pl/memoize (pl/contour left))
(pl/memoize (pl/contour right))
(pl/memoize (pl/curve left))
(pl/memoize (pl/curve right))
(pl/memoize (pl/rounded left))
(pl/memoize (pl/rounded right))
(pl/memoize (pl/roundstub left))
(pl/memoize (pl/roundstub right))
(pl/memoize (pl/slant left))
(pl/memoize (pl/slant right))
(pl/memoize (pl/wave left))
(pl/memoize (pl/wave right))
(pl/memoize (pl/zigzag left))
(pl/memoize (pl/zigzag right))
(pl/memoize (pl/nil left))
(pl/memoize (pl/nil right))
(pl/utf-8 left)
(pl/utf-8 right)
(pl/reset-cache))
(powerline-reset)
(defun pl/make-xpm (name color1 color2 data)
"Return an XPM image with NAME using COLOR1 for enabled and COLOR2 for disabled bits specified in DATA."
(when window-system
(create-image
(concat
(format "/* XPM */
static char * %s[] = {
\"%i %i 2 1\",
\". c %s\",
\" c %s\",
"
(downcase (replace-regexp-in-string " " "_" name))
(length (car data))
(length data)
(or (pl/hex-color color1) "None")
(or (pl/hex-color color2) "None"))
(let ((len (length data))
(idx 0))
(apply 'concat
(mapcar #'(lambda (dl)
(setq idx (+ idx 1))
(concat
"\""
(concat
(mapcar #'(lambda (d)
(if (eq d 0)
(string-to-char " ")
(string-to-char ".")))
dl))
(if (eq idx len)
"\"};"
"\",\n")))
data))))
'xpm t :ascent 'center)))
(defun pl/percent-xpm
(height pmax pmin winend winstart width color1 color2)
"Generate percentage xpm of HEIGHT for PMAX to PMIN given WINEND and WINSTART with WIDTH and COLOR1 and COLOR2."
(let* ((height- (1- height))
(fillstart (round (* height- (/ (float winstart) (float pmax)))))
(fillend (round (* height- (/ (float winend) (float pmax)))))
(data nil)
(i 0))
(while (< i height)
(setq data (cons
(if (and (<= fillstart i)
(<= i fillend))
(append (make-list width 1))
(append (make-list width 0)))
data))
(setq i (+ i 1)))
(pl/make-xpm "percent" color1 color2 (reverse data))))
(pl/memoize 'pl/percent-xpm)
;;;###autoload
(defun powerline-hud (face1 face2 &optional width)
"Return an XPM of relative buffer location using FACE1 and FACE2 of optional WIDTH."
(unless width (setq width 2))
(let ((color1 (if face1 (face-background face1) "None"))
(color2 (if face2 (face-background face2) "None"))
(height (or powerline-height (frame-char-height)))
pmax
pmin
(ws (window-start))
(we (window-end)))
(save-restriction
(widen)
(setq pmax (point-max))
(setq pmin (point-min)))
(pl/percent-xpm height pmax pmin we ws
(* (frame-char-width) width) color1 color2)))
;;;###autoload
(defun powerline-mouse (click-group click-type string)
"Return mouse handler for CLICK-GROUP given CLICK-TYPE and STRING."
(cond ((eq click-group 'minor)
(cond ((eq click-type 'menu)
`(lambda (event)
(interactive "@e")
(minor-mode-menu-from-indicator ,string)))
((eq click-type 'help)
`(lambda (event)
(interactive "@e")
(describe-minor-mode-from-indicator ,string)))
(t
`(lambda (event)
(interactive "@e")
nil))))
(t
`(lambda (event)
(interactive "@e")
nil))))
;;;###autoload
(defun powerline-concat (&rest strings)
"Concatonate STRINGS and pad sides by spaces."
(concat
" "
(mapconcat 'identity (delq nil strings) " ")
" "))
;;;###autoload
(defmacro defpowerline (name body)
"Create function NAME by wrapping BODY with powerline padding an propetization."
`(defun ,name
(&optional face pad)
(powerline-raw ,body face pad)))
(defun pl/property-substrings (str prop)
"Return a list of substrings of STR when PROP change."
(let ((beg 0) (end 0)
(len (length str))
(out))
(while (< end (length str))
(setq end (or (next-single-property-change beg prop str) len))
(setq out (append out (list (substring str beg (setq beg end))))))
out))
(defun pl/assure-list (item)
"Assure that ITEM is a list."
(if (listp item)
item
(list item)))
(defun pl/add-text-property (str prop val)
(mapconcat
(lambda (mm)
(let ((cur (pl/assure-list (get-text-property 0 'face mm))))
(propertize mm 'face (append cur (list val)))))
(pl/property-substrings str prop)
""))
;;;###autoload
(defun powerline-raw (str &optional face pad)
"Render STR as mode-line data using FACE and optionally PAD import on left (l) or right (r)."
(when str
(let* ((rendered-str (format-mode-line str))
(padded-str (concat
(when (and (> (length rendered-str) 0) (eq pad 'l)) " ")
(if (listp str) rendered-str str)
(when (and (> (length rendered-str) 0) (eq pad 'r)) " "))))
(if face
(pl/add-text-property padded-str 'face face)
padded-str))))
;;;###autoload
(defun powerline-fill (face reserve)
"Return empty space using FACE and leaving RESERVE space on the right."
(unless reserve
(setq reserve 20))
(when powerline-text-scale-factor
(setq reserve (* powerline-text-scale-factor reserve)))
(when (and window-system (eq 'right (get-scroll-bar-mode)))
(setq reserve (- reserve 3)))
(propertize " "
'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve)))
'face face))
(defun powerline-fill-center (face reserve)
"Return empty space using FACE to the center of remaining space leaving RESERVE space on the right."
(unless reserve
(setq reserve 20))
(when powerline-text-scale-factor
(setq reserve (* powerline-text-scale-factor reserve)))
(propertize " "
'display `((space :align-to (- (+ center (.5 . right-margin)) ,reserve
(.5 . left-margin))))
'face face))
;;;###autoload (autoload 'powerline-major-mode "powerline")
(defpowerline powerline-major-mode
(propertize (format-mode-line mode-name)
'mouse-face 'mode-line-highlight
'help-echo "Major mode\n\ mouse-1: Display major mode menu\n\ mouse-2: Show help for major mode\n\ mouse-3: Toggle minor modes"
'local-map (let ((map (make-sparse-keymap)))
(define-key map [mode-line down-mouse-1]
`(menu-item ,(purecopy "Menu Bar") ignore
:filter (lambda (_) (mouse-menu-major-mode-map))))
(define-key map [mode-line mouse-2] 'describe-mode)
(define-key map [mode-line down-mouse-3] mode-line-mode-menu)
map)))
;;;###autoload (autoload 'powerline-minor-modes "powerline")
(defpowerline powerline-minor-modes
(mapconcat (lambda (mm)
(propertize mm
'mouse-face 'mode-line-highlight
'help-echo "Minor mode\n mouse-1: Display minor mode menu\n mouse-2: Show help for minor mode\n mouse-3: Toggle minor modes"
'local-map (let ((map (make-sparse-keymap)))
(define-key map
[mode-line down-mouse-1]
(powerline-mouse 'minor 'menu mm))
(define-key map
[mode-line mouse-2]
(powerline-mouse 'minor 'help mm))
(define-key map
[mode-line down-mouse-3]
(powerline-mouse 'minor 'menu mm))
(define-key map
[header-line down-mouse-3]
(powerline-mouse 'minor 'menu mm))
map)))
(split-string (format-mode-line minor-mode-alist))
(propertize " " 'face face)))
;;;###autoload (autoload 'powerline-narrow "powerline")
(defpowerline powerline-narrow
(when ;; (buffer-narrowed-p) introduced in Emacs 24.3.
(/= (- (point-max) (point-min)) (buffer-size))
(propertize powerline-narrowed-indicator
'mouse-face 'mode-line-highlight
'help-echo "mouse-1: Remove narrowing from the current buffer"
'local-map (make-mode-line-mouse-map
'mouse-1 'mode-line-widen))))
;;;###autoload (autoload 'powerline-vc "powerline")
(defpowerline powerline-vc
(when (and (buffer-file-name (current-buffer)) vc-mode)
(if (and window-system (not powerline-gui-use-vcs-glyph))
(format-mode-line '(vc-mode vc-mode))
(format " %s%s"
(char-to-string #xe0a0)
(format-mode-line '(vc-mode vc-mode))))))
;;;###autoload (autoload 'powerline-encoding "powerline")
(defpowerline powerline-encoding
(let ((buf-coding (format "%s" buffer-file-coding-system)))
(if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding)
(match-string 1 buf-coding)
buf-coding)))
;;;###autoload (autoload 'powerline-buffer-size "powerline")
(defpowerline powerline-buffer-size
(propertize
(if powerline-buffer-size-suffix
"%I"
"%i")
'mouse-face 'mode-line-highlight
'local-map (make-mode-line-mouse-map
'mouse-1 (lambda () (interactive)
(setq powerline-buffer-size-suffix
(not powerline-buffer-size-suffix))
(force-mode-line-update)))))
;;;###autoload (autoload 'powerline-buffer-id "powerline")
(defun powerline-buffer-id (&optional face pad)
(powerline-raw
(format-mode-line
(concat " " (propertize
(format-mode-line mode-line-buffer-identification)
'face face
'mouse-face 'mode-line-highlight
'help-echo "Buffer name\n\ mouse-1: Previous buffer\n\ mouse-3: Next buffer"
'local-map (let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
(define-key map [mode-line mouse-3] 'mode-line-next-buffer)
map))))
face pad))
;;;###autoload (autoload 'powerline-process "powerline")
(defpowerline powerline-process
(cond
((symbolp mode-line-process) (symbol-value mode-line-process))
((listp mode-line-process) (format-mode-line mode-line-process))
(t mode-line-process)))
(defvar pl/default-mode-line mode-line-format)
(defvar pl/minibuffer-selected-window-list '())
(defun pl/minibuffer-selected-window ()
"Return the selected window when entereing the minibuffer."
(when pl/minibuffer-selected-window-list
(car pl/minibuffer-selected-window-list)))
(defun pl/minibuffer-setup ()
"Save the `minibuffer-selected-window' to `pl/minibuffer-selected-window'."
(push (minibuffer-selected-window) pl/minibuffer-selected-window-list))
(add-hook 'minibuffer-setup-hook 'pl/minibuffer-setup)
(defun pl/minibuffer-exit ()
"Set `pl/minibuffer-selected-window' to nil."
(pop pl/minibuffer-selected-window-list))
(add-hook 'minibuffer-exit-hook 'pl/minibuffer-exit)
(defvar powerline-selected-window (frame-selected-window)
"Selected window.")
(defun powerline-set-selected-window ()
"Set the variable `powerline-selected-window' appropriately."
(when (not (minibuffer-window-active-p (frame-selected-window)))
(setq powerline-selected-window (frame-selected-window))
(force-mode-line-update)))
(defun powerline-unset-selected-window ()
"Unset the variable `powerline-selected-window' and update the mode line."
(setq powerline-selected-window nil)
(force-mode-line-update))
(add-hook 'window-configuration-change-hook 'powerline-set-selected-window)
;; focus-in-hook was introduced in emacs v24.4.
;; Gets evaluated in the last frame's environment.
(add-hook 'focus-in-hook 'powerline-set-selected-window)
;; focus-out-hook was introduced in emacs v24.4.
(add-hook 'focus-out-hook 'powerline-unset-selected-window)
;; Executes after the window manager requests that the user's events
;; be directed to a different frame.
(defadvice handle-switch-frame (after powerline-handle-switch-frame activate)
"Call `powerline-set-selected-window'."
(powerline-set-selected-window))
(add-hook 'buffer-list-update-hook #'powerline-set-selected-window)
;;;###autoload (autoload 'powerline-selected-window-active "powerline")
(defun powerline-selected-window-active ()
"Return whether the current window is active."
(eq powerline-selected-window (selected-window)))
(defun powerline-revert ()
"Revert to the default Emacs mode-line."
(interactive)
(setq-default mode-line-format pl/default-mode-line))
(defun pl/render (item)
"Render a powerline ITEM."
(cond
((and (listp item) (eq 'image (car item)))
(propertize " " 'display item
'face (plist-get (cdr item) :face)))
(item item)))
(defun powerline-render (values)
"Render a list of powerline VALUES."
(mapconcat 'pl/render values ""))
(defun powerline-width (values)
"Get the length of VALUES."
(if values
(let ((val (car values)))
(+ (cond
((stringp val) (string-width (format-mode-line val)))
((and (listp val) (eq 'image (car val)))
(car (image-size val)))
(t 0))
(powerline-width (cdr values))))
0))
(provide 'powerline)
;;; powerline.el ends here

View File

@ -0,0 +1 @@
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2019-09-21T20:55:44+0300 using RSA

View File

@ -0,0 +1,64 @@
;;; undo-tree-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "undo-tree" "undo-tree.el" (0 0 0 0))
;;; Generated autoloads from undo-tree.el
(autoload 'undo-tree-mode "undo-tree" "\
Toggle undo-tree mode.
With no argument, this command toggles the mode.
A positive prefix argument turns the mode on.
A negative prefix argument turns it off.
Undo-tree-mode replaces Emacs' standard undo feature with a more
powerful yet easier to use version, that treats the undo history
as what it is: a tree.
The following keys are available in `undo-tree-mode':
\\{undo-tree-map}
Within the undo-tree visualizer, the following keys are available:
\\{undo-tree-visualizer-mode-map}
\(fn &optional ARG)" t nil)
(defvar global-undo-tree-mode nil "\
Non-nil if Global Undo-Tree mode is enabled.
See the `global-undo-tree-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-undo-tree-mode'.")
(custom-autoload 'global-undo-tree-mode "undo-tree" nil)
(autoload 'global-undo-tree-mode "undo-tree" "\
Toggle Undo-Tree mode in all buffers.
With prefix ARG, enable Global Undo-Tree mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Undo-Tree mode is enabled in all buffers where
`turn-on-undo-tree-mode' would do it.
See `undo-tree-mode' for more information on Undo-Tree mode.
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "undo-tree" '("undo-" "turn-on-undo-tree-mode" "*undo-tree-id-counter*" "buffer-undo-tree")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; undo-tree-autoloads.el ends here

View File

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "undo-tree" "0.6.5" "Treat undo history as a tree" 'nil :keywords '("convenience" "files" "undo" "redo" "history" "tree") :authors '(("Toby Cubitt" . "toby-undo-tree@dr-qubit.org")) :maintainer '("Toby Cubitt" . "toby-undo-tree@dr-qubit.org") :url "http://www.dr-qubit.org/emacs.php")

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,18 @@
This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir, Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "q" exits, "H" lists all Info commands, "d" returns here,
"h" gives a primer for first-timers,
"mEmacs<Return>" visits the Emacs manual, etc.
In Emacs, you can click mouse button 2 on a menu item or cross reference
to select it.
* Menu:
Emacs
* use-package: (use-package). Declarative package configuration for Emacs.

View File

@ -0,0 +1,228 @@
;;; use-package-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "use-package-bind-key" "use-package-bind-key.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from use-package-bind-key.el
(autoload 'use-package-autoload-keymap "use-package-bind-key" "\
Loads PACKAGE and then binds the key sequence used to invoke
this function to KEYMAP-SYMBOL. It then simulates pressing the
same key sequence a again, so that the next key pressed is routed
to the newly loaded keymap.
This function supports use-package's :bind-keymap keyword. It
works by binding the given key sequence to an invocation of this
function for a particular keymap. The keymap is expected to be
defined by the package. In this way, loading the package is
deferred until the prefix key sequence is pressed.
\(fn KEYMAP-SYMBOL PACKAGE OVERRIDE)" nil nil)
(autoload 'use-package-normalize-binder "use-package-bind-key" "\
\(fn NAME KEYWORD ARGS)" nil nil)
(defalias 'use-package-normalize/:bind 'use-package-normalize-binder)
(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder)
(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode)
(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode)
(autoload 'use-package-handler/:bind "use-package-bind-key" "\
\(fn NAME KEYWORD ARGS REST STATE &optional BIND-MACRO)" nil nil)
(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder)
(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder)
(autoload 'use-package-handler/:bind-keymap "use-package-bind-key" "\
\(fn NAME KEYWORD ARGS REST STATE &optional OVERRIDE)" nil nil)
(autoload 'use-package-handler/:bind-keymap* "use-package-bind-key" "\
\(fn NAME KEYWORD ARG REST STATE)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-bind-key" '("use-package-handler/:bind*")))
;;;***
;;;### (autoloads nil "use-package-core" "use-package-core.el" (0
;;;;;; 0 0 0))
;;; Generated autoloads from use-package-core.el
(autoload 'use-package "use-package-core" "\
Declare an Emacs package by specifying a group of configuration options.
For full documentation, please see the README file that came with
this file. Usage:
(use-package package-name
[:keyword [option]]...)
:init Code to run before PACKAGE-NAME has been loaded.
:config Code to run after PACKAGE-NAME has been loaded. Note that
if loading is deferred for any reason, this code does not
execute until the lazy load has occurred.
:preface Code to be run before everything except `:disabled'; this
can be used to define functions for use in `:if', or that
should be seen by the byte-compiler.
:mode Form to be added to `auto-mode-alist'.
:magic Form to be added to `magic-mode-alist'.
:magic-fallback Form to be added to `magic-fallback-mode-alist'.
:interpreter Form to be added to `interpreter-mode-alist'.
:commands Define autoloads for commands that will be defined by the
package. This is useful if the package is being lazily
loaded, and you wish to conditionally call functions in your
`:init' block that are defined in the package.
:hook Specify hook(s) to attach this package to.
:bind Bind keys, and define autoloads for the bound commands.
:bind* Bind keys, and define autoloads for the bound commands,
*overriding all minor mode bindings*.
:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the
package. This is like `:bind', but for keymaps.
:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings
:defer Defer loading of a package -- this is implied when using
`:commands', `:bind', `:bind*', `:mode', `:magic', `:hook',
`:magic-fallback', or `:interpreter'. This can be an integer,
to force loading after N seconds of idle time, if the package
has not already been loaded.
:after Defer loading of a package until after any of the named
features are loaded.
:demand Prevent deferred loading in all cases.
:if EXPR Initialize and load only if EXPR evaluates to a non-nil value.
:disabled The package is ignored completely if this keyword is present.
:defines Declare certain variables to silence the byte-compiler.
:functions Declare certain functions to silence the byte-compiler.
:load-path Add to the `load-path' before attempting to load the package.
:diminish Support for diminish.el (if installed).
:delight Support for delight.el (if installed).
:custom Call `customize-set-variable' with each variable definition.
:custom-face Call `customize-set-faces' with each face definition.
:ensure Loads the package using package.el if necessary.
:pin Pin the package to an archive.
\(fn NAME &rest ARGS)" nil t)
(function-put 'use-package 'lisp-indent-function '1)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-core" '("use-package-")))
;;;***
;;;### (autoloads nil "use-package-delight" "use-package-delight.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from use-package-delight.el
(autoload 'use-package-normalize/:delight "use-package-delight" "\
Normalize arguments to delight.
\(fn NAME KEYWORD ARGS)" nil nil)
(autoload 'use-package-handler/:delight "use-package-delight" "\
\(fn NAME KEYWORD ARGS REST STATE)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-delight" '("use-package-normalize-delight")))
;;;***
;;;### (autoloads nil "use-package-diminish" "use-package-diminish.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from use-package-diminish.el
(autoload 'use-package-normalize/:diminish "use-package-diminish" "\
\(fn NAME KEYWORD ARGS)" nil nil)
(autoload 'use-package-handler/:diminish "use-package-diminish" "\
\(fn NAME KEYWORD ARG REST STATE)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-diminish" '("use-package-normalize-diminish")))
;;;***
;;;### (autoloads nil "use-package-ensure" "use-package-ensure.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from use-package-ensure.el
(autoload 'use-package-normalize/:ensure "use-package-ensure" "\
\(fn NAME KEYWORD ARGS)" nil nil)
(autoload 'use-package-handler/:ensure "use-package-ensure" "\
\(fn NAME KEYWORD ENSURE REST STATE)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-ensure" '("use-package-")))
;;;***
;;;### (autoloads nil "use-package-jump" "use-package-jump.el" (0
;;;;;; 0 0 0))
;;; Generated autoloads from use-package-jump.el
(autoload 'use-package-jump-to-package-form "use-package-jump" "\
Attempt to find and jump to the `use-package' form that loaded
PACKAGE. This will only find the form if that form actually
required PACKAGE. If PACKAGE was previously required then this
function will jump to the file that originally required PACKAGE
instead.
\(fn PACKAGE)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-jump" '("use-package-find-require")))
;;;***
;;;### (autoloads nil "use-package-lint" "use-package-lint.el" (0
;;;;;; 0 0 0))
;;; Generated autoloads from use-package-lint.el
(autoload 'use-package-lint "use-package-lint" "\
Check for errors in use-package declarations.
For example, if the module's `:if' condition is met, but even
with the specified `:load-path' the module cannot be found.
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "use-package-lint" '("use-package-lint-declaration")))
;;;***
;;;### (autoloads nil nil ("use-package-pkg.el" "use-package.el")
;;;;;; (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; use-package-autoloads.el ends here

View File

@ -0,0 +1,172 @@
;;; use-package-bind-key.el --- Support for the :bind/:bind-keymap keywords -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 4 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4") (bind-key "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides support for the :bind, :bind*, :bind-keymap and :bind-keymap*
;; keywords. Note that these are currently still baked into
;; `use-package-keywords' and `use-package-deferring-keywords', although this
;; is harmless if they are never used.
;;; Code:
(require 'use-package-core)
(require 'bind-key)
;;;###autoload
(defun use-package-autoload-keymap (keymap-symbol package override)
"Loads PACKAGE and then binds the key sequence used to invoke
this function to KEYMAP-SYMBOL. It then simulates pressing the
same key sequence a again, so that the next key pressed is routed
to the newly loaded keymap.
This function supports use-package's :bind-keymap keyword. It
works by binding the given key sequence to an invocation of this
function for a particular keymap. The keymap is expected to be
defined by the package. In this way, loading the package is
deferred until the prefix key sequence is pressed."
(if (not (require package nil t))
(use-package-error (format "Cannot load package.el: %s" package))
(if (and (boundp keymap-symbol)
(keymapp (symbol-value keymap-symbol)))
(let* ((kv (this-command-keys-vector))
(key (key-description kv))
(keymap (symbol-value keymap-symbol)))
(if override
(bind-key* key keymap)
(bind-key key keymap))
(setq unread-command-events
(mapcar (lambda (ev) (cons t ev))
(listify-key-sequence kv))))
(use-package-error
(format "package.el %s failed to define keymap %s"
package keymap-symbol)))))
;;;###autoload
(defun use-package-normalize-binder (name keyword args)
(let ((arg args)
args*)
(while arg
(let ((x (car arg)))
(cond
;; (KEY . COMMAND)
((and (consp x)
(or (stringp (car x))
(vectorp (car x)))
(or (use-package-recognize-function (cdr x) t #'stringp)))
(setq args* (nconc args* (list x)))
(setq arg (cdr arg)))
;; KEYWORD
;; :map KEYMAP
;; :prefix-docstring STRING
;; :prefix-map SYMBOL
;; :prefix STRING
;; :filter SEXP
;; :menu-name STRING
;; :package SYMBOL
((or (and (eq x :map) (symbolp (cadr arg)))
(and (eq x :prefix) (stringp (cadr arg)))
(and (eq x :prefix-map) (symbolp (cadr arg)))
(and (eq x :prefix-docstring) (stringp (cadr arg)))
(eq x :filter)
(and (eq x :menu-name) (stringp (cadr arg)))
(and (eq x :package) (symbolp (cadr arg))))
(setq args* (nconc args* (list x (cadr arg))))
(setq arg (cddr arg)))
((listp x)
(setq args*
(nconc args* (use-package-normalize-binder name keyword x)))
(setq arg (cdr arg)))
(t
;; Error!
(use-package-error
(concat (symbol-name name)
" wants arguments acceptable to the `bind-keys' macro,"
" or a list of such values"))))))
args*))
;;;; :bind, :bind*
;;;###autoload
(defalias 'use-package-normalize/:bind 'use-package-normalize-binder)
;;;###autoload
(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder)
;; jww (2017-12-07): This is too simplistic. It will fail to determine
;; autoloads in this situation:
;; (use-package foo
;; :bind (:map foo-map (("C-a" . func))))
;;;###autoload
(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode)
;;;###autoload
(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode)
;;;###autoload
(defun use-package-handler/:bind
(name _keyword args rest state &optional bind-macro)
(use-package-concat
(use-package-process-keywords name rest state)
`(,@(mapcar
#'(lambda (xs)
`(,(if bind-macro bind-macro 'bind-keys)
:package ,name ,@(use-package-normalize-commands xs)))
(use-package-split-list-at-keys :break args)))))
(defun use-package-handler/:bind* (name keyword arg rest state)
(use-package-handler/:bind name keyword arg rest state 'bind-keys*))
;;;; :bind-keymap, :bind-keymap*
;;;###autoload
(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder)
;;;###autoload
(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder)
;;;###autoload
(defun use-package-handler/:bind-keymap
(name _keyword args rest state &optional override)
(use-package-concat
(use-package-process-keywords name rest state)
(mapcar
#'(lambda (binding)
`(,(if override 'bind-key* 'bind-key)
,(car binding)
#'(lambda ()
(interactive)
(use-package-autoload-keymap
',(cdr binding) ',(use-package-as-symbol name)
,override))))
args)))
;;;###autoload
(defun use-package-handler/:bind-keymap* (name keyword arg rest state)
(use-package-handler/:bind-keymap name keyword arg rest state t))
(provide 'use-package-bind-key)
;;; use-package-bind-key.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
;;; use-package-delight.el --- Support for the :delight keyword -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 3 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides support for the :delight keyword, which is made available by
;; default by requiring `use-package'.
;;; Code:
(require 'use-package-core)
(defun use-package-normalize-delight (name args)
"Normalize ARGS for a single call to `delight'."
(when (eq :eval (car args))
;; Handle likely common mistake.
(use-package-error ":delight mode line constructs must be quoted"))
(cond ((and (= (length args) 1)
(use-package-non-nil-symbolp (car args)))
`(,(nth 0 args) nil ,name))
((= (length args) 2)
`(,(nth 0 args) ,(nth 1 args) ,name))
((= (length args) 3)
args)
(t
(use-package-error
":delight expects `delight' arguments or a list of them"))))
;;;###autoload
(defun use-package-normalize/:delight (name _keyword args)
"Normalize arguments to delight."
(cond ((null args)
`((,(use-package-as-mode name) nil ,name)))
((and (= (length args) 1)
(use-package-non-nil-symbolp (car args)))
`((,(car args) nil ,name)))
((and (= (length args) 1)
(stringp (car args)))
`((,(use-package-as-mode name) ,(car args) ,name)))
((and (= (length args) 1)
(listp (car args))
(eq 'quote (caar args)))
`((,(use-package-as-mode name) ,@(cdar args) ,name)))
((and (= (length args) 2)
(listp (nth 1 args))
(eq 'quote (car (nth 1 args))))
`((,(car args) ,@(cdr (nth 1 args)) ,name)))
(t (mapcar
(apply-partially #'use-package-normalize-delight name)
(if (use-package-non-nil-symbolp (car args))
(list args)
args)))))
;;;###autoload
(defun use-package-handler/:delight (name _keyword args rest state)
(let ((body (use-package-process-keywords name rest state)))
(use-package-concat
body
`((if (fboundp 'delight)
(delight '(,@args)))))))
(add-to-list 'use-package-keywords :delight t)
(provide 'use-package-delight)
;;; use-package-delight.el ends here

View File

@ -0,0 +1,80 @@
;;; use-package-diminish.el --- Support for the :diminish keyword -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 3 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides support for the :diminish keyword, which is made available by
;; default by requiring `use-package'.
;;; Code:
(require 'use-package-core)
(defun use-package-normalize-diminish (name label arg &optional recursed)
"Normalize the arguments to diminish down to a list of one of two forms:
SYMBOL
(SYMBOL . STRING)"
(cond
((not arg)
(list (use-package-as-mode name)))
((use-package-non-nil-symbolp arg)
(list arg))
((stringp arg)
(list (cons (use-package-as-mode name) arg)))
((and (consp arg) (stringp (cdr arg)))
(list arg))
((and (not recursed) (listp arg) (listp (cdr arg)))
(mapcar #'(lambda (x) (car (use-package-normalize-diminish
name label x t))) arg))
(t
(use-package-error
(concat label " wants a string, symbol, "
"(symbol . string) or list of these")))))
;;;###autoload
(defun use-package-normalize/:diminish (name keyword args)
(use-package-as-one (symbol-name keyword) args
(apply-partially #'use-package-normalize-diminish name) t))
;;;###autoload
(defun use-package-handler/:diminish (name _keyword arg rest state)
(let ((body (use-package-process-keywords name rest state)))
(use-package-concat
(mapcar #'(lambda (var)
`(if (fboundp 'diminish)
,(if (consp var)
`(diminish ',(car var) ,(cdr var))
`(diminish ',var))))
arg)
body)))
(add-to-list 'use-package-keywords :diminish t)
(provide 'use-package-diminish)
;;; use-package-diminish.el ends here

View File

@ -0,0 +1,214 @@
;;; use-package-ensure.el --- Support for the :ensure and :pin keywords -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 3 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides support for the :ensure and :pin keywords, which is made available
;; by default by requiring `use-package'.
;;; Code:
(require 'cl-lib)
(require 'use-package-core)
(defgroup use-package-ensure nil
"Support for :ensure and :pin keywords in use-package declarations."
:group 'use-package)
(eval-when-compile
(declare-function package-installed-p "package")
(declare-function package-read-all-archive-contents "package" ()))
(defcustom use-package-always-ensure nil
"Treat every package as though it had specified using `:ensure SEXP'.
See also `use-package-defaults', which uses this value."
:type 'sexp
:group 'use-package-ensure)
(defcustom use-package-always-pin nil
"Treat every package as though it had specified using `:pin SYM'.
See also `use-package-defaults', which uses this value."
:type 'symbol
:group 'use-package-ensure)
(defcustom use-package-ensure-function 'use-package-ensure-elpa
"Function that ensures a package is installed.
This function is called with three arguments: the name of the
package declared in the `use-package' form; the arguments passed
to all `:ensure' keywords (always a list, even if only one); and
the current `state' plist created by previous handlers.
Note that this function is called whenever `:ensure' is provided,
even if it is nil. It is up to the function to decide on the
semantics of the various values for `:ensure'.
This function should return non-nil if the package is installed.
The default value uses package.el to install the package."
:type '(choice (const :tag "package.el" use-package-ensure-elpa)
(function :tag "Custom"))
:group 'use-package-ensure)
;;;; :pin
(defun use-package-normalize/:pin (_name keyword args)
(use-package-only-one (symbol-name keyword) args
#'(lambda (_label arg)
(cond
((stringp arg) arg)
((use-package-non-nil-symbolp arg) (symbol-name arg))
(t
(use-package-error
":pin wants an archive name (a string)"))))))
(eval-when-compile
(defvar package-pinned-packages)
(defvar package-archives))
(defun use-package-archive-exists-p (archive)
"Check if a given ARCHIVE is enabled.
ARCHIVE can be a string or a symbol or 'manual to indicate a
manually updated package."
(if (member archive '(manual "manual"))
't
(let ((valid nil))
(dolist (pa package-archives)
(when (member archive (list (car pa) (intern (car pa))))
(setq valid 't)))
valid)))
(defun use-package-pin-package (package archive)
"Pin PACKAGE to ARCHIVE."
(unless (boundp 'package-pinned-packages)
(setq package-pinned-packages ()))
(let ((archive-symbol (if (symbolp archive) archive (intern archive)))
(archive-name (if (stringp archive) archive (symbol-name archive))))
(if (use-package-archive-exists-p archive-symbol)
(add-to-list 'package-pinned-packages (cons package archive-name))
(error "Archive '%s' requested for package '%s' is not available."
archive-name package))
(unless (bound-and-true-p package--initialized)
(package-initialize t))))
(defun use-package-handler/:pin (name _keyword archive-name rest state)
(let ((body (use-package-process-keywords name rest state))
(pin-form (if archive-name
`(use-package-pin-package ',(use-package-as-symbol name)
,archive-name))))
;; Pinning should occur just before ensuring
;; See `use-package-handler/:ensure'.
(if (bound-and-true-p byte-compile-current-file)
(eval pin-form) ; Eval when byte-compiling,
(push pin-form body)) ; or else wait until runtime.
body))
;;;; :ensure
(defvar package-archive-contents)
;;;###autoload
(defun use-package-normalize/:ensure (_name keyword args)
(if (null args)
(list t)
(use-package-only-one (symbol-name keyword) args
#'(lambda (_label arg)
(cond
((symbolp arg)
(list arg))
((and (listp arg) (= 3 (length arg))
(symbolp (nth 0 arg))
(eq :pin (nth 1 arg))
(or (stringp (nth 2 arg))
(symbolp (nth 2 arg))))
(list (cons (nth 0 arg) (nth 2 arg))))
(t
(use-package-error
(concat ":ensure wants an optional package name "
"(an unquoted symbol name), or (<symbol> :pin <string>)"))))))))
(defun use-package-ensure-elpa (name args _state &optional _no-refresh)
(dolist (ensure args)
(let ((package
(or (and (eq ensure t) (use-package-as-symbol name))
ensure)))
(when package
(require 'package)
(when (consp package)
(use-package-pin-package (car package) (cdr package))
(setq package (car package)))
(unless (package-installed-p package)
(condition-case-unless-debug err
(progn
(when (assoc package (bound-and-true-p
package-pinned-packages))
(package-read-all-archive-contents))
(if (assoc package package-archive-contents)
(package-install package)
(package-refresh-contents)
(when (assoc package (bound-and-true-p
package-pinned-packages))
(package-read-all-archive-contents))
(package-install package))
t)
(error
(display-warning 'use-package
(format "Failed to install %s: %s"
name (error-message-string err))
:error))))))))
;;;###autoload
(defun use-package-handler/:ensure (name _keyword ensure rest state)
(let* ((body (use-package-process-keywords name rest state)))
;; We want to avoid installing packages when the `use-package' macro is
;; being macro-expanded by elisp completion (see `lisp--local-variables'),
;; but still install packages when byte-compiling, to avoid requiring
;; `package' at runtime.
(if (bound-and-true-p byte-compile-current-file)
;; Eval when byte-compiling,
(funcall use-package-ensure-function name ensure state)
;; or else wait until runtime.
(push `(,use-package-ensure-function ',name ',ensure ',state)
body))
body))
(add-to-list 'use-package-defaults
'(:ensure (list use-package-always-ensure)
(lambda (name args)
(and use-package-always-ensure
(not (plist-member args :load-path))))) t)
(add-to-list 'use-package-defaults
'(:pin use-package-always-pin use-package-always-pin) t)
(add-to-list 'use-package-keywords :ensure)
(add-to-list 'use-package-keywords :pin)
(provide 'use-package-ensure)
;;; use-package-ensure.el ends here

View File

@ -0,0 +1,79 @@
;;; use-package-jump.el --- Attempt to jump to a use-package declaration -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 3 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides the command `M-x use-package-jump-to-package-form', however it
;; only works if the package being jumped to was required during
;; initialization. If it was delay-loaded, it will not work. Improvements are
;; needed.
;;; Code:
(require 'use-package-core)
(defun use-package-find-require (package)
"Find file that required PACKAGE by searching `load-history'.
Returns an absolute file path or nil if none is found."
(catch 'suspect
(dolist (filespec load-history)
(dolist (entry (cdr filespec))
(when (equal entry (cons 'require package))
(throw 'suspect (car filespec)))))))
;;;###autoload
(defun use-package-jump-to-package-form (package)
"Attempt to find and jump to the `use-package' form that loaded
PACKAGE. This will only find the form if that form actually
required PACKAGE. If PACKAGE was previously required then this
function will jump to the file that originally required PACKAGE
instead."
(interactive (list (completing-read "Package: " features)))
(let* ((package (if (stringp package) (intern package) package))
(requiring-file (use-package-find-require package))
file location)
(if (null requiring-file)
(user-error "Can't find file requiring file; may have been autoloaded")
(setq file (if (string= (file-name-extension requiring-file) "elc")
(concat (file-name-sans-extension requiring-file) ".el")
requiring-file))
(when (file-exists-p file)
(find-file-other-window file)
(save-excursion
(goto-char (point-min))
(setq location
(re-search-forward
(format (eval use-package-form-regexp-eval) package) nil t)))
(if (null location)
(message "No use-package form found.")
(goto-char location)
(beginning-of-line))))))
(provide 'use-package-jump)
;;; use-package-jump.el ends here

View File

@ -0,0 +1,84 @@
;;; use-package-lint.el --- Attempt to find errors in use-package declarations -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 3 Dec 2017
;; Version: 1.0
;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Provides the command `M-x use-package-lint'.
;;; Code:
(require 'cl-lib)
(require 'use-package-core)
(defun use-package-lint-declaration (name plist)
(dolist (path (plist-get plist :load-path))
(unless (file-exists-p path)
(display-warning
'use-package
(format "%s :load-path does not exist: %s"
name path) :error)))
(unless (or (plist-member plist :disabled)
(plist-get plist :no-require)
(locate-library (use-package-as-string name) nil
(plist-get plist :load-path)))
(display-warning
'use-package
(format "%s module cannot be located" name) :error))
;; (dolist (command (plist-get plist :commands))
;; (unless (string= (find-lisp-object-file-name command nil)
;; (locate-library (use-package-as-string name) nil
;; (plist-get plist :load-path)))
;; (display-warning
;; 'use-package
;; (format "%s :command is from different path: %s"
;; name (symbol-name command)) :error)))
)
;;;###autoload
(defun use-package-lint ()
"Check for errors in use-package declarations.
For example, if the module's `:if' condition is met, but even
with the specified `:load-path' the module cannot be found."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((re (eval use-package-form-regexp-eval)))
(while (re-search-forward re nil t)
(goto-char (match-beginning 0))
(let ((decl (read (current-buffer))))
(when (eq (car decl) 'use-package)
(use-package-lint-declaration
(use-package-as-string (cadr decl))
(use-package-normalize-keywords
(cadr decl) (cddr decl)))))))))
(provide 'use-package-lint)
;;; use-package-lint.el ends here

View File

@ -0,0 +1,13 @@
(define-package "use-package" "20191110.416" "A configuration macro for simplifying your .emacs"
'((emacs "24.3")
(bind-key "2.4"))
:keywords
'("dotemacs" "startup" "speed" "config" "package")
:authors
'(("John Wiegley" . "johnw@newartisans.com"))
:maintainer
'("John Wiegley" . "johnw@newartisans.com")
:url "https://github.com/jwiegley/use-package")
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@ -0,0 +1,54 @@
;;; use-package.el --- A configuration macro for simplifying your .emacs -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2017 John Wiegley
;; Author: John Wiegley <johnw@newartisans.com>
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 29 Nov 2017
;; Version: 2.4
;; Package-Requires: ((emacs "24.3") (bind-key "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; The `use-package' declaration macro allows you to isolate package
;; configuration in your ".emacs" in a way that is performance-oriented and,
;; well, just tidy. I created it because I have over 80 packages that I use
;; in Emacs, and things were getting difficult to manage. Yet with this
;; utility my total load time is just under 1 second, with no loss of
;; functionality!
;;
;; Please see README.md from the same repository for documentation.
;;; Code:
(require 'use-package-core)
(require 'use-package-bind-key)
(require 'use-package-diminish)
(require 'use-package-delight)
(require 'use-package-ensure)
(declare-function use-package-jump-to-package-form "use-package-jump")
(autoload #'use-package-jump-to-package-form "use-package-jump" nil t)
(provide 'use-package)
;;; use-package.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
;;; typing-speed.el --- Minor mode which displays your typing speed
;; Copyright (C) 2008 Wangdera Corporation
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use,
;; copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following
;; conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
;; OTHER DEALINGS IN THE SOFTWARE.
;; Author: Craig Andera <candera@wangdera.com>
;; Commentary: Invoke this minor mode to have your typing speed
;; continuously displayed in the mode line, in the format [75 WPM]
;; To use, just load this file and invoke (typing-speed-mode) or
;; (turn-on-typing-speed-mode)
(define-minor-mode typing-speed-mode
"Displays your typing speed in the status bar."
:lighter typing-speed-mode-text
:group 'typing-speed
(if typing-speed-mode
(progn
(add-hook 'post-command-hook 'typing-speed-post-command-hook)
(setq typing-speed-event-queue '())
(setq typing-speed-update-timer (run-with-timer 0 typing-speed-update-interval 'typing-speed-update)))
(progn
(remove-hook 'post-command-hook 'typing-speed-post-command-hook)
(cancel-timer typing-speed-update-timer))))
(defcustom typing-speed-window 5
"The window (in seconds) over which typing speed should be evaluated."
:group 'typing-speed)
(defcustom typing-speed-mode-text-format " [%s/%s WPM]"
"A format string that controls how the typing speed is displayed in the mode line.
Must contain at least one %s delimeter. Typing speed will be inserted at the first
delimiter, and peak typing speed at the second."
:group 'typing-speed)
(defcustom typing-speed-update-interval 1
"How often the typing speed will update in the mode line, in seconds.
It will always also update after every command."
:group 'typing-speed)
(defvar typing-speed-mode-text (format typing-speed-mode-text-format 0 0))
(defvar typing-speed-event-queue '())
(defvar typing-speed-update-timer nil)
(defvar typing-speed-peak-speed 0)
(defvar typing-speed-previous-mode-text "")
(make-variable-buffer-local 'typing-speed-peak-speed)
(make-variable-buffer-local 'typing-speed-previous-mode-text)
(make-variable-buffer-local 'typing-speed-mode-text)
(make-variable-buffer-local 'typing-speed-event-queue)
(defun typing-speed-post-command-hook ()
"When typing-speed-mode is enabled, fires after every command. If the
command is self-insert-command, log it as a keystroke and update the
typing speed."
(cond ((eq this-command 'self-insert-command)
(let ((current-time (float-time)))
(push current-time typing-speed-event-queue)
(typing-speed-update)))
((member this-command '(delete-backward-char backward-delete-char-untabify))
(progn
(pop typing-speed-event-queue)
(typing-speed-update)))))
(defun typing-speed-update ()
"Calculate and display the typing speed."
(let ((current-time (float-time)))
(setq typing-speed-event-queue
(typing-speed-remove-old-events
(- current-time typing-speed-window)
typing-speed-event-queue))
(typing-speed-message-update)))
(defun typing-speed-message-update ()
"Updates the status bar with the current typing speed"
(let* ((chars-per-second (/ (length typing-speed-event-queue) (float typing-speed-window)))
(chars-per-min (* chars-per-second 60))
(words-per-min (/ chars-per-min 5)))
(setq typing-speed-peak-speed (max words-per-min typing-speed-peak-speed))
(setq typing-speed-mode-text
(if (minibufferp (current-buffer))
""
(format typing-speed-mode-text-format (floor words-per-min) (floor typing-speed-peak-speed))))
;; Attempt to prevent unnecessary flicker in the menu bar. Doesn't seem to help, though.
(if (not (string-equal typing-speed-mode-text typing-speed-previous-mode-text))
(progn
(setq typing-speed-previous-mode-text typing-speed-mode-text)
(force-mode-line-update)))))
(defun typing-speed-remove-old-events (threshold queue)
"Removes events older than than the threshold (in seconds) from the specified queue"
(if (or (null queue)
(> threshold (car queue)))
nil
(cons (car queue)
(typing-speed-remove-old-events threshold (cdr queue)))))
(defun turn-on-typing-speed ()
"Turns on typing-speed-mode"
(if (not typing-speed-mode)
(typing-speed-mode)))
(defun turn-off-typing-speed ()
"Turns off typing-speed-mode"
(if typing-speed-mode
(typing-speed-mode)))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -1,34 +0,0 @@
#!/bin/bash
# Clear the store first
./clean_store.sh
# Build the directory structure
mkdir -p .config/
mkdir -p .emacs.d/
# Make sure that the directories are there.
mkdir -p ~/.config
mkdir -p ~/.emacs.d/
# Copy configuration files.
# Copy i3 configuration files.
cp -rf ~/.config/i3/ .config/
cp -rf ~/.config/i3status/ .config/
# Copy EMACS configuration files.
cp ~/.emacs.d/init.el .emacs.d/
cp ~/.emacs.d/config.org .emacs.d/
cp -rf ~/.emacs.d/scripts/ .emacs.d/
# Copy .Xresources configuration.
cp ~/.Xresources .Xresources
# Copy vim configuration.
cp ~/.vimrc .vimrc
# Copy zsh configuration.
cp ~/.zshrc .zshrc

16
git/.gitconfig Normal file
View File

@ -0,0 +1,16 @@
[user]
email = 56314286+realaltffour@users.noreply.github.com
name = altffour
signingkey = 2E7B9E061AF66FC3
[core]
editor = vim
[diff]
tool = meld
[difftool]
prompt = false
[difftool "meld"]
cmd = meld \"$LOCAL\" \"$REMOTE\"
[credential]
helper = cache --timeout 21600
[commit]
gpgsign = true

View File

@ -164,7 +164,9 @@ bindsym $mod+r mode "resize"
# finds out, if available)
bar {
font pango:monospace, Awesome 8
status_command i3status
# status_command i3status
position top
status_command bumblebee-status -m nic spotify cpu memory battery brightness sensors date time pasink pasource dnf -p root.path=/ time.format="%H:%M CW %V" date.format="%a, %b %d %Y" -t solarized-powerline
}
# Pulse Audio controls
@ -180,8 +182,7 @@ bindsym XF86MonBrightnessDown exec light -U 10 # decrease screen brightness
bindsym $mod+Print exec ~/.config/i3/script/toggletouchpad.sh # toggle touchpad
# Media player controls
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
@ -189,7 +190,11 @@ bindsym XF86AudioPrev exec playerctl previous
exec_always feh --bg-fill ~/.config/i3/res/bg.jpg
# Set Window Borders
for_window [class="^.*"] border pixel 0
for_window [class="^.*"] border pixel 2
# Set gaps
gaps inner 15
gaps outer 12
# Set Caps lock as Escape
exec_always xmodmap -e "Clear lock"

BIN
i3/.config/i3/res/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 680 KiB

After

Width:  |  Height:  |  Size: 680 KiB

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ xinput list-props 12 | sed -n 's/.*Device Enabled (165):\(.*\).*/\1/p' | sed 's/^[[:space:]]*//' -eq "1" ]; then
xinput set-prop 12 165 0
exit
fi
if [ xinput list-props 12 | sed -n 's/.*Device Enabled (165):\(.*\).*/\1/p' | sed 's/^[[:space:]]*//' -eq "0" ]; then
xinput set-prop 12 165 0
exit
fi

View File

@ -1,53 +0,0 @@
#!/bin/bash
# Check for host distro and version.
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$ID
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
VER=$(cat /etc/redhat-release)
else
# Distro not supported or not recognized.
# TODO: Refrence script help.
echo 'Distro is not recognized.'
# TODO: Maybe ask the user for the distro and version?
exit
fi
# Standarize naming.
_OS="$(echo $OS | tr '[:upper:]' '[:lower:]')" # Upper -> Lower
_VER="$(echo $VER | tr '[:upper:]' '[:lower:]')" # Upper -> Lower
_VER=${_VER/.*} # decimal -> int
unset OS
unset VER
# Execute installation packages.
# Arch, Gentoo linux is a rolling distro.
if [ _OS = arch ] || [ _OS = gentoo ]; then
./install_scripts/$_OS/install_packages.sh
else
# For other distors this should work.
./install_scripts/$_OS/$_VER/install_packages.sh
fi

View File

@ -1,3 +0,0 @@
#!/bin/bash
# Install git.

Some files were not shown because too many files have changed in this diff Show More