Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!njin!princeton!phoenix!ghh From: ghh@cognito.princeton.edu (Gilbert Harman) Newsgroups: gnu.emacs Subject: Re: save-context-predicate in saveconf.el Message-ID: Date: 25 Jul 89 16:35:28 GMT References: <1989Jul25.145204.3015@talos.uucp> Sender: news@phoenix.Princeton.EDU Distribution: na Organization: Princeton University Cognitive Science Lab Lines: 66 In-reply-to: kjones@talos.uucp's message of 25 Jul 89 14:52:04 GMT In article <1989Jul25.145204.3015@talos.uucp> kjones@talos.uucp (Kyle Jones) writes: Gilbert Harman writes: > This is what I tried in my .emacs file so as to prevent my > RMAIL file from being remembered. > > (setq save-context-predicate > (function (lambda (w) > (and (buffer-file-name (window-buffer w)) > (not (string-match "\\(^\\(/usr\\)?/tmp/\\)\\|RMAIL" > (buffer-file-name (window-buffer w))))))) > ) This won't work unless the RMAIL buffer is in a window. The value of save-context-predicate is called for each *window*, not each buffer. Perhaps save-context-predicate's semantics should be changed to the latter. Thanks for the pointer. I have a quick and dirty solution that introduces a new variable, save-buffer-predicate, initially defined as follows: (defvar save-buffer-predicate (function (lambda (w) (and (not (string-match "\\(^\\(/usr\\)?/tmp/\\)\\|RMAIL" w))))) "*Value is a predicate function which determines which buffers' contexts are saved. When the `save-context' command is invoked and save-buffer-context is not nil, this function will be called once for each existing Emacs buffer. The function should accept one argument which will be a buffer name, and should return non-nil if the buffer's context should be saved.") Then I modified the save-context function by inserting an application of this function: ... (if save-buffer-context (mapcar (function (lambda (b) (set-buffer b) (cond ((and buffer-file-name (funcall save-buffer-predicate buffer-file-name)) (prin1 buffer-file-name context-buffer) (princ " " context-buffer) (prin1 (point) context-buffer) (princ "\n" context-buffer))))) (buffer-list))) ... The antecedent in the cond originally checked to make sure that buffer-file-name is not nil. This now also checks to make sure the name isn't the name of a file you don't want to save the context for. This seems to work. -- Gilbert Harman Princeton University Cognitive Science Laboratory 221 Nassau Street, Princeton, NJ 08542 ghh@princeton.edu HARMAN@PUCC.BITNET