Path: utzoo!attcan!uunet!samsung!know!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!psuvax1!rutgers!mcnc!rti!talos!kjones From: kjones@talos.pm.com (Kyle Jones) Newsgroups: comp.emacs Subject: Re: %% vs. @@ Message-ID: <1990Jun27.145013.29422@talos.pm.com> Date: 27 Jun 90 14:50:13 GMT References: <87.P022y01JM01@JUTS.ccc.amdahl.com> Lines: 39 Kimball P Collins writes: > The %% (toggle-read-only) capability of emacs does not meet my needs > because I want the capability of changing the buffer. > > I am looking into implementing an additional feature, which has @@ on > the mode line in a different spot (different from where (**, %%) are) > and allows you to write into the buffer, but won't let the buffer be > saved. This is somewhat like making a buffer into another scratch > buffer for as long as it is in @@ mode. > > For this, I need to > > * write toggle-buffer-offer-save You'll need to do a bit more than just toggle buffer-offer-save. Emacs will ask to save any buffer that has a filename associated with it (via buffer-file-name). So your toggle function will need to set/reset the value of buffer-file-name for file buffers. > * add mode-line-buffer-offer-save to mode-line so that it > prints "@@" or "--" depending on the value of > mode-line-modified, or another variable > > The problem is that mode-line is not flexible about functions that can > be called for it. In fact, no user-specified functions can be called during mode-line-format processing. (I suspect that this restriction exists so that the display routines and other routines that call them needn't worry about garbage collection.) But you can control the mode-line based on the value of Lisp variables, and that's all you need here. Try this: (setq-default mode-line-modified (cons '(buffer-file-name "----" (buffer-offer-save "----" "--@@")) mode-line-modified))