Mercurial > emacs
changeset 48214:22a18a9dae2a
(format-decode): Be careful with the order in `format'.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 08 Nov 2002 02:37:46 +0000 |
parents | a54c4e29ca9e |
children | 4758bc5cd792 |
files | lisp/format.el |
diffstat | 1 files changed, 21 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/format.el Thu Nov 07 23:18:45 2002 +0000 +++ b/lisp/format.el Fri Nov 08 02:37:46 2002 +0000 @@ -246,8 +246,8 @@ 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. +to the reverted list of formats used, and call any mode functions defined +for those formats. Returns the new length of the decoded region. @@ -269,7 +269,7 @@ (if (and regexp (looking-at regexp) (< (match-end 0) (+ begin length))) (progn - (setq format (cons (car f) format)) + (push (car f) format) ;; Decode it (if (nth 3 f) (setq end (format-decode-run-method (nth 3 f) begin end))) @@ -291,7 +291,9 @@ (setq end (format-decode-run-method (nth 3 f) begin end))) ;; Call visit function if required (if (and visit-flag (nth 6 f)) (funcall (nth 6 f) 1)) - (setq do (cdr do))))) + (setq do (cdr do)))) + ;; Encode in the opposite order. + (setq format (reverse format))) (if visit-flag (setq buffer-file-format format))) @@ -613,7 +615,7 @@ (delete-region loc end) (cond ;; Positive annotations are stacked, remembering location - (positive (setq open-ans (cons `(,name ((,loc . nil))) open-ans))) + (positive (push `(,name ((,loc . nil))) open-ans)) ;; It is a negative annotation: ;; Close the top annotation & add its text property. ;; If the file's nesting is messed up, the close might not match @@ -693,7 +695,7 @@ ;; Not a property, but a function. (let ((rtn (apply value start loc params))) - (if rtn (setq todo (cons rtn todo))))) + (if rtn (push rtn todo)))) (t ;; Normal property/value pair (setq todo @@ -758,12 +760,12 @@ (cond ;; The minuend starts after the subtrahend ends; keep it. ((> (car m) (cdr s)) - (setq results (cons m results) - minuend (cdr minuend) + (push m results) + (setq minuend (cdr minuend) m (car minuend))) ;; The minuend extends beyond the end of the subtrahend. Chop it off. ((or (null (cdr m)) (> (cdr m) (cdr s))) - (setq results (cons (cons (1+ (cdr s)) (cdr m)) results)) + (push (cons (1+ (cdr s)) (cdr m)) results) (setcdr m (cdr s))) ;; The subtrahend starts after the minuend ends; throw it away. ((< (cdr m) (car s)) @@ -878,7 +880,7 @@ (while (not (equal (car neg-ans) (car open-ans))) ;; To close anno. N, need to first close ans 1 to N-1, ;; remembering to re-open them later. - (setq pos-ans (cons (car open-ans) pos-ans)) + (push (car open-ans) pos-ans) (setq all-ans (cons (cons loc (funcall format-fn (car open-ans) nil)) all-ans)) @@ -886,17 +888,15 @@ ;; Now remove the one we're really interested in from open list. (setq open-ans (cdr open-ans)) ;; And put the closing annotation here. - (setq all-ans - (cons (cons loc (funcall format-fn (car neg-ans) nil)) - all-ans))) + (push (cons loc (funcall format-fn (car neg-ans) nil)) + all-ans)) (setq neg-ans (cdr neg-ans))) ;; Now deal with positive (opening) annotations (let ((p pos-ans)) (while pos-ans - (setq open-ans (cons (car pos-ans) open-ans)) - (setq all-ans - (cons (cons loc (funcall format-fn (car pos-ans) t)) - all-ans)) + (push (car pos-ans) open-ans) + (push (cons loc (funcall format-fn (car pos-ans) t)) + all-ans) (setq pos-ans (cdr pos-ans)))))) ;; Close any annotations still open @@ -937,17 +937,16 @@ (setq p before-plist) (while p (if (not (memq (car p) props)) - (setq props (cons (car p) props))) + (push (car p) props)) (setq p (cdr (cdr p)))) (setq p after-plist) (while p (if (not (memq (car p) props)) - (setq props (cons (car p) props))) + (push (car p) props)) (setq p (cdr (cdr p)))) (while props - (setq prop (car props) - props (cdr props)) + (setq prop (pop props)) (if (memq prop ignore) nil ; If it's been ignored before, ignore it now. (let ((before (if all nil (car (cdr (memq prop before-plist))))) @@ -957,7 +956,7 @@ (let ((result (format-annotate-single-property-change prop before after translations))) (if (not result) - (setq not-found (cons prop not-found)) + (push prop not-found) (setq negatives (nconc negatives (car result)) positives (nconc positives (cdr result))))))))) (vector negatives positives not-found)))