add lisp packages

This commit is contained in:
2020-12-05 21:29:49 +01:00
parent 85e20365ae
commit a6e2395755
7272 changed files with 1363243 additions and 0 deletions

124
lisp/ivy/colir.el Normal file
View File

@@ -0,0 +1,124 @@
;;; colir.el --- Color blending library -*- lexical-binding: t -*-
;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
;; This file is part of GNU Emacs.
;; 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 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.
;; For a full copy of the GNU General Public License
;; see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This package solves the problem of adding a face with a background
;; to text which may already have a background. In all conflicting
;; areas, instead of choosing either the original or the new
;; background face, their blended sum is used.
;;
;; The blend mode functions are taken from URL
;; `https://en.wikipedia.org/wiki/Blend_modes'.
;;; Code:
(require 'cl-lib)
(require 'color)
(defcustom colir-compose-method #'colir-compose-alpha
"Select a method to compose two color channels."
:group 'ivy
:type '(radio
(function-item colir-compose-alpha)
(function-item colir-compose-overlay)
(function-item colir-compose-soft-light)))
(defun colir-compose-soft-light (a b)
"Compose A and B channels."
(if (< b 0.5)
(+ (* 2 a b) (* a a (- 1 b b)))
(+ (* 2 a (- 1 b)) (* (sqrt a) (- (* 2 b) 1)))))
(defun colir-compose-overlay (a b)
"Compose A and B channels."
(if (< a 0.5)
(* 2 a b)
(- 1 (* 2 (- 1 a) (- 1 b)))))
(defun colir-compose-alpha (a b &optional alpha gamma)
"Compose A and B channels.
Optional argument ALPHA is a number between 0.0 and 1.0 which corresponds
to the influence of A on the result. Default value is 0.5.
Optional argument GAMMA is used for gamma correction. Default value is 2.2."
(setq alpha (or alpha 0.5))
(setq gamma (or gamma 2.2))
(+ (* (expt a gamma) alpha) (* (expt b gamma) (- 1 alpha))))
(defun colir-blend (c1 c2)
"Blend the two colors C1 and C2 using `colir-compose-method'.
C1 and C2 are triples of floats in [0.0 1.0] range."
(apply #'color-rgb-to-hex
(cl-mapcar
(if (eq (frame-parameter nil 'background-mode) 'dark)
;; this method works nicely for dark themes
'colir-compose-soft-light
colir-compose-method)
c1 c2)))
(defun colir-color-parse (color)
"Convert string COLOR to triple of floats in [0.0 1.0]."
(if (string-match "#\\([[:xdigit:]]\\{2\\}\\)\\([[:xdigit:]]\\{2\\}\\)\\([[:xdigit:]]\\{2\\}\\)" color)
(mapcar (lambda (v) (/ (string-to-number v 16) 255.0))
(list (match-string 1 color) (match-string 2 color) (match-string 3 color)))
;; does not work properly in terminal (maps color to nearest color
;; from available color palette).
(color-name-to-rgb color)))
(defun colir--blend-background (start next prevn face object)
(let ((background-prev (face-background prevn)))
(progn
(put-text-property
start next 'face
(if background-prev
(cons `(background-color
. ,(colir-blend
(colir-color-parse background-prev)
(colir-color-parse (face-background face nil t))))
prevn)
(list face prevn))
object))))
(defun colir-blend-face-background (start end face &optional object)
"Append to the face property of the text from START to END the face FACE.
When the text already has a face with a non-plain background,
blend it with the background of FACE.
Optional argument OBJECT is the string or buffer containing the text.
See also `font-lock-append-text-property'."
(let (next prev prevn)
(while (/= start end)
(setq next (next-single-property-change start 'face object end))
(setq prev (get-text-property start 'face object))
(setq prevn (if (listp prev)
(cl-find-if #'atom prev)
prev))
(cond
((or (keywordp (car-safe prev)) (consp (car-safe prev)))
(put-text-property start next 'face (cons face prev) object))
((facep prevn)
(colir--blend-background start next prevn face object))
(t
(put-text-property start next 'face face object)))
(setq start next))))
(provide 'colir)
;;; colir.el ends here

18
lisp/ivy/dir Normal file
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
* Ivy: (ivy). Using Ivy for completion.

6
lisp/ivy/elpa.el Normal file
View File

@@ -0,0 +1,6 @@
(setq package-user-dir
(expand-file-name
(format "~/.elpa/%s/elpa"
(concat emacs-version (when (getenv "MELPA_STABLE") "-stable")))))
(package-initialize)
(add-to-list 'load-path default-directory)

138
lisp/ivy/ivy-faces.el Normal file
View File

@@ -0,0 +1,138 @@
;;; ivy-faces.el --- Faces for Ivy -*- lexical-binding: t -*-
;; Copyright (C) 2020 Free Software Foundation, Inc.
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(defgroup ivy-faces nil
"Font-lock faces for `ivy'."
:group 'ivy
:group 'faces)
(defface ivy-current-match
'((((class color) (background light))
:background "#1a4b77" :foreground "white" :extend t)
(((class color) (background dark))
:background "#65a7e2" :foreground "black" :extend t))
"Face used by Ivy for highlighting the current match.")
(defface ivy-minibuffer-match-highlight
'((t :inherit highlight))
"Face used by Ivy for highlighting the match under the cursor.")
(defface ivy-minibuffer-match-face-1
'((((class color) (background light))
:background "#d3d3d3")
(((class color) (background dark))
:background "#555555"))
"The background face for `ivy' minibuffer matches.")
(defface ivy-minibuffer-match-face-2
'((((class color) (background light))
:background "#e99ce8" :weight bold)
(((class color) (background dark))
:background "#777777" :weight bold))
"Face for `ivy' minibuffer matches numbered 1 modulo 3.")
(defface ivy-minibuffer-match-face-3
'((((class color) (background light))
:background "#bbbbff" :weight bold)
(((class color) (background dark))
:background "#7777ff" :weight bold))
"Face for `ivy' minibuffer matches numbered 2 modulo 3.")
(defface ivy-minibuffer-match-face-4
'((((class color) (background light))
:background "#ffbbff" :weight bold)
(((class color) (background dark))
:background "#8a498a" :weight bold))
"Face for `ivy' minibuffer matches numbered 3 modulo 3.")
(defface ivy-confirm-face
'((t :foreground "ForestGreen" :inherit minibuffer-prompt))
"Face used by Ivy for a confirmation prompt.")
(defface ivy-match-required-face
'((t :foreground "red" :inherit minibuffer-prompt))
"Face used by Ivy for a match required prompt.")
(defface ivy-subdir
'((t :inherit dired-directory))
"Face used by Ivy for highlighting subdirs in the alternatives.")
(defface ivy-org
'((t :inherit org-level-4))
"Face used by Ivy for highlighting Org buffers in the alternatives.")
(defface ivy-modified-buffer
'((t :inherit default))
"Face used by Ivy for highlighting modified file visiting buffers.")
(defface ivy-modified-outside-buffer
'((t :inherit default))
"Face used by Ivy for highlighting file visiting buffers modified outside Emacs.")
(defface ivy-remote
'((((class color) (background light))
:foreground "#110099")
(((class color) (background dark))
:foreground "#7B6BFF"))
"Face used by Ivy for highlighting remotes in the alternatives.")
(defface ivy-virtual
'((t :inherit font-lock-builtin-face))
"Face used by Ivy for matching virtual buffer names.")
(defface ivy-action
'((t :inherit font-lock-builtin-face))
"Face used by Ivy for displaying keys in `ivy-read-action'.")
(defface ivy-highlight-face
'((t :inherit highlight))
"Face used by Ivy to highlight certain candidates.")
(defface ivy-prompt-match
'((t :inherit ivy-current-match))
"Face used by Ivy for highlighting the selected prompt line.")
(defface ivy-separator
'((t :inherit font-lock-doc-face))
"Face for multiline source separator.")
(defface ivy-grep-info
'((t :inherit compilation-info))
"Face for highlighting grep information such as file names.")
(defface ivy-grep-line-number
'((t :inherit compilation-line-number))
"Face for displaying line numbers in grep messages.")
(defface ivy-completions-annotations
'((t :inherit completions-annotations))
"Face for displaying completion annotations.")
(defface ivy-yanked-word
'((t :inherit highlight))
"Face used to highlight yanked word.")
(provide 'ivy-faces)
;;; ivy-faces.el ends here

138
lisp/ivy/ivy-help.org Normal file
View File

@@ -0,0 +1,138 @@
* Ivy Generic Help
=ivy= is an Emacs incremental completion framework.
- Narrow the list by typing some pattern,
- Multiple patterns are allowed by separating with a space,
- Select with ~C-n~ and ~C-p~, choose with ~RET~.
** Help
- ~C-h m~ :: Pop to this generic help buffer.
** Basic Operations
*** Key bindings for navigation
- ~C-n~ (=ivy-next-line=) :: next candidate.
- ~C-p~ (=ivy-previous-line=) :: previous candidate.
- ~C-v~ (=ivy-scroll-up-command=) :: next page.
- ~M-v~ (=ivy-scroll-down-command=) :: previous page.
- ~M-<~ (=ivy-beginning-of-buffer=) :: first candidate.
- ~M->~ (=ivy-end-of-buffer=) :: last candidate.
*** Key bindings for single selection
When selecting a candidate, an action is called on it. You can think
of an action as a function that takes the selected candidate as an
argument and does something with it.
Ivy can offer several actions from which to choose. This can be
independently composed with whether you want to end completion when
the action is called. Depending on this, the short term is either
"calling an action" or "exiting with action".
~C-m~ or ~RET~ (=ivy-done=) - exit with the current action.
~M-o~ (=ivy-dispatching-done=) - select an action and exit with it.
~C-j~ (=ivy-alt-done=) - when the candidate is a directory, enter
it. Otherwise, exit with the current action.
~TAB~ (=ivy-partial-or-done=) - attempt partial completion, extending
the current input as much as possible. ~TAB TAB~ is the same as ~C-j~.
~C-M-j~ (=ivy-immediate-done=) - exit with the current action, calling
it on the /current input/ instead of the current candidate. This is
useful especially when creating new files or directories - often the
input will match an existing file, which you don't want to select.
~C-'~ (=ivy-avy=) - select a candidate from the current page with avy
and exit with the current action.
** Advanced Operations
*** Key bindings for multiple selection
For repeatedly applying multiple actions or acting on multiple
candidates, Ivy does not close the minibuffer between commands. It
keeps the minibuffer open for applying subsequent actions.
Adding an extra meta key to the normal key chord invokes the special
version of the regular commands that enables applying multiple
actions.
~C-M-m~ (=ivy-call=) is the non-exiting version of ~C-m~ (=ivy-done=).
~C-M-n~ (=ivy-next-line-and-call=) combines ~C-n~ and ~C-M-m~.
~C-M-p~ (=ivy-previous-line-and-call=) combines ~C-p~ and ~C-M-m~.
~C-M-o~ (=ivy-dispatching-call=) is a non-exiting version of ~M-o~
(=ivy-dispatching-done=).
*** Key bindings that alter the minibuffer input
~M-n~ (=ivy-next-history-element=) select the next history element or
symbol/URL at point.
~M-p~ (=ivy-previous-history-element=) select the previous history
element.
~C-r~ (=ivy-reverse-i-search=) start a recursive completion session to
select a history element.
~M-i~ (=ivy-insert-current=) insert the current candidate into the
minibuffer. Useful for copying and renaming files, for example: ~M-i~
to insert the original file name string, edit it, and then ~C-m~ to
complete the renaming.
~M-j~ (=ivy-yank-word=) insert the sub-word at point into the
minibuffer.
~S-SPC~ (=ivy-restrict-to-matches=) deletes the current input, and
resets the candidates list to the currently restricted matches. This
is how Ivy provides narrowing in successive tiers.
*** Other key bindings
~M-w~ (=ivy-kill-ring-save=) copies the selected candidates to the
kill ring; when the region is active, copies the active region.
*** Saving the current completion session to a buffer
~C-c C-o~ (=ivy-occur=) saves the current candidates to a new buffer;
the list is active in the new buffer.
~RET~ or ~mouse-1~ in the new buffer calls the appropriate action on
the selected candidate.
Ivy has no limit on the number of active buffers like these.
Ivy takes care of making these buffer names unique. It applies
descriptive names, for example: =*ivy-occur counsel-describe-variable
"function$*=.
*** Global key bindings
=ivy-resume= recalls the state of the completion session just before
its last exit. Useful after an accidental ~C-m~ (=ivy-done=).
Recommended global binding: ~C-c C-r~.
*** Hydra in the minibuffer
~C-o~ (=hydra-ivy/body=) invokes Hydra menus with key shortcuts.
When in Hydra, ~C-o~ or ~i~ resumes editing.
Hydra reduces key strokes, for example: ~C-n C-n C-n C-n~ is ~C-o
jjjj~ in Hydra. Besides certain shorter keys, Hydra shows useful info
such as case folding and the current action.
Additionally, here are the keys that are otherwise not bound:
- ~<~ and ~>~ adjust the height of the minibuffer.
- ~c~ (=ivy-toggle-calling=) - toggle calling the current action each
time a different candidate is selected.
- ~M~ (=ivy-rotate-preferred-builders=) - rotate regex matcher.
- ~w~ and ~s~ scroll the actions list.
Minibuffer editing is disabled when Hydra is active.

155
lisp/ivy/ivy-overlay.el Normal file
View File

@@ -0,0 +1,155 @@
;;; ivy-overlay.el --- Overlay display functions for Ivy -*- lexical-binding: t -*-
;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This package allows to setup Ivy's completion at point to actually
;; show the candidates and the input at point, instead of in the
;; minibuffer.
;;; Code:
(eval-when-compile
(require 'subr-x))
(defface ivy-cursor
'((((class color) (background light))
:background "black" :foreground "white")
(((class color) (background dark))
:background "white" :foreground "black"))
"Cursor face for inline completion."
:group 'ivy-faces)
(defvar ivy--old-cursor-type t)
(defvar ivy-overlay-at nil
"Overlay variable for `ivy-display-function-overlay'.")
(declare-function ivy--truncate-string "ivy")
(defun ivy-left-pad (str width)
"Return STR, but with each line indented by WIDTH spaces.
Lines are truncated to the window width."
(let ((padding (make-string width ?\s)))
(mapconcat (lambda (x)
(ivy--truncate-string (concat padding x)
(1- (+ (window-width)
(window-hscroll)))))
(split-string str "\n")
"\n")))
(defun ivy-overlay-cleanup ()
"Clean up after `ivy-display-function-overlay'."
(when (overlayp ivy-overlay-at)
(delete-overlay ivy-overlay-at)
(setq ivy-overlay-at nil))
(unless cursor-type
(setq cursor-type ivy--old-cursor-type))
(when (fboundp 'company-abort)
(company-abort)))
(defvar ivy-height)
(defun ivy-overlay-show-after (str)
"Display STR in an overlay at point.
First, fill each line of STR with spaces to the current column.
Then attach the overlay to the character before point."
(if ivy-overlay-at
(progn
(move-overlay ivy-overlay-at (1- (point)) (line-end-position))
(overlay-put ivy-overlay-at 'invisible nil))
(let ((available-height (- (window-height) (count-lines (window-start) (point)) 1)))
(unless (>= available-height ivy-height)
(recenter (- (window-height) ivy-height 2))))
(setq ivy-overlay-at (make-overlay (1- (point)) (line-end-position)))
;; Specify face to avoid clashing with other overlays.
(overlay-put ivy-overlay-at 'face 'default)
(overlay-put ivy-overlay-at 'priority 9999))
(overlay-put ivy-overlay-at 'display str)
(overlay-put ivy-overlay-at 'after-string ""))
(declare-function org-current-level "org")
(declare-function org-at-heading-p "org")
(defvar org-indent-indentation-per-level)
(defvar ivy-height)
(defvar ivy-last)
(defvar ivy-text)
(defvar ivy-completion-beg)
(declare-function ivy--get-window "ivy")
(declare-function ivy-state-current "ivy")
(declare-function ivy-state-window "ivy")
(defun ivy-overlay-impossible-p (_str)
(or
(and (eq major-mode 'org-mode)
(plist-get (text-properties-at (point)) 'src-block))
(<= (window-height) (+ ivy-height 2))
(= (point) (point-min))
(< (- (+ (window-width) (window-hscroll)) (current-column))
30)))
(defun ivy-display-function-overlay (str)
"Called from the minibuffer, display STR in an overlay in Ivy window.
Hide the minibuffer contents and cursor."
(if (save-selected-window
(select-window (ivy-state-window ivy-last))
(ivy-overlay-impossible-p str))
(let ((buffer-undo-list t))
(save-excursion
(forward-line 1)
(insert str)))
(add-face-text-property (minibuffer-prompt-end) (point-max)
'(:foreground "white"))
(setq cursor-type nil)
(with-selected-window (ivy--get-window ivy-last)
(when cursor-type
(setq ivy--old-cursor-type cursor-type))
(setq cursor-type nil)
(let ((overlay-str
(apply
#'concat
(buffer-substring (max (point-min) (1- (point))) (point))
ivy-text
(and (eolp) " ")
(buffer-substring (point) (line-end-position))
(and (> (length str) 0)
(list "\n"
(ivy-left-pad
(string-remove-prefix "\n" str)
(+
(if (and (eq major-mode 'org-mode)
(bound-and-true-p org-indent-mode))
(if (org-at-heading-p)
(1- (org-current-level))
(* org-indent-indentation-per-level (or (org-current-level) 1)))
0)
(save-excursion
(when ivy-completion-beg
(goto-char ivy-completion-beg))
(current-column)))))))))
(let ((cursor-offset (1+ (length ivy-text))))
(add-face-text-property cursor-offset (1+ cursor-offset)
'ivy-cursor t overlay-str))
(ivy-overlay-show-after overlay-str)))))
(provide 'ivy-overlay)
;;; ivy-overlay.el ends here

12
lisp/ivy/ivy-pkg.el Normal file
View File

@@ -0,0 +1,12 @@
(define-package "ivy" "20200624.1140" "Incremental Vertical completYon"
'((emacs "24.5"))
:commit "d951004c7f3ebf98d55fc5a80a3471ec95b6db05" :keywords
'("matching")
:authors
'(("Oleh Krehel" . "ohwoeowho@gmail.com"))
:maintainer
'("Oleh Krehel" . "ohwoeowho@gmail.com")
:url "https://github.com/abo-abo/swiper")
;; Local Variables:
;; no-byte-compile: t
;; End:

5255
lisp/ivy/ivy.el Normal file

File diff suppressed because it is too large Load Diff

1966
lisp/ivy/ivy.info Normal file

File diff suppressed because it is too large Load Diff