[comp.emacs] deleted buffers

jcgs@harlqn.UUCP (John Sturdy) (11/22/88)

Could anyone tell me how to recognize a deleted buffer object? I'm looking
for something like
   (buffer-deleted-p BUFFER)
or
   (deleted-buffer-p OBJECT)
but I can't find anything like them.


__John            When asked to attend a court case, Father Moses took with him
          a leaking jug of water. Asked about it, he said: "You ask me to judge
               the faults of another, while mine run out like water behind me."
         jcgs@uk.co.harlqn Harlequin Ltd,Barrington,Cambridge,UK +44-223-872522
-- 
__John            When asked to attend a court case, Father Moses took with him
          a leaking jug of water. Asked about it, he said: "You ask me to judge
               the faults of another, while mine run out like water behind me."
         jcgs@uk.co.harlqn Harlequin Ltd,Barrington,Cambridge,UK +44-223-872522

mesard@bbn.com (Wayne Mesard) (11/27/88)

From article <1587@harlqn.UUCP>, by jcgs@harlqn.UUCP (John Sturdy):
> Could anyone tell me how to recognize a deleted buffer object? I'm looking
> for something like
>    (buffer-deleted-p BUFFER)
> or
>    (deleted-buffer-p OBJECT)
> but I can't find anything like them.

When a buffer gets killed, the buffer structure (I assume) gets set to
#<killed buffer> if anything's still pointing to it.  And the
buffer-name of this psuedo buffer is nil.  So, this should do what you want:

  (defun killed-bufferp (buffer)
    (and (bufferp buffer)
         (null (buffer-name buffer))))


[The above was derived from setq'ing a variable to (car (buffer-list)),
killing the buffer and seeing what happened.  IOW, this is the voice of
limited experience, not authority.]

-- 
unsigned *Wayne_Mesard();    "Whatta maroon!"
MESARD@BBN.COM                           -B.Bunny
BBN, Cambridge, MA            

merlyn@intelob.biin.com (Randal L. Schwartz @ Stonehenge) (11/27/88)

In article <1587@harlqn.UUCP>, jcgs@harlqn (John Sturdy) writes:
| Could anyone tell me how to recognize a deleted buffer object? I'm looking
| for something like
|    (buffer-deleted-p BUFFER)
| or
|    (deleted-buffer-p OBJECT)
| but I can't find anything like them.

How about something like:

(defun deleted-buffer-p (object)
  "T if OBJECT is a deleted editor buffer."
  (and (bufferp object)
       (not (memq object (buffer-list)))))

I tried it on two test cases, and it worked.  Your mileage may vary.

Why are you testing for a deleted buffer?
-- 
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN Technical Information Services (for now :-),
in a former Intel building in Hillsboro, Oregon, USA.
<merlyn@intelob.biin.com> or ...!tektronix!inteloa[!intelob]!merlyn
SOME MAILERS REQUIRE <merlyn@intelob.intel.com> GRRRRR!
Standard disclaimer: I *am* my employer!

umerin@photon.stars.flab.Fujitsu.JUNET (Masanobu UMEDA) (11/28/88)

In article <32722@bbn.COM> mesard@bbn.com (Wayne Mesard) writes:
   From article <1587@harlqn.UUCP>, by jcgs@harlqn.UUCP (John Sturdy):
   > Could anyone tell me how to recognize a deleted buffer object? I'm looking
   > for something like
   >    (buffer-deleted-p BUFFER)
   > or
   >    (deleted-buffer-p OBJECT)
   > but I can't find anything like them.

   When a buffer gets killed, the buffer structure (I assume) gets set to
   #<killed buffer> if anything's still pointing to it.  And the
   buffer-name of this psuedo buffer is nil.  So, this should do what you want:

     (defun killed-bufferp (buffer)
       (and (bufferp buffer)
	    (null (buffer-name buffer))))

Or, (not (memq buffer (buffer-list)))
--
Masanobu UMEDA
umerin@flab.flab.Fujitsu.JUNET
umerin%flab.flab.Fujitsu.JUNET@uunet.uu.NET

jcgs@harlqn.UUCP (John Sturdy) (11/28/88)

In article <3234@mipos3.intel.com> merlyn@intelob.biin.com (Randal L. Schwartz @ Stonehenge) writes:
>Why are you testing for a deleted buffer?
So that a special buffer, which may get deleted at some time, can be 
reconstructed next time it is wanted.

-- 
__John
                      All manner of things will be well (St. Julian of Norwich)

         jcgs@uk.co.harlqn Harlequin Ltd,Barrington,Cambridge,UK +44-223-872522