;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (require 'tabulated-list) #@30 Version of the `sx' package. (defconst sx-version "0.3" (#$ . 113)) (custom-declare-group 'sx nil "Customization group for the `sx' package." :prefix "sx-" :tag "SX" :group 'applications) #@51 Print and return the version of the `sx' package. (defalias 'sx-version #[0 "\301\302\300#\210\207" [sx-version message "%s: %s"] 4 (#$ . 307) nil]) #@43 File a bug report about the `sx' package. (defalias 'sx-bug-report #[0 "\300\301!\207" [browse-url "https://github.com/vermiculus/sx.el/issues/new"] 2 (#$ . 464) nil]) #@171 Get the site in which DATA belongs. DATA can be a question, answer, comment, or user (or any object with a `link' property). DATA can also be the link itself. (fn DATA) (defalias 'sx--site #[257 "\211;\203 \211\202 \300\236A\211;\205\301\302\303#\207" [link replace-regexp-in-string "\\`https?://\\(?:\\(?1:[^/]+\\)\\.stackexchange\\|\\(?2:[^/]+\\)\\)\\.[^.]+/.*\\'" "\\1\\2"] 6 (#$ . 639)]) #@169 Add a `site' property to DATA if it doesn't have one. Return DATA. DATA can be a question, answer, comment, or user (or any object with a `link' property). (fn DATA) (defalias 'sx--ensure-site #[257 "\211\205'\211\300\236A\301\236A\204$\300\302\236A\206\303!BAB\241\210\266\211\207" [site_par site api_site_parameter sx--site] 8 (#$ . 1045)]) #@65 Convert string LINK into data that can be displayed. (fn LINK) (defalias 'sx--link-to-data #[257 "\300\301!BC\302\303\"\204\302\304\"\203\305B\211\262\202O\302\306\"\2042\302\307\"\2042\302\310\"\203;\311B\211\262\202O\302\312\"\204I\302\313\"\203^\314B\211\262\203^\315\316\317\320\"!BB\262\207" [site_par sx--site string-match "#comment\\(?1:[[:digit:]]+\\)_[[:digit:]]+\\'" "/posts/comments/\\(?1:[[:digit:]]+\\)\\(?:[#?].*\\|\\)\\'" (type . comment) "#\\(?1:[[:digit:]]+\\)\\'" "/a/\\(?1:[[:digit:]]+\\)/[[:digit:]]+\\(?:[#?].*\\)?\\'" "/questions/[[:digit:]]+/[^/]+/\\(?1:[[:digit:]]+\\)/?\\(?:[#?].*\\)?\\'" (type . answer) "/q/\\(?1:[[:digit:]]+\\)\\(?:/[[:digit:]]+\\)?\\(?:[#?].*\\)?\\'" "/questions/\\(?1:[[:digit:]]+\\)/" (type . question) id string-to-number match-string-no-properties 1] 7 (#$ . 1409)]) #@97 Return a list of all paths in TREE. Adapted from http://stackoverflow.com/q/3019250. (fn TREE) (defalias 'sx--tree-paths #[257 "\211:\204 \211CC\207\300\301\302\303\304\"A\"\"\207" [apply append mapcar make-closure #[257 "\301\302\303\300\"\304!\"\207" [V0 mapcar make-closure #[257 "\300@B\207" [V0] 3 "\n\n(fn PATH)"] sx--tree-paths] 5 "\n\n(fn NODE)"]] 7 (#$ . 2262)]) #@103 Apply PATH-FUNC to every path in TREE. Return the result. See `sx--tree-paths'. (fn PATH-FUNC TREE) (defalias 'sx--tree-expand #[514 "\300\301\302\300\303\"\"\"\207" [mapcar apply append sx--tree-paths] 9 (#$ . 2647)]) #@215 Use ALIST with `let-alist' to execute BODY. `.site_par' has a special meaning, thanks to `sx--ensure-site'. If ALIST doesn't have a `site' property, one is created using the `link' property. (fn ALIST &rest BODY) (defalias 'sx-assoc-let '(macro . #[385 "\300\301!\210\302\303D\304\301BB!E\207" [require let-alist progn sx--ensure-site macroexpand] 8 (#$ . 2878)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put sx-assoc-let lisp-indent-function 1 put edebug-form-spec t] 5) #@70 Returned a pretty and capitalized version of string SITE. (fn SITE) (defalias 'sx--pretty-site-parameter #[257 "\300\301\302\303\"\304#\207" [mapconcat capitalize split-string "\\." " "] 6 (#$ . 3382)]) #@99 Split STRING into substrings bounded by matches for SEPARATORS. (fn STRING &optional SEPARATORS) (defalias 'sx--split-string #[513 "\300\301\302\303#\"\207" [mapcar #[257 "\300\301\302#\207" [replace-regexp-in-string "\\` +\\| +\\'" ""] 5 "\n\n(fn S)"] split-string omit-nulls] 8 (#$ . 3593)]) #@131 Like `completing-read', but possibly use ido. All ARGS are passed to `completing-read' or `ido-completing-read'. (fn &rest ARGS) (defalias 'sx-completing-read #[128 "\301\203 \302\202\n\303\"\207" [ido-mode apply ido-completing-read completing-read] 4 (#$ . 3898)]) #@104 Like `user-error', but prepend FORMAT-STRING with "[sx]". See `format'. (fn FORMAT-STRING &rest ARGS) (defalias 'sx-user-error #[385 "\300\301\302\303\304P#C\"\207" [signal user-error apply format "[sx] "] 8 (#$ . 4176)]) #@92 Display FORMAT-STRING as a message with ARGS. See `format'. (fn FORMAT-STRING &rest ARGS) (defalias 'sx-message #[385 "\300\301\302\303#\"\207" [message "[sx] %s" apply format] 8 (#$ . 4408)]) #@59 If there's a 'help-echo property under point, message it. (defalias 'sx-message-help-echo #[0 "\300`\301\"\211\205\f\302\303\"\207" [get-text-property help-echo message "%s"] 4 (#$ . 4610)]) #@521 Return a string representation of THING. If THING is already a string, just return it. Optional argument SEQUENCE-SEP is the separator applied between elements of a sequence. If SEQUENCE-SEP is a list, use the first element for the top level joining, the second for the next level, etc. ";" is used as a default. If optional argument URL-HEXIFY is non-nil, this function behaves as `url-hexify-string'; this option is only effective on strings and sequences of strings. (fn THING &optional SEQUENCE-SEP URL-HEXIFY) (defalias 'sx--thing-as-string #[769 "\211\203\300\202 \301<\203\302\202\301<\203\303\202\301;\203'!\2079\2033\304!!\207\247\203=\305!\207\306!\205]\307\310\311$\203[!\202\\\312#\207" [url-hexify-string identity car cdr symbol-name number-to-string sequencep mapconcat make-closure #[257 "\303\302\300!\301#\207" [V0 V1 V2 sx--thing-as-string] 5 "\n\n(fn THING)"] ";"] 12 (#$ . 4810)]) #@154 Shorten URL hiding anything other than the domain. Paths after the domain are replaced with "...". Anything before the (sub)domain is removed. (fn URL) (defalias 'sx--shorten-url #[257 "\300\301\302\300\303\304##\207" [replace-regexp-in-string "\\(?1:[.[:word:]]+/\\)[^z-a]+\\'" "\\1..." "\\`[[:word:]]*:?//" ""] 8 (#$ . 5768)]) #@184 In KEYMAP, define key sequence KEY as DEF conditionally. This is like `define-key', except the definition "disappears" whenever BODY evaluates to nil. (fn KEYMAP KEY DEF &rest BODY) (defalias 'sx--define-conditional-key '(macro . #[899 "\300\301\302\303\304\243@\206\"\305\306\307\310\311\312\fB EE\257DF\207" [define-key quote menu-item format "maybe-%s" ignore :filter lambda (&optional _) when progn] 17 (#$ . 6107)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put sx--define-conditional-key lisp-indent-function 3 put edebug-form-spec (form form form &rest sexp)] 5) #@177 Move forward to the next change of text-property PROP. Return the new value of PROP at point. If DIRECTION is negative, move backwards instead. (fn PROP &optional DIRECTION) (defalias 'sx--goto-property-change #[513 "\211\247\203\211\300W\203\301\202\302\247\203\300W\203e\202 d`\303$b\210\304`\"\207" [0 previous-single-property-change next-single-property-change nil get-text-property] 9 (#$ . 6717)]) #@303 Move point to an object of TYPE and ID. That is, move forward from beginning of buffer until `sx--data-here' is an object of type TYPE with the respective id ID. If point is left at the of a line, move over the line break. TYPE is either question, answer, or comment. ID is an integer. (fn TYPE ID) (defalias 'sx--find-in-buffer #[514 "\301\267\202\302\202\303\202\304\202\305\212eb\210m\2044\306\307\"\211\205)\236AU\262\2044\310u\210\202`)\211d\232\203A\311\312\"\207\211b\210\313\307\314!)\262\205R\310u\207" [inhibit-changing-match-data #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (answer 6 comment 10 question 14)) answer_id comment_id question_id nil sx--data-here t 1 sx-message "Can't find the specified %s" "$" looking-at] 7 (#$ . 7147)]) #@201 Define a new comparator called NAME with documentation DOC. COMPARE-FUNC is a function that takes the return value of GET-FUNC and performs the actual comparison. (fn NAME DOC COMPARE-FUNC GET-FUNC) (defalias 'sx--create-comparator '(macro . #[1028 "\300\301\302\302\303BB\302\304BBF\257\207" [defun (a b) funcall (a) (b)] 14 (#$ . 7971)])) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put sx--create-comparator lisp-indent-function 1 doc-string-elt 2] 5) #@75 Return STRING with consecutive whitespace squashed together. (fn STRING) (defalias 'sx--squash-whitespace #[257 "\300\301\302#\207" [replace-regexp-in-string "[ \n]+" " "] 5 (#$ . 8464)]) #@64 Return non-nil if DATA represents a deleted object. (fn DATA) (defalias 'sx--deleted-p #[257 "\211@\300=\207" [deleted] 3 (#$ . 8662)]) #@177 Return PREDICATE function with arguments inverted. For instance (sx--invert-predicate #'<) is the same as #'>. Note this is not the same as negating PREDICATE. (fn PREDICATE) (defalias 'sx--invert-predicate #[257 "\300\301\"\207" [make-closure #[128 "\301\300\302!\"\207" [V0 apply reverse] 5 "\n\n(fn &rest ARGS)"]] 4 (#$ . 8806)]) #@40 Overlays created by sx on this buffer. (defvar sx--overlays nil (#$ . 9148)) (make-variable-buffer-local 'sx--overlays) #@116 Track how many overlays we're printing on top of each other. Used for assigning higher priority to inner overlays. (defvar sx--overlay-printing-depth 0 (#$ . 9275)) (make-variable-buffer-local 'sx--overlay-printing-depth) #@197 Start a scope with overlay PROPERTIES and execute BODY. Overlay is pushed on the buffer-local variable `sx--overlays' and given PROPERTIES. Return the result of BODY. (fn PROPERTIES &rest BODY) (defalias 'sx--wrap-in-overlay '(macro . #[385 "\300\301\302\303BD\304BB\300\305\306DD\307BB\310BBB\207" [let (p (point-marker)) result progn ((sx--overlay-printing-depth (1+ sx--overlay-printing-depth))) (ov (make-overlay p (point))) props ((while props (overlay-put ov (pop props) (pop props))) (overlay-put ov 'priority (* 10 sx--overlay-printing-depth)) (push ov sx--overlays)) (result)] 8 (#$ . 9504)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put sx--wrap-in-overlay lisp-indent-function 1 put edebug-form-spec t] 5) #@70 Replace each car of ALIST with its cdr in STRING. (fn ALIST STRING) (defalias 'sx--recursive-replace #[514 "\203\300A@\301\302\303@\"A#\262\"\207\207" [sx--recursive-replace replace-regexp-in-string format "[%s]"] 9 (#$ . 10254)]) #@680 Use FORMAT-STRING to format the values in ALIST. ALIST is a list with elements of the form (CHAR . STRING). The value is a copy of FORMAT-STRING, but with certain constructs replaced by text as given by ALIST. The construct is a `%' character followed by any other character. The replacement is the STRING corresponding to CHAR in ALIST. In addition, if CHAR is also the car of an element in PROPERTY-ALIST, the cdr of that element should be a list of text properties which will be applied on the replacement. The %% construct is special, it is replaced with a single %, even if ALIST contains a different string at the ?% entry. (fn FORMAT ALIST &optional PROPERTY-ALIST) (defalias 'sx-format-replacements #[770 "\300B\301\302\303\"r\211q\210\304\305\"\216c\210eb\210\306\307\310\311#\203W\310f\312\313!\236\243\211\2040\314\315\"\210\316\317\320\321Q\"!\210\203I\322\323\225` \236\243#\210\323\224\323\225|\210\324\313!\266\202\325 *\207" [(37 . "%") generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] search-forward-regexp "%\\(?1:[ #+.0-9-]*\\)" nil noerror match-string 1 error "Invalid format character: `%%%c'" insert-and-inherit format "%" "s" add-text-properties 0 delete-char buffer-string] 13 (#$ . 10503)]) #@263 Return a `header-line-format' from DEFINITIONS. DEFINITIONS is a list where each element has one of the following two forms (KEY COMMAND) (KEY COMMAND DESCRIPTION) The latter are used to build the return value, the former are ignored. (fn DEFINITIONS) (defalias 'sx--key-definitions-to-header-line #[257 "\300\301\211\211\203=\211@\211G\302V\2036\211@\302\234\303\"\211\203+\211\211AB\241\266\2026CBB\262\266A\266\202\202\210\211\203\216\211@\211@A\304@!\305\306\307 \"A\"BG\310U\205g\311\312@!\"\211\247\203{\211\313U\203{@G\301O\202~\314P\262EB\262\266A\266\202\202?\207" [#[257 "\300\301BB\207" [:propertize (face mode-line-buffer-id)] 4 "\n\n(fn X)"] nil 2 assoc " " mapcar make-closure #[257 "\301\300!D\207" [V0 ","] 4 "\n\n(fn K)"] 1 string-match regexp-quote 0 ":"] 14 (#$ . 11813)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable sx-init-hook funcall function #[0 "\300\207" [nil] 1] "Hook run when SX initializes.\nRun after `sx-init--internal-hook'." :group sx :type hook] 8) #@108 Hook run when SX initializes. This is used internally to set initial values for variables such as filters. (defvar sx-init--internal-hook nil (#$ . 12907)) #@155 Set VARIABLE to VALUE using SETTER. SETTER should be a function of two arguments. If SETTER is nil, `set' is used. (fn VARIABLE VALUE &optional SETTER) (defalias 'sx-init-variable '(macro . #[770 "\300\301\302\303\304\206\n\305EEE!\210\304\207" [eval add-hook 'sx-init--internal-hook lambda nil setq] 11 (#$ . 13070)])) #@100 Nil if sx hasn't been initialized yet. If it has, holds the time at which initialization happened. (defvar sx-initialized nil (#$ . 13405)) #@198 Run initialization hooks if they haven't been run yet. These are `sx-init--internal-hook' and `sx-init-hook'. If FORCE is non-nil, run them even if they've already been run. (fn &optional FORCE) (defalias 'sx-initialize #[256 "\211\204 ?\205\301\302\303\"\304 \207" [sx-initialized run-hooks sx-init--internal-hook sx-init-hook current-time] 4 (#$ . 13552)]) (provide 'sx)