all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Buffers not deleted correctly with server/emacsclient
@ 2003-08-08 17:50 daniel dever
  0 siblings, 0 replies; only message in thread
From: daniel dever @ 2003-08-08 17:50 UTC (permalink / raw)
  Cc: daniel.dever

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 bug-gnu-emacs@gnu.org 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
daniel.dever@intel.com

------------------------------------------------------------
;; 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)))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-08-08 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-08 17:50 Buffers not deleted correctly with server/emacsclient daniel dever

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.