;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\303\304 \305\"\203\300\306!\210\300\207" [require org-element thingatpt version< org-version "8.3" ox] 3) #@27 The path to your yankpad. (defvar yankpad-file (expand-file-name "yankpad.org" org-directory) (#$ . 234)) #@68 The current yankpad category. Change with `yankpad-set-category'. (defvar yankpad-category nil (#$ . 346)) (put 'yankpad-category 'safe-local-variable 'string-or-null-p) #@67 The `org-mode' heading level of categories in the `yankpad-file'. (defvar yankpad-category-heading-level 1 (#$ . 523)) #@65 The `org-mode' heading level of snippets in the `yankpad-file'. (defvar yankpad-snippet-heading-level 2 (#$ . 648)) #@107 Whether to respect `org-current-level' when using * in snippets and yanking them into `org-mode' buffers. (defvar yankpad-respect-current-org-level t (#$ . 771)) #@46 Hooks run after changing `yankpad-category'. (defvar yankpad-switched-category-hook nil (#$ . 939)) #@112 String used to separate a keyword, at the start of a snippet name, from the title. Used for `yankpad-expand'. (defvar yankpad-expand-separator ":" (#$ . 1046)) #@59 A cached version of the snippets in the current category. (defvar yankpad--active-snippets nil (#$ . 1213)) #@43 Get the snippets in the current category. (defalias 'yankpad-active-snippets #[nil "\206\301 \207" [yankpad--active-snippets yankpad-set-active-snippets] 1 (#$ . 1327)]) #@30 Change the yankpad category. (defalias 'yankpad-set-category #[nil "\301\302\303 \"\304\305!\207" [yankpad-category completing-read "Category: " yankpad--categories run-hooks yankpad-switched-category-hook] 3 (#$ . 1506) nil]) #@45 Set `yankpad-category' to CATEGORY locally. (defalias 'yankpad-set-local-category #[(category) "\303\301!\210\303\302!\210\304\305\306!\207" [category yankpad-category yankpad--active-snippets make-local-variable nil run-hooks yankpad-switched-category-hook] 2 (#$ . 1740)]) #@212 Set the `yankpad--active-snippets' to the snippets in the active category. If no active category, call `yankpad-set-category'. Also append major mode and/or projectile categories if `yankpad-category' is local. (defalias 'yankpad-set-active-snippets #[nil "\2039\305!\306\300!\2037\307\n!\310 \235@\211\203\311 !\210)\312\313\314\315#\2037\316 \310 \235@\211\2036\311\f!\210) \207\317 \210\320 \207" [yankpad-category yankpad--active-snippets major-mode major-mode-category projectile-category yankpad--snippets local-variable-p symbol-name yankpad--categories yankpad-append-category require projectile nil t projectile-project-name yankpad-set-category yankpad-set-active-snippets] 5 (#$ . 2025)]) #@105 Add snippets from CATEGORY into the list of active snippets. Prompts for CATEGORY if it isn't provided. (defalias 'yankpad-append-category #[(&optional category) "\204\n\303\304\305 \" \232?\205 \n\204\306 \210\307\n\310!\"\211\207" [category yankpad-category yankpad--active-snippets completing-read "Category: " yankpad--categories yankpad-set-active-snippets append yankpad--snippets] 4 (#$ . 2743) nil]) #@135 Clear the snippet cache. The next try to `yankpad-insert` will reload `yankpad-file`. Useful to run after editing the `yankpad-file`. (defalias 'yankpad-reload #[nil "\301\211\207" [yankpad--active-snippets nil] 2 (#$ . 3167) nil]) (add-hook 'yankpad-switched-category-hook 'yankpad-reload) #@96 Insert an entry from the yankpad. Uses `yankpad-category', and prompts for it if it isn't set. (defalias 'yankpad-insert #[nil "\204\f\301 \204\f\302 \210\303 \207" [yankpad-category yankpad-local-category-to-major-mode yankpad-set-category yankpad-insert-from-current-category] 1 (#$ . 3465) nil]) #@122 Insert TEXT into buffer. INDENT is whether/how to indent the snippet. Use yasnippet and `yas-indent-line' if available. (defalias 'yankpad--insert-snippet-text #[(text indent) "\304\305\306#\307\310\311\312#\2031 \2031\313 \203%\314\315 \316 \317\320\nDDC$\207\314\311\211\317\320\nDDC$\207`c\210\n\205>\321 `\")\207" [text yas-minor-mode indent start substring-no-properties 0 -1 require yasnippet nil t region-active-p yas-expand-snippet region-beginning region-end yas-indent-line quote indent-region] 7 (#$ . 3774)]) #@210 SNIPPETNAME can be an elisp function, without arguments, if CONTENT is nil. If non-nil, CONTENT should hold a single `org-mode' src-block, to be executed. Return the result of the function output as a string. (defalias 'yankpad--trigger-snippet-function #[(snippetname content) "@\2031\304\305\306\"r q\210\307\216\310\302!\210\306\311 \210@c\210eb\210\312 \203,\313\314 !\202/\315\316!,\207\317 !\203>\313\317 ! !\207\315\320 \321Q!\207" [content #1=#:temp-buffer delay-mode-hooks snippetname generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] make-local-variable org-mode org-in-src-block-p prin1-to-string org-babel-execute-src-block error "No org-mode src-block at start of snippet" intern-soft "\"" "\" isn't a function"] 4 (#$ . 4313)]) #@33 Triggers the SNIPPET behaviour. (defalias 'yankpad--run-snippet #[(snippet) "@A@AA\306\n\235\203\307 \"\202\214\310\n\235\203&\307 \"c\202\214 @\203\206\311\312\n\235\2036\313\202[\314\n\235\203@\315\202[\316\n\235\203J\317\202[\320\321\313\322#\203Z\f\203Z \202[\322\203t \323=\203t\324 \203t\324 \325\326\327\330\331\" @#\"*\202\214\332\333 \334Q!+\207" [snippet content tags name yas-minor-mode yas-indent-line "func" yankpad--trigger-snippet-function "results" 1 "indent_nil" nil "indent_fixed" fixed "indent_auto" auto require yasnippet t org-mode org-current-level yankpad--insert-snippet-text replace-regexp-in-string "^\\\\[*]" make-string 42 message "\"" "\" snippet doesn't contain any text. Check your yankpad file." indent prepend-asterisks yankpad-respect-current-org-level major-mode] 6 (#$ . 5115)]) #@112 Insert snippet NAME from `yankpad-category'. Prompts for NAME unless set. Does not change `yankpad-category'. (defalias 'yankpad-insert-from-current-category #[(&optional name) "\303  \204\f\304\305\"\306 \303 \"\211\203\307\n!\202#\310\311 P!\210\312*\207" [snippets name snippet yankpad-active-snippets completing-read "Snippet: " assoc yankpad--run-snippet message "No snippet named " nil] 4 (#$ . 5977)]) #@134 Replace word at point with a snippet. Only works if the word is found in the first matching group of `yankpad-expand-keyword-regex'. (defalias 'yankpad-expand #[nil "\305 \306\300!\nP\205\f\205\3072\310\311\312 \"\210\3130+\207" [word bounds yankpad-expand-separator snippet-prefix yankpad-category word-at-point bounds-of-thing-at-point loop mapc #[(snippet) "\303 @\"\205\n@\nA|\210\304 !\210\305\306 \"\207" [snippet-prefix snippet bounds string-prefix-p yankpad--run-snippet throw loop] 3] yankpad-active-snippets nil] 3 (#$ . 6402) nil]) #@36 Open the yankpad file for editing. (defalias 'yankpad-edit #[nil "\301!\207" [yankpad-file find-file] 2 (#$ . 6965) nil]) #@55 Run `org-element-parse-buffer' on the `yankpad-file'. (defalias 'yankpad--file-elements #[nil "\303\304\305\"rq\210\306\216\307\301!\210\305\310 \210\311\n!\210\312 ,\207" [#1=#:temp-buffer delay-mode-hooks yankpad-file generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] make-local-variable org-mode insert-file-contents org-element-parse-buffer] 3 (#$ . 7094)]) #@39 Get the yankpad categories as a list. (defalias 'yankpad--categories #[nil "\301 \302\303\304#)\207" [data yankpad--file-elements org-element-map headline #[(h) "\302\211;\203\303\304#\266\202\202\305A@\"\266\202 \232\2053\306\211;\203+\303\304#\207\305A@\"\266\202\207" [h yankpad-category-heading-level :level get-text-property 0 plist-get :raw-value] 6]] 4 (#$ . 7511)]) #@67 Get all the snippet `org-mode' heading elements in CATEGORY-NAME. (defalias 'yankpad--snippet-elements #[(category-name) "\302 \303\304 \305\"\203\306\202\307\310 \311\312#*\207" [lineage-func data yankpad--file-elements version< org-version "8.3" org-export-get-genealogy org-element-lineage org-element-map headline #[(h) " !\305 \211;\203\306\307#\266\202\202\310A@\"\266\202 \232\205,\f\311\312\n\"\235\205, )\207" [lineage-func h lineage yankpad-snippet-heading-level category-name :level get-text-property 0 plist-get mapcar #[(x) "\301\211;\203 \302\303#\207\304A@\"\207" [x :raw-value get-text-property 0 plist-get] 6]] 6]] 4 (#$ . 7909)]) #@48 Get the "INCLUDE" property from CATEGORY-NAME. (defalias 'yankpad--category-include-property #[(category-name) "\301 \302\303\304\305\306%)\207" [data yankpad--file-elements org-element-map headline #[(h) "\303\211;\203\304\305#\266\202\202\306A@\"\266\202 \232\205Q\307\211;\203/\304\305#\266\202\2027\306A@\"\266\202\n\232\205Q\310\211;\203I\304\305#\207\306A@\"\266\202\207" [h yankpad-category-heading-level category-name :level get-text-property 0 plist-get :raw-value :INCLUDE] 6] nil t] 6 (#$ . 8587)]) #@121 Get an alist of the snippets in CATEGORY-NAME. The car is the snippet name and the cdr is a cons (tags snippet-string). (defalias 'yankpad--snippets #[(category-name) "\304!\211\205\f\305 \306\"\307\310\311!\"\312 \313\312\307\314\n\"\"\"+\207" [category-name propertystring include snippets yankpad--category-include-property split-string "|" mapcar #[(h) "\304\211;\203\305\306#\266\202\202\307A@\"\266\202\310\311\312#\313\211;\203/\305\306#\266\202\2027\307A@\"\266\202\211 \n+BB\207" [h tags text heading :raw-value get-text-property 0 plist-get org-element-map section org-element-interpret-data :tags] 9] yankpad--snippet-elements append cl-reduce yankpad--snippets] 8 (#$ . 9130)]) #@85 Create and execute a keymap out of the last tags of snippets in `yankpad-category'. (defalias 'yankpad-map #[nil "\300\301!\210\302\303\304 \"\210\305\301!\207" [define-prefix-command yankpad-keymap mapc #[(snippet) "\306A@!@\211\205F \307=?\205F \310=?\205F\311\312 \"?\205F@AAA@\313 \314\315 !!\316\317\320\321\322\f\322\323\nB\323 BEEDF#+)\207" [snippet last-tag tags content heading yankpad-keymap last "func" "results" string-prefix-p "indent_" define-key kbd substring-no-properties lambda nil (interactive) yankpad--run-snippet cons list] 14] yankpad-active-snippets set-transient-map] 3 (#$ . 9852) nil]) #@121 Try to change `yankpad-category' to match the buffer's major mode. If successful, make `yankpad-category' buffer-local. (defalias 'yankpad-local-category-to-major-mode #[nil "\303!\205\304 !\305 \235@\211\205\306\n!)\207" [yankpad-file major-mode category file-exists-p symbol-name yankpad--categories yankpad-set-local-category] 3 (#$ . 10484)]) (add-hook 'after-change-major-mode-hook 'yankpad-local-category-to-major-mode) #@127 Try to change `yankpad-category' to match the `projectile-project-name'. If successful, make `yankpad-category' buffer-local. (defalias 'yankpad-local-category-to-projectile #[nil "\302\303\304\305#\205\306!\205\307 \310 \235@\211\205\311 !)\207" [yankpad-file category require projectile nil t file-exists-p projectile-project-name yankpad--categories yankpad-set-local-category] 5 (#$ . 10923)]) (byte-code "\300\301\302\303\304\"\"\207" [eval-after-load "projectile" add-hook projectile-find-file-hook yankpad-local-category-to-projectile] 5) #@165 Return candidates that match the string entered. ARG is what the user has entered and expects a match for. FN is the function that will extract either name or key. (defalias 'company-yankpad--name-or-key #[(arg fn) "\300\301\302\303\304 \"\"\207" [delq nil mapcar #[(c) "\305@ \"\306 \n@\307#\205-\310 @\"\203\"\311\312\313\314\n@$\210\202*\311\312\313\315\n@$\210\f\n!)\207" [c yankpad-expand-separator snip arg fn split-string string-prefix-p t string-match set-text-properties 0 1 (type keyword) (type name)] 5] yankpad-active-snippets] 5 (#$ . 11484)]) #@30 Company backend for yankpad. (defalias 'company-yankpad #[(command &optional arg &rest ignored) "\305\306\307\310#\203G\311\307\312\313 !\314\315 \316\"@!\317\315 \320\"!\321\322\323\302 #\211\324=\203.\325 \202?\326 \327\304! @ A|\210\330 !*)!\331\310!&\207\332\333!\207" [command arg type bounds word require company nil t case prefix company-grab-symbol annotation company-yankpad--name-or-key #[(snippet) "\301\302A\303#\207" [snippet mapconcat identity " "] 4] candidates #[(snippet) "@\207" [snippet] 1] post-completion get-text-property 0 keyword yankpad-expand word-at-point bounds-of-thing-at-point yankpad-insert-from-current-category duplicates error "You need company in order to use company-yankpad"] 12 (#$ . 12053) (list 'interactive)]) (provide 'yankpad)