Skip to content

Commit

Permalink
ivy.el (ivy-switch-buffer-transformer): Move ivy-remote logic here
Browse files Browse the repository at this point in the history
  • Loading branch information
abo-abo committed Apr 24, 2020
1 parent 9e1513f commit 38c90e8
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -4244,20 +4244,7 @@ If optional argument PREDICATE is non-nil, use it to test each
possible match. See `all-completions' for further information."
(delete-dups
(nconc
(mapcar
(lambda (x)
(let* ((buf (get-buffer x))
(dir (buffer-local-value 'default-directory buf))
(face (if (and dir
(ignore-errors
(file-remote-p dir)))
'ivy-remote
(cdr (assq (buffer-local-value 'major-mode buf)
ivy-switch-buffer-faces-alist)))))
(if face
(propertize x 'face face)
x)))
(all-completions str #'internal-complete-buffer predicate))
(all-completions str #'internal-complete-buffer predicate)
(and virtual
(ivy--virtual-buffers)))))

Expand Down Expand Up @@ -4582,16 +4569,21 @@ Skip buffers that match `ivy-ignore-buffers'."

(defun ivy-switch-buffer-transformer (str)
"Transform candidate STR when switching buffers."
(let ((b (get-buffer str)))
(if (and b (buffer-file-name b))
(cond
((and (not (ignore-errors (file-remote-p (buffer-file-name b))))
(not (verify-visited-file-modtime b)))
(ivy-append-face str 'ivy-modified-outside-buffer))
((buffer-modified-p b)
(ivy-append-face str 'ivy-modified-buffer))
(t str))
str)))
(let* ((b (get-buffer str))
(dir (buffer-local-value 'default-directory b))
(mode (buffer-local-value 'major-mode b)))
(cond
((and dir (ignore-errors (file-remote-p dir)))
(ivy-append-face str 'ivy-remote))
((not (verify-visited-file-modtime b))
(ivy-append-face str 'ivy-modified-outside-buffer))
((buffer-modified-p b)
(ivy-append-face str 'ivy-modified-buffer))
(t
(let ((face (cdr (assq mode ivy-switch-buffer-faces-alist))))
(if face
(ivy-append-face str face)
str))))))

(defun ivy-switch-buffer-occur (cands)
"Occur function for `ivy-switch-buffer' using `ibuffer'.
Expand Down

0 comments on commit 38c90e8

Please sign in to comment.