Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 94 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,120 +40,121 @@ Installation:
-------------

To use bm.el, put it in your load-path and add the following to your .emacs

(require 'bm)

```emacs-lisp
(require 'bm)
```
or

(autoload 'bm-toggle "bm" "Toggle bookmark in current buffer." t)
(autoload 'bm-next "bm" "Goto bookmark." t)
(autoload 'bm-previous "bm" "Goto previous bookmark." t)

```emacs-lisp
(autoload 'bm-toggle "bm" "Toggle bookmark in current buffer." t)
(autoload 'bm-next "bm" "Goto bookmark." t)
(autoload 'bm-previous "bm" "Goto previous bookmark." t)
```

Configuration:
--------------

To make it easier to use, assign the commands to some keys.

M$ Visual Studio key setup.

(global-set-key (kbd "<C-f2>") 'bm-toggle)
(global-set-key (kbd "<f2>") 'bm-next)
(global-set-key (kbd "<S-f2>") 'bm-previous)

```emacs-lisp
(global-set-key (kbd "<C-f2>") 'bm-toggle)
(global-set-key (kbd "<f2>") 'bm-next)
(global-set-key (kbd "<S-f2>") 'bm-previous)
```
Click on fringe to toggle bookmarks, and use mouse wheel to move between them.

(global-set-key (kbd "<left-fringe> <mouse-5>") 'bm-next-mouse)
(global-set-key (kbd "<left-fringe> <mouse-4>") 'bm-previous-mouse)
(global-set-key (kbd "<left-fringe> <mouse-1>") 'bm-toggle-mouse)

```emacs-lisp
(global-set-key (kbd "<left-fringe> <mouse-5>") 'bm-next-mouse)
(global-set-key (kbd "<left-fringe> <mouse-4>") 'bm-previous-mouse)
(global-set-key (kbd "<left-fringe> <mouse-1>") 'bm-toggle-mouse)
```
If you would like the markers on the right fringe instead of the left, add the following line:

(setq bm-marker 'bm-marker-right)

```emacs-lisp
(setq bm-marker 'bm-marker-right)
```
If you would like to cycle bookmark in LIFO order, add the following line:

(setq bm-in-lifo-order t)

```emacs-lisp
(setq bm-in-lifo-order t)
```
If you would like to cycle through bookmarks in *all* open buffers, add the following line:

(setq bm-cycle-all-buffers t)

```emacs-lisp
(setq bm-cycle-all-buffers t)
```
If you would like to remove bookmark after jump to it by `bm-next` or `bm-previous`:

(setq temporary-bookmark-p t)

```emacs-lisp
(setq temporary-bookmark-p t)
```
or if you want use this feature in your library:

(bm-bookmark-add nil nil t)

```emacs-lisp
(bm-bookmark-add nil nil t)
```
If you need org-mode to expand the region containing a bookmark, add the following:

(add-hook 'bm-after-goto-hook 'org-bookmark-jump-unhide)

```emacs-lisp
(add-hook 'bm-after-goto-hook 'org-bookmark-jump-unhide)
```


Configuring bm.el with use-package:
---------------------------------
Configuring bm.el with [use-package](https://github.com/jwiegley/use-package)

(use-package bm
:ensure t
:demand t

:init
;; restore on load (even before you require bm)
(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.
(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)


:bind (("<f2>" . bm-next)
("S-<f2>" . bm-previous)
("C-<f2>" . bm-toggle))
)

```emacs-lisp
(use-package bm
:ensure t
:demand t

:init
;; restore on load (even before you require bm)
(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.
(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)


:bind (("<f2>" . bm-next)
("S-<f2>" . bm-previous)
("C-<f2>" . bm-toggle))
)
```


Reviews and comments:
Expand Down