ui/tabs: fix recursive load errors & update

An autoload was causing an autoload before their respective packages
could declare they had been loaded, leading to cyclical loading errors.
This commit is contained in:
Henrik Lissner 2019-09-05 13:43:49 -04:00
parent 1031adb6af
commit 7e36c5c2b3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 36 additions and 32 deletions

View file

@ -6,33 +6,6 @@
(or (memq buffer (window-parameter nil 'tab-buffers))
(eq buffer (doom-fallback-buffer))))
;;;###autoload
(defun +tabs-window-tab-list ()
(+tabs-window-buffer-list-fn))
;;;###autoload
(defun +tabs-window-buffer-list-fn ()
(cl-delete-if-not #'buffer-live-p (window-parameter nil 'tab-buffers)))
;;;###autoload
(defun +tabs-buffer-groups-fn ()
(list
(cond ((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'eshell-mode)
"EShell")
((derived-mode-p 'dired-mode)
"Dired")
((centaur-tabs-get-group-name (current-buffer))))))
;;
;;; Commands
@ -54,7 +27,7 @@
;;;###autoload
(defun +tabs-kill-current-buffer-a (&rest _)
(+tabs|remove-buffer))
(+tabs-remove-buffer-h))
;;;###autoload
(defun +tabs-bury-buffer-a (orig-fn &rest args)
@ -63,7 +36,7 @@
(apply orig-fn args)
(unless (eq b (current-buffer))
(with-current-buffer b
(+tabs|remove-buffer))))
(+tabs-remove-buffer-h))))
(apply orig-fn args)))
;;;###autoload
@ -86,11 +59,11 @@
(let* ((this-buf (current-buffer))
(buffers (window-parameter nil 'tab-buffers)))
(cl-pushnew this-buf buffers)
(add-hook 'kill-buffer-hook #'+tabs|remove-buffer nil t)
(add-hook 'kill-buffer-hook #'+tabs-remove-buffer-h nil t)
(set-window-parameter nil 'tab-buffers buffers))))
;;;###autoload
(defun +tabs|remove-buffer ()
(defun +tabs-remove-buffer-h ()
(when centaur-tabs-mode
(set-window-parameter
nil

View file

@ -1,7 +1,7 @@
;;; ui/tabs/config.el -*- lexical-binding: t; -*-
(use-package! centaur-tabs
:after-call (after-find-file dired-initial-position-hook)
:after-call after-find-file dired-initial-position-hook
:init
(setq centaur-tabs-height 28
centaur-tabs-set-bar 'left
@ -18,6 +18,37 @@
(add-to-list 'window-persistent-parameters '(tab-buffers . writable))
(defun +tabs-window-buffer-list-fn ()
(centaur-tabs-filter-out
'centaur-tabs-hide-tab-cached
(delq nil
(cl-mapcar #'(lambda (b)
(cond
;; Always include the current buffer.
((eq (current-buffer) b) b)
((buffer-file-name b) b)
((char-equal ?\ (aref (buffer-name b) 0)) nil)
((buffer-live-p b) b)))
(window-parameter nil 'tab-buffers)))))
(defun +tabs-buffer-groups-fn ()
(list
(cond ((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'eshell-mode)
"EShell")
((derived-mode-p 'dired-mode)
"Dired")
((centaur-tabs-get-group-name (current-buffer))))))
(setq centaur-tabs-buffer-list-function #'+tabs-window-buffer-list-fn
centaur-tabs-buffer-groups-function #'+tabs-buffer-groups-fn)