;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\304\305\306\307\310\311\312\313\314\302& \207" [require markdown-mode sx sx-tag custom-declare-group sx-compose-mode nil "Customization group for sx-compose-mode." :prefix "sx-compose-mode-" :tag "SX compose Mode" :group] 10) #@328 Hook run before POSTing to the API. Functions are called without arguments and should return non-nil. Returning nil indicates something went wrong and the sending will be aborted. In this case, the function is responsible for notifying the user. Current buffer is the compose-mode buffer whose content is about to be POSTed. (defvar sx-compose-before-send-hook nil (#$ . 366)) #@279 Hook run after POSTing to the API. Functions on this hook should take two arguments, the `sx-compose-mode' buffer (which not be live) and the data returned by `sx-compose--send-function' (usually the object created by the API). They are only called if the transaction succeeds. (defvar sx-compose-after-send-functions nil (#$ . 752)) #@142 Function used by `sx-compose-send' to send the data. Is invoked between `sx-compose-before-send-hook' and `sx-compose-after-send-functions'. (defvar sx-compose--send-function nil (#$ . 1093)) #@78 Headers inserted when composing a new question. Used by `sx-compose-create'. (defconst sx-compose--question-headers #("Title: %s\nTags : %s\n________________________________________\n\n" 0 7 (intangible t read-only t rear-nonsticky t) 9 10 (read-only t) 10 17 (read-only t intangible t rear-nonsticky t) 19 20 (read-only t rear-nonsticky t) 20 61 (read-only t rear-nonsticky t intangible t sx-compose-separator t)) (#$ . 1291)) #@47 Header-line used on `sx-compose-mode' drafts. (defconst sx-compose--header-line '(" " (:propertize "C-c C-c" face mode-line-buffer-id) ": Finish and Send" (sx-compose--is-question-p (" " (:propertize "C-c C-q" face mode-line-buffer-id) ": Insert tags")) " " (:propertize "C-c C-k" face mode-line-buffer-id) ": Discard Draft") (#$ . 1725)) #@57 Non-nil if this `sx-compose-mode' buffer is a question. (defvar sx-compose--is-question-p nil (#$ . 2079)) (make-variable-buffer-local 'sx-compose--is-question-p) #@50 Site which the curent compose buffer belongs to. (defvar sx-compose--site nil (#$ . 2248)) (make-variable-buffer-local 'sx-compose--site) (defvar sx-compose-mode-hook nil) (byte-code "\300\301N\204\f\302\300\301\303#\210\304\305!\204\302\305\306\307#\210\300\207" [sx-compose-mode-hook variable-documentation put "Hook run after entering Compose mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp sx-compose-mode-map definition-name sx-compose-mode] 4) (defvar sx-compose-mode-map (make-sparse-keymap)) (byte-code "\301\302N\204\303\301\302\304\305!#\210\306\307!\204\303\307\310\311#\210\312\313 !\210\307\302N\204-\303\307\302\304\314!#\210\306\300!\204B\303\300\310\311#\210\315\316\300\317\"\210!\210\300\302N\204P\303\300\302\304\320!#\210\303\311\321\322#\207" [sx-compose-mode-abbrev-table sx-compose-mode-map variable-documentation put purecopy "Keymap for `sx-compose-mode'." boundp sx-compose-mode-syntax-table definition-name sx-compose-mode (lambda (def-tmp-var) (defvar sx-compose-mode-syntax-table def-tmp-var)) make-syntax-table "Syntax table for `sx-compose-mode'." (lambda (def-tmp-var) (defvar sx-compose-mode-abbrev-table def-tmp-var)) define-abbrev-table nil "Abbrev table for `sx-compose-mode'." derived-mode-parent markdown-mode] 5) #@670 Major mode for coposing questions and answers. Most of the functionality comes from `markdown-mode'. This mode just implements some extra features related to posting to the API. This mode won't function if `sx-compose--send-function' isn't set. To make sure you set it correctly, you can create the buffer with the `sx-compose-create' function. If creating a question draft, the `sx-compose--is-question-p' variable should also be set to enable more functionality. \ \{sx-compose-mode} In addition to any hooks its parent mode might have run, this mode runs the hook `sx-compose-mode-hook', as the final or penultimate step during initialization. (defalias 'sx-compose-mode #[0 "\306\300!\210\307\310 \210\311\312\310\313N\203\314\311\313\310\313N#\210\315 !\204'\316 \317 \"\210\320\f!\211\2035\211\321 =\203;\322\f\323 \"\210\210\324 \325\"\204R  =\204R\326 \325 C#\210\327 !\210\330\f!\210  !\"\331\332\333\334\307$\210\331\332\335\334\307$\210)\336\337!\207" [delay-mode-hooks major-mode mode-name sx-compose-mode-map sx-compose-mode-syntax-table sx-compose-mode-abbrev-table make-local-variable t markdown-mode sx-compose-mode "Compose" mode-class put keymap-parent set-keymap-parent current-local-map char-table-parent standard-syntax-table set-char-table-parent syntax-table abbrev-table-get :parents abbrev-table-put use-local-map set-syntax-table add-hook sx-compose-after-send-functions sx-compose-quit nil sx-compose--copy-as-kill run-mode-hooks sx-compose-mode-hook local-abbrev-table sx-compose--header-line header-line-format] 5 (#$ . 3611) nil]) (byte-code "\301\302\303#\210\301\304\305#\210\301\306\307#\207" [sx-compose-mode-map define-key "" sx-compose-send " " sx-compose-quit "" (menu-item "maybe-sx-compose-insert-tags" ignore :filter (lambda (&optional _) (when (progn sx-compose--is-question-p) #'sx-compose-insert-tags)))] 4) #@179 Finish composing current buffer and send it. Calls `sx-compose-before-send-hook', POSTs the the current buffer contents to the API, then calls `sx-compose-after-send-functions'. (defalias 'sx-compose-send #[0 "\301\302!\205 p\303\304\305\306#\"\266\202\207" [sx-compose--send-function run-hook-with-args-until-failure sx-compose-before-send-hook run-hook-wrapped sx-compose-after-send-functions make-closure #[257 "\3021 \211\301\300\"0\210\202\303\304\"\266\305\207" [V0 V1 (debug error) message "[sx] Error encountered AFTER sending post, but the post was sent successfully: %s" nil] 5 "\n\n(fn FUNC)"]] 8 (#$ . 5514) nil]) #@55 Prompt for a tag list for this draft and insert them. (defalias 'sx-compose-insert-tags #[0 "\212\301 \302 \303\304\"\216\305\306\307\310#\311#)\262\312\313!\203'\314\315\316\211\313%\202)\211c\266\202)\207" [sx-compose--site sx-compose--goto-tag-header match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] mapconcat identity sx-tag-multiple-read "Tags" " " match-string 1 replace-match :fixedcase nil] 8 (#$ . 6156) nil]) #@51 Close BUFFER's window and kill it. (fn BUFFER _) (defalias 'sx-compose-quit #[514 "\300!\205!\301!\302!\203\3031\304!0\266\202\210\210\305!\207" [buffer-live-p get-buffer-window window-live-p (error) delete-window kill-buffer] 5 (#$ . 6622) (byte-code "p\300D\207" [nil] 2)]) #@55 Copy BUFFER contents to the kill-ring. (fn BUFFER _) (defalias 'sx-compose--copy-as-kill #[514 "\300!\205rq\210\301\302 !)\207" [buffer-live-p kill-new buffer-string] 4 (#$ . 6918)]) #@138 Move to the "Tags:" header. Match data is set so group 1 encompasses any already inserted tags. Return a list of already inserted tags. (defalias 'sx-compose--goto-tag-header #[0 "eb\210\300\301\302e\303\"\304#\204\305\306!\210\307 \310\311\"\216\312\313\314!\315\")\207" [search-forward-regexp "^Tags : \\(?1:.*\\)$" next-single-property-change sx-compose-separator noerror error "No Tags header found" match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] sx--split-string match-string 1 "[,;[:space:]]"] 5 (#$ . 7113)]) #@52 Check if tags in current compose buffer are valid. (defalias 'sx-compose--check-tags #[0 "\212\301\302 \"\211\203\303\304\305\"!\202\306\262)\207" [sx-compose--site sx-tag--invalid-name-p sx-compose--goto-tag-header y-or-n-p format "Following tags don't exist. Create them? %s " t] 5 (#$ . 7674)]) #@469 Create an `sx-compose-mode' buffer. SITE is the site where it will be posted. If composing questions, PARENT is nil. If composing answers, it is the `question_id'. If editing answers or questions, it should be the alist data related to that object. Each element of BEFORE-FUNCTIONS and AFTER-FUNCTIONS are respectively added locally to `sx-compose-before-send-hook' and `sx-compose-after-send-functions'. (fn SITE PARENT &optional BEFORE-FUNCTIONS AFTER-FUNCTIONS) (defalias 'sx-compose-create #[1026 "\250\204<\204\305\306!\210<\205?\206\307\236Ar\310\"q\210\311 \210\211:\203[\312!\210\307\236A\313\236A\314\236A\315\236A\316\317 &\266\204\262\202c\316\320$\321!\211\203{\211@\322\323\324\325$\210A\266\202\202g\210\321!\211\203\223\211@\322\326\324\325$\210A\266\202\202\210\211\203\237\322\323\327\324\325$\210\330 \331\230\204\254\332\333!\203\330\325\211\334 \210:\203\276\335\236Ac\210\211\203\327\336:\205\311!\210:\204\327eb\210\337 b\210*p)\207" [sx-compose--site sx-compose--is-question-p sx-compose--send-function inhibit-read-only inhibit-point-motion-hooks error "Invalid PARENT" title sx-compose--get-buffer-create sx-compose-mode sx--ensure-site comment_id answer_id question_id make-closure #[0 "\306\302\203 \307\202\303\203\310\202\311\312\313\314\315\316\317\300\320\321\301!\322\303\206)\304\206)\305\323\324&\207" [V0 V1 V2 V3 V4 V5 sx-method-call questions comments answers :auth warn :url-method post :filter :site :keywords sx-compose--generate-keywords :id :submethod edit sx-browse-filter] 16] #[0 "\304\305\306\307\310\311\312 \313\300\314\315\302!\316\301\317\301\203\320\202\321&\207" [V0 V1 V2 sx-browse-filter sx-method-call questions :auth warn :url-method post :filter :site :keywords sx-compose--generate-keywords :id :submethod answers/add add] 16] reverse add-hook sx-compose-before-send-hook nil t sx-compose-after-send-functions sx-compose--check-tags buffer-string "" y-or-n-p "Draft buffer exists. Reset it? " erase-buffer body_markdown sx-compose--print-question-headers line-end-position] 18 (#$ . 7986)]) #@133 Print question headers for the compose buffer. If QUESTION is non-nil, fill the headers with the data from QUESTION. (fn QUESTION) (defalias 'sx-compose--print-question-headers #[257 "\301!\210\211\302\236A\303\236Aeb\210\304\206\305\306\307\310##c\207" [sx-compose--question-headers sx--ensure-site title tags format "" mapconcat identity " "] 11 (#$ . 10133)]) #@225 Reading current buffer, generate a keywords alist. Keywords meant to be used in `sx-method-call'. `body' is read as the `buffer-string'. If IS-QUESTION is non-nil, other keywords are read from the header (fn IS-QUESTION) (defalias 'sx-compose--generate-keywords #[257 "eb\210\301\205H\302\303e\304\"\305\306\307\310#\204\311\312!\210\313\314\315!BC\262eb\210\306\316\310#\2043\311\317!\210\320\321\314\315!\322\"BB\262\303\304\"b\210)\266\202\323\324`d\"BC\"\207" [inhibit-point-motion-hooks append t next-single-property-change sx-compose-separator nil search-forward-regexp "^Title: *\\(.*\\) *$" noerror error "No Title header found" title match-string 1 "^Tags : *\\([^[:space:]].*\\) *$" "No Tags header found" tags sx--split-string "[[:space:],;]" body buffer-substring-no-properties] 9 (#$ . 10512)]) #@399 Get or create a buffer for use with `sx-compose-mode'. SITE is the site for which composing is aimed (just used to uniquely identify the buffers). If DATA is nil, get a fresh compose buffer. If DATA is an integer, try to find an existing buffer corresponding to that integer, otherwise create one. If DATA is an alist (question or answer data), like above but use the id property. (fn SITE DATA) (defalias 'sx-compose--get-buffer-create #[514 "\211\204 \300\301\302\"!\207\211\250\203\303\301\304#!\207\303\305!\210\306\236A\307\236A\310\236A\311\236A\301\312 \203;\313\202D\203C\314\202D\315\206N\206N$\266\204\262!\207" [generate-new-buffer format "*sx draft question %s*" get-buffer-create "*sx draft answer %s %s*" sx--ensure-site title comment_id answer_id question_id "*sx draft edit %s %s %s*" "question" "comment" "answer"] 13 (#$ . 11343)]) (provide 'sx-compose)