Updating Doom Emacs.

This commit is contained in:
Derek Taylor
2020-06-19 22:43:40 -05:00
parent 0f664d532a
commit a5c86c514a
453 changed files with 13527 additions and 12455 deletions

View File

@@ -68,20 +68,19 @@ error if NAME doesn't exist."
"Return a list of workspace structs (satisifes `+workspace-p')."
;; We don't use `hash-table-values' because it doesn't ensure order in older
;; versions of Emacs
(cdr (cl-loop for persp being the hash-values of *persp-hash*
collect persp)))
(cl-loop for name in persp-names-cache
if (gethash name *persp-hash*)
collect it))
;;;###autoload
(defun +workspace-list-names ()
"Return the list of names of open workspaces."
(mapcar #'safe-persp-name (+workspace-list)))
persp-names-cache)
;;;###autoload
(defun +workspace-buffer-list (&optional persp)
"Return a list of buffers in PERSP.
The buffer list is ordered by recency (same as `buffer-list').
PERSP can be a string (name of a workspace) or a workspace (satisfies
`+workspace-p'). If nil or omitted, it defaults to the current workspace."
(let ((persp (or persp (+workspace-current))))
@@ -174,11 +173,12 @@ throws an error."
(+workspace-new name)
(error "%s is not an available workspace" name)))
(let ((old-name (+workspace-current-name)))
(setq +workspace--last
(or (and (not (string= old-name persp-nil-name))
old-name)
+workspaces-main))
(persp-frame-switch name)
(unless (equal old-name name)
(setq +workspace--last
(or (and (not (string= old-name persp-nil-name))
old-name)
+workspaces-main))
(persp-frame-switch name))
(equal (+workspace-current-name) name)))
@@ -268,13 +268,20 @@ workspace to delete."
('error (+workspace-error ex t))))
;;;###autoload
(defun +workspace/kill-session ()
(defun +workspace/kill-session (&optional interactive)
"Delete the current session, all workspaces, windows and their buffers."
(interactive)
(unless (cl-every #'+workspace-delete (+workspace-list-names))
(+workspace-error "Could not clear session"))
(+workspace-switch +workspaces-main t)
(doom/kill-all-buffers (buffer-list)))
(interactive (list t))
(let ((windows (length (window-list)))
(persps (length (+workspace-list-names)))
(buffers 0))
(let ((persp-autokill-buffer-on-remove t))
(unless (cl-every #'+workspace-delete (+workspace-list-names))
(+workspace-error "Could not clear session")))
(+workspace-switch +workspaces-main t)
(setq buffers (doom/kill-all-buffers (buffer-list)))
(when interactive
(message "Killed %d workspace(s), %d window(s) & %d buffer(s)"
persps windows buffers))))
;;;###autoload
(defun +workspace/kill-session-and-quit ()
@@ -335,7 +342,8 @@ end of the workspace list."
;;;###autoload
(dotimes (i 9)
(defalias (intern (format "+workspace/switch-to-%d" i))
(lambda () (interactive) (+workspace/switch-to i))))
(lambda () (interactive) (+workspace/switch-to i))
(format "Switch to workspace #%d" (1+ i))))
;;;###autoload
(defun +workspace/switch-to-final ()
@@ -396,6 +404,31 @@ the next."
((+workspace-error "Can't delete last workspace" t)))))))
;;;###autoload
(defun +workspace/swap-left (&optional count)
"Swap the current workspace with the COUNTth workspace on its left."
(interactive "p")
(let* ((current-name (+workspace-current-name))
(count (or count 1))
(index (- (cl-position current-name persp-names-cache :test #'equal)
count))
(names (remove current-name persp-names-cache)))
(unless names
(user-error "Only one workspace"))
(let ((index (min (max 0 index) (length names))))
(setq persp-names-cache
(append (cl-subseq names 0 index)
(list current-name)
(cl-subseq names index))))
(when (called-interactively-p 'any)
(+workspace/display))))
;;;###autoload
(defun +workspace/swap-right (&optional count)
"Swap the current workspace with the COUNTth workspace on its right."
(interactive "p")
(funcall-interactively #'+workspace/swap-left (- count)))
;;
;;; Tabs display in minibuffer
@@ -492,32 +525,46 @@ the user to open a file in the new project.
This be hooked to `projectile-after-switch-project-hook'."
(when dir
(setq +workspaces--project-dir dir))
(when (and persp-mode +workspaces--project-dir)
(unwind-protect
(if (and (not (null +workspaces-on-switch-project-behavior))
(or (eq +workspaces-on-switch-project-behavior t)
(+workspace-buffer-list)))
(let* ((persp
(let ((project-name (doom-project-name +workspaces--project-dir)))
(or (+workspace-get project-name t)
(+workspace-new project-name))))
(new-name (persp-name persp)))
(+workspace-switch new-name)
(with-current-buffer (doom-fallback-buffer)
(setq default-directory +workspaces--project-dir))
(unless current-prefix-arg
(funcall +workspaces-switch-project-function +workspaces--project-dir))
(+workspace-message
(format "Switched to '%s' in new workspace" new-name)
'success))
(with-current-buffer (doom-fallback-buffer)
(setq default-directory +workspaces--project-dir)
(message "Switched to '%s'" (doom-project-name +workspaces--project-dir)))
(with-demoted-errors "Workspace error: %s"
(+workspace-rename (+workspace-current-name) (doom-project-name +workspaces--project-dir)))
(unless current-prefix-arg
(funcall +workspaces-switch-project-function +workspaces--project-dir)))
(setq +workspaces--project-dir nil))))
;; HACK Clear projectile-project-root, otherwise cached roots may interfere
;; with project switch (see #3166)
(let (projectile-project-root)
(when (and persp-mode +workspaces--project-dir)
(when projectile-before-switch-project-hook
(with-temp-buffer
;; Load the project dir-local variables into the switch buffer, so the
;; action can make use of them
(setq default-directory +workspaces--project-dir)
(hack-dir-local-variables-non-file-buffer)
(run-hooks 'projectile-before-switch-project-hook)))
(unwind-protect
(if (and (not (null +workspaces-on-switch-project-behavior))
(or (eq +workspaces-on-switch-project-behavior t)
(equal (safe-persp-name (get-current-persp)) persp-nil-name)
(+workspace-buffer-list)))
(let* ((persp
(let ((project-name (doom-project-name +workspaces--project-dir)))
(or (+workspace-get project-name t)
(+workspace-new project-name))))
(new-name (persp-name persp)))
(+workspace-switch new-name)
(with-current-buffer (doom-fallback-buffer)
(setq default-directory +workspaces--project-dir)
(hack-dir-local-variables-non-file-buffer))
(unless current-prefix-arg
(funcall +workspaces-switch-project-function +workspaces--project-dir))
(+workspace-message
(format "Switched to '%s' in new workspace" new-name)
'success))
(with-current-buffer (doom-fallback-buffer)
(setq default-directory +workspaces--project-dir)
(hack-dir-local-variables-non-file-buffer)
(message "Switched to '%s'" (doom-project-name +workspaces--project-dir)))
(with-demoted-errors "Workspace error: %s"
(+workspace-rename (+workspace-current-name) (doom-project-name +workspaces--project-dir)))
(unless current-prefix-arg
(funcall +workspaces-switch-project-function +workspaces--project-dir)))
(run-hooks 'projectile-after-switch-project-hook)
(setq +workspaces--project-dir nil)))))
;;