From: lamport@src.dec.com
Subject: apparent obscure emacs bug
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 15 Dec 1992 08:51:48 GMT

Under some obscure set of circumstances, in 

  GNU Emacs 18.58.0 of Wed Nov 11 1992 on stuff.pa.dec.com (berkeley-unix)

the mode line isn't being redisplayed when the name of the buffer is
changed.  I have customized quite a bit, but I can't find anything in
the documentation that indicates that I should have been able to cause
the mode line not to be redisplayed when it gets changed.

Here is a recipe that causes the problem.  

1.  Evaluate the following defun.  (Sorry it's so long, but the
obvious two lines by themselves don't provoke the problem, and I don't
have time to find the minimal example.)

(defun reset-buffer-name ()
  "Removes a .xxx suffix from the current buffer's name"
  (let ( (newname (buffer-name))
         (oldname (buffer-name))
         mymark
         (done nil)
       )
    (save-window-excursion 
       (get-buffer-create "*#temp#*")
       (set-buffer "*#temp#*")
       (erase-buffer)
       (insert newname)
       (beginning-of-buffer)
       (if (not (null (search-forward "." nil t)))
          ; "." found
           (progn 
              (backward-char 1)
              (if (not (bobp))
                 ; name doesn't begin with "."
                 (progn 
                  (setq mymark (point))
                  (end-of-buffer)
                  (kill-region mymark (point))
                  (end-of-buffer)
                  (setq mymark (point))
                  (beginning-of-buffer)
                  (setq newname (buffer-substring (point) mymark)))))))
    (if (not (string= newname oldname))
       ; a "." has been stripped from name
       (while (not done)
        (if (and (not (null (get-buffer newname)))
                 (not (string= newname oldname)))
           ; a buffer by new name exists
            (if (y-or-n-p 
                    (message "Buffer %s exists; kill it? " newname))
               ; yes : delete buffer
                (progn (setq done t) 
                       (if (not (string= newname oldname))
                          (progn (kill-buffer newname)
                                 (rename-buffer newname))))
               ; no : ask for new name
                  (setq newname
                     (read-string "Enter name of buffer: " (buffer-name))))
           ; no buffer by new name exists--or user insists on re-using old name
            (progn (setq done t)
                   (if (not (string= newname oldname))
                      (rename-buffer newname))))))
   (message "Read file %s" (buffer-file-name))))

2.  Create a buffer named "foo" and one named "foo.1".  

3.  Enter buffer foo.1, using only one window.

4. Type <escape> <escape> (reset-buffer-name) <return>

    Emacs will then type "Buffer foo exists; kill it?  " and ask for a "y"
    or "n".  Type "y".

At this point, the mode line will claim that the buffer name is "foo.1".

5. Type ^L.

The mode line will now reveal that the buffer name is "foo".

Leslie Lamport

=============================================================================

P.S.  I understand that a new X-based version of Emacs is being written.
Is there anyone who would like to receive suggestions?

L. L.

Newsgroups: gnu.emacs.bug