fix: isolate project bookmarks from globals, mu4e maildir format
This commit is contained in:
@@ -2316,8 +2316,8 @@ only injects when the project's context-tag matches current mu4e context."
|
|||||||
("Drafts" . ?D)
|
("Drafts" . ?D)
|
||||||
("Trash" . ?T)
|
("Trash" . ?T)
|
||||||
("Archive" . ?A)))
|
("Archive" . ?A)))
|
||||||
(push (cons (format "[%s] %s" proj-tag (car folder))
|
(push (cons (format "maildir:/%s.%s" (car folder) proj-tag)
|
||||||
(format "maildir:/%s.%s" (car folder) proj-tag))
|
(cdr folder))
|
||||||
project-bm)))
|
project-bm)))
|
||||||
;; Inject into mu4e-maildir-shortcuts
|
;; Inject into mu4e-maildir-shortcuts
|
||||||
(setq gortium/project-mu4e-bookmarks project-bm)
|
(setq gortium/project-mu4e-bookmarks project-bm)
|
||||||
@@ -3572,11 +3572,19 @@ Returns alist ((NAME . URL) ...) where URL is the link target."
|
|||||||
(nreverse bookmarks))))))
|
(nreverse bookmarks))))))
|
||||||
|
|
||||||
(defun gortium//append-bookmark-to-plan (name url)
|
(defun gortium//append-bookmark-to-plan (name url)
|
||||||
"Add a bookmark NAME with URL to the project's .bookmarks file."
|
"Add a bookmark NAME with URL to the project's .bookmarks file.
|
||||||
|
Saves only project bookmarks without contaminating global list."
|
||||||
(when (projectile-project-p)
|
(when (projectile-project-p)
|
||||||
(let ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))))
|
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
|
||||||
|
(saved-alist (copy-tree bookmark-alist)))
|
||||||
|
;; Save globals first, then load project bookmarks
|
||||||
|
(bookmark-save)
|
||||||
|
(when (file-exists-p proj-file)
|
||||||
|
(bookmark-load proj-file t))
|
||||||
(bookmark-store name `((filename . ,url)) nil)
|
(bookmark-store name `((filename . ,url)) nil)
|
||||||
(bookmark-save nil proj-file)
|
(bookmark-save nil proj-file)
|
||||||
|
;; Restore globals
|
||||||
|
(setq bookmark-alist saved-alist)
|
||||||
(message "Bookmark added to .bookmarks"))))
|
(message "Bookmark added to .bookmarks"))))
|
||||||
(defun gortium//remove-bookmark-from-plan (name)
|
(defun gortium//remove-bookmark-from-plan (name)
|
||||||
"Remove a bookmark entry from * Bookmarks in the Plan file."
|
"Remove a bookmark entry from * Bookmarks in the Plan file."
|
||||||
@@ -3608,10 +3616,20 @@ Project bookmarks go to .bookmarks file in project root."
|
|||||||
(name (read-string (format "[%s] Bookmark name: " tag)))
|
(name (read-string (format "[%s] Bookmark name: " tag)))
|
||||||
(proj-file (expand-file-name
|
(proj-file (expand-file-name
|
||||||
".bookmarks" (projectile-project-root)))
|
".bookmarks" (projectile-project-root)))
|
||||||
(bm (bookmark-make-record)))
|
(saved-alist (copy-tree bookmark-alist))
|
||||||
(bookmark-store name (cdr bm) nil)
|
(record (bookmark-make-record)))
|
||||||
|
;; Save current globals to disk first
|
||||||
|
(bookmark-save)
|
||||||
|
;; Load existing .bookmarks (if any)
|
||||||
|
(when (file-exists-p proj-file)
|
||||||
|
(bookmark-load proj-file t))
|
||||||
|
;; Add new bookmark to alist
|
||||||
|
(bookmark-store name (cdr record) nil)
|
||||||
|
;; Write ONLY project bookmarks to .bookmarks
|
||||||
(bookmark-save nil proj-file)
|
(bookmark-save nil proj-file)
|
||||||
(message "Project bookmark saved to .bookmarks"))
|
;; Restore global bookmarks
|
||||||
|
(setq bookmark-alist saved-alist)
|
||||||
|
(message "Project bookmark \"%s\" saved to .bookmarks" name))
|
||||||
(user-error "Not in a Projectile project"))))))
|
(user-error "Not in a Projectile project"))))))
|
||||||
|
|
||||||
(defun gortium/list-project-bookmarks ()
|
(defun gortium/list-project-bookmarks ()
|
||||||
|
|||||||
@@ -1470,8 +1470,8 @@ only injects when the project's context-tag matches current mu4e context."
|
|||||||
("Drafts" . ?D)
|
("Drafts" . ?D)
|
||||||
("Trash" . ?T)
|
("Trash" . ?T)
|
||||||
("Archive" . ?A)))
|
("Archive" . ?A)))
|
||||||
(push (cons (format "[%s] %s" proj-tag (car folder))
|
(push (cons (format "maildir:/%s.%s" (car folder) proj-tag)
|
||||||
(format "maildir:/%s.%s" (car folder) proj-tag))
|
(cdr folder))
|
||||||
project-bm)))
|
project-bm)))
|
||||||
;; Inject into mu4e-maildir-shortcuts
|
;; Inject into mu4e-maildir-shortcuts
|
||||||
(setq gortium/project-mu4e-bookmarks project-bm)
|
(setq gortium/project-mu4e-bookmarks project-bm)
|
||||||
@@ -2642,11 +2642,19 @@ Returns alist ((NAME . URL) ...) where URL is the link target."
|
|||||||
(nreverse bookmarks))))))
|
(nreverse bookmarks))))))
|
||||||
|
|
||||||
(defun gortium//append-bookmark-to-plan (name url)
|
(defun gortium//append-bookmark-to-plan (name url)
|
||||||
"Add a bookmark NAME with URL to the project's .bookmarks file."
|
"Add a bookmark NAME with URL to the project's .bookmarks file.
|
||||||
|
Saves only project bookmarks without contaminating global list."
|
||||||
(when (projectile-project-p)
|
(when (projectile-project-p)
|
||||||
(let ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))))
|
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
|
||||||
|
(saved-alist (copy-tree bookmark-alist)))
|
||||||
|
;; Save globals first, then load project bookmarks
|
||||||
|
(bookmark-save)
|
||||||
|
(when (file-exists-p proj-file)
|
||||||
|
(bookmark-load proj-file t))
|
||||||
(bookmark-store name `((filename . ,url)) nil)
|
(bookmark-store name `((filename . ,url)) nil)
|
||||||
(bookmark-save nil proj-file)
|
(bookmark-save nil proj-file)
|
||||||
|
;; Restore globals
|
||||||
|
(setq bookmark-alist saved-alist)
|
||||||
(message "Bookmark added to .bookmarks"))))
|
(message "Bookmark added to .bookmarks"))))
|
||||||
(defun gortium//remove-bookmark-from-plan (name)
|
(defun gortium//remove-bookmark-from-plan (name)
|
||||||
"Remove a bookmark entry from * Bookmarks in the Plan file."
|
"Remove a bookmark entry from * Bookmarks in the Plan file."
|
||||||
@@ -2678,10 +2686,20 @@ Project bookmarks go to .bookmarks file in project root."
|
|||||||
(name (read-string (format "[%s] Bookmark name: " tag)))
|
(name (read-string (format "[%s] Bookmark name: " tag)))
|
||||||
(proj-file (expand-file-name
|
(proj-file (expand-file-name
|
||||||
".bookmarks" (projectile-project-root)))
|
".bookmarks" (projectile-project-root)))
|
||||||
(bm (bookmark-make-record)))
|
(saved-alist (copy-tree bookmark-alist))
|
||||||
(bookmark-store name (cdr bm) nil)
|
(record (bookmark-make-record)))
|
||||||
|
;; Save current globals to disk first
|
||||||
|
(bookmark-save)
|
||||||
|
;; Load existing .bookmarks (if any)
|
||||||
|
(when (file-exists-p proj-file)
|
||||||
|
(bookmark-load proj-file t))
|
||||||
|
;; Add new bookmark to alist
|
||||||
|
(bookmark-store name (cdr record) nil)
|
||||||
|
;; Write ONLY project bookmarks to .bookmarks
|
||||||
(bookmark-save nil proj-file)
|
(bookmark-save nil proj-file)
|
||||||
(message "Project bookmark saved to .bookmarks"))
|
;; Restore global bookmarks
|
||||||
|
(setq bookmark-alist saved-alist)
|
||||||
|
(message "Project bookmark \"%s\" saved to .bookmarks" name))
|
||||||
(user-error "Not in a Projectile project"))))))
|
(user-error "Not in a Projectile project"))))))
|
||||||
|
|
||||||
(defun gortium/list-project-bookmarks ()
|
(defun gortium/list-project-bookmarks ()
|
||||||
|
|||||||
Reference in New Issue
Block a user