bug-gnu-emacs
[Top][All Lists]
Advanced

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

Buffers not deleted correctly with server/emacsclient


From: daniel dever
Subject: Buffers not deleted correctly with server/emacsclient
Date: Fri, 8 Aug 2003 13:50:46 -0400

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the address@hidden mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2002-05-27 on s0022
configured using `configure  --prefix=/proj/usertools/ia32_linux/'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

from shell tcsh on Linux (er, GNU/Linux :-):
    > setenv EDITOR emacsclient
    > emacs -q -f server-start &
    > more phone_listing.txt
      v     [in more]
      C-x # [in emacs]
      [Notice that buffer is buried, but _not_ deleted in emacs,
       as it should be.]

The value of server-kill-new-buffers is t.

I believe the problem is that server-buffer-done in
server.el checks for server-existing-buffer instead of
(not server-existing-buffer).  I've included a copy of
that function with this change made to it.

The function now seems to work, but be warned that I
haven't spent much effort testing it.

Search for DED to locate my change.

/Dan Dever
address@hidden

------------------------------------------------------------
;; Here is the documentation for server-kill-new-buffers:
;;
;;      Documentation:
;;      *Whether to kill buffers when done with them.
;;      If non-nil, kill a buffer unless it already existed before editing
;;      it with Emacs server. If nil, kill only buffers as specified by
;;      `server-temp-file-regexp'.
;;      Please note that only buffers are killed that still have a client,
;;      i.e. buffers visited which "emacsclient --no-wait" are never killed in
;;      this way.
;;      
;;      You can customize this variable.
;;      
;;      Defined in `server'.
;;
;; However, the opposite was happening.  The buffer was only being deleted
;; if it did already exist.
;;
;; Search for 'DED' to see my change.

(defun server-buffer-done (buffer &optional for-killing)
  "Mark BUFFER as \"done\" for its client(s).
This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED).
NEXT-BUFFER is another server buffer, as a suggestion for what to select next,
or nil.  KILLED is t if we killed BUFFER
\(typically, because it was visiting a temp file)."
  (let ((running (eq (process-status server-process) 'run))
        (next-buffer nil)
        (killed nil)
        (first t)
        (old-clients server-clients))
    (while old-clients
      (let ((client (car old-clients)))
        (or next-buffer 
            (setq next-buffer (nth 1 (memq buffer client))))
        (delq buffer client)
        ;; Delete all dead buffers from CLIENT.
        (let ((tail client))
          (while tail
            (and (bufferp (car tail))
                 (null (buffer-name (car tail)))
                 (delq (car tail) client))
            (setq tail (cdr tail))))
        ;; If client now has no pending buffers,
        ;; tell it that it is done, and forget it entirely.
        (if (cdr client) nil
          (if running
              (progn
                ;; Don't send emacsserver two commands in close succession.
                ;; It cannot handle that.
                (or first (sit-for 1))
                (setq first nil)
                (send-string server-process 
                             (format "Close: %s Done\n" (car client)))
                (server-log (format "Close: %s Done\n" (car client)))))
          (setq server-clients (delq client server-clients))))
      (setq old-clients (cdr old-clients)))
    (if (and (bufferp buffer) (buffer-name buffer))
        ;; We may or may not kill this buffer;
        ;; if we do, do not call server-buffer-done recursively
        ;; from kill-buffer-hook.
        (let ((server-kill-buffer-running t))
          (save-excursion
            (set-buffer buffer)
            (setq server-buffer-clients nil)
            (run-hooks 'server-done-hook))
          ;; Notice whether server-done-hook killed the buffer.
          (if (null (buffer-name buffer))
              (setq killed t)
            ;; Don't bother killing or burying the buffer
            ;; when we are called from kill-buffer.
            (unless for-killing
              (when (and (not killed)
                         server-kill-new-buffers
                         ;; DED: Added the 'not' 8 August 2003
                         (not (save-excursion
                                (set-buffer buffer)
                                server-existing-buffer)))
                (setq killed t)
                (bury-buffer buffer)
                (kill-buffer buffer))
              (unless killed
                (if (server-temp-file-p buffer)
                    (progn
                      (kill-buffer buffer)
                      (setq killed t))
                  (bury-buffer buffer)))))))
    (list next-buffer killed)))





reply via email to

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