Emacs lisp - auto-complete bookmark names

I am new to elisp. http://www.gnu.org/s/emacs/manual/html_node/elisp/Interactive-Codes.html#Interactive-Codes lists code characters for interactive parameters that AFAIK changes the behavior of the input mechanism when a user requests input (for example: if you indicate that the input is the name of the file that exists, the emacs autocomplete functionality will look for the names of the files that exist).

I'm trying to find code for a bookmark name that already exists, that is: emacs will prompt the user to enter a bookmark name, and when you click the tab, emacs will show possible replenishment of the bookmark name.

Is there such a code?

+5
source share
2 answers

Use for this completing-read. You can write a function that asks the user for this bookmark:

(defun my-function ()
  (interactive)
  (let ((bookmark (completing-read "Bookmark: " (bookmark-all-names))))
    ...))

If you prefer the invitation to be part interactive(so that the result will be automatically bound to your function arguments), you can use the following alternative:

(defun my-function (bookmark)
  (interactive (list (completing-read "Bookmark: " (bookmark-all-names))))
  ...)

In order for Emacs to find the function bookmark-all-names, you also need to add the following line to the .emacs file:

(require 'bookmark)
+1
source

A function bookmark-completing-readis a standard way to populate a bookmark name. You do not need a lower level function for this completing-read. Example:

    (bookmark-completing-read "Bookmark" bookmark-current-bookmark)

+, bookmark-completing-read ( completing-read), :

  • ALIST - ( : bookmark-alist)

  • PRED - ,

  • HIST -

bmkp-completing-read-lax, , .

+1

All Articles