Skip to content

Commit 5fa8419

Browse files
[File-Management] Take into account that read file names might be empty.
1 parent acd69f4 commit 5fa8419

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/elisp/treemacs-bookmarks.el

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,19 @@ treemacs node is pointing to a valid buffer position."
196196
(pcase (treemacs-button-get current-btn :state)
197197
((or 'file-node-open 'file-node-closed 'dir-node-open 'dir-node-closed)
198198
(-let [name (treemacs--read-string "Bookmark name: ")]
199-
(bookmark-store name `((filename . ,(treemacs-button-get current-btn :path))) nil)))
199+
(when name
200+
(bookmark-store name `((filename . ,(treemacs-button-get current-btn :path))) nil))))
200201
('tag-node
201202
(-let [(tag-buffer . tag-pos)
202203
(treemacs--extract-position (treemacs-button-get current-btn :marker) nil)]
203204
(if (buffer-live-p tag-buffer)
204-
(bookmark-store
205-
(treemacs--read-string "Bookmark name: ")
206-
`((filename . ,(buffer-file-name tag-buffer))
207-
(position . ,tag-pos))
208-
nil)
205+
(-let [name (treemacs--read-string "Bookmark name: ")]
206+
(when name
207+
(bookmark-store
208+
name
209+
`((filename . ,(buffer-file-name tag-buffer))
210+
(position . ,tag-pos))
211+
nil)))
209212
(treemacs-log-failure "Tag info can not be saved because it is not pointing to a live buffer."))))
210213
((or 'tag-node-open 'tag-node-closed)
211214
(treemacs-pulse-on-failure "There is nothing to bookmark here.")))))

src/elisp/treemacs-file-management.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,10 @@ will likewise be updated."
360360
(treemacs-error-return-if (not (file-exists-p old-path))
361361
"The file to be renamed does not exist.")
362362
(let* ((old-name (treemacs--filename old-path))
363-
(new-name (treemacs--read-string
364-
"New name: " (file-name-nondirectory old-path)))
363+
(new-name (--if-let (treemacs--read-string
364+
"New name: " (file-name-nondirectory old-path))
365+
it
366+
(treemacs-return nil)))
365367
(dir (treemacs--parent-dir old-path))
366368
(new-path (treemacs-join-path dir new-name))
367369
(parent (treemacs-button-get btn :parent)))

src/elisp/treemacs-workspaces.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ PATH: String"
176176
('always-ask
177177
(treemacs--select-workspace-by-name))))))))
178178

179-
;; TODO(2020/11/25): NAME
180179
(define-inline treemacs--find-project-for-buffer (&optional buffer-file)
181180
"In the current workspace find the project current buffer's file falls under.
182181
Optionally supply the BUFFER-FILE in case it is not available by calling the
@@ -703,7 +702,8 @@ Returns t when the name is invalid.
703702
704703
NAME: String"
705704
(declare (pure t) (side-effect-free t))
706-
(or (s-blank-str? name)
705+
(or (null name)
706+
(s-blank-str? name)
707707
(s-contains? "\n" name)
708708
(not (s-matches? (rx (1+ (or space (syntax word) (syntax symbol) (syntax punctuation)))) name))))
709709

0 commit comments

Comments
 (0)