emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make-indirect-buffer


From: Luc Teirlinck
Subject: make-indirect-buffer
Date: Sun, 11 Apr 2004 23:58:56 -0500 (CDT)

Executing the following ielm run after `emacs -q' makes Emacs crash:

===File ~/indi-after-crash==================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setq apr (get-buffer-create "april"))
#<buffer april>
ELISP> (with-current-buffer apr (insert "123"))
nil
ELISP> (kill-buffer apr)
t
ELISP> (make-indirect-buffer apr "indi")
#<buffer indi>
ELISP> (buffer-base-buffer (get-buffer "indi"))
#<killed buffer>
ELISP> (buffer-size (get-buffer "indi"))
3
ELISP> (switch-to-buffer "indi")
#<buffer indi>
ELISP> 
============================================================

(The last two lines are from the auto-save file.)

I do not understand how it could possibly be useful to make an
indirect buffer with a killed base buffer, especially since killing a
base buffer automatically kills all indirect buffers.  So my solution
is to throw an error if one tries to make an indirect buffer with
killed base buffer.  The following trivial patch would do that.  I
could install if desired.

===File ~/buffer.c-diff=====================================
*** buffer.c    11 Apr 2004 10:08:04 -0500      1.448
--- buffer.c    11 Apr 2004 23:08:34 -0500      
***************
*** 539,544 ****
--- 539,546 ----
    base_buffer = Fget_buffer (base_buffer);
    if (NILP (base_buffer))
      error ("No such buffer: `%s'", SDATA (name));
+   if (NILP (XBUFFER (base_buffer)->name))
+     error ("Base buffer has been killed");
  
    if (SCHARS (name) == 0)
      error ("Empty string for buffer name is not allowed");
============================================================

After the patch we get:

===File ~/indi-after-patch==================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setq apr (get-buffer-create "april"))
#<buffer april>
ELISP> (with-current-buffer apr (insert "123"))
nil
ELISP> (kill-buffer apr)
t
ELISP> (make-indirect-buffer apr "indi")
*** Eval error ***  Base buffer has been killed
ELISP> (make-indirect-buffer apr "indi" t)
*** Eval error ***  Base buffer has been killed
ELISP> 
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]