Insert in the buffer the @emph{contents} of the file that bookmark
@var{bookmark} points to.
@end table
+
+@cindex bookmark types
+@cindex types of bookmarks
+ Bookmarks can also record positions in buffers that are not visiting
+any file, such as web pages that you browse with EWW
+(@pxref{Top,EWW,,eww,}). While jumping to a regular bookmark simply
+visits the corresponding file, different @dfn{bookmark types} can do
+different things when you jump to them. As an example, EWW bookmarks
+store a URL instead of a file name, and jumping to such an EWW
+bookmark opens that URL in EWW.
+
+When you specify a bookmark name in the minibuffer in response to a
+prompt from one of the above commands, you can use @kbd{C-x n m} to
+restrict the list of bookmark completion candidates to only include
+bookmarks of a given type.
*** New commands for narrowing (restricting) minibuffer completions list.
You can now use 'C-x n n' ('minibuffer-narrow-completions-to-current')
in the minibuffer to restrict the list of possible completions to only
-include candidates matching the current minibuffer input. See the
-Info node "(emacs) Narrow Completions" for more information.
+include candidates matching the current minibuffer input. New command
+'C-x n m' ('minibuffer-narrow-completions') is similar, but uses an
+alternative restriction method that depends on the relevant completion
+candidates. For example, commands that read an Elisp symbol let you
+restrict the completions list with 'C-x n m' to only include symbols
+with a given property. Similarly, commands that read a bookmark name
+let you restrict the completions list to only include bookmarks of a
+given type. See the new Info node "(emacs) Narrow Completions" for
+more information.
*** New minor mode 'completions-auto-update-mode'.
This global minor mode automatically updates the *Completions* buffer
(completing-read (format-prompt prompt default)
(lambda (string pred action)
(if (eq action 'metadata)
- '(metadata (category . bookmark))
+ '(metadata
+ (category . bookmark)
+ (narrow-completions-function
+ . bookmark-narrow-completions-by-type))
(complete-with-action
action bookmark-alist string pred)))
nil 0 nil 'bookmark-history default))))
+(defun bookmark-narrow-completions-by-type ()
+ "Restrict bookmark completions list to bookmarks of a given type."
+ (let* ((get-type
+ (lambda (bmk-record)
+ (let ((res (bookmark-type-from-full-record bmk-record)))
+ (if (and res (not (string-empty-p res))) res "Regular"))))
+ (types (delete-dups (mapcar get-type bookmark-alist)))
+ (type (completing-read "Keep bookmark completions of type: "
+ types nil t)))
+ (cons (lambda (cand &rest _)
+ (let ((string (cond
+ ((stringp cand) cand)
+ ((symbolp cand) (symbol-name cand))
+ (t (car cand)))))
+ (string= type (funcall get-type (assoc string bookmark-alist)))))
+ (concat "bookmark type " (prin1-to-string
+ (substring-no-properties type))))))
(defmacro bookmark-maybe-historicize-string (string)
"Put STRING into the bookmark prompt history, if caller non-interactive.