(defgroup ivy-faces nil
"Font-lock faces for `ivy'."
- :group 'ivy)
+ :group 'ivy
+ :group 'faces)
(defface ivy-current-match
'((((class color) (background light))
'((t :foreground "red" :inherit minibuffer-prompt))
"Face used by Ivy for a match required prompt.")
-(setcdr (assoc load-file-name custom-current-group-alist) 'ivy)
-
(defface ivy-subdir
'((t (:inherit 'dired-directory)))
"Face used by Ivy for highlighting subdirs in the alternatives.")
'((t :inherit font-lock-builtin-face))
"Face used by Ivy for matching virtual buffer names.")
+(setcdr (assoc load-file-name custom-current-group-alist) 'ivy)
+
(defcustom ivy-height 10
"Number of lines for the minibuffer window."
:type 'integer)
(defsubst ivy-set-action (action)
(setf (ivy-state-action ivy-last) action))
+(defun ivy-thing-at-point ()
+ "Return a string that corresponds to the current thing at point."
+ (or
+ (thing-at-point 'url)
+ (let (s)
+ (cond ((stringp (setq s (thing-at-point 'symbol)))
+ (if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
+ (match-string 1 s)
+ s))
+ ((looking-at "(+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
+ (match-string-no-properties 1))
+ (t
+ "")))))
+
(defvar ivy-history nil
"History list of candidates entered in the minibuffer.
:type
'(alist
:key-type (choice
- (const :tag "All other functions" t)
- (symbol :tag "Function"))
+ (const :tag "Fall-through" t)
+ (symbol :tag "Collection"))
:value-type (choice
- (const :tag "plain sort" string-lessp)
- (const :tag "file sort" ivy-sort-file-function-default)
- (const :tag "no sort" nil)))
+ (const :tag "Plain sort" string-lessp)
+ (const :tag "File sort" ivy-sort-file-function-default)
+ (const :tag "No sort" nil)))
:group 'ivy)
(defvar ivy-index-functions-alist
(buffer-substring
(region-beginning)
(region-end))
- (or
- (thing-at-point 'url)
- (thing-at-point 'symbol)
- "")))
+ (ivy-thing-at-point)))
(setq ivy--prompt
(cond ((string-match "%.*d" prompt)
prompt)
preselect)
((cl-position preselect candidates :test #'equal))
((stringp preselect)
- (let ((re (regexp-quote preselect)))
+ (let ((re preselect))
(cl-position-if
(lambda (x)
(string-match re x))
(setq ivy--subexps (length subs))
(mapconcat
(lambda (x)
- (if (string-match "\\`\\\\(.*\\\\)\\'" x)
+ (if (string-match "\\`\\\\([^?].*\\\\)\\'" x)
x
(format "\\(%s\\)" x)))
subs
(setq ivy--subexps (length (match-string 2 str))))
str))
+(defcustom ivy-fixed-height-minibuffer nil
+ "When non nil, fix the height of the minibuffer during ivy
+completion at `ivy-height'. This effectively sets the minimum
+height at this level and tries to ensure that it does not change
+depending on the number of candidates."
+ :group 'ivy
+ :type 'boolean)
+
;;** Rest
(defun ivy--minibuffer-setup ()
"Setup ivy completion in the minibuffer."
(when (display-graphic-p)
(setq truncate-lines t))
(setq-local max-mini-window-height ivy-height)
+ (when ivy-fixed-height-minibuffer
+ (set-window-text-height (selected-window) ivy-height))
(add-hook 'post-command-hook #'ivy--exhibit nil t)
;; show completions with empty input
(ivy--exhibit))
previously unmatched collection functions.
The alist VAL is a sorting function with the signature of
-`ivy--prefix-sort'.")
+`ivy--prefix-sort'."
+ :type '(alist
+ :key-type (choice
+ (const :tag "Fall-through" t)
+ (symbol :tag "Collection"))
+ :value-type
+ (choice
+ (const :tag "Don't sort" nil)
+ (const :tag "Put prefix matches ahead" 'ivy--prefix-sort)
+ (function :tag "Custom sort function"))))
(defun ivy--sort-files-by-date (_name candidates)
"Re-soft CANDIDATES according to file modification date."
ivy-minibuffer-match-face-2
ivy-minibuffer-match-face-3
ivy-minibuffer-match-face-4)
- "List of `ivy' faces for minibuffer group matches.")
+ "List of `ivy' faces for minibuffer group matches."
+ :type '(repeat :tag "Faces"
+ (choice
+ (const ivy-minibuffer-match-face-1)
+ (const ivy-minibuffer-match-face-2)
+ (const ivy-minibuffer-match-face-3)
+ (const ivy-minibuffer-match-face-4)
+ (face :tag "Other face"))))
(defvar ivy-flx-limit 200
"Used to conditionally turn off flx sorting.
There is no limit on the number of *ivy-occur* buffers."
(interactive)
- (let* ((caller (ivy-state-caller ivy-last))
- (occur-fn (plist-get ivy--occurs-list caller))
- (buffer
- (generate-new-buffer
- (format "*ivy-occur%s \"%s\"*"
- (if caller
- (concat " " (prin1-to-string caller))
- "")
- ivy-text))))
- (with-current-buffer buffer
- (let ((inhibit-read-only t))
- (erase-buffer)
- (if occur-fn
- (funcall occur-fn)
- (ivy-occur-mode)
- (insert (format "%d candidates:\n" (length ivy--old-cands)))
- (ivy--occur-insert-lines
- (mapcar
- (lambda (cand) (concat " " cand))
- ivy--old-cands))))
- (setf (ivy-state-text ivy-last) ivy-text)
- (setq ivy-occur-last ivy-last)
- (setq-local ivy--directory ivy--directory))
- (ivy-exit-with-action
- `(lambda (_) (pop-to-buffer ,buffer)))))
+ (if (not (window-minibuffer-p))
+ (user-error "No completion session is active")
+ (let* ((caller (ivy-state-caller ivy-last))
+ (occur-fn (plist-get ivy--occurs-list caller))
+ (buffer
+ (generate-new-buffer
+ (format "*ivy-occur%s \"%s\"*"
+ (if caller
+ (concat " " (prin1-to-string caller))
+ "")
+ ivy-text))))
+ (with-current-buffer buffer
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (if occur-fn
+ (funcall occur-fn)
+ (ivy-occur-mode)
+ (insert (format "%d candidates:\n" (length ivy--old-cands)))
+ (ivy--occur-insert-lines
+ (mapcar
+ (lambda (cand) (concat " " cand))
+ ivy--old-cands))))
+ (setf (ivy-state-text ivy-last) ivy-text)
+ (setq ivy-occur-last ivy-last)
+ (setq-local ivy--directory ivy--directory))
+ (ivy-exit-with-action
+ `(lambda (_) (pop-to-buffer ,buffer))))))
(declare-function wgrep-change-to-wgrep-mode "ext:wgrep")