Giter Site home page Giter Site logo

joodland / bm Goto Github PK

View Code? Open in Web Editor NEW
258.0 8.0 30.0 524 KB

bm.el -- Visual Bookmarks for GNU Emacs

Home Page: http://joodland.github.io/bm/

License: GNU General Public License v2.0

Emacs Lisp 99.56% Shell 0.44%
visual-bookmarks gnu-emacs melpa bookmark fringe emacs

bm's Introduction

MELPA MELPA CI

Visible bookmarks in buffer for GNU Emacs 26.x, 27.x, 28.x, 29.x

This package provides visible, buffer local, bookmarks and the ability to jump forward and backward to the next bookmark.

It was created because I missed the bookmarks from M$ Visual Studio in GNU Emacs. I think they provide an easy way to navigate in a buffer.

Features:

  • Auto remove bookmark after jump to it by bm-next or bm-previous:
  • Cycle through bookmarks in all open buffers in LIFO order
  • Toggle bookmarks. Jump to next/previous bookmark.
  • Setting bookmarks based on a regexp. (Useful when searching logfiles.)
  • Mouse navigation.
  • Annotate bookmarks.
  • Different wrapping modes.
  • Different bookmarks styles, line-only, fringe-only or both.
  • Persistent bookmarks (buffer local), also in non-file buffers (info) and indirect buffers.
  • List bookmarks (in all buffers) in a separate buffer.
  • Cycle through bookmarks in all open buffers.

Known Limitations:

