fix: transfer-to-global uses .bookmarks, not Plan file
This commit is contained in:
@@ -3672,17 +3672,32 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(defun gortium/transfer-to-global ()
|
||||
"Transfer a project bookmark to the global bookmarks list."
|
||||
(interactive)
|
||||
(let* ((bookmarks (gortium/read-plan-bookmarks))
|
||||
(names (mapcar #'car bookmarks)))
|
||||
(if names
|
||||
(if (not (projectile-project-p))
|
||||
(user-error "Not in a project")
|
||||
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
|
||||
(proj-bms (and (file-exists-p proj-file)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents proj-file)
|
||||
(ignore-errors (read (current-buffer))))))
|
||||
(names (mapcar (lambda (b) (if (consp b) (car b) b)) proj-bms)))
|
||||
(if (not names)
|
||||
(message "No project bookmarks to transfer.")
|
||||
(let* ((name (completing-read "Transfer to global: " names nil t))
|
||||
(url (cdr (assoc name bookmarks))))
|
||||
(entry (assoc name proj-bms))
|
||||
(url (alist-get 'filename (cdr entry))))
|
||||
(when (and name url (y-or-n-p (format "Transfer '%s' to global? " name)))
|
||||
(bookmark-store name `((filename . ,url)) t)
|
||||
(bookmark-save)
|
||||
(gortium/remove-bookmark-from-plan name)
|
||||
(message "Transferred '%s' to global" name)))
|
||||
(message "No project bookmarks to transfer."))))
|
||||
;; Remove from .bookmarks — re-read, delete, save
|
||||
(let ((saved-alist (copy-tree bookmark-alist)))
|
||||
(setq bookmark-alist
|
||||
(with-temp-buffer
|
||||
(insert-file-contents proj-file)
|
||||
(read (current-buffer))))
|
||||
(setq bookmark-alist (assq-delete-all name bookmark-alist))
|
||||
(bookmark-save nil proj-file)
|
||||
(setq bookmark-alist saved-alist))
|
||||
(message "Transferred '%s' to global" name)))))))
|
||||
|
||||
(defun gortium/list-project-bookmarks ()
|
||||
"Show project bookmarks menu — restores globals after RET jump and on q."
|
||||
|
||||
@@ -2739,17 +2739,32 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(defun gortium/transfer-to-global ()
|
||||
"Transfer a project bookmark to the global bookmarks list."
|
||||
(interactive)
|
||||
(let* ((bookmarks (gortium/read-plan-bookmarks))
|
||||
(names (mapcar #'car bookmarks)))
|
||||
(if names
|
||||
(if (not (projectile-project-p))
|
||||
(user-error "Not in a project")
|
||||
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
|
||||
(proj-bms (and (file-exists-p proj-file)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents proj-file)
|
||||
(ignore-errors (read (current-buffer))))))
|
||||
(names (mapcar (lambda (b) (if (consp b) (car b) b)) proj-bms)))
|
||||
(if (not names)
|
||||
(message "No project bookmarks to transfer.")
|
||||
(let* ((name (completing-read "Transfer to global: " names nil t))
|
||||
(url (cdr (assoc name bookmarks))))
|
||||
(entry (assoc name proj-bms))
|
||||
(url (alist-get 'filename (cdr entry))))
|
||||
(when (and name url (y-or-n-p (format "Transfer '%s' to global? " name)))
|
||||
(bookmark-store name `((filename . ,url)) t)
|
||||
(bookmark-save)
|
||||
(gortium/remove-bookmark-from-plan name)
|
||||
(message "Transferred '%s' to global" name)))
|
||||
(message "No project bookmarks to transfer."))))
|
||||
;; Remove from .bookmarks — re-read, delete, save
|
||||
(let ((saved-alist (copy-tree bookmark-alist)))
|
||||
(setq bookmark-alist
|
||||
(with-temp-buffer
|
||||
(insert-file-contents proj-file)
|
||||
(read (current-buffer))))
|
||||
(setq bookmark-alist (assq-delete-all name bookmark-alist))
|
||||
(bookmark-save nil proj-file)
|
||||
(setq bookmark-alist saved-alist))
|
||||
(message "Transferred '%s' to global" name)))))))
|
||||
|
||||
(defun gortium/list-project-bookmarks ()
|
||||
"Show project bookmarks menu — restores globals after RET jump and on q."
|
||||
|
||||
Reference in New Issue
Block a user