;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\303\304\305\306\307\310\311\312\313\314& \210\315\316\317\320\321DD\322\323\324%\210\315\325\317\320\326DD\327\323\324%\210\315\330\317\320\331DD\332\323\324%\210\315\333\317\320\334DD\335\323\336%\210\315\337\317\320\340DD\341\323\342%\210\315\343\317\320\344DD\345\323\346%\210\315\347\317\320\350DD\351\323\352%\210\315\353\317\320\354DD\355\323\352%\210\315\356\317\320\357DD\360\323\352%\210\315\361\317\320\362DD\363\323\352%\210\315\364\317\320\365DD\366\323\367%\207" [require cl-lib subr-x custom-declare-group prescient nil "Simple but effective candidate sorting by usage." :group convenience :prefix "prescient-" :link (url-link "https://github.com/raxod502/prescient.el") custom-declare-variable prescient-history-length funcall function #[0 "\300\207" [100] 1] "Number of recently chosen candidates that will be remembered." :type number prescient-frequency-decay #[0 "\300\207" [0.997] 1] "Rate at which frequently chosen candidates will be forgotten.\nEvery time a candidate is selected, all candidates are multiplied\nby this factor. See also `prescient-frequency-threshold'." prescient-frequency-threshold #[0 "\300\207" [0.05] 1] "Threshold for forgetting about a frequently chosen candidate.\nAny candidates with frequencies less than this after a selection\nwill be discarded. See also `prescient-frequency-decay'." prescient-save-file #[0 "\301\302\"\207" [user-emacs-directory expand-file-name "var/prescient-save.el"] 3] "File in which to save usage information.\nThis only has an effect if `prescient-persist-mode' is enabled." file prescient-filter-method #[0 "\300\207" [(literal regexp initialism)] 1] "How to interpret prescient.el filtering queries.\nQueries are first split on spaces (with two consecutive spaces\nstanding for a literal space). Then, the candidates are filtered\nusing each subquery in turn. This variable affects how that\nfiltering takes place.\n\nValue `literal' means the subquery must be a substring of the\ncandidate. Supports char folding.\n\nValue `literal-prefix' means the first subquery must be the\nprefix of the candidate and the remaining subqueries must be\nprefixes of words in the candidate. Supports char folding.\n\nValue `regexp' means the subquery is interpreted directly as a\nregular expression.\n\nValue `initialism' means the subquery must match a substring of\nthe initials of the candidate.\n\nValue `fuzzy' means the characters of the subquery must match\nsome subset of those of the candidate, in the correct order but\nnot necessarily contiguous.\n\nValue `prefix' means the words (substrings of only word\ncharacters) match the beginning of words found in the candidate,\nin order, separated by the same non-word characters that separate\nwords in the query. This is similar to the completion style\n`partial'.\n\nValue `anchored' means words are separated by capital letters or\nsymbols, with capital letters being the start of a new word. This\nis similar to `prefix', but allows for less typing.\n\nValue can also be a list of any of the above methods, in which\ncase each method will be applied in order until one matches.\n\nFor backwards compatibility, the value of this variable can also\nbe `literal+initialism', which equivalent to the list (`literal'\n`initialism')." (set (const :tag "Literal" literal) (const :tag "Literal Prefix" literal-prefix) (const :tag "Regexp" regexp) (const :tag "Initialism" initialism) (const :tag "Fuzzy" fuzzy) (const :tag "Prefix" prefix) (const :tag "Anchored" anchored)) prescient-filter-alist #[0 "\300\207" [((literal . prescient-literal-regexp) (literal-prefix . prescient-literal-prefix-regexp) (initialism . prescient-initials-regexp) (regexp . prescient-regexp-regexp) (fuzzy . prescient-fuzzy-regexp) (prefix . prescient-prefix-regexp) (anchored . prescient-anchored-regexp))] 1] "An alist of filter methods and their functions.\n\nThese symbols can be included in `prescient-filter-method', and\ntheir corresponding functions will be used to create regexps for\nmatching candidates.\n\nA function should take the sub-query for which it should create a\nregexp, and keyword arguments of which there are currently:\n\n with-group \n subquery-number \n\nThe boolean keyword argument WITH-GROUP describes whether the\nfunction should enclose matched text in a capture group (such as\nwith `prescient-with-group'). Additionally, if the value is the\nsymbol `all', then literal substrings should be enclosed in\ncapture groups.\n\nThe integer keyword argument SUBQUERY-NUMBER states the order of\nhow the input has been split into individual subqueries (starting\nwith 0). For example, if the input was \"foo bar baz\" the\nfunction will be called three times:\n\n (fn \"foo\" :subquery-number 0)\n (fn \"bar\" :subquery-number 1)\n (fn \"baz\" :subquery-number 2)" (alist :key-type symbol :value-type function) prescient-sort-length-enable #[0 "\300\207" [t] 1] "Whether to sort candidates by length.\nIf non-nil, then candidates with identical recency and frequency\nwill be sorted by length. If nil, then they will be left in the\norder of the original collection.\n\nIt might be desirable to set this variable to nil (via\n`company-prescient-sort-length-enable') when working with a\nCompany backend which returns fuzzy-matched results that cannot\nusefully be sorted by length (presumably, the backend returns\nthese results in some already-sorted order)." boolean prescient-aggressive-file-save #[0 "\300\207" [nil] 1] "Whether to save the cache file aggressively.\nIf non-nil, then write the cache data to `prescient-save-file'\nafter the cache data is updated by `prescient-remember' when\n`prescient-persist-mode' is activated." prescient-sort-full-matches-first #[0 "\300\207" [nil] 1] "Whether to sort fully matched candidates before others.\n\nPrescient can sort by recency, frequency, and candidate length.\nWith this option, fully matched candidates will be sorted before\npartially matched candidates, but candidates in each group will\nstill be sorted like normal." prescient-use-char-folding #[0 "\300\207" [t] 1] "Whether certain literal filtering methods use character folding.\n\nThis affects the `literal' and `literal-prefix' filtering methods.\n\nIn Emacs versions 27 or greater, see also the customizable\nvariables `char-fold-include', `char-fold-exclude', and\n`char-fold-symmetric'." prescient-use-case-folding #[0 "\300\207" [smart] 1] "Whether filtering methods are case folding.\n\nIf t, always use case folding. If nil, never use case folding.\nIf `smart' (the default), use case folding only when the query\ncontains no upper-case letters." (choice (const :tag "Always" t) (const :tag "Never" nil) (const :tag "Unless using upper-case letters" smart))] 10) #@217 Hash table of recently chosen candidates. The keys are candidates as strings and the values are 0-based indices, less than `prescient-history-length'. The number of values will be at most `prescient-history-length'. (defvar prescient--history (make-hash-table :test 'equal) (#$ . 6895)) #@178 Return a list of the most recently chosen candidates as strings. The most recently chosen candidates are at the front of the list. This function is mostly useful for debugging. (defalias 'prescient--history-as-list #[0 "\302\303\"\304\305\306\" \"\210\307\303\310\303\"\"\207" [prescient-history-length prescient--history make-vector nil maphash make-closure #[514 "\3011\n\300I0\207\210\302\207" [V0 (error) nil] 5 "\n\n(fn CAND INDEX)"] cl-remove append] 6 (#$ . 7189)]) #@199 Hash table of frequently chosen candidates. The keys are candidates as strings and the values are frequencies (floating-point numbers). Frequencies will be at least `prescient-frequency-threshold'. (defvar prescient--frequency (make-hash-table :test 'equal) (#$ . 7675)) #@166 Non-nil if prescient.el data was loaded from `prescient-save-file'. Even if the load failed, this variable is still set to non-nil when `prescient--load' is called. (defvar prescient--cache-loaded nil (#$ . 7953)) #@187 Number of times `prescient-remember' has been called. This is used to determine which set of changes to the save file should "win" when two concurrent Emacs sessions want to modify it. (defvar prescient--serial-number 0 (#$ . 8174)) #@57 Current version number of `prescient-save-file' format. (defvar prescient--cache-version 5 (#$ . 8414)) #@281 Callback function called by loading `prescient-save-file'. A `funcall' to this variable is written to `prescient-save-file'. The function may produce errors; they will be ignored. Usually this variable is dynamically bound to another value while `prescient-save-file' is loaded. (defvar prescient-cache-callback 'ignore (#$ . 8525)) #@46 Load `prescient-save-file', ignoring errors. (defalias 'prescient--load-save-file #[0 "\302\3031\304 \305\306#0\202\210\302)\207" [load-source-file-function prescient-save-file nil (error) load noerror nomessag] 4 (#$ . 8865)]) #@39 Read data from `prescient-save-file'. (defalias 'prescient--load #[0 "\302\303 \210)\304\211\207" [prescient-cache-callback prescient--cache-loaded #[128 "\304\305\"\232\205\304\306\"\304\307\"\304\310\"\211\207" [prescient--cache-version prescient--history prescient--frequency prescient--serial-number plist-get :version :history :frequency :serial-number] 4 "\n\n(fn &rest ARGS)"] prescient--load-save-file t] 2 (#$ . 9104) nil]) #@38 Write data to `prescient-save-file'. (defalias 'prescient--save #[0 "\306C\307\310\"\306\211\311 \210\211\242\247\203 \242Y\205[\312\313\314\f!!\315\"\210\f\316\317\320\"\307\321\"\216r\211q\210\322\323\300\324\325 D\326\325D\327\325D\330\325 D\257\np\")rq\210\331\306\211\306\332%\210*\266\202+\207" [prescient-cache-callback print-length print-level prescient--serial-number prescient-save-file prescient--cache-version nil make-closure #[128 "\302\303\" \232\205\300\302\304\"\240\207" [V0 prescient--cache-version plist-get :version :serial-number] 5 "\n\n(fn &rest ARGS)"] prescient--load-save-file make-directory file-name-directory expand-file-name parents generate-new-buffer " *temp file*" t #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] print funcall :version quote :history :frequency :serial-number write-region 0 prescient--history prescient--frequency] 16 (#$ . 9555)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311\312\313\314\315& \207" [custom-declare-variable prescient-persist-mode funcall function #[0 "\300\207" [nil] 1] "Non-nil if Prescient-Persist mode is enabled.\nSee the `prescient-persist-mode' command\nfor a description of this minor mode.\nSetting this variable directly does not take effect;\neither customize it (see the info node `Easy Customization')\nor call the function `prescient-persist-mode'." :set custom-set-minor-mode :initialize custom-initialize-default :type boolean :group prescient] 12) #@658 Minor mode to persist prescient.el statistics to `prescient-save-file'. This is a minor mode. If called interactively, toggle the `Prescient-Persist mode' mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode. If called from Lisp, toggle the mode if ARG is `toggle'. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `(default-value 'prescient-persist-mode)'. The mode's hook is called both when the mode is enabled and when it is disabled. (fn &optional ARG) (defalias 'prescient-persist-mode #[256 "\302 \303\301\304=\203\305\301!?\202!\247\203 \306W\203 \307\202!\310\"\210\311\300!\2038\312\301\"\305\301!\2038\301B \203J\301\313!\210\310\314\315\316\"\210\202O\317\315\316\"\210\320\321\305\301!\203[\322\202\\\323\"\210\324\325!\203\204\326\301!\210\302 \203t\211\302 \232\203\204\327\330\305\301!\203\200\331\202\201\332\333#\210\210\334 \210\305\301!\207" [global-minor-modes prescient-persist-mode current-message set-default toggle default-value 1 nil t boundp delq -1 add-hook kill-emacs-hook prescient--save remove-hook run-hooks prescient-persist-mode-hook prescient-persist-mode-on-hook prescient-persist-mode-off-hook called-interactively-p any customize-mark-as-set message "Prescient-Persist mode %sabled%s" "en" "dis" "" force-mode-line-update] 6 (#$ . 11047) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar prescient-persist-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\310\313\300!\205#\310\211%\207" [prescient-persist-mode-map prescient-persist-mode-hook variable-documentation put "Hook run after entering or leaving `prescient-persist-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode prescient-persist-mode boundp] 6) #@202 Split QUERY string into sub-queries. The query is split on spaces, but a sequence of two or more spaces has one space removed and is treated literally rather than as a sub-query delimiter. (fn QUERY) (defalias 'prescient-split-query #[257 "\301\302\303\304#)\266\203\203\211G\305X?\205v\211\305\302OC\207\306\307\310\311$\262\312\313\"\314\302\211\211\203c\211@\211\211\314\230\262\203H\313P\262\302\262\202\\\203TB\262\314\262P\262\303\262A\266\202\202.\210\211\314\230\262\204rB\262\211\237\266\204\207" [inhibit-changing-match-data "\\` *\\'" nil t string-match 1 replace-regexp-in-string "\\` ?\\(.*?\\) ?\\'" "\\1" fixedcase split-string " " ""] 10 (#$ . 13185)]) #@92 Wrap REGEXP in a capture group, but only if WITH-GROUP is non-nil. (fn REGEXP WITH-GROUP) (defalias 'prescient-with-group #[514 "\211\203 \300\301\"\207\207" [format "\\(%s\\)"] 5 (#$ . 13898)]) #@240 Return a regexp matching QUERY with optional character folding. If WITH-GROUP is `all', enclose the match in a capture group. See also the customizable variable `prescient-use-char-folding'. (fn QUERY &key WITH-GROUP &allow-other-keys) (defalias 'prescient-literal-regexp #[385 "\301\302\"A@\303\203\304!\202\305=\"\207" [prescient-use-char-folding plist-member :with-group prescient-with-group char-fold-to-regexp all] 7 (#$ . 14104)]) #@336 Return a regexp matching QUERY with optional character folding. If WITH-GROUP is `all', enclose the match in a capture group. Anchor the QUERY at the beginning of the candidate if SUBQUERY-NUMBER equals 0. See also the customizable variable `prescient-use-char-folding'. (fn QUERY &key WITH-GROUP SUBQUERY-NUMBER &allow-other-keys) (defalias 'prescient-literal-prefix-regexp #[385 "\301\302\"A@\301\303\"A@\304\305U\203\306\202\307\203#\310!\202$P\311=\"\207" [prescient-use-char-folding plist-member :with-group :subquery-number prescient-with-group 0 "^" "\\b" char-fold-to-regexp all] 8 (#$ . 14560)]) #@556 Return a regexp matching QUERY as an initialism. This means that the regexp will only match a given string if QUERY is a substring of the initials of the string. If WITH-GROUP is non-nil, enclose the parts of the regexp that match the actual initials in capture groups, so that the match data can be used to highlight the initials of the match. To illustrate, if "fa" matches "find-file-at-point", then the entire match will be the text "file-at", and there will be two capture groups matching "f" and "a". (fn QUERY &key WITH-GROUP &allow-other-keys) (defalias 'prescient-initials-regexp #[385 "\300\301\"A@\302\303\304\"\305#\207" [plist-member :with-group mapconcat make-closure #[257 "\301\302!!\300\203\303\304\"\262\303\305\"\207" [V0 regexp-quote char-to-string format "\\(%s\\)" "\\b%s\\w*"] 5 "\n\n(fn CHAR)"] "\\W*"] 7 (#$ . 15189)]) #@93 Unless using the regexp QUERY would return an error, return QUERY. (fn QUERY &rest IGNORE) (defalias 'prescient-regexp-regexp #[385 "\3011\302\303\304\305#)\2660\207\210\303\207" [inhibit-changing-match-data (error) "" nil t string-match] 9 (#$ . 16051)]) #@560 Return a regexp matching QUERY with anchors. This means uppercase and symbols will be used as begin of words. If WITH-GROUP is non-nil, enclose the parts of the regexp that match the actual initials in capture groups, so that the match data can be used to highlight the initials of the match. To illustrate, "FiFiAt" matches "find-file-at-point" with the entire match being "file-find-at" and with three groups "find", "file", and "at". A similar match can be achieve with "fi-fi-at", or "FFA", or "find-f-a". (fn QUERY &key WITH-GROUP &allow-other-keys) (defalias 'prescient-anchored-regexp #[385 "\301\302\"A@\303\203\304\202\305\306\307\310\311\"\312\313%)\207" [case-fold-search plist-member :with-group nil "\\(\\b%s\\)[^\\/]*?" "\\b%s[^\\/]*?" replace-regexp-in-string "[[:upper:]][[:lower:]]*\\|\\W[[:lower:]]*\\|[[:lower:]]+" make-closure #[257 "\301\300\302\227!\"\207" [V0 format regexp-quote] 5 "\n\n(fn S)"] fixed-case literal] 11 (#$ . 16324)]) #@415 Return a regexp for fuzzy-matching QUERY. This means that the regexp will only match a given string if all characters in QUERY are present anywhere in the string in the specified order. If WITH-GROUP is non-nil, enclose the parts of the regexp that match the QUERY characters in capture groups, so that the match data can be used to highlight the matched substrings. (fn QUERY &key WITH-GROUP &allow-other-keys) (defalias 'prescient-fuzzy-regexp #[385 "\300\301\"A@\302\303\"\262\304\305\306@!!\"\307\310\311\"A\312#P\207" [plist-member :with-group append nil prescient-with-group regexp-quote char-to-string mapconcat make-closure #[257 "\301\302\303\304\305!!\300\"#\207" [V0 format "[^%c\n]*?%s" prescient-with-group regexp-quote char-to-string] 8 "\n\n(fn CHAR)"] ""] 9 (#$ . 17305)]) #@530 Return a regexp for matching the beginnings of words in QUERY. This is similar to the `partial-completion' completion style provided by Emacs, except that non-word characters are taken literally (i.e., one can't glob using "*"). Prescient already covers that case by separating queries with a space. If WITH-GROUP is non-nil, enclose the parts of the regexp that match the QUERY characters in capture groups, so that the match data can be used to highlight the matched substrings. (fn QUERY &key WITH-GROUP &allow-other-keys) (defalias 'prescient-prefix-regexp #[385 "\301\302\"A@\303\304\203\305\202\306\303\307\310\311\312%\311%\313\314\315\316#)\266\203\317=\2032\320P\207\207" [inhibit-changing-match-data plist-member :with-group replace-regexp-in-string "[[:word:]]+" #[257 "\300\301Q\207" ["\\(" "\\)[[:word:]]*"] 4 "\n\n(fn S)"] "\\&[[:word:]]*" "[^[:word:]]" #[257 "\300!\207" [regexp-quote] 3 "\n\n(fn S)"] fixed-case literal "[[:word:]]" nil t string-match 0 "\\<"] 12 (#$ . 18114)]) #@322 Convert QUERY to list of regexps. Each regexp must match the candidate in order for a candidate to match the QUERY. If WITH-GROUP is non-nil, enclose the initials in initialisms with capture groups. If it is the symbol `all', additionally enclose literal substrings with capture groups. (fn QUERY &optional WITH-GROUP) (defalias 'prescient-filter-regexps #[513 "\300C\301\302\303#\304!\"\207" [0 mapcar make-closure #[257 "\303\304\305\306\307\300\301$\n\310=\203\311\202%\n<\203 \n\211\262\202%\n\211C\262\"\312\313$\314\315\316#\266\202\301\211\242T\240\210\207" [V0 V1 prescient-filter-method cl-remove nil mapcar make-closure #[257 "\304 \"\211\203\211\211\302\305\300\306\301\242%\207\307\310\"\207" [V0 V1 V2 prescient-filter-alist alist-get :with-group :subquery-number message "No function in `prescient-filter-alist' for method: %s"] 9 "\n\n(fn METHOD)"] literal+initialism (literal initialism) :test eq "\\|" mapconcat identity] 9 "\n\n(fn SUBQUERY)"] prescient-split-query] 8 (#$ . 19137)]) #@317 Use QUERY to filter list of CANDIDATES. Split the query using `prescient-split-query'. Each candidate must match each subquery, either using substring or initialism matching. Discard any that do not, and return the resulting list. Do not modify CANDIDATES; always make a new copy of the list. (fn QUERY CANDIDATES) (defalias 'prescient-filter #[514 "\304!\305\211\306=\203\305\307\305\310\311#)\266\203)?\202 \312 \313\314\"\216\211\203\202\211@\3152z\305\211\203b\211@\311\"\204H\316\315\305\"\210 \203[G\317\320\"G\232\203[\310\262A\266\202\2026\210\211\203pB\211\262\202wB\211\262\2620\210A\266\202\202)\210\237\237\244)\262)\207" [prescient-use-case-folding case-fold-search inhibit-changing-match-data prescient-sort-full-matches-first prescient-filter-regexps nil smart "[[:upper:]]" t string-match match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] --cl-block-done-- throw match-string 0] 15 (#$ . 20166)]) #@137 Hack used to cause the byte-compiler to produce faster code. Note that this macro must be used with several variables in lexical scope. (defalias 'prescient--sort-compare '(macro . #[0 "\300\207" [(progn (let* ((p1 (gethash c1 hist len)) (p2 (gethash c2 hist len))) (or (< p1 p2) (and (eq p1 p2) (let* ((f1 (gethash c1 freq 0)) (f2 (gethash c2 freq 0))) (or (> f1 f2) (and (eq f1 f2) len-enable (< (length c1) (length c2)))))))))] 1 (#$ . 21165)])) #@330 Compare candidates C1 and C2 by usage and length. If `prescient-persist-mode' is enabled, then ensure that usage data has been loaded from `prescient-save-file' before comparing. Loading will only be attempted once, not before every comparison. If `prescient-sort-length-enable' is nil, then do not sort by length. (fn C1 C2) (defalias 'prescient-sort-compare #[514 "\203 \204 \306 \210\n \f \307#\307#W\206O=\205O\307\310#\307\310#V\206M=\205M\205M G GW\266\202\207" [prescient-persist-mode prescient--cache-loaded prescient--history prescient-history-length prescient--frequency prescient-sort-length-enable prescient--load gethash 0] 13 (#$ . 21621)]) #@120 Sort CANDIDATES using frequency data. Return the sorted list. The original is modified destructively. (fn CANDIDATES) (defalias 'prescient-sort #[257 "\203 \204 \306 \210\n \f \307\310\311%\"\207" [prescient-persist-mode prescient--cache-loaded prescient--history prescient-history-length prescient--frequency prescient-sort-length-enable prescient--load sort make-closure #[514 "\304\300\301#\304\300\301#W\2067=\2057\304\302\305#\304\302\305#V\2065=\2055\303\2055GGW\266\202\207" [V0 V1 V2 V3 gethash 0] 9 "\n\n(fn C1 C2)"]] 13 (#$ . 22323)]) #@86 Record CANDIDATE in `prescient--history' and `prescient--frequency'. (fn CANDIDATE) (defalias 'prescient-remember #[257 "\306!\262\307 #\310\311\312\"\"\210\313\314#\266\313\307\n\314#T\n#\210\310\315\n\"\210 T\f\2056 \2056\316 \207" [prescient--history prescient-history-length prescient--frequency prescient--serial-number prescient-persist-mode prescient-aggressive-file-save substring-no-properties gethash maphash make-closure #[514 "\211\300W\203 \303T #\207\211\nY\204 \211\nSU\205$\300\nU\205$\304 \"\207" [V0 prescient--history prescient-history-length puthash remhash] 6 "\n\n(fn OTHER-CANDIDATE OTHER-POS)"] puthash 0 #[514 "\211_\211 W\203\303\n\"\207\304\n#\207" [prescient-frequency-decay prescient-frequency-threshold prescient--frequency remhash puthash] 7 "\n\n(fn CAND OLD-FREQ)"] prescient--save] 7 (#$ . 22907)]) (provide 'prescient)