There are some incompatibilities with lazy-lock when using fill-paragraph. All bookmark below the paragraph being filled will be lost. This issue can be resolved using the `jit-lock-mode'.

Installation:

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

(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)

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)

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)

If you would like the markers on the right fringe instead of the left, add the following line:

(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)

If you would like to cycle through bookmarks in all open buffers, add the following line:

(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)

or if you want use this feature in your library:

(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)

Configuring bm.el with use-package:

Configuring bm.el with 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))
         )

Reviews and comments:

bm's People

Contributors

darth10 avatar drothlis avatar dsedivec avatar jixiuf avatar joodland avatar pataquets avatar snowman avatar sten0 avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bm's Issues

Go to bookmark with helm

helm

The idea is basically the same helm-mark-ring

Here is some prototype code for this (by me GPL license)

(defvar bm-helm--buffer nil "Buffer that bm-helm is running on")
(require 'bm)
(defun bm-helm ()
  (interactive)
  (setq bm-helm--buffer (current-buffer) )
  (helm :sources (list (bm-helm--source))))

(defun bm-helm--source ()
  (list
   (cons 'name "Jump to bm bookmark")
   (cons 'action (bm-helm--actions))
   (cons 'candidates 'bm-helm--candidates)))

(defun bm-helm--actions ()
  "Actions for used by helm.  On return run DEFAULT-ACTION."
  (list
   (cons "Default action" 'bm-helm--goto)
   (cons "Goto action" 'bm-helm--goto)))

(defun bm-helm--goto (x)
  (interactive)
  (message "Goto %S" x)
  (with-current-buffer bm-helm--buffer
    (bm-goto x)))

(defun bm-helm--candidates ()
  (with-current-buffer bm-helm--buffer
    (mapcar (lambda (overlay)
              (cons (bm-helm--line overlay) overlay))
            (bm-overlays-lifo-order bm-cycle-all-buffers))))

(defun bm-helm--line (overlay)
  (save-excursion
    (goto-char (overlay-start overlay))
    (s-trim (thing-at-point 'line))))

"args out of range" error when quitting emacs with persistent bookmarks set outside of narrowed region

If persistent bookmarks are set somewhere, e.g., the first line, and the remaining part of the buffer is then narrowed down (narrow-to-region), bm will show "args out of range" error when I quit emacs. Non-file buffers don't have the problem.
My bm settings:

(setq-default bm-buffer-persistence t)
(setq bm-restore-repository-on-load t
      bm-highlight-style 'bm-highlight-only-fringe)

(add-hook 'after-init-hook 'bm-repository-load)
(add-hook 'find-file-hooks 'bm-buffer-restore)
(add-hook 'kill-buffer-hook 'bm-buffer-save)
(add-hook 'kill-emacs-hook '(lambda nil
                  (bm-buffer-save-all)
                  (bm-repository-save)))
(add-hook 'after-save-hook 'bm-buffer-save)
(add-hook 'after-revert-hook 'bm-buffer-restore)
(add-hook 'vc-before-checkin-hook 'bm-buffer-save)

Backtrace:

Debugger entered--Lisp error: (args-out-of-range #<buffer bm-test.el> 1 326)
  buffer-substring-no-properties(326 1)
  (let ((context-start (max (point-min) (- position bm-bookmark-context-size)))) (buffer-substring-no-properties context-start position))
  (cons (quote before-context-string) (let ((context-start (max (point-min) (- position bm-bookmark-context-size)))) (buffer-substring-no-properties context-start position)))
  (list (cons (quote position) position) (cons (quote time) (overlay-get bm (quote time))) (cons (quote temporary-bookmark) (overlay-get bm (quote temporary-bookmark))) (cons (quote annotation) (overlay-get bm (quote annotation))) (cons (quote before-context-string) (let ((context-start (max (point-min) (- position bm-bookmark-context-size)))) (buffer-substring-no-properties context-start position))) (cons (quote after-context-string) (let ((context-end (min (+ position bm-bookmark-context-size) (point-max)))) (buffer-substring-no-properties position context-end))))
  (let ((position (marker-position (overlay-get bm (quote position))))) (list (cons (quote position) position) (cons (quote time) (overlay-get bm (quote time))) (cons (quote temporary-bookmark) (overlay-get bm (quote temporary-bookmark))) (cons (quote annotation) (overlay-get bm (quote annotation))) (cons (quote before-context-string) (let ((context-start (max (point-min) (- position bm-bookmark-context-size)))) (buffer-substring-no-properties context-start position))) (cons (quote after-context-string) (let ((context-end (min (+ position bm-bookmark-context-size) (point-max)))) (buffer-substring-no-properties position context-end)))))
  (lambda (bm) (let ((position (marker-position (overlay-get bm (quote position))))) (list (cons (quote position) position) (cons (quote time) (overlay-get bm (quote time))) (cons (quote temporary-bookmark) (overlay-get bm (quote temporary-bookmark))) (cons (quote annotation) (overlay-get bm (quote annotation))) (cons (quote before-context-string) (let ((context-start (max ... ...))) (buffer-substring-no-properties context-start position))) (cons (quote after-context-string) (let ((context-end (min ... ...))) (buffer-substring-no-properties position context-end))))))(#<overlay from 1 to 78 in bm-test.el>)
  mapcar((lambda (bm) (let ((position (marker-position (overlay-get bm (quote position))))) (list (cons (quote position) position) (cons (quote time) (overlay-get bm (quote time))) (cons (quote temporary-bookmark) (overlay-get bm (quote temporary-bookmark))) (cons (quote annotation) (overlay-get bm (quote annotation))) (cons (quote before-context-string) (let ((context-start (max ... ...))) (buffer-substring-no-properties context-start position))) (cons (quote after-context-string) (let ((context-end (min ... ...))) (buffer-substring-no-properties position context-end)))))) (#<overlay from 1 to 78 in bm-test.el>))
  (let ((bookmarks (bm-lists))) (mapcar (function (lambda (bm) (let ((position (marker-position ...))) (list (cons (quote position) position) (cons (quote time) (overlay-get bm ...)) (cons (quote temporary-bookmark) (overlay-get bm ...)) (cons (quote annotation) (overlay-get bm ...)) (cons (quote before-context-string) (let ... ...)) (cons (quote after-context-string) (let ... ...)))))) (append (car bookmarks) (cdr bookmarks))))
  (cons (quote bookmarks) (let ((bookmarks (bm-lists))) (mapcar (function (lambda (bm) (let ((position ...)) (list (cons ... position) (cons ... ...) (cons ... ...) (cons ... ...) (cons ... ...) (cons ... ...))))) (append (car bookmarks) (cdr bookmarks)))))
  (list (bm-buffer-file-name) (cons (quote version) bm-bookmark-repository-version) (cons (quote size) (point-max)) (cons (quote timestamp) (current-time)) (cons (quote bookmarks) (let ((bookmarks (bm-lists))) (mapcar (function (lambda (bm) (let (...) (list ... ... ... ... ... ...)))) (append (car bookmarks) (cdr bookmarks))))))
  (let ((buffer-data (list (bm-buffer-file-name) (cons (quote version) bm-bookmark-repository-version) (cons (quote size) (point-max)) (cons (quote timestamp) (current-time)) (cons (quote bookmarks) (let ((bookmarks ...)) (mapcar (function ...) (append ... ...))))))) (bm-repository-remove (car buffer-data)) (let ((count (length (cdr (assoc (quote bookmarks) buffer-data))))) (if (> count 0) (bm-repository-add buffer-data)) (if (called-interactively-p (quote interactive)) (message "%d bookmark(s) saved to repository." count))))
  (if bm-buffer-persistence (let ((buffer-data (list (bm-buffer-file-name) (cons (quote version) bm-bookmark-repository-version) (cons (quote size) (point-max)) (cons (quote timestamp) (current-time)) (cons (quote bookmarks) (let (...) (mapcar ... ...)))))) (bm-repository-remove (car buffer-data)) (let ((count (length (cdr (assoc ... buffer-data))))) (if (> count 0) (bm-repository-add buffer-data)) (if (called-interactively-p (quote interactive)) (message "%d bookmark(s) saved to repository." count)))) (if (called-interactively-p (quote interactive)) (message "No bookmarks saved. Buffer is not persistent.")))
  (if (bm-buffer-file-name) (if bm-buffer-persistence (let ((buffer-data (list (bm-buffer-file-name) (cons (quote version) bm-bookmark-repository-version) (cons (quote size) (point-max)) (cons (quote timestamp) (current-time)) (cons (quote bookmarks) (let ... ...))))) (bm-repository-remove (car buffer-data)) (let ((count (length (cdr ...)))) (if (> count 0) (bm-repository-add buffer-data)) (if (called-interactively-p (quote interactive)) (message "%d bookmark(s) saved to repository." count)))) (if (called-interactively-p (quote interactive)) (message "No bookmarks saved. Buffer is not persistent."))) (if (called-interactively-p (quote interactive)) (message "Unable to save bookmarks in non-file buffers.")))
  bm-buffer-save()
  (lambda (buffer) (set-buffer buffer) (bm-buffer-save))(#<buffer bm-test.el>)
  mapc((lambda (buffer) (set-buffer buffer) (bm-buffer-save)) (#<buffer bm-test.el> #<buffer  *Minibuf-1*> #<buffer *scratch*> #<buffer  *Minibuf-0*> #<buffer *Messages*> #<buffer  *code-conversion-work*> #<buffer  *Echo Area 0*> #<buffer  *Echo Area 1*> #<buffer *Disabled Command*> #<buffer *Help*>))
  (save-current-buffer (mapc (function (lambda (buffer) (set-buffer buffer) (bm-buffer-save))) (buffer-list)))
  bm-buffer-save-all()
  (lambda nil (bm-buffer-save-all) (bm-repository-save))()
  kill-emacs()
  save-buffers-kill-emacs()

persp-mode compatible?

projectile or persp-mode or whatever, right now it goes jumping around between unrelated projects, perspectives, etc.

Return to original window when bm-cycle-all-buffers?

When bm-cycle-all-buffers is true, is it possible to make bm-next and bm-previous jump to the original window where the bookmark was defined instead of opening the bookmark buffer in the current window?

I like to have multiple windows open, each with its own unique buffer, and I was hoping to set a bookmark in each window and then use bm-next and bm-previous to jump from window to window to each of the bookmarks.

Instead it jumps from buffer to buffer in the current window, which might be a nice option for some work flows, but not what I was hoping.

Integrating bm with org-mode: expanding tree on jump

Hi bm-mode developers,

Thanks very much for an incredibly useful mode which I have been using daily for many years. I'd like to improve my workflow with regards to how bm integrates with org-mode, but I did not manage to find any solutions via googling. My basic problem is that I tend to collapse org documents a lot, as they are quite large, and then make use of bm to find particular spots of interest as required. However, the problem then is that the tree does not uncollapse as I move to the bookmark. Apparently a similar issue is face with traditional bookmakrs [1, 2], and it is addressed by the following function: org-bookmark-jump-unhide. It is used like so:

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

My question is: what is the bm equivalent to bookmark-after-jump-hook so that I can bind this function in a similar fashion? I assume bm does not use this hook as I tried this binding to no avail, but if my assumption is incorrect do let me know.

Many thanks for your time.

[1] SO: bookmark-jump to org-mode file with collapsed headings not working as expected
[2] SO: Go to a bookmark that is not visible currently due to narrowing

bm-buffer-save: Wrong type argument: listp, \.\.\.

When bm-buffer-persistence is t, it looks like it's trying to save all bm information.

However, it doesn't seem to work.

I got

bm-buffer-save: Wrong type argument: listp, \.\.\.

The Backtrace shows

  bm-repository-remove("/Users/ysong/org/personal/data/98/7982F8-57F5-4B57-8959-697522A860FE/MonkeyIsland2-Walkthrough-Daniel2.txt")
  bm-buffer-save()
  #f(compiled-function (buffer) #<bytecode 0x1fef21e97305>)(#<buffer MonkeyIsland2-Walkthrough-Daniel2.txt<7982F8-57F5-4B57-8959-697522A860FE>>)
  mapc(#f(compiled-function (buffer) #<bytecode 0x1fef21e97305>) (#<buffer *Messages*> #<buffer bm.el> #<buffer  *Minibuf-1*> #<buffer *Help*> #<buffer todo_personal_project.org> #<buffer note_emacs.org> #<buffer *scratch*> #<buffer MonkeyIsland2-Walkthrough-Daniel2.txt<7982F8-57F5-4B57-8959-697522A860FE>> #<buffer *spacemacs*> #<buffer  *Minibuf-0*> #<buffer  *code-conversion-work*> #<buffer  *Echo Area 0*> #<buffer  *Echo Area 1*> #<buffer MonkeyIsland2-Walkthrough-Daniel.txt> #<buffer MonkeyIsland2-Walkthrough-Daniel2.txt<MonkeyIsland2>> #<buffer MonkeyIsland2-Walkthrough.txt> #<buffer magit: .spacemacs.d<4>> ...))
  bm-buffer-save-all()

Could you figure out why it happens?

emacs 29.0.60: bm-lists is broken

Due to a bug in the current emacs git head (29.0.60, https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60058), bm.el does not work at all as overlays-list is broken. The following snippet provides a work around for now:

(defun bm-lists (&optional direction predicate)
  "Return a pair of lists giving all the bookmarks of the current buffer.
The car has all the bookmarks before the overlay center;
the cdr has all the bookmarks after the overlay center.
A bookmark implementation of `overlay-lists'.

