Skip to content

Instantly share code, notes, and snippets.

@mrcat323
Forked from gilbertw1/projectile-bookmark.el
Created January 25, 2020 11:10
Show Gist options
  • Save mrcat323/3d4867305333449393dc9f07ccf40380 to your computer and use it in GitHub Desktop.
Save mrcat323/3d4867305333449393dc9f07ccf40380 to your computer and use it in GitHub Desktop.
the fork of counsel projectile bookmarks
(defun counsel-projectile-bookmark ()
"Forward to `bookmark-jump' or `bookmark-set' if bookmark doesn't exist."
(interactive)
(require 'bookmark)
(let ((projectile-bookmarks (projectile-bookmarks)))
(ivy-read "Create or jump to bookmark: "
projectile-bookmarks
:action (lambda (x)
(cond ((and counsel-bookmark-avoid-dired
(member x projectile-bookmarks)
(file-directory-p (bookmark-location x)))
(with-ivy-window
(let ((default-directory (bookmark-location x)))
(counsel-find-file))))
((member x projectile-bookmarks)
(with-ivy-window
(bookmark-jump x)))
(t
(bookmark-set x))))
:caller 'counsel-projectile-bookmark)))
(ivy-set-actions
'counsel-projectile-bookmark
'(("d" bookmark-delete "delete")
("e" bookmark-rename "edit")))
(defun projectile-bookmarks ()
(let ((bmarks (bookmark-all-names)))
(cl-remove-if-not #'workspace-bookmark-p bmarks)))
(defun workspace-bookmark-p (bmark)
(let ((bmark-path (expand-file-name (bookmark-location bmark))))
(string-prefix-p (bmacs-project-root) bmark-path)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment