Remove all bookmarks when archiving a project
Not only the one to the project diary.
This commit is contained in:
parent
297bb6ac6e
commit
9c0d630703
|
@ -85,35 +85,32 @@ with some standard information like title and creation date."
|
||||||
(when (require 'projectile nil 'no-error)
|
(when (require 'projectile nil 'no-error)
|
||||||
(projectile-add-known-project project-directory))))
|
(projectile-add-known-project project-directory))))
|
||||||
|
|
||||||
|
(defun projects--find-bookmarks-for-path (path)
|
||||||
|
"Find all bookmark names that point into PATH."
|
||||||
|
(unless (file-name-absolute-p path)
|
||||||
|
(user-error "Given path %s is not absolute" path))
|
||||||
|
(let ((path (file-truename path)))
|
||||||
|
(cl-remove-if-not #'(lambda (bmk)
|
||||||
|
(let ((filename (bookmark-get-filename bmk)))
|
||||||
|
(and (not (file-remote-p filename))
|
||||||
|
(string-prefix-p path (file-truename filename)))))
|
||||||
|
(bookmark-all-names))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun projects-archive-project (short-name)
|
(defun projects-archive-project (short-name)
|
||||||
"Archive existing project identified by SHORT-NAME.
|
"Archive existing project identified by SHORT-NAME.
|
||||||
This amounts to moving the project directory SHORT-NAME under
|
This amounts to moving the project directory SHORT-NAME under
|
||||||
`projects-main-project-directory' to
|
`projects-main-project-directory' to
|
||||||
`projects-archive-directory', deleting the bookmark to the
|
`projects-archive-directory', deleting all bookmarks into the
|
||||||
project diary, and updating projectile's cache."
|
project, and updating projectile's cache."
|
||||||
(interactive
|
(interactive
|
||||||
(list (completing-read "Short Name: " (projects-existing-projects) nil t)))
|
(list (completing-read "Short Name: " (projects-existing-projects) nil t)))
|
||||||
(unless (projects-project-exists-p short-name)
|
(unless (projects-project-exists-p short-name)
|
||||||
(user-error "Project %s does not exist, exiting" short-name))
|
(user-error "Project %s does not exist, exiting" short-name))
|
||||||
|
|
||||||
;; Remove bookmark first
|
;; Remove bookmarks first
|
||||||
(let* ((notebook-path (expand-file-name (concat
|
(mapc #'bookmark-delete (projects--find-bookmarks-for-path
|
||||||
(file-name-as-directory short-name)
|
(expand-file-name short-name projects-main-project-directory)))
|
||||||
"projekttagebuch.org")
|
|
||||||
projects-main-project-directory))
|
|
||||||
(bookmark-entry (cl-find-if (lambda (entry)
|
|
||||||
(let ((filename (->> entry
|
|
||||||
cdr
|
|
||||||
(cl-assoc 'filename)
|
|
||||||
cdr)))
|
|
||||||
(and (not (file-remote-p filename))
|
|
||||||
(file-equal-p notebook-path
|
|
||||||
filename))))
|
|
||||||
bookmark-alist)))
|
|
||||||
(if (null bookmark-entry)
|
|
||||||
(warn "No bookmark for project notebook of %s found." short-name)
|
|
||||||
(bookmark-delete (car bookmark-entry))))
|
|
||||||
|
|
||||||
;; Move project directory into archive
|
;; Move project directory into archive
|
||||||
(unless (file-exists-p projects-archive-directory)
|
(unless (file-exists-p projects-archive-directory)
|
||||||
|
|
Loading…
Reference in New Issue