Changeset 4140 for trunk/lisp/format.el
- Timestamp:
- 08/10/06 11:19:54 (2 years ago)
- Files:
-
- trunk/lisp/format.el (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/format.el
r4037 r4140 118 118 REGEXP is a regular expression to match against the beginning of the file; 119 119 it should match only files in that format. Use nil to avoid 120 matching at all for formats for which thisisn't appropriate to120 matching at all for formats for which it isn't appropriate to 121 121 require explicit encoding/decoding. 122 122 123 FROM-FN is called to decode files in that format; it gets two args, BEGIN123 FROM-FN is called to decode files in that format; it takes two args, BEGIN 124 124 and END, and can make any modifications it likes, returning the new 125 125 end. It must make sure that the beginning of the file no longer … … 128 128 (including options) to be used as a filter to perform the conversion. 129 129 130 TO-FN is called to encode a region into that format; it is passedthree130 TO-FN is called to encode a region into that format; it takes three 131 131 arguments: BEGIN, END, and BUFFER. BUFFER is the original buffer that 132 132 the data being written came from, which the function could use, for … … 143 143 MODE-FN, if specified, is called when visiting a file with that format. 144 144 It is called with a single positive argument, on the assumption 145 that it turns on some Emacsmode.145 that this would turn on some minor mode. 146 146 147 147 PRESERVE, if non-nil, means that `format-write-file' should not remove … … 151 151 152 152 (defun format-encode-run-method (method from to &optional buffer) 153 "Translate using function or shell scriptMETHOD the text from FROM to TO.154 If METHOD is a string, it is a shell command ;153 "Translate using METHOD the text from FROM to TO. 154 If METHOD is a string, it is a shell command (including options); 155 155 otherwise, it should be a Lisp function. 156 156 BUFFER should be the buffer that the output originally came from." … … 174 174 175 175 (defun format-decode-run-method (method from to &optional buffer) 176 "Decode using function or shell scriptMETHOD the text from FROM to TO.177 If METHOD is a string, it is a shell command ; otherwise, it should be178 a Lisp function. Decoding is done for the given BUFFER."176 "Decode using METHOD the text from FROM to TO. 177 If METHOD is a string, it is a shell command (including options); otherwise, 178 it should be a Lisp function. Decoding is done for the given BUFFER." 179 179 (if (stringp method) 180 180 (let ((error-buff (get-buffer-create "*Format Errors*")) … … 201 201 (defun format-annotate-function (format from to orig-buf format-count) 202 202 "Return annotations for writing region as FORMAT. 203 FORMAT is a symbol naming one of the formats defined in `format-alist' ,204 it must be a single symbol, not a list like `buffer-file-format'.203 FORMAT is a symbol naming one of the formats defined in `format-alist'. 204 It must be a single symbol, not a list like `buffer-file-format'. 205 205 FROM and TO delimit the region to be operated on in the current buffer. 206 206 ORIG-BUF is the original buffer that the data came from. … … 209 209 been called in the process of decoding ORIG-BUF. 210 210 211 This function works like a function on `write-region-annotate-functions':211 This function works like a function in `write-region-annotate-functions': 212 212 it either returns a list of annotations, or returns with a different buffer 213 213 current, which contains the modified text to write. In the latter case, … … 254 254 for those formats. 255 255 256 Return sthe new length of the decoded region.256 Return the new length of the decoded region. 257 257 258 258 For most purposes, consider using `format-decode-region' instead." … … 313 313 (defun format-decode-buffer (&optional format) 314 314 "Translate the buffer from some FORMAT. 315 If the format is not specified, this function attempts toguess.316 `buffer-file-format' is set to the format used, and any mode-functions 317 for the format are called."315 If the format is not specified, attempt a regexp-based guess. 316 Set `buffer-file-format' to the format used, and call any 317 format-specific mode functions." 318 318 (interactive 319 319 (list (format-read "Translate buffer from format (default guess): "))) … … 344 344 (defun format-encode-region (beg end &optional format) 345 345 "Translate the region into some FORMAT. 346 FORMAT defaults to `buffer-file-format' , it is a symbol naming346 FORMAT defaults to `buffer-file-format'. It is a symbol naming 347 347 one of the formats defined in `format-alist', or a list of such symbols." 348 348 (interactive … … 375 375 name as FILENAME, to write a file of the same old name in that directory. 376 376 377 If optional third arg CONFIRM is non-nil, this function asks for378 confirmation before overwriting an existing file. Interactively, 379 confirmation is requiredunless you supply a prefix argument."377 If optional third arg CONFIRM is non-nil, ask for confirmation before 378 overwriting an existing file. Interactively, confirmation is required 379 unless you supply a prefix argument." 380 380 (interactive 381 381 ;; Same interactive spec as write-file, plus format question. … … 420 420 If FORMAT is nil then do not do any format conversion. 421 421 The optional third and fourth arguments BEG and END specify 422 the part of the file to read.422 the part (in bytes) of the file to read. 423 423 424 424 The return value is like the value of `insert-file-contents': … … 457 457 "Do multiple replacements on the buffer. 458 458 ALIST is a list of (FROM . TO) pairs, which should be proper arguments to 459 `search-forward' and `replace-match' respectively.460 Optional 2nd arg REVERSE, if non-nil, means the pairs are (TO . FROM), so that461 you can use the same list in both directions if it contains only literal 462 strings.459 `search-forward' and `replace-match', respectively. 460 Optional second arg REVERSE, if non-nil, means the pairs are (TO . FROM), 461 so that you can use the same list in both directions if it contains only 462 literal strings. 463 463 Optional args BEG and END specify a region of the buffer on which to operate." 464 464 (save-excursion … … 498 498 (defun format-make-relatively-unique (a b) 499 499 "Delete common elements of lists A and B, return as pair. 500 Compare susing `equal'."500 Compare using `equal'." 501 501 (let* ((acopy (copy-sequence a)) 502 502 (bcopy (copy-sequence b)) … … 512 512 (defun format-common-tail (a b) 513 513 "Given two lists that have a common tail, return it. 514 Compare s with `equal', and returnsthe part of A that is equal to the514 Compare with `equal', and return the part of A that is equal to the 515 515 equivalent part of B. If even the last items of the two are not equal, 516 return snil."516 return nil." 517 517 (let ((la (length a)) 518 518 (lb (length b))) … … 535 535 536 536 (defun format-reorder (items order) 537 "Arrange ITEMS to follow ingpartial ORDER.538 Elements of ITEMS equal to elements of ORDER will be rearranged to follow the539 ORDER. Unmatched items will go last."537 "Arrange ITEMS to follow partial ORDER. 538 Elements of ITEMS equal to elements of ORDER will be rearranged 539 to follow the ORDER. Unmatched items will go last." 540 540 (if order 541 541 (let ((item (member (car order) items))) … … 794 794 ;; we have to see if we passed TO. 795 795 (defun format-property-increment-region (from to prop delta default) 796 " Over the region between FROM andTO increment property PROP by amount DELTA.796 "In the region from FROM to TO increment property PROP by amount DELTA. 797 797 DELTA may be negative. If property PROP is nil anywhere 798 798 in the region, it is treated as though it were DEFAULT." … … 811 811 (defun format-insert-annotations (list &optional offset) 812 812 "Apply list of annotations to buffer as `write-region' would. 813 Insert seach element of the given LIST of buffer annotations at its813 Insert each element of the given LIST of buffer annotations at its 814 814 appropriate place. Use second arg OFFSET if the annotations' locations are 815 815 not relative to the beginning of the buffer: annotations will be inserted … … 835 835 (defun format-annotate-region (from to translations format-fn ignore) 836 836 "Generate annotations for text properties in the region. 837 Search es for changes between FROM and TO, and describesthem with a list of837 Search for changes between FROM and TO, and describe them with a list of 838 838 annotations as defined by alist TRANSLATIONS and FORMAT-FN. IGNORE lists text 839 839 properties not to consider; any text properties that are neither ignored nor … … 976 976 These are searched for in the translations alist TRANSLATIONS 977 977 (see `format-annotate-region' for the format). 978 If NEW does not appear in the list, but there is a default function, then that979 function is called.980 Return sa cons of the form (CLOSE . OPEN)978 If NEW does not appear in the list, but there is a default function, 979 then call that function. 980 Return a cons of the form (CLOSE . OPEN) 981 981 where CLOSE is a list of annotations to close 982 982 and OPEN is a list of annotations to open. … … 1017 1017 1018 1018 (defun format-annotate-atomic-property-change (prop-alist old new) 1019 "Internal function annotate a single property change.1019 "Internal function to annotate a single property change. 1020 1020 PROP-ALIST is the relevant element of a TRANSLATIONS list. 1021 1021 OLD and NEW are the values."
