;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\207" [require bibtex cl-lib] 2) #@125 List of fields used to create a hash id for each entry. The hash id is stored in the entry in the special field `=hashid='. (defvar parsebib-hashid-fields nil (#$ . 155)) #@708 Inheritance scheme for BibLaTeX cross-referencing. Inheritances are specified for pairs of source and target entry type, where the target is the cross-referencing entry and the source the cross-referenced entry. Each pair specifies the fields in the source and the fields in the target that they correspond with. Inheritances valid for all entry types are defined by specifying the entry type as "all". The entry type may also be a comma-separated list of entry types. If no inheritance rule is set up for a given entry type+field combination, the field inherits from the same-name field in the cross-referenced entry. If no inheritance should take place, the target field is set to the symbol `none'. (defvar parsebib--biblatex-inheritances '(("all" "all" (("ids" . none) ("crossref" . none) ("xref" . none) ("entryset" . none) ("entrysubtype" . none) ("execute" . none) ("label" . none) ("options" . none) ("presort" . none) ("related" . none) ("relatedoptions" . none) ("relatedstring" . none) ("relatedtype" . none) ("shorthand" . none) ("shorthandintro" . none) ("sortkey" . none))) ("mvbook, book" "inbook, bookinbook, suppbook" (("author" . "author") ("author" . "bookauthor"))) ("mvbook" "book, inbook, bookinbook, suppbook" (("title" . "maintitle") ("subtitle" . "mainsubtitle") ("titleaddon" . "maintitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("mvcollection, mvreference" "collection, reference, incollection, inreference, suppcollection" (("title" . "maintitle") ("subtitle" . "mainsubtitle") ("titleaddon" . "maintitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("mvproceedings" "proceedings, inproceedings" (("title" . "maintitle") ("subtitle" . "mainsubtitle") ("titleaddon" . "maintitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("book" "inbook, bookinbook, suppbook" (("title" . "booktitle") ("subtitle" . "booksubtitle") ("titleaddon" . "booktitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("collection, reference" "incollection, inreference, suppcollection" (("title" . "booktitle") ("subtitle" . "booksubtitle") ("titleaddon" . "booktitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("proceedings" "inproceedings" (("title" . "booktitle") ("subtitle" . "booksubtitle") ("titleaddon" . "booktitleaddon") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none))) ("periodical" "article, suppperiodical" (("title" . "journaltitle") ("subtitle" . "journalsubtitle") ("shorttitle" . none) ("sorttitle" . none) ("indextitle" . none) ("indexsorttitle" . none)))) (#$ . 333)) #@46 Regexp describing a licit BibTeX identifier. (defconst parsebib--bibtex-identifier "[^\"@\\#%',={}() \n\f]+" (#$ . 3157)) #@32 Regexp describing a licit key. (defconst parsebib--key-regexp "[^\"@\\#%',={} \n\f]+" (#$ . 3286)) #@42 Regexp describing the start of an entry. (defconst parsebib--entry-start "^[ ]*@" (#$ . 3392)) (define-error 'parsebib-entry-type-error "Illegal entry type" 'error) #@205 Like `looking-at' but move point to the end of the matching string STR. MATCH acts just like the argument to MATCH-END, and defaults to 0. Comparison is done case-insensitively. (fn STR &optional MATCH) (defalias 'parsebib--looking-at-goto-end #[513 "\211\204\301\262\302\303!\205\211\225b)\207" [case-fold-search 0 t looking-at] 4 (#$ . 3565)]) #@241 Move forward to the closing paren matching the opening paren at point. This function handles parentheses () and braces {}. Return t if a matching parenthesis was found. This function puts point immediately after the matching parenthesis. (defalias 'parsebib--match-paren-forward #[0 "\300f\301=\203\n\302 \207\300f\303=\205\304 \207" [nil 123 parsebib--match-brace-forward 40 bibtex-end-of-entry] 2 (#$ . 3926)]) #@170 Move forward to the closing delimiter matching the delimiter at point. This function handles braces {} and double quotes "". Return t if a matching delimiter was found. (defalias 'parsebib--match-delim-forward #[0 "\300f\301=\203\n\302 \207\300f\303=\205\304 \207" [nil 123 parsebib--match-brace-forward 34 parsebib--match-quote-forward] 2 (#$ . 4351)]) #@72 Move forward to the closing brace matching the opening brace at point. (defalias 'parsebib--match-brace-forward #[0 "\301 p\302\303#\216\304!\210\305\306!\210)\307\207" [bibtex-braced-string-syntax-table syntax-table make-closure #[0 "r\301q\210\302\300!)\207" [V0 V1 set-syntax-table] 2] set-syntax-table forward-sexp 1 t] 6 (#$ . 4714)]) #@63 Move to the closing double quote matching the quote at point. (defalias 'parsebib--match-quote-forward #[0 "\301 p\302\303#\216\304!\210\305\306!\210)\307\207" [bibtex-quoted-string-syntax-table syntax-table make-closure #[0 "r\301q\210\302\300!)\207" [V0 V1 set-syntax-table] 2] set-syntax-table forward-sexp 1 t] 6 (#$ . 5063)]) #@524 Parse value at point. A value is either a field value or a @String expansion. Return the value as a string. No parsing is done beyond LIMIT, but note that parsing may stop well before LIMIT. STRINGS, if non-nil, is a hash table of @String definitions. @String abbrevs in the value to be parsed are then replaced with their expansions. Additionally, newlines in field values are removed, white space is reduced to a single space and braces or double quotes around field values are removed. (fn LIMIT &optional STRINGS) (defalias 'parsebib--parse-value #[513 "\302`W\203W\303\304\305!)\262\204W\306\304\305!)\262\203.`\307 \210\310`\"B\266\202\202\305 !\203D\310`\311\225\"B\262\311\225b\210\202\305\312!\203Q\311\225b\210\202\313u\210\202\203g\314\237\"\302\315\316#\207\211\237\317\315\316#\207" [inhibit-changing-match-data parsebib--bibtex-identifier nil "," t looking-at "[{\"]" parsebib--match-delim-forward buffer-substring-no-properties 0 "[[:space:]]*#[[:space:]]*" 1 parsebib--expand-strings mapconcat identity " # "] 9 (#$ . 5404)]) #@388 Expand strings in STRINGS using expansions in ABBREVS. STRINGS is a list of strings. If a string in STRINGS has an expansion in hash table ABBREVS, replace it with its expansion. Otherwise, if the string is enclosed in braces {} or double quotes "", remove the delimiters. In addition, newlines and multiple spaces in the string are replaced with a single space. (fn STRINGS ABBREVS) (defalias 'parsebib--expand-strings #[514 "\300\301\302\"\"\207" [mapcar make-closure #[257 "\301\302\303#\262\304\300\"\206\305\306\"\203\307\310\"\207\211\207" [V0 replace-regexp-in-string "[ \n\f]+" " " gethash string-match "\\`[\"{]\\(.*?\\)[\"}]\\'" match-string 1] 5 "\n\n(fn STR)"]] 6 (#$ . 6490)]) #@571 Expand cross-referencing items in ENTRIES. BibTeX entries in ENTRIES that have a `crossref' field are expanded with the fields in the cross-referenced entry. ENTRIES is a hash table with entries. This hash table is updated with the new fields. The return value of this function is always nil. INHERITANCE indicates the inheritance schema. It can be a symbol `BibTeX' or `biblatex', or it can be an explicit inheritance schema. See the variable `parsebib--biblatex-inheritances' for details on the structure of such an inheritance schema. (fn ENTRIES INHERITANCE) (defalias 'parsebib-expand-xrefs #[514 "\300\301\302#\"\207" [maphash make-closure #[514 "\304\305\"A\211\2056\306\n\307Q\310\311\312#)\266\203\203\"\211\313\314O\262\315\300\"\316\301#\211\2054\317\300#\266\202\207" [V0 V1 parsebib--key-regexp inhibit-changing-match-data assoc-string "crossref" "\\b[\"{]" "[\"}]\\b" nil t string-match 1 -1 gethash parsebib--get-xref-fields puthash] 10 "\n\n(fn KEY FIELDS)"]] 7 (#$ . 7202)]) #@555 Return TARGET-ENTRY supplemented with fields inherited from SOURCE-ENTRY. TARGET-ENTRY and SOURCE-ENTRY are entry alists. Fields in SOURCE-ENTRY for which TARGET-ENTRY has no value are added to TARGET-ENTRY. Return value is the modified TARGET-ENTRY. INHERITANCE is an inheritance schema. It can either be one of the symbols `BibTeX' or `biblatex', or it can be an explicit inheritance schema. See the variable `parsebib--biblatex-inheritances' for details on the structure of such an inheritance schema. (fn TARGET-ENTRY SOURCE-ENTRY INHERITANCE) (defalias 'parsebib--get-xref-fields #[771 "\205B\205B\211\301=\203\262\211\302=?\205.\303\304\305\306#\"AA@\307\310\"AA@\"\311\312\313\305\314#\"\"\303\"\266\202\207" [parsebib--biblatex-inheritances biblatex BibTeX append cl-find-if make-closure #[257 "\303\304\305\301\"A\303Q@\306\307\310#)\266\203\205.\303\304\305\300\"A\303QA@\306\307\310#)\266\203\207" [V0 V1 inhibit-changing-match-data "\\b" assoc-string "=type=" nil t string-match] 8 "\n\n(fn ELEM)"] assoc-string "all" delq nil mapcar #[257 "\302@\301\"\211\205\303\300\304#?\205\211AB\207" [V0 V1 parsebib--get-target-field assoc-string case-fold] 6 "\n\n(fn FIELD)"]] 11 (#$ . 8226)]) #@434 Return the target field for inheritance from SOURCE-FIELD. Inheritance is determined by INHERITANCES, which is an alist of source/target pairs. If no inheritance should take place for SOURCE-FIELD, the target in the relevant item in INHERITANCES is the symbol `none'. If there is no item for SOURCE-FIELD in INHERITANCES, SOURCE-FIELD is returned. Note that it is valid for INHERITANCES to be nil. (fn SOURCE-FIELD INHERITANCES) (defalias 'parsebib--get-target-field #[514 "\300\301#A\211\204\f\207\211\302=\203\303\207\207" [assoc-string case-fold none nil] 6 (#$ . 9478)]) #@820 Find the first (potential) BibTeX item following POS. This function simply searches for an @ at the start of a line, possibly preceded by spaces or tabs, followed by a string of characters as defined by `parsebib--bibtex-identifier'. When successful, point is placed right after the item's type, i.e., generally on the opening brace or parenthesis following the entry type, "@Comment", "@Preamble" or "@String". The return value is the name of the item as a string, either "Comment", "Preamble" or "String", or the entry type (without the @). If an item name is found that includes an illegal character, an error of type `parsebib-entry-type-error' is raised. If no item is found, nil is returned and point is left at the end of the buffer. POS can be a number or a marker and defaults to point. (fn &optional POS) (defalias 'parsebib-find-next-item #[256 "\211\203\211b\210\302\303\304#\205\"\305\306 \307Q\310\"\203\311\310!\207\312\313`C\"\207" [parsebib--entry-start parsebib--bibtex-identifier re-search-forward nil 0 parsebib--looking-at-goto-end "\\(" "\\)[[:space:]]*[({]?" 1 match-string-no-properties signal parsebib-entry-type-error] 5 (#$ . 10070)]) #@565 Read the @Comment beginning at the line POS is on. Return value is the text of the @Comment including the braces. For comments that last until the end of the line (i.e., comments that are not delimited by braces), the return value includes the whitespace between `@comment' and the actual comment text. If no comment could be found, return nil. POS can be a number or a marker. It does not have to be at the beginning of a line, but the @Comment entry must start at the beginning of the line POS is on. If POS is nil, it defaults to point. (fn &optional POS) (defalias 'parsebib-read-comment #[256 "\211\203\211b\210\302 \210\303\304P\305\"\2054`\306\307\310!)\262\203*\311\312w\210\313 \210\202.\314 b\210\315`\"\262\207" [parsebib--entry-start inhibit-changing-match-data beginning-of-line parsebib--looking-at-goto-end "\\(comment\\)[[:space:]]*[({]?" 1 "[[:space:]]*[({]" t looking-at "[:space:]" nil parsebib--match-paren-forward point-at-eol buffer-substring-no-properties] 5 (#$ . 11249)]) #@562 Read the @String definition beginning at the line POS is on. If a proper abbreviation and expansion are found, they are returned as a cons cell ( . ). Otherwise, nil is returned. POS can be a number or a marker. It does not have to be at the beginning of a line, but the @String entry must start at the beginning of the line POS is on. If POS is nil, it defaults to point. If STRINGS is provided it should be a hash table with string abbreviations, which are used to expand abbrevs in the string's expansion. (fn &optional POS STRINGS) (defalias 'parsebib-read-string #[512 "\203b\210\302 \210\303\304P\305\"\205>\212\306 \210`)\303\307 \310Q!\210\311\305!\211\205:\211G\312V\205:\313\"b\210B\262\262\262\207" [parsebib--entry-start parsebib--bibtex-identifier beginning-of-line parsebib--looking-at-goto-end "\\(string[[:space:]]*\\)[({]" 1 parsebib--match-paren-forward "[({]\\(" "\\)[[:space:]]*=[[:space:]]*" match-string-no-properties 0 parsebib--parse-value] 7 (#$ . 12269)]) #@386 Read the @Preamble definition at the line POS is on. Return the preamble as a string (including the braces surrounding the preamble text), or nil if no preamble was found. POS can be a number or a marker. It does not have to be at the beginning of a line, but the @Preamble must start at the beginning of the line POS is on. If POS is nil, it defaults to point. (fn &optional POS) (defalias 'parsebib-read-preamble #[256 "\211\203\211b\210\301 \210\302\303P\304\"\205`\305 \205\306`\"\262\207" [parsebib--entry-start beginning-of-line parsebib--looking-at-goto-end "\\(preamble[[:space:]]*\\)[({]" 1 parsebib--match-paren-forward buffer-substring-no-properties] 5 (#$ . 13299)]) #@80 Create a string from the contents of FIELDS to compute a hash id. (fn FIELDS) (defalias 'parsebib--get-hashid-string #[257 "\301\211:\203(@\262\211\302\303\304\305 \306#A#\206\304C\244\262A\262\202\307\310\304#\207" [parsebib-hashid-fields nil replace-regexp-in-string "^{\\|}\\'" "" assoc-string case-fold mapconcat identity] 12 (#$ . 13997)]) #@1136 Read a BibTeX entry of type TYPE at the line POS is on. TYPE should be a string and should not contain the @ sign. The return value is the entry as an alist of ( . ) cons pairs, or nil if no entry was found. In this alist, the entry key is provided in the field "=key=" and the entry type in the field "=type=". If `parsebib-hashid-fields' is non-nil, a hash ID is added in the field "=hashid=". The hash is computed on the basis of the contents of the fields listed in `parsebib-hashid-fields' using the function `secure-hash' and the `sha256' algorithm. POS can be a number or a marker. It does not have to be at the beginning of a line, but the entry must start at the beginning of the line POS is on. If POS is nil, it defaults to point. ENTRY should not be "Comment", "Preamble" or "String", but is otherwise not limited to any set of possible entry types. If so required, the calling function has to ensure that the entry type is valid. If STRINGS is provided, it should be a hash table with string abbreviations, which are used to expand abbrevs in the entry's fields. (fn TYPE &optional POS STRINGS) (defalias 'parsebib-read-entry #[769 "\303\304\"?\205\205\203b\210\305 \210\306\307Q!\205\205\212\310u\210\311 \210`)\312\313w\210`\306\314 \315Q\316\"\2057\317`\"\211\204>\320\262\321w\210\313\211\211\322\"\262\203\\B\262\313\262\202E\237\266\203\323BB\262\324BB\262\n\203\325\326\327\330!\"BB\262\211\237\262\266\203\207" [parsebib--entry-start parsebib--key-regexp parsebib-hashid-fields member-ignore-case ("comment" "preamble" "string") beginning-of-line parsebib--looking-at-goto-end "[[:space:]]*[({]" -1 parsebib--match-paren-forward " \n \f" nil "\\(" "\\)[ \n\f]*," 1 buffer-substring-no-properties "" "^," parsebib--find-bibtex-field "=type=" "=key=" "=hashid=" secure-hash sha256 parsebib--get-hashid-string] 12 (#$ . 14367)]) #@301 Find the field after point. Do not search beyond LIMIT (a buffer position). Return a cons (FIELD . VALUE), or nil if no field was found. If STRINGS is provided it should be a hash table with string abbreviations, which are used to expand abbrevs in the field's value. (fn LIMIT &optional STRINGS) (defalias 'parsebib--find-bibtex-field #[513 "\301w\210`Y?\205'`\302\303\304Q\305\"\205%\306`\"\307\"B\262\262\262\207" [parsebib--bibtex-identifier "\"#%'(),={} \n \f" parsebib--looking-at-goto-end "\\(" "\\)[[:space:]]*=[[:space:]]*" 1 buffer-substring-no-properties parsebib--parse-value] 7 (#$ . 16289)]) #@118 Collect all @Preamble definitions in the current buffer. Return a list of strings, each string a separate @Preamble. (defalias 'parsebib-collect-preambles #[0 "\212eb\210\300\211\211\301 \262\203\"\302\303\"\203\304 B\262\300\262\202\266\211\237\262)\207" [nil parsebib-find-next-item cl-equalp "preamble" parsebib-read-preamble] 6 (#$ . 16918)]) #@116 Collect all @Comment definitions in the current buffer. Return a list of strings, each string a separate @Comment. (defalias 'parsebib-collect-comments #[0 "\212eb\210\300\211\211\301 \262\203\"\302\303\"\203\304 B\262\300\262\202\266\305\300\"\237\262)\207" [nil parsebib-find-next-item cl-equalp "comment" parsebib-read-comment delq] 6 (#$ . 17285)]) #@402 Collect all @String definitions in the current buffer. Return value is a hash with the abbreviations as keys and the expansions as values. If HASH is a hash table with test function `equal', it is used to store the @String definitions. If EXPAND-STRINGS is non-nil, @String expansions are expanded themselves using the @String definitions already stored in HASH. (fn &optional HASH EXPAND-STRINGS) (defalias 'parsebib-collect-strings #[512 "\300!\203\301!\302=\204\303\304\302\"\262\212eb\210\305\211\211\306 \262\203D\307\310\"\203>\311\305\2052\"\262\312@A#\210\305\262\202\266)\207" [hash-table-p hash-table-test equal make-hash-table :test nil parsebib-find-next-item cl-equalp "string" parsebib-read-string puthash] 9 (#$ . 17659)]) #@1102 Collect all entries in the current buffer. Return value is a hash table containing the entries. If HASH is a hash table, with test function `equal', it is used to store the entries. If STRINGS is non-nil, it should be a hash table of string definitions, which are used to expand abbreviations used in the entries. If INHERITANCE is non-nil, cross-references in the entries are resolved: if the crossref field of an entry points to an entry already in HASH, the fields of the latter that do not occur in the entry are added to it. INHERITANCE indicates the inheritance schema used for determining which fields inherit from which fields. It can be a symbol `BibTeX' or `biblatex', or it can be an explicit inheritance schema. (See the variable `parsebib--biblatex-inheritances' for details on the structure of such an inheritance schema.) It can also be the symbol t, in which case the local variable block is checked for a dialect (using the variable `bibtex-dialect'), or, if no such local variable is found, the value of the variable `bibtex-dialect'. (fn &optional HASH STRINGS INHERITANCE) (defalias 'parsebib-collect-entries #[768 "\301!\203\302!\303=\204\304\305\303\"\262\211\306=\203&\307 \206$\206$\310\262\212eb\210\311\211\211\312 \262\203Y\313\314\"\204S\315\311#\262\203S\316\317\320\"A#\210\311\262\202-\266\211\203d\321\"\210)\207" [bibtex-dialect hash-table-p hash-table-test equal make-hash-table :test t parsebib-find-bibtex-dialect BibTeX nil parsebib-find-next-item member-ignore-case ("preamble" "string" "comment") parsebib-read-entry puthash assoc-string "=key=" parsebib-expand-xrefs] 10 (#$ . 18434)]) #@209 Find the BibTeX dialect of a file if one is set. This function looks for a local value of the variable `bibtex-dialect' in the local variable block at the end of the file. Return nil if no dialect is found. (defalias 'parsebib-find-bibtex-dialect #[0 "\212db\210\304\305 \306Pd\307Z\304#\205O\310 \211\205M\311\312\304\313#)\266\203\205M\314\312\304\313#)\266\203\205M\313\315\316\317\320 \"\304\"P\"\205M\321\322\323\"!\262*\207" [case-fold-search parsebib--entry-start inhibit-changing-match-data bibtex-dialect-list t re-search-backward "comment" 3000 parsebib-read-comment "\\`{[ \n ]*Local Variables:" nil string-match "End:[ \n ]*}\\'" "bibtex-dialect: " regexp-opt mapcar symbol-name intern match-string 1] 8 (#$ . 20109)]) #@1539 Parse the current buffer and return all BibTeX data. Return list of five elements: a hash table with the entries, a hash table with the @String definitions, a list of @Preamble definitions, a list of @Comments and the BibTeX dialect, if present in the file. If ENTRIES is a hash table with test function `equal', it is used to store the entries. Any existing entries with identical keys are overwritten. Similarly, if STRINGS is a hash table with test function `equal', the @String definitions are stored in it. If EXPAND-STRINGS is non-nil, abbreviations in the entries and @String definitions are expanded using the @String definitions already in STRINGS. If INHERITANCE is non-nil, cross-references in the entries are resolved: if the crossref field of an entry points to an entry already in ENTRIES, the fields of the latter that do not occur in the entry are added to it. INHERITANCE indicates the inheritance schema used for determining which fields inherit from which fields. It can be a symbol `BibTeX' or `biblatex', which means to use the default inheritance schema for either dialect, or it can be an explicit inheritance schema. (See the variable `parsebib--biblatex-inheritances' for details on the structure of such an inheritance schema.) It can also be the symbol t, in which case the local variable block is checked for a dialect (using the variable `bibtex-dialect'), or, if no such local variable is found, the value of the variable `bibtex-dialect'. (fn &optional ENTRIES STRINGS EXPAND-STRINGS INHERITANCE) (defalias 'parsebib-parse-buffer #[1024 "\212eb\210\301!\203\302!\303=\204\304\305\303\"\262\301!\203&\302!\303=\204,\304\305\303\"\262\306 \2066\2066\307\310\211\211\211\311 \262\203\252\312\313\"\203d\314\310\205R \"\211\203`\315@A #\210\210\202\244\312\316\"\203t\317 B\262\202\244\312\320\"\203\204\321 B\262\202\244;\203\244\322\310 \205\223\n#\211\203\243\315\323\324\"A\f#\210\210\310\262\202:\266\203\300\325\326=\203\275\202\276\"\210\237\237\257\266\203)\207" [bibtex-dialect hash-table-p hash-table-test equal make-hash-table :test parsebib-find-bibtex-dialect BibTeX nil parsebib-find-next-item cl-equalp "string" parsebib-read-string puthash "preamble" parsebib-read-preamble "comment" parsebib-read-comment parsebib-read-entry assoc-string "=key=" parsebib-expand-xrefs t] 14 (#$ . 20870)]) (provide 'parsebib)