Mercurial > hg > xemacs-beta
comparison lisp/cmdloop.el @ 3698:7d97cf62c899
[xemacs-hg @ 2006-11-24 13:45:37 by aidan]
Within truncate-command-history-for-gc, delay execution of all things that look up variable bindings, via 'enqueue-eval-event'.
author | aidan |
---|---|
date | Fri, 24 Nov 2006 13:45:38 +0000 |
parents | 94903620d912 |
children | 38ef5a6da799 |
comparison
equal
deleted
inserted
replaced
3697:29836a140619 | 3698:7d97cf62c899 |
---|---|
181 ;;#### Must be done later in the loadup sequence | 181 ;;#### Must be done later in the loadup sequence |
182 ;(define-key (symbol-function 'help-command) "e" 'describe-last-error) | 182 ;(define-key (symbol-function 'help-command) "e" 'describe-last-error) |
183 | 183 |
184 | 184 |
185 (defun truncate-command-history-for-gc () | 185 (defun truncate-command-history-for-gc () |
186 (let ((tail (nthcdr 30 command-history))) | 186 ;; We should try to avoid accessing any bindings to speak of in this |
187 (if tail (setcdr tail nil))) | 187 ;; function; as this hook is called asynchronously, the search for |
188 (let ((tail (nthcdr 30 values))) | 188 ;; those bindings might search local bindings from essentially |
189 (if tail (setcdr tail nil))) | 189 ;; arbitrary functions. We force the body of the function to run at |
190 ) | 190 ;; command-loop level, where the danger of local bindings is much |
191 ;; reduced; the code can still do its job because the command history | |
192 ;; and values list will not grow before then anyway. | |
193 ;; | |
194 ;; Nothing is done in batch mode, both because it is a waste of time | |
195 ;; (there is no command loop!) and because this any GCs during dumping | |
196 ;; will invoke this code, and if it were to enqueue an eval event, | |
197 ;; the portable dumper would try to dump it and fail. | |
198 (if (not (noninteractive)) | |
199 (enqueue-eval-event | |
200 (lambda (arg) | |
201 (let ((tail (nthcdr 30 command-history))) | |
202 (if tail (setcdr tail nil))) | |
203 (let ((tail (nthcdr 30 values))) | |
204 (if tail (setcdr tail nil)))) | |
205 nil))) | |
191 | 206 |
192 (add-hook 'pre-gc-hook 'truncate-command-history-for-gc) | 207 (add-hook 'pre-gc-hook 'truncate-command-history-for-gc) |
193 | 208 |
194 | 209 |
195 ;;;; Object-oriented programming at its finest | 210 ;;;; Object-oriented programming at its finest |