Make buffer library (and ivy switch-buffer commands) workspace-centric, rather than project centric

This commit is contained in:
Henrik Lissner 2017-02-21 00:43:15 -05:00
parent 8ded4819e2
commit 5374d96781
2 changed files with 49 additions and 46 deletions

View file

@ -1,7 +1,7 @@
;;; completion/ivy/autoload/ivy.el
;; Show more information in ivy-switch-buffer; and only display
;; project/workgroup-relevant buffers.
;; workgroup-relevant buffers.
(defun +ivy--get-buffers (&optional buffer-list)
(let ((min-name 5)
(min-mode 5)
@ -19,21 +19,20 @@
(setq min-name (+ (length buffer-name) 15)))
(when (> (length mode-name) min-mode)
(setq min-mode (+ (length mode-name) 3)))
(list
(concat
(propertize buffer-name
'face (cond ((string-match-p "^ ?\\*" buffer-name)
'font-lock-comment-face)
((not (string= proot (doom-project-root)))
'font-lock-keyword-face)
(buffer-read-only
'error)))
(when (and buffer-file-name (buffer-modified-p))
(propertize "[+]" 'face 'doom-modeline-buffer-modified)))
(propertize mode-name 'face 'font-lock-constant-face)
(when buffer-file-name
(abbreviate-file-name (file-name-directory buffer-file-name)))))))
(or buffer-list (doom-buffer-list t))))))
(list (concat
(propertize buffer-name
'face (cond ((string-match-p "^ ?\\*" buffer-name)
'font-lock-comment-face)
((not (string= proot (doom-project-root)))
'font-lock-keyword-face)
(buffer-read-only
'error)))
(when (and buffer-file-name (buffer-modified-p))
(propertize "[+]" 'face 'doom-modeline-buffer-modified)))
(propertize mode-name 'face 'font-lock-constant-face)
(when buffer-file-name
(abbreviate-file-name (file-name-directory buffer-file-name)))))))
(or buffer-list (doom-buffer-list))))))
(defun +ivy--select-buffer-action (buffer)
(ivy--switch-buffer-action
@ -42,22 +41,22 @@
(substring buffer 0 (s-index-of " " buffer)))))
;;;###autoload
(defun +ivy/switch-project-buffer (&optional all-p)
"Displays open buffers in current project and workspace. If ALL-P, then show
all open buffers."
(defun +ivy/switch-workspace-buffer ()
"Switch to an open buffer in the current workspace."
(interactive)
(ivy-read (format "%s buffers: " (if all-p "All" "Project"))
(+ivy--get-buffers (if all-p (buffer-list)))
(+ivy/switch-buffer t))
;;;###autoload
(defun +ivy/switch-buffer (&optional workspace-only-p)
"Switch to an open buffer in the global buffer list. If WORKSPACE-ONLY-P,
limit to buffers in the current workspace."
(interactive)
(ivy-read (format "%s buffers: " (if workspace-only-p "Workspace" "Global"))
(+ivy--get-buffers (unless workspace-only-p (buffer-list)))
:matcher #'ivy--switch-buffer-matcher
:action #'+ivy--select-buffer-action
:keymap ivy-switch-buffer-map
:caller '+ivy/switch-project-buffer))
;;;###autoload
(defun +ivy/switch-buffer ()
"Displays all open buffers, across projects and workspaces."
(interactive)
(+ivy/switch-project-buffer t))
:caller '+ivy/switch-workspace-buffer))
;;;###autoload
(defun +ivy/kill-ring ()