;ELC ;;; compiled by kwzh@hal.gnu.ai.mit.edu on Thu Jun 8 22:13:30 1995 ;;; from file /gd/gnu/emacs/19.0/lisp/format.el ;;; emacs version 19.28.93.6. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.28.90"))) (error "`format.el' was compiled for Emacs 19.29 or later")) (put (quote buffer-file-format) (quote permanent-local) t) #@1255 List of information about understood file formats. Elements are of the form (NAME DOC-STR REGEXP FROM-FN TO-FN MODIFY MODE-FN). NAME is a symbol, which is stored in `buffer-file-format'. DOC-STR should be a single line providing more information about the format. It is currently unused, but in the future will be shown to the user if they ask for more information. REGEXP is a regular expression to match against the beginning of the file; it should match only files in that format. FROM-FN is called to decode files in that format; it gets two args, BEGIN and END, and can make any modifications it likes, returning the new end. It must make sure that the beginning of the file no longer matches REGEXP, or else it will get called again. TO-FN is called to encode a region into that format; it is also passed BEGIN and END, and either returns a list of annotations like `write-region-annotate-functions', or modifies the region and returns the new end. MODIFY, if non-nil, means the TO-FN modifies the region. If nil, TO-FN may not make any changes and should return a list of annotations. MODE-FN, if specified, is called when visiting a file with that format. (defconst format-alist (quote ((text/enriched "Extended MIME text/enriched format." "Content-[Tt]ype:[ ]*text/enriched" enriched-decode enriched-encode t enriched-mode) (plain "Standard ASCII format, no text properties." nil nil nil nil nil))) (#$ . 535)) #@458 Returns annotations for writing region as FORMAT. FORMAT is a symbol naming one of the formats defined in `format-alist', it must be a single symbol, not a list like `buffer-file-format'. This function works like a function on `write-region-annotate-functions': it either returns a list of annotations, or returns with a different buffer current, which contains the modified text to write. For most purposes, consider using `format-encode-region' instead. (defalias 'format-annotate-function #[(format from to) " \n8\n8\f?9!   \f# q \"\fed\")ς?\f \f\"+" [format format-alist info 4 to-fn 5 modify get-buffer-create " *Format Temp*" copy-buf copy-to-buffer from to format-insert-annotations write-region-annotations-so-far nil] 4 (#$ . 2053)]) #@705 Decode text from any known FORMAT. FORMAT is a symbol appearing in `format-alist' or a list of such symbols, or nil, in which case this function tries to guess the format of the data by matching against the regular expressions in `format-alist'. After a match is found and the region decoded, the alist is searched again from the beginning for another match. Second arg LENGTH is the number of characters following point to operate on. If optional third arg VISIT-FLAG is true, set `buffer-file-format' to the list of formats used, and call any mode functions defined for those formats. Returns the new length of the decoded region. For most purposes, consider using `format-decode-region' instead. (defalias 'format-decode #[(format length &optional visit-flag) " `` \\ yu@8\n` \nl\n!l͕ \\Wl@ B8N8 \n\"a8a8! bqA+) < C @@\"88 \n\"88!A* \f!\n Z+" [buffer-modified-p length end begin mod format format-alist try f 2 regexp p looking-at 0 3 visit-flag 6 1 nil do error "Unknown format" buffer-file-format set-buffer-modified-p] 5 (#$ . 2839)]) #@204 Translate the buffer from some FORMAT. If the format is not specified, this function attempts to guess. `buffer-file-format' is set to the format used, and any mode-functions for the format are called. (defalias 'format-decode-buffer #[(&optional format) "eb #)" [format-decode format buffer-size t] 4 (#$ . 4043) (list (format-read "Translate buffer from format (default: guess): "))]) #@181 Decode the region from some format. Arg FORMAT is optional; if omitted the format will be determined by looking for identifying regular expressions at the beginning of the region. (defalias 'format-decode-region #[(from to &optional format) "b\n Z#)" [from format-decode format to nil] 4 (#$ . 4445) (list (region-beginning) (region-end) (format-read "Translate region from format (default: guess): "))]) #@172 Translate the buffer into FORMAT. FORMAT defaults to `buffer-file-format'. It is a symbol naming one of the formats defined in `format-alist', or a list of such symbols. (defalias 'format-encode-buffer #[(&optional format) "ed #" [format-encode-region format] 4 (#$ . 4864) (list (format-read (format "Translate buffer to format (default %s): " buffer-file-format)))]) #@176 Translate the region into some FORMAT. FORMAT defaults to `buffer-file-format', it is a symbol naming one of the formats defined in `format-alist', or a list of such symbols. (defalias 'format-encode-region #[(beg end &optional format) " 9C\nbp T@ 88\n\fM\nD \n\"M \n\"!A,+" [format buffer-file-format end point-marker cur-buf format-alist info 4 to-fn 5 modify nil result beg format-insert-annotations] 4 (#$ . 5243) (list (region-beginning) (region-end) (format-read (format "Translate region to format (default %s): " buffer-file-format)))]) #@276 Write current buffer into a FILE using some FORMAT. Makes buffer visit that file and sets the format as the default for future saves. If the buffer is already visiting a file, you can specify a directory name as FILE, to write a file of the same old name in that directory. (defalias 'format-write-file #[(filename format) " !" [format buffer-file-format write-file filename] 2 (#$ . 5853) (byte-code "É% AÉ %!\"!\f\f*D" [buffer-file-name read-file-name "Write file: " nil default-directory buffer-local-variables buffer-name file format-read format "Write file `%s' in format: " file-name-nondirectory fmt] 6)]) #@101 Find the file FILE using data format FORMAT. If FORMAT is nil then do not do any format conversion. (defalias 'format-find-file #[(filename format) " !)\f\f!" [nil format-alist find-file filename format format-decode-buffer] 2 (#$ . 6510) (byte-code "!\n!\"!\n*D" [read-file-name "Find file: " file format-read format "Read file `%s' in format: " file-name-nondirectory fmt] 5)]) #@304 Insert the contents of file FILE using data format FORMAT. If FORMAT is nil then do not do any format conversion. The optional third and fourth arguments BEG and END specify the part of the file to read. The return value is like the value of `insert-file-contents': a list (ABSOLUTE-FILE-NAME . SIZE). (defalias 'format-insert-file #[(filename format &optional beg end) " $A@)$ \"\n@ B\n*" [nil size value format-alist insert-file-contents filename beg end format format-decode] 6 (#$ . 6918) (byte-code "!\n!\"!\n*D" [read-file-name "Find file: " file format-read format "Read file `%s' in format: " file-name-nondirectory fmt] 5)]) #@180 Read and return the name of a format. Return value is a list, like `buffer-file-format'; it may be nil. Formats are defined in `format-alist'. Optional arg is the PROMPT to use. (defalias 'format-read #[(&optional prompt) "\n\" $ ʚ? !C*" [mapcar #[(x) " @!C" [symbol-name x] 2] format-alist table completing-read prompt "Format: " nil t ans "" intern] 6 (#$ . 7597)]) #@402 Do multiple replacements on the buffer. ALIST is a list of (from . to) pairs, which should be proper arguments to `search-forward' and `replace-match' respectively. Optional 2nd arg REVERSE, if non-nil, means the pairs are (to . from), so that you can use the same list in both directions if it contains only literal strings. Optional args BEGIN and END specify a region of the buffer to operate on. (defalias 'format-replace-strings #[(alist &optional reverse beg end) "e e }\na \n@A!\n@@ +\nA@.\n@Ab #Zɔb\fc`\fGZ``!#``ɕɔZ\\|3\nA**" [beg end alist reverse to from search-forward nil t 0 set-text-properties text-properties-at] 5 (#$ . 7995)]) #@217 Remove the given CONS from LIST by side effect, and return the new LIST. Since CONS could be the first element of LIST, write `(setq foo (format-delq-cons element foo))' to be sure of changing the value of `foo'. (defalias 'format-delq-cons #[(cons list) " = A A=!\n!\nA\f\nA )" [cons list p error "format-delq-cons: not an element."] 3 (#$ . 8694)]) #@82 Delete common elements of lists A and B, return as pair. Compares using `equal'. (defalias 'format-make-relatively-unique #[(a b) " ! !\n . @\f A' \n\"\f\"*\n\n\f+B" [copy-sequence a acopy b bcopy tail next dup format-delq-cons] 4 (#$ . 9078)]) #@208 Given two lists that have a common tail, return it. Compares with `equal', and returns the part of A that is equal to the equivalent part of B. If even the last items of the two are not equal, returns nil. (defalias 'format-common-tail #[(a b) "G G\nV \nZ\n Z * +A A" [a b lb la] 3 (#$ . 9357)]) #@159 Arrange ITEMS to following partial ORDER. Elements of ITEMS equal to elements of ORDER will be rearranged to follow the ORDER. Unmatched items will go last. (defalias 'format-reorder #[(items order) "\"@ \n@\n \"A\"B A\") " [order items item format-reorder format-delq-cons] 6 (#$ . 9688)]) (byte-code "##" [put face format-list-valued t unknown] 4) #@2527 Translate annotations in the region into text properties. This sets text properties between FROM to TO as directed by the TRANSLATIONS and NEXT-FN arguments. NEXT-FN is a function that searches forward from point for an annotation. It should return a list of 4 elements: (BEGIN END NAME POSITIVE). BEGIN and END are buffer positions bounding the annotation, NAME is the name searched for in TRANSLATIONS, and POSITIVE should be non-nil if this annotation marks the beginning of a region with some property, or nil if it ends the region. NEXT-FN should return nil if there are no annotations after point. The basic format of the TRANSLATIONS argument is described in the documentation for the `format-annotate-region' function. There are some additional things to keep in mind for decoding, though: When an annotation is found, the TRANSLATIONS list is searched for a text-property name and value that corresponds to that annotation. If the text-property has several annotations associated with it, it will be used only if the other annotations are also in effect at that point. The first match found whose annotations are all present is used. The text property thus determined is set to the value over the region between the opening and closing annotations. However, if the text-property name has a non-nil `format-list-valued' property, then the value will be consed onto the surrounding value of the property, rather than replacing that value. There are some special symbols that can be used in the "property" slot of the TRANSLATIONS list: PARAMETER and FUNCTION (spelled in uppercase). Annotations listed under the pseudo-property PARAMETER are considered to be arguments of the immediately surrounding annotation; the text between the opening and closing parameter annotations is deleted from the buffer but saved as a string. The surrounding annotation should be listed under the pseudo-property FUNCTION. Instead of inserting a text-property for this annotation, the function listed in the VALUE slot is called to make whatever changes are appropriate. The function's first two arguments are the START and END locations, and the rest of the arguments are any PARAMETERs found in that region. Any annotations that are found by NEXT-FN but not defined by TRANSLATIONS are saved as values of the `unknown' text-property (which is list-valued). The TRANSLATIONS list should usually contain an entry of the form (unknown (nil format-annotate-value)) to write these unknown annotations back into the file. (defalias 'format-deannotate-region #[(from to translations next-fn) "e} b‰ X@A@ 8 8 \f | M \fDBT \"_ \"TT@@A@AA !6@@@A,@@@A\"\"\"A=@\f{C\"AB\f|\"=\f$%% B)\"\fF B*A*AOA\fF B B._-  @'@'A@'8'8( (( \"\\N \"-(-<--C)B($- A\\  \"." [to from nil unknown-ans loc todo open-ans next next-fn end 2 name 3 positive found assoc message "Extra closing annotation (%s) in file" top top-name start params translations aalist matched t "Improper nesting in file." alist prop ans value mapcar #[(r) " \n\"" [assoc r open-ans] 3] PARAMETER append FUNCTION apply rtn unknown item val put-text-property get-text-property 0 format-list-valued prev "Unknown annotations: %s"] 9 (#$ . 10077)]) #@397 Apply list of annotations to buffer as `write-region' would. Inserts each element of the given LIST of buffer annotations at its appropriate place. Use second arg OFFSET if the annotations' locations are not relative to the beginning of the buffer: annotations will be inserted at their location-OFFSET+1 (ie, the offset is treated as the character number of the first character in the buffer). (defalias 'format-insert-annotations #[(list &optional offset) " \fS !(\f@@Zb\f@Ac\fA)" [offset 0 reverse list l nil] 3 (#$ . 13605)]) #@239 Return OLD and NEW as a (close . open) annotation pair. Useful as a default function for TRANSLATIONS alist when the value of the text property is the name of the annotation that you want to use, as it is for the `unknown' text property. (defalias 'format-annotate-value #[(old new) "C \f CB" [old new] 2 (#$ . 14167)]) #@1733 Generate annotations for text properties in the region. Searches for changes between FROM and TO, and describes them with a list of annotations as defined by alist TRANSLATIONS and FORMAT-FN. IGNORE lists text properties not to consider; any text properties that are neither ignored nor listed in TRANSLATIONS are warned about. If you actually want to modify the region, give the return value of this function to `format-insert-annotations'. Format of the TRANSLATIONS argument: Each element is a list whose car is a PROPERTY, and the following elements are VALUES of that property followed by the names of zero or more ANNOTATIONS. Whenever the property takes on that value, the annotations (as formatted by FORMAT-FN) are inserted into the file. When the property stops having that value, the matching negated annotation will be inserted (it may actually be closed earlier and reopened, if necessary, to keep proper nesting). If the property's value is a list, then each element of the list is dealt with separately. If a VALUE is numeric, then it is assumed that there is a single annotation and each occurrence of it increments the value of the property by that number. Thus, given the entry (left-margin (4 "indent")), if the left margin changes from 4 to 12, two annotations will be generated. If the VALUE is nil, then instead of annotations, a function should be specified. This function is used as a default: it is called for all transitions not explicitly listed in the table. The function is called with two arguments, the OLD and NEW values of the property. It should return lists of annotations like `format-annotate-location' does. The same structure can be used in reverse for reading files. (defalias 'format-annotate-region #[(from to trans format-fn ignore) "\n\n#\nW\n%\nU \n$  H \" H H \" \" @ l@\"@ @ @B\n @\"B\fB Al A\n@\"B\fBAZ@ B\n@\"B\fBA-  @\"B\fB A \"\f," [nil not-found loc open-ans all-ans next-property-change to from format-annotate-location ignore trans ans format-reorder 0 neg-ans 1 pos-ans 2 ignored append message "Can't close %s: not open." format-fn p t "These text properties could not be saved:\n %s"] 6 (#$ . 14503)]) #@473 Return annotation(s) needed at LOCATION. This includes any properties that change between LOC-1 and LOC. If ALL is true, don't look at previous location, but generate annotations for all non-nil properties. Third argument IGNORE is a list of text-properties not to consider. Return value is a vector of 3 elements: 1. List of names of the annotations to close 2. List of the names of annotations to open. 3. List of properties that were ignored or couldn't be annotated. (defalias 'format-annotate-location #[(loc all ignore trans) "S\n? !! \n \f\fD@ >:@ B AA) f@ >\\@ B AAK  @\n A \n >f\n?\n\f>A@\n >A@\n$\n\fB\f@ A )*f \f#. " [loc prev-loc all text-properties-at before-plist after-plist nil p negatives positives prop props not-found ignore after before format-annotate-single-property-change trans result vector] 6 (#$ . 16857)]) #@272 Return annotations for PROPERTY changing from OLD to NEW. These are searched for in the TRANSLATIONS alist. If NEW does not appear in the list, but there is a default function, then that function is called. Annotations to open and to close are returned as a dotted pair. (defalias 'format-annotate-single-property-change #[(prop old new trans) " \n\"A??---:9: