update of packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; treemacs.el --- A tree style file viewer package -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2022 Alexander Miller
|
||||
;; Copyright (C) 2023 Alexander Miller
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@@ -58,7 +58,6 @@
|
||||
treemacs--maybe-load-workspaces)
|
||||
|
||||
(treemacs-import-functions-from "treemacs-visuals"
|
||||
treemacs--forget-last-highlight
|
||||
treemacs-pulse-on-failure)
|
||||
|
||||
(treemacs-import-functions-from "treemacs-async"
|
||||
@@ -76,9 +75,11 @@
|
||||
(:conc-name treemacs-workspace->)
|
||||
(:constructor treemacs-workspace->create!))
|
||||
name
|
||||
projects)
|
||||
projects
|
||||
is-disabled?)
|
||||
|
||||
(defvar treemacs--workspaces (list (treemacs-workspace->create! :name "Default")))
|
||||
(defvar treemacs--disabled-workspaces (list))
|
||||
|
||||
(defvar treemacs--find-user-project-functions
|
||||
(list #'treemacs--current-builtin-project-function
|
||||
@@ -123,6 +124,11 @@ To be called whenever a project or workspace changes."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote treemacs--workspaces))
|
||||
|
||||
(define-inline treemacs-disabled-workspaces ()
|
||||
"Return the list of all workspaces in treemacs that are disabled."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote treemacs--disabled-workspaces))
|
||||
|
||||
(defun treemacs-current-workspace ()
|
||||
"Get the current workspace.
|
||||
The return value can be overridden by let-binding `treemacs-override-workspace'.
|
||||
@@ -281,7 +287,6 @@ Does not preserve the current position in the buffer."
|
||||
(when (treemacs-project->is-expanded? self)
|
||||
(let ((root-btn (treemacs-project->position self)))
|
||||
(goto-char root-btn)
|
||||
(treemacs--forget-last-highlight)
|
||||
(funcall (alist-get (treemacs-button-get root-btn :state)
|
||||
treemacs-TAB-actions-config))
|
||||
(unless (treemacs-project->is-unreadable? self)
|
||||
@@ -603,7 +608,6 @@ Return values may be as follows:
|
||||
(if (equal (point-min) prev-project-pos)
|
||||
(goto-char next-project-pos)
|
||||
(goto-char prev-project-pos)))
|
||||
(treemacs--forget-last-highlight)
|
||||
(treemacs--invalidate-buffer-project-cache)
|
||||
(--when-let (treemacs-get-local-window)
|
||||
(with-selected-window it
|
||||
@@ -655,8 +659,12 @@ Return values may be as follows:
|
||||
(treemacs-return
|
||||
`(success ,new-workspace)))))
|
||||
|
||||
(defun treemacs-do-rename-workspace ()
|
||||
(defun treemacs-do-rename-workspace (&optional workspace new-name)
|
||||
"Rename a workspace.
|
||||
|
||||
Takes either a WORKSPACE and a NEW-NAME as arguments or reads them
|
||||
interactively.
|
||||
|
||||
Return values may be as follows:
|
||||
|
||||
* If the given name is invalid:
|
||||
@@ -667,19 +675,23 @@ Return values may be as follows:
|
||||
- the old-name
|
||||
- the renamed workspace"
|
||||
(treemacs-block
|
||||
(let* ((current-ws (treemacs-current-workspace))
|
||||
(old-name (treemacs-workspace->name current-ws))
|
||||
(name-map (-> (--map (cons (treemacs-workspace->name it) it) treemacs--workspaces)
|
||||
(sort (lambda (n _) (string= (car n) old-name)))))
|
||||
(str-to-rename (completing-read "Rename: " name-map))
|
||||
(ws-to-rename (cdr (assoc str-to-rename name-map)))
|
||||
(new-name (treemacs--read-string "New name: ")))
|
||||
(let ((old-name))
|
||||
(unless workspace
|
||||
(let* ((current-ws (treemacs-current-workspace))
|
||||
(old-name (treemacs-workspace->name current-ws))
|
||||
(name-map (-> (--map (cons (treemacs-workspace->name it) it) treemacs--workspaces)
|
||||
(sort (lambda (n _) (string= (car n) old-name)))))
|
||||
(str-to-rename (completing-read "Rename: " name-map)))
|
||||
(setf workspace (cdr (assoc str-to-rename name-map)))))
|
||||
(setf old-name (treemacs-workspace->name workspace))
|
||||
(unless new-name
|
||||
(setf new-name (treemacs--read-string "New name: ")))
|
||||
(treemacs-return-if (treemacs--is-name-invalid? new-name)
|
||||
`(invalid-name ,new-name))
|
||||
(setf (treemacs-workspace->name ws-to-rename) new-name)
|
||||
(setf (treemacs-workspace->name workspace) new-name)
|
||||
(treemacs--persist)
|
||||
(run-hook-with-args 'treemacs-rename-workspace-functions ws-to-rename old-name)
|
||||
`(success ,old-name ,ws-to-rename))))
|
||||
(run-hook-with-args 'treemacs-rename-workspace-functions workspace old-name)
|
||||
`(success ,old-name ,workspace))))
|
||||
|
||||
(defun treemacs--is-name-invalid? (name)
|
||||
"Validate the NAME of a project or workspace.
|
||||
@@ -750,7 +762,6 @@ PROJECT: Project Struct"
|
||||
(ht-remove! treemacs-dom (treemacs-project->path project-in-buffer))
|
||||
(setf projects-in-buffer (delete project-in-buffer projects-in-buffer))))
|
||||
(treemacs-with-writable-buffer
|
||||
(treemacs--forget-last-highlight)
|
||||
(treemacs--reset-dom)
|
||||
;; delete everything's that's visible and render it again - the order of projects could
|
||||
;; have been changed
|
||||
|
||||
Reference in New Issue
Block a user