1

I've recently started using the BookmarkPlus package and I've been loving it. However there is one thing that I can't seem to figure out. I want, from my big list of bookmarks, to create a set of smaller lists, that would function as sort of projects, so I can have only the bookmarks related to a certain project in the *Bookmark List* visible.

Edit: Maybe I should also mention I'm working on Windows 10 with the windows version of emacs. What I tried was this (It was based on the description here).

I will describe my problem in the form of a minimum working example. Let's say we have a bookmark file with three bookmarks:

Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp

All Bookmarks
-------------
 t  file A                  fileA.txt
 t  file B                  fileB.txt
 t  file C                  fileC.txt

with tags:

  • file A has tag proj1
  • file B has tag proj2
  • file C has tag proj1

Then to view just the files from "Project 1", I do one of the following:

  • In the *Bookmark List* buffer use P T proj1 <ret> which gives me the filtered view:
Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp

Bookmarks with Tags Matching Regexp `proj1'
-------------------------------------------
 t  file A              fileA.txt
 t  file C              fileC.txt

Now I wish to save this view as for later use so I do C-x r m Project1 <ret>. This throws me back to the bookmark list with a new bookmark like so:

Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp

All Bookmarks
-------------
 t  file A                  fileA.txt
 t  file B                  fileB.txt
 t  file C                  fileC.txt
    Project1                *Bookmark List*

Now when I go to the bookmark Project1 and press <ret>, I expect to get back to the filtered view like above, yet this does not happen and doing so simply moves point to the bookmark file A.

  • The second approach is much the same, except instead of filtering with P T I use T m * proj1 <ret> <ret> to first tag the files and then filter them with > and again save with C-x r m. The end result is the same.

My init file for the example is the following

(let ((default-directory  "~/.emacs.d/packages/"))
  (normal-top-level-add-subdirs-to-load-path))

(require 'bookmark+)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(bmkp-last-as-first-bookmark-file "c:/Users/me/.emacs.d/bookmark_test.bmkp")
 '(bookmark-default-file "~/.emacs.d/bookmark_test.bmkp"))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

The file bookmark_test.bmkp looks like:

;;;; Emacs Bookmark Format Version 1 ;;;; -*- coding: utf-8 -*-
;;; This format is meant to be slightly human-readable;
;;; nevertheless, you probably don't want to edit it.
;;; -*- End Of Bookmark File Format Version Stamp -*-
(#1=(#("file C" 0 6
      (bmkp-full-record #1#))
    (tags "proj1")
    (filename . "~/Documents/fileC.txt")
    (buffer-name . "fileC.txt")
    (front-context-string)
    (rear-context-string . "s the last file.")
    (front-context-region-string)
    (rear-context-region-string)
    (visits . 1)
    (time 24513 1396 891997 0)
    (created 24512 60521 908157 0)
    (position . 23))
#1=(#("file B" 0 6
      (bmkp-full-record #1#))
    (tags "proj2")
    (filename . "~/Documents/fileB.txt")
    (buffer-name . "fileB.txt")
    (front-context-string)
    (rear-context-string . "is the last one.")
    (front-context-region-string)
    (rear-context-region-string)
    (visits . 1)
    (time 24513 355 491409 0)
    (created 24512 60464 541235 0)
    (position . 69))
#1=(#("file A" 0 6
      (bmkp-full-record #1#))
    (tags "proj1")
    (filename . "~/Documents/fileA.txt")
    (buffer-name . "fileA.txt")
    (front-context-string)
    (rear-context-string . "t has two lines.")
    (front-context-region-string)
    (rear-context-region-string)
    (visits . 0)
    (time . #2=(24512 60394 692321 0))
    (created . #2#)
    (position . 42))
)

Saving the filtered view adds the following bookmark to the bookmark file:

(#1=(#("Project1" 0 8
      (bmkp-full-record #1#))
    (buffer-name . "*Bookmark List*")
    (visits . 1)
    (time 24513 2965 108585 0)
    (created 24513 2958 669730 0)
    (position . 147)
    (filename . "   - no file -")
    (bookmark-list
     (last-sort-comparer
      (bmkp-info-node-name-cp bmkp-gnus-cp bmkp-url-cp bmkp-local-file-type-cp)
      bmkp-alpha-p)
     (last-reverse-sort-p)
     (last-reverse-multi-sort-p)
     (last-bmenu-filter-function)
     (last-bmenu-filter-pattern . "proj1")
     (last-bmenu-omitted-bookmarks)
     (last-bmenu-title . "")
     (last-bmenu-toggle-filenames . t))
    (handler . bmkp-jump-bookmark-list))

1 Answer 1

1

You don't give details of what you tried, but from your use case it sounds like the best approach is to create one or more bookmark-list bookmarks. Jumping to such a bookmark opens the bookmark-list display state that was bookmarked.

For that, you should be able to just use C-x r m in the bookmark-list display, once you have it the way you want it, to create a bookmark recording its state. When you later jump to that bookmark you should see that state you recorded.

For example, do this in the bookmark-list display:

  1. I S, to show only Info bookmarks (bookmarks to Info manual pages). (Using menu Bookmark+ this is Show > Only Bookmarks of Type > Info Nodes.)

  2. C-x r m, and enter a name for the bookmark to be created.

Later, to restore the bookmark-list display to what was recorded, just jump to that bookmark.

As you mentioned, there are other, related ways to record a bookmark-list display, depending on what you need. But this one is quite simple, and from what you describe it should do what you want.

Maybe you need to give more details about the filtering you are doing.


UPDATE after you added more detail in the question (thanks).

  1. A bookmark-list display state arrived at with incremental pattern matching (e.g. P T), as opposed to, say using a filtering command (I gave an example of that, above), was not captured in a bookmark-list bookmark. I fixed that (i.e., implemented that missing feature) yesterday, having guessed that that's maybe what you tried. (Had you happened to download yesterday's bookmark+-bmu.el that would have been fixed.)

  2. As the doc says, markings are not captured by bookmark-list bookmarks. They are also not captured by the commands you create using C-c C-c (command bmkp-bmenu-define-command) -- that captures only the current sort order, filter, and omit list.

  3. As the doc also says, markings are captured by the much heavier-weight C-c C-S-c (aka C-c C-C, command bmkp-bmenu-define-full-snapshot-command). That captures pretty much everything, at the cost of storing a full bookmark list, list of markings, etc.

  4. However, there were some bugs in #3 (C-c C-C). I've think I've fixed those today.

Please try the latest bookmark+-bmu.el. And please read up again on the differences between the different ways of capturing and restoring bookmark-list state. Each method has its advantages.


BTW, if you turn off option bmkp-propertize-bookmark-names-flag then the bookmark list you copy and paste somewhere (e.g. here) is much simpler to read and understand. It then has no shared structure that allows for multiple bookmarks with the same name but different behavior/targets. The toggle command for flipping this option value is bmkp-toggle-propertize-bookmark-names. It's also Bookmark+ menu item Toggle > Allowing Identical Bookmark Names.

The ability to have multiple bookmarks with the same name is importantly primarily for autofile bookmarks, whose names are their relative file names: you can have multiple files named foo.el in different directories..

3
  • You're right, I added a more detailed explanation of my problem
    – burek
    Commented Nov 27, 2020 at 14:29
  • Works perfectly. Thank you so much!! Also thanks for the tip.
    – burek
    Commented Nov 28, 2020 at 11:48
  • Glad it helped. Thanks for the question, which motivated me to take care of the relevant longstanding issues/lacks.
    – Drew
    Commented Nov 28, 2020 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.