5.5 The Preset Data Structure and Programatically Creating Sessions

p-search supports creating sessions from data, as opposed to being manually created by users. Preset plists are the data structures that support this functionality. It should be possible to reproduce any p-search session with a preset plist. A preset plist is defined by the following structure:

The following is an example of a preset plist with multiple items in it.

(:group ((:candidate-generator p-search-candidate-generator-filesystem :args ((base-directory . "/Users/zacharyromero/dev/emacs/emacs/") (filename-regexp . ".*") (search-tool . :rg) (use-git-ignore . on)))
         (:prior-template p-search-prior-query :args ((query-string . "list") (importance . medium)))
         (:prior-template p-search-prior-query :args ((query-string . "cons") (importance . medium)))
         (:prior-template p-search-prior-git-author :args ((git-author . Richard\ M.\ Stallman) (importance . medium)))
         (:prior-template p-search-prior-name :args ((name . ".c") (importance . medium)))))

Remember, in a p-search session you can run the command p-search-show-session-preset to view the current session as a preset plist.

Once you have the preset plist, you can pass it as the first argument to the p-search-setup-buffer function to create a session with that preset. You can also set the variable p-search-default-command-behavior to a preset to configure p-search to create a session of your choosing (see Starting a session).

Function: p-search-setup-buffer &optional preset-plist

Start a p-search session. If a preset plist is provided, the session will be created with the preset instantiated.