[gnu.emacs] Bug

randy@umn-cs.CS.UMN.EDU (Randy Orrison) (01/18/89)

I'm using GNU emacs in server mode under X windows.  The problem that
I've found is that when I use emacsclient, and change the mode of the
buffer (say, from Fundamental to Text for editing mail), emacs forgets
that that buffer was a server buffer, and so C-x # does nothing, and
the only way I've found to let the client continue on is to exit
emacs.  Shouldn't the server attribute (is it a minor mode?) be kept
when the major mode of a buffer changes?

Relevant stats:  Emacs version 18.51 under X11R2 on SunOS 3.5 on Sun 3
	machines (varied).

(Is this fixed in 18.52?)

	-randy
--
Randy Orrison, Chemical Computer Thinking Battery  --  randy@cctb.mn.org
(aka randy@{ux.acss.umn.edu, umn-cs.uucp, umnacca.bitnet, garnet.uucp})
Tonight's the night: Sleep in a eucalyptus tree.

nate@hobbes.intel.com (Nate Hess) (01/19/89)

In article <10864@umn-cs.CS.UMN.EDU>, randy@umn-cs (Randy Orrison) writes:
>the only way I've found to let the client continue on is to exit emacs.

You can always go back to the "Waiting for Emacs..." message and type
'C-c' to kill the emacsclient process -- you don't have to do anything
to the Emacs process.

--woodstock
--
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

woodstock@hobbes.intel.com   ...!{decwrl|hplabs!oliveb|amd}!intelca!mipos3!nate 

jbw@bucsb.UUCP (Joe Wells) (01/19/89)

In article <10864@umn-cs.CS.UMN.EDU> randy@umn-cs (Randy Orrison) writes:
>I'm using GNU emacs in server mode under X windows.  The problem that
>I've found is that when I use emacsclient, and change the mode of the
>buffer (say, from Fundamental to Text for editing mail), emacs forgets
>that that buffer was a server buffer, and so C-x # does nothing, and
>the only way I've found to let the client continue on is to exit
>emacs.  Shouldn't the server attribute (is it a minor mode?) be kept
>when the major mode of a buffer changes?
>
>(Is this fixed in 18.52?)

No, this isn't fixed in any version.  This is a consequence of the
fact that almost every major mode calls the function
kill-all-local-variables to clear out mode specific settings.  This
also destroys any other local variables.

Here is a fix:
(require 'kill-fix) ; this file follows
(put 'server-buffer-clients 'preserved t)

The file kill-fix.el is at the end of this message.
--
Joe Wells		INTERNET: jbw%bucsf.bu.edu@bu-it.bu.edu
UUCP: ...!harvard!bu-cs!bucsf!jbw	      IP: [128.197.2.9]
----------------------------------------------------------------------
;; Enhancement to kill-all-local-variables
;; Copyright (C) 1988 Free Software Foundation, Inc.

;; This file is not officially part of GNU Emacs, but is being donated
;; to the Free Software Foundation.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY.  No author or distributor
;; accepts responsibility to anyone for the consequences of using it
;; or for whether it serves any particular purpose or works at all,
;; unless he says so in writing.  Refer to the GNU Emacs General Public
;; License for full details.

;; Everyone is granted permission to copy, modify and redistribute
;; GNU Emacs, but only under the conditions described in the
;; GNU Emacs General Public License.   A copy of this license is
;; supposed to have been given to you along with GNU Emacs so you
;; can know your rights and responsibilities.  It should be in a
;; file named COPYING.  Among other things, the copyright notice
;; and this notice must be preserved on all copies.

;; Author: Joe Wells
;; jbw%bucsf.bu.edu@bu-it.bu.edu (school year)
;; joew%uswest@boulder.colorado.edu (summer)

;; save the original subr function definition of kill-all-local-variables
(or (fboundp 'original-kill-all-local-variables)
    (fset 'original-kill-all-local-variables
	  (symbol-function 'kill-all-local-variables)))

(defun kill-all-local-variables ()
  "Eliminate all the buffer-local variable values of the current
buffer.  This buffer will then see the default values of all
variables.  NOTE: This function has been modified to ignore
buffer-local variables whose preserved property is non-nil."
  (let ((oldvars (buffer-local-variables)))
    (original-kill-all-local-variables)
    (while oldvars
      (let ((var (car (car oldvars))))
	(cond ((get var 'preserved)
	       (make-local-variable var)
	       (set var (cdr (car oldvars))))))
      (setq oldvars (cdr oldvars)))))

(provide 'kill-fix)