Bookmarks
You might find it easiest to get around your computer with Bookmarks
;bookmarks configuration
(setq bookmark-default-file bookmarks-p)
(global-set-key (kbd "C-c d") 'counsel-bookmarked-directory)
(global-set-key (kbd "C-c f") 'counsel-bookmark)
(global-set-key (kbd "C-c s") 'bookmark-set)
Address Book
You can use addressbook-bookmark
to manage addresses.
(use-package addressbook-bookmark
:after helm-addressbook
:commands (addressbook-bookmark-set helm-addressbook-bookmarks)
);end package addressbook-bookmark
Bookmark Hydra
You can research and test the functions in this bookmarks hydra
. The keys to the piano are right here, you only need to learn to play it, and then compose.
;bookmark hydra
(setq bookmarks-title (with-faicon "book" "Manage Book Marks"))
;generate hydra
(pretty-hydra-define Bookmarks (:title bookmarks-title :quit-key "q" :color teal )
("Local Bookmarks"
(
("b" counsel-bookmark "Jump To A Bookmark C-c f")
("d" counsel-bookmarked-directory "Jump Bookmarked dir C-c d")
("s" bookmark-set "Set A Bookmark")
("e" edit-bookmarks "Edit Bookmarks")
);end local
"Session Bookmarks"
(
("J" bm-toggle "Set/Unset Session Bkmrk M-j")
("j" poseidon/bm-counsel-find-bookmark "Call Session Bkmrk C-c j")
("m" bm-bookmark-annotate "Annotate Bkmrk")
("n" bm-next "bm next")
("p" bm-previous "Open in new buffer")
("a" bm-show-all "List session bkmarks")
("A" bm-show "List session bkmarks in buffer")
("g" bm-show-goto-bookmark "Jmp to bkmrk from list")
("r" bm-remove-all-current-buffer "Remove buffer session bkmrks ")
("R" bm-remove-all-all-buffers "Remove all sesssion bkmrks")
("c" bm-toggle-cycle-all-buffers "Cycle All Buffer Bkmarks")
);end chrome
"Address Book"
(
("@" addressbook-bookmark-set "Enter Contact To Addressbook")
("c" helm-chrome-bookmarks "Select A Chrome Bookmark")
("r" helm-chrome-reload-bookmarks "Refresh Chrome Bookmarks")
("P" bm-toggle-buffer-persistence "Toggle Bm Persistance")
("S" bm-buffer-save-all "Bm save session bmkrks")
("+" bm-repository-add "Bm Add Repo")
("L" bm-repository-load "Bm Load Repo")
("C" bm-repository-clear "Bm Clear Repo")
("$" bm-repository-save "Bm Save Repo")
("h" hydra-helm/body "Return To Helm" :color blue )
("<SPC>" nil "Quit" :color blue )
);end addressbook
);end hydra body
);end pretty-hydra-find-files
(bind-key "<C-m> m" 'Bookmarks/body)
Bookmarks Hydra Screenshot
BM Bookmarks
With bm
you can mark session files and pull them into the window. You can also keep the marks for next time.
(use-package bm
;:ensure t
;:demand t
:init
(setq bm-restore-repository-on-load t)
:config
;; Allow cross-buffer 'next'
(setq bm-cycle-all-buffers t)
;; where to store persistant files
(setq bm-repository-file "~/.emacs.d/bm-repository")
;; save bookmarks
(setq-default bm-buffer-persistence t)
;; Loading the repository from file when on start up.
(add-hook 'after-init-hook 'bm-repository-load)
;; Saving bookmarks
(add-hook 'kill-buffer-hook #'bm-buffer-save)
;; Saving the repository to file when on exit.
;; kill-buffer-hook is not called when Emacs is killed, so we
;; must save all bookmarks first.
(add-hook 'kill-emacs-hook #'(lambda nil
(bm-buffer-save-all)
(bm-repository-save)))
;; The `after-save-hook' is not necessary to use to achieve persistence,
;; but it makes the bookmark data in repository more in sync with the file
;; state.
;bm-modeline-info
;bm-bookmark-add
;bm-bookmark-remove
;(add-hook 'after-save-hook #'bm-buffer-save)
;; Restoring bookmarks
(add-hook 'find-file-hooks #'bm-buffer-restore)
(add-hook 'after-revert-hook #'bm-buffer-restore)
;; The `after-revert-hook' is not necessary to use to achieve persistence,
;; but it makes the bookmark data in repository more in sync with the file
;; state. This hook might cause trouble when using packages
;; that automatically reverts the buffer (like vc after a check-in).
;; This can easily be avoided if the package provides a hook that is
;; called before the buffer is reverted (like `vc-before-checkin-hook').
;; Then new bookmarks can be saved before the buffer is reverted.
;; Make sure bookmarks is saved before check-in (and revert-buffer)
(add-hook 'vc-before-checkin-hook #'bm-buffer-save)
(defun poseidon/bm-counsel-get-list (bookmark-overlays)
"TODO: docstring.
Arguments: BOOKMARK-OVERLAYS."
(-map (lambda (bm)
(with-current-buffer (overlay-buffer bm)
(let* ((line (replace-regexp-in-string
"\n$"
""
(buffer-substring (overlay-start bm)
(overlay-end bm))))
;; line numbers start on 1
(line-num (+ 1 (count-lines (point-min) (overlay-start bm))))
(name (format "%s:%d - %s" (buffer-name) line-num line)))
`(,name . ,bm))))
bookmark-overlays))
(defun poseidon/bm-counsel-find-bookmark ()
"TODO: docstring.
Arguments: none."
(interactive)
(let* ((bm-list (poseidon/bm-counsel-get-list (bm-overlays-lifo-order t)))
(bm-hash-table (make-hash-table :test 'equal))
(search-list (-map (lambda (bm) (car bm)) bm-list)))
(-each bm-list (lambda (bm)
(puthash (car bm) (cdr bm) bm-hash-table)))
(ivy-read "Find bookmark: "
search-list
:require-match t
:keymap counsel-describe-map
:action (lambda (chosen)
(let ((bookmark (gethash chosen bm-hash-table)))
(switch-to-buffer (overlay-buffer bookmark))
(bm-goto bookmark)))
:sort t)))
;(global-unset-key (kbd "<C-tab>"))
(global-set-key (kbd "M-j") 'bm-toggle)
(global-set-key (kbd "C-c j") 'poseidon/bm-counsel-find-bookmark)
(global-set-key (kbd "C-c ,") 'bm-previous)
(global-set-key (kbd "C-c .") 'bm-next)
);end bm bookmarks
BM Bookmarks Hydra
(setq bm-bookmarks-title (with-faicon "book" "Visual Bookmarks Command"))
;generate hydra
(pretty-hydra-define bm-bookmarks (:title bm-bookmarks-title :quit-key "q" :color pink )
("A"
(
("J" bm-toggle "Set/unset session bkmrk")
("j" poseidon/bm-counsel-find-bookmark "Counsel Bkmark")
("m" bm-bookmark-annotate "Annotate Bkmrk")
("n" bm-next "bm next")
("p" bm-previous "Open in new buffer")
);end theme
"Bkmark Remove"
(
("a" bm-show-all "List session bkmarks")
("A" bm-show "List session bkmarks in buffer")
("g" bm-show-goto-bookmark "Jmp to bkmrk from list")
("r" bm-remove-all-current-buffer "Remove buffer session bkmrks ")
("R" bm-remove-all-all-buffers "Remove all sesssion bkmrks")
("c" bm-toggle-cycle-all-buffers "Cycle All Buffer Bkmarks")
);end highlighting
"Bkmark Repo"
(
("P" bm-toggle-buffer-persistence "Toggle Bm Persistance")
("S" bm-buffer-save-all "Bm Save session bmkrks")
("+" bm-repository-add "Bm Add Repo")
("L" bm-repository-load "Bm Load Repo")
("C" bm-repository-clear "Bm Clear Repo")
("$" bm-repository-save "Bm Save Repo")
("h" hydra-helm/body "Return To Helm" :color blue )
("<SPC>" nil "Quit" :color pink)
);end other
);end hydra body
);end pretty-hydra-bookmark
(bind-key "<C-m> j" 'bm-bookmarks/body)