If optional argument DIRECTION is provided, only return bookmarks
in the specified direction.

If optional argument PREDICATE is provided, it is used as a
selection criteria for filtering the lists."
  (if (null predicate)
    (setq predicate 'bm-bookmarkp))

  (overlay-recenter (point))
  (cond ((equal 'forward direction)
         (cons nil (remq nil (mapcar predicate (overlays-in (point) (point-max))))))
        ((equal 'backward direction)
         (cons (remq nil (mapcar predicate (overlays-in (point-min) (point)))) nil))
        (t
         (cons
          (remq nil (mapcar predicate (overlays-in (point-min) (point))))
          (remq nil (mapcar predicate (overlays-in (point) (point-max))))))))

Please tag 20170815.1609 as a stable release

Dear Jo,

Thank you for maintaining bm.el. As 20170815.1609 has been in use for almost a year now, would you please consider tagging it as a stable release?

The Debian Emacsen Team is currently in the process of transitioning from emacs-goodies-el to a set of ELPA and MELPA packages. As we have a policy of only using tagged releases it would be a shame to use 201610, which only has 321 downloads rather than 20170815.1609 which is clearly the version most people want, as it has 11 531 downloads.

Thank you :-)
Nicholas

Option to silence "2 bookmark(s) restored." messages

First of all, many thanks for bm. I have used it for years. 8-)

Is there a way to silence those "2 bookmark(s) restored." messages?

Package dtrt-indent, for example, has a setting dtrt-indent-verbosity to make it less chatty.

Bookmark loses track of correct line

Follow these steps and the bookmark will lose track of the correct line number to jump to:

  1. Create a new file with 4 lines
  2. Put a bookmark on lines 1 and 3
  3. With the cursor at the beginning of line 3, insert a newline
  4. Call bm-next and bm-previous to see that the second bookmark is now on the unmarked line. Also, notice that wrapping doesn't work with bm-next. It only works with bm-previous.

Add tags for MELPA Stable

Could you please add tags when a release is ready so MELPA Stable will pick it up? Thanks.

MELPA, of course, grabs the tip of the master branch, but stable only grabs tagged releases.

Not sincronize with bookmark-alist

Hello,

The function ivy-switch-buffer use the build in variable bookmark-alist to incorporate bookmarks to its options, but with bm the variable bookmark-alist has always nil value.
The code (load-bookmark bm-repository-file) says that the bm-repository-file is not in the "standard form".

Is there a way to get bookmark-alist syncronized with bm-repository-file or at least a way to get a file in "standard form" with the bookmarks of bm-repository-file??

Thank you very much.

bookmark in LIFO order not work as expect

For example, when there are three bookmarks in the current buffer,
and then remove the last bookmark, then run bm-previous,
the point goes to the first bookmark instead of the second bookmark.

The script to reproduce:

;; FILE: /tmp/reproduce.el
;;
;; $ emacs -Q -nw -l bm.el /tmp/reproduce.el
;;
;; In Emacs:
;; 1. M-x end-of-buffer RET
;; 2. M-x edebug-defun  RET

(progn
  ;; prepare bookmarks
  (require 'bm)
  (save-excursion
    (goto-line 1) (bm-bookmark-add)
    (goto-line 3) (bm-bookmark-add)
    (goto-line 5) (bm-bookmark-add)
    (bm-bookmark-remove) ;; remove the 3rd bookmark
    )

  (progn
    (goto-char (point-max))
    (setq bm-in-lifo-order t)
    (bm-previous)
    (when (equal (point) (point-min))
      (message "Point in the first bookmark, but shouldn't be in the second bookmark?")))
  )

Feature request - show markers in terminal emacs

It would be great if bookmark markers could be shown in terminal emacs.

Since terminal emacs doesn't have the fringe, they obviously can't go there. So there has to be some other way to display them.

Perhaps overlays could be used, with user-configurable properties, such as background and/or foreground color.

This way, maybe bookmarked lines could be indicated with, say, a user-configurable background color on lines that have bookmarks.

Allowing these markers to be toggled on and off would prevent them from permanently interfering with existing text properties or overlays in the buffer.

Help with setting up persistance

I'm trying to make the bm bookmarks persistent across sessions (and load when the file is opened).
This is my setup based on my understanding now:

(use-package bm
         :ensure t
         :diminish helm-mode
         :init
         (progn
           (setq bm-repository-size 100) ; nil means unlimitted
           (setq bm-marker 'bm-marker-left)
           (setq bm-highlight-style 'bm-highlight-only-fringe)
           (setq-default bm-buffer-persistence t)
           (setq-default bm-repository-file "~/.emacs.d/data/bm-bookmarks")
           (setq bm-restore-repository-on-load t)
           )
         :bind
         (("<M-S-f1>" . bm-toggle)
          ("<M-f1>" . bm-next)
          ("<S-f1>" . bm-previous))
         :config
         (progn (
                 (add-hook' after-init-hook 'bm-repository-load)
                 (add-hook 'find-file-hooks 'bm-buffer-restore)
                 (add-hook 'kill-buffer-hook 'bm-buffer-save)
                 (add-hook 'kill-emacs-hook '(lambda nil
                                               (bm-buffer-save-all)
                                               (bm-repository-save)))
                 )))

While I don't get errors (and the bookmarks work), the repository file is never created or loaded.
Any idea what am I doing incorrectly?

Thank you very much!

Please include full-text copy of GPL-2+ as LICENSE or COPYRIGHT

Hi Jo,

Today I was surprised to discover that bm still isn't in Debian, so I reviewed the package again, and found that a full-text copy of the GPL-2+ was missing. I think there's a github button that will add it as either LICENSE or COPYRIGHT. Alternatively, here is a link for your convenience: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

Sorry I missed this back in July! Would you please tag another stable release after adding this file?

Thanks,
Nicholas

Feature request - show all bookmarks

Hi Jo,

Please could you add a function which will display all bookmarks that exist, not just those in open buffers.
Currently, you have to open a file before the bookmarks become available. Instead, it would be nice to use the bookmark list as an entry point to opening files.

bm bookmarks arent saved

Hi. i love using bm yet for the life if me i cant get them to save between sessions. i added the following config after googling to try and get the bm's to be persistant

(use-package bm
 :ensure t
 :config
;;restore on load (even before you require bm)
(setq bm-restore-repository-on-load t)

(require 'bm)
;; 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)

   ;; Restoring bookmarks when on file find.
   (add-hook 'find-file-hooks 'bm-buffer-restore)


;; 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.
      (defun modi/bm-save-all-bm-to-repository ()
        (bm-buffer-save-all)
        (bm-repository-save))
      (add-hook 'kill-emacs-hook #'modi/bm-save-all-bm-to-repository)
      (add-hook 'after-save-hook #'bm-buffer-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.


      ;; 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)
 )

im using arch linux with latest emacs (24.4) and latest bm from MELPA

from the above config i should see the bm saves in ~/.emacs.d/bm-repository correct?
the current file has nothing in it:

;; bm.el -- persistent bookmarks. Do not edit this file.
nil

any clue?

thx

Z

Feature request - add total bookmarks in buffer to the modeline

It would be handy if the total number of bookmarks in the current buffer could be included in the modeline, something simple like this is would do....

BM: 6

This allows a quick glance to see if there are actually any bookmarks in the buffer (6 in this case) without having to open a new window with bm-show

This is a great package by the way, very useful, thanks for creating it

persistence?

I have the following setup:

(use-package bm
  :ensure t
  :config
  (setq bm-in-lifo-order t)
  (setq bm-cycle-all-buffers t)
  (setq bm-repository-file "~/.emacs.d/bm")
  (setq-default bm-buffer-persistence t)
  (add-hook' after-init-hook 'bm-repository-load)
  (add-hook 'kill-buffer-hook #'bm-buffer-save)
  (add-hook 'after-save-hook #'bm-buffer-save)
  (add-hook 'kill-emacs-hook #'(lambda nil
				 (bm-buffer-save-all)
				 (bm-repository-save)))
  (add-hook 'find-file-hooks   #'bm-buffer-restore)
  (add-hook 'after-revert-hook #'bm-buffer-restore)
  (global-set-key (kbd "<C-f2>") 'bm-toggle)
  (global-set-key (kbd "<f2>")   'bm-next)
  (global-set-key (kbd "<S-f2>") 'bm-previous)
  (global-set-key (kbd "M-<f2>") 'bm-show-all))

yet for some reason nothing is persisting. Yes, the folder "bm" does exist but it is sadly empty.

persistence not working

Hi there, I copied the suggested customization but I can't seem to get persistence working. The only change I made was in saving them to my ~/.emacs.d/bm/ folder.

Here is my code:

(use-package bm
         :ensure t
         :demand t
         :init
         ;; restore on load (even before you require bm)
         (setq bm-restore-repository-on-load t)
         :config
         (setq bm-cycle-all-buffers t)
         (setq bm-repository-file "~/.emacs.d/bm") ;; yes there is a folder called ~/.emacs.d/bm
         (setq-default bm-buffer-persistence t)
         (add-hook' after-init-hook 'bm-repository-load)
	 
         (add-hook 'find-file-hooks 'bm-buffer-restore)
         (add-hook 'kill-buffer-hook #'bm-buffer-save)
         (add-hook 'kill-emacs-hook #'(lambda nil
                                          (bm-buffer-save-all)
                                          (bm-repository-save)))
         (add-hook 'after-save-hook #'bm-buffer-save)
         (add-hook 'find-file-hooks   #'bm-buffer-restore)
         (add-hook 'after-revert-hook #'bm-buffer-restore)
         (add-hook 'vc-before-checkin-hook #'bm-buffer-save)
         :bind (("<f2>" . bm-next)
                ("S-<f2>" . bm-previous)
                ("C-<f2>" . bm-toggle))
         )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.