(const :tag "Count matches and show current match" "(%d/%d) ")
string))
+(defcustom ivy-add-newline-after-prompt nil
+ "When non-nil, add a newline after the `ivy-read' prompt."
+ :type 'boolean)
+
(defcustom ivy-wrap nil
"When non-nil, wrap around after the first and the last candidate."
:type 'boolean)
"Return a string that corresponds to the current thing at point."
(or
(thing-at-point 'url)
- (ffap-file-at-point)
+ (and (eq (ivy-state-collection ivy-last) 'read-file-name-internal)
+ (ffap-file-at-point))
(let (s)
(cond ((stringp (setq s (thing-at-point 'symbol)))
(if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
(progn
(insert ivy--default)
(when (and (with-ivy-window (derived-mode-p 'prog-mode))
+ (eq (ivy-state-caller ivy-last) 'swiper)
(not (file-exists-p ivy--default))
(not (ffap-url-p ivy--default))
(not (ivy-state-dynamic-collection ivy-last))
: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 "No sort" nil)
+ (function :tag "Custom function")))
:group 'ivy)
(defvar ivy-index-functions-alist
(not (equal (ivy--get-action ivy-last) 'identity)))
(setq initial-input nil))))
((eq collection 'internal-complete-buffer)
- (setq coll (ivy--buffer-list "" ivy-use-virtual-buffers)))
+ (setq coll (ivy--buffer-list "" ivy-use-virtual-buffers predicate)))
(dynamic-collection
(setq coll (funcall collection ivy-text)))
((or (functionp collection)
(if (and (setq sort-fn (cdr (assoc t ivy-sort-functions-alist)))
(<= (length coll) ivy-sort-max-size))
(setq coll (cl-sort (copy-sequence coll) sort-fn))))))
+ (setq coll (ivy--set-candidates coll))
(when preselect
(unless (or (and require-match
(not (eq collection 'internal-complete-buffer)))
:history history
:keymap nil
:sort
- (let ((sort (assoc this-command ivy-sort-functions-alist)))
+ (let ((sort (or (assoc this-command ivy-sort-functions-alist)
+ (assoc t ivy-sort-functions-alist))))
(if sort
(cdr sort)
t)))))
(set (make-local-variable 'minibuffer-default-add-function)
(lambda ()
(list ivy--default)))
+ (set (make-local-variable 'inhibit-field-text-motion) nil)
(when (display-graphic-p)
(setq truncate-lines t))
(setq-local max-mini-window-height ivy-height)
(window-width))
(setq n-str (concat n-str "\n" d-str))
(setq n-str (concat n-str d-str)))
+ (when ivy-add-newline-after-prompt
+ (setq n-str (concat n-str "\n")))
(let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width))))
(while (string-match regex n-str)
(setq n-str (replace-match (concat (match-string 1 n-str) "\n") nil t n-str 1))))
(cl-incf i))))))
str))
+(ivy-set-display-transformer
+ 'counsel-find-file 'ivy-read-file-transformer)
(ivy-set-display-transformer
'read-file-name-internal 'ivy-read-file-transformer)
"List of regexps or functions matching buffer names to ignore."
:type '(repeat (choice regexp function)))
-(defun ivy--buffer-list (str &optional virtual)
+(defun ivy--buffer-list (str &optional virtual predicate)
"Return the buffers that match STR.
When VIRTUAL is non-nil, add virtual buffers."
(delete-dups
(abbreviate-file-name default-directory)))
(propertize x 'face 'ivy-remote)
x))
- (all-completions str 'internal-complete-buffer))
+ (all-completions str 'internal-complete-buffer predicate))
(and virtual
(ivy--virtual-buffers)))))
(interactive)
(let ((caller (ivy-state-caller ivy-occur-last))
(ivy-last ivy-occur-last))
- (when (eq caller 'swiper)
- (let ((buffer (ivy-state-buffer ivy-occur-last)))
- (unless (buffer-live-p buffer)
- (error "buffer was killed"))
- (let ((inhibit-read-only t))
- (erase-buffer)
- (funcall (plist-get ivy--occurs-list caller) t))))))
+ (cond ((eq caller 'swiper)
+ (let ((buffer (ivy-state-buffer ivy-occur-last)))
+ (unless (buffer-live-p buffer)
+ (error "buffer was killed"))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (funcall (plist-get ivy--occurs-list caller) t))))
+ ((memq caller '(counsel-git-grep counsel-grep counsel-ag))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (funcall (plist-get ivy--occurs-list caller)))))))
(declare-function wgrep-change-to-wgrep-mode "ext:wgrep")