From xemacs-m  Wed May 14 14:56:21 1997
Received: from frege.math.ethz.ch (root@frege-d-math-north-g-west.math.ethz.ch [129.132.145.3])
	by xemacs.org (8.8.5/8.8.5) with SMTP id OAA25109
	for <xemacs-beta@xemacs.org>; Wed, 14 May 1997 14:56:19 -0500 (CDT)
Received: from midget.math.ethz.ch (vroonhof@midget [129.132.145.4]) by frege.math.ethz.ch (8.6.12/Main-STAT-mailer) with ESMTP id VAA22927; Wed, 14 May 1997 21:55:21 +0200
Received: (vroonhof@localhost) by midget.math.ethz.ch (8.6.12/D-MATH-client) id VAA28261; Wed, 14 May 1997 21:54:36 +0200
Sender: vroonhof@math.ethz.ch
To: xemacs-beta@xemacs.org, Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: [patch] Gnuserv rewritten
References: <kign2pyb8d1.fsf@jagor.srce.hr>
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_May_14_21:54:36_1997-1"
Content-Transfer-Encoding: 7bit
From: Jan Vroonhof <vroonhof@math.ethz.ch>
Date: 14 May 1997 21:54:36 +0200
In-Reply-To: Hrvoje Niksic's message of 14 May 1997 13:28:42 +0200
Message-ID: <byenb9q16r.fsf@midget.math.ethz.ch>
Lines: 175
X-Mailer: Gnus v5.4.37/XEmacs 19.15

--Multipart_Wed_May_14_21:54:36_1997-1
Content-Type: text/plain; charset=US-ASCII

Hrvoje Niksic <hniksic@srce.hr> writes:

> Here is the new, rewritten version of gnuserv.el.  All the variables
> and functions have been renamed from `server-*' to `gnuserv-*', but I
> kept the old variables as aliases, to avoid major breakage for old
> users.

The following patches:

1. Reintroduce rcs strings. That's easier for me and my CVS tree.
2. Change some framep's to frame-live-p's
3. Add some nifty stuff for gnuserv-frame (including customizations).

There is one bug (incompatibilty). It used to be that if you pressed
C-x # in a buffer that didn't have client you switched to the first
buffer to have one, now it just barfs.

Late Addition: I am seeing far too many "Restarted Server" when
calling gnuserv-edit.

Jan


--Multipart_Wed_May_14_21:54:36_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="gs2.patch"
Content-Transfer-Encoding: 7bit

Index: gnuserv.el
===================================================================
RCS file: /u/users/vroonhof/master/emacs/gnuserv/lisp/packages/gnuserv.el,v
retrieving revision 3.1.1.1
retrieving revision 3.1.1.1.2.2
diff -u -r3.1.1.1 -r3.1.1.1.2.2
--- gnuserv.el	1997/05/14 16:52:25	3.1.1.1
+++ gnuserv.el	1997/05/14 19:35:08	3.1.1.1.2.2
@@ -68,6 +68,7 @@
 ;;     Completely rewritten.  Now uses `defstruct' and other CL stuff
 ;;     to define clients cleanly.  Dave, thanks!
 ;;
+(setq gnuserv-rcs-version "$Id: gnuserv.el,v 3.1.1.1.2.2 1997/05/14 19:35:08 vroonhof Exp $")
 
 
 ;;; Code:
@@ -83,8 +84,22 @@
 (defcustom gnuserv-frame nil
   "*The frame to be used to display all edited files.
 If nil, then a new frame is created for each file edited.
-If t, then the currently selected frame will be used."
-  :type 'sexp
+If t, then the currently selected frame will be used.
+
+If this is function, then this will be called with one argument `type'
+as in `server-edit-files'. The return value of this function is interpreted as
+above. See also `gnuserv-frame-main-frame-function' and
+`gnuserv-frame-main-frame-function'."
+  :tag "Create new frame for client buffer?"
+  :type '(radio (const :tag "Yes, each time" nil)
+		(const :tag "No, use selected frame" t)
+	        (function-item :tag "No, use main Emacs frame"
+			       gnuserv-frame-main-frame-function)
+		(function-item :tag "Only if there is no frame visible"
+			       gnuserv-frame-truely-visible-frame-function)
+		(function-item :tag "Create special Gnuserv frame"
+			       gnuserv-frame-create-special-function)
+		(sexp :tag "Other"))
   :group 'gnuserv)
 
 (defcustom gnuserv-done-function 'kill-buffer 
@@ -290,19 +305,22 @@
        (error "%s: invalid flags" flags))
   (let* ((old-device-num (length (device-list)))
 	 (new-frame nil)
-	 ;; The gnuserv-frame dependencies are ugly.
-	 (device (cond ((framep gnuserv-frame)
-			(frame-device gnuserv-frame))
-		       ((null gnuserv-frame)
+	 (local-gnuserv-frame (cond ((functionp gnuserv-frame)
+				      (funcall gnuserv-frame type))
+				      (t gnuserv-frame)))
+	 ;; The local-gnuserv-frame dependencies are ugly.
+	 (device (cond ((frame-live-p local-gnuserv-frame)
+			(frame-device local-gnuserv-frame))
+		       ((null local-gnuserv-frame)
 			(case (car type)
 			  (tty (apply 'make-tty-device (cdr type)))
 			  (x   (make-x-device (cadr type)))
 			  (t   (error "Invalid device type"))))
 		       (t
 			(selected-device))))
-	 (frame (cond ((framep gnuserv-frame)
-		       gnuserv-frame)
-		      ((null gnuserv-frame)
+	 (frame (cond ((frame-live-p local-gnuserv-frame)
+		       local-gnuserv-frame)
+		      ((null local-gnuserv-frame)
 		       (setq new-frame (make-frame nil device))
 		       new-frame)
 		      (t (selected-frame))))
@@ -330,20 +348,20 @@
 	  (pushnew (current-buffer) (gnuclient-buffers client))
 	  (setq gnuserv-minor-mode t))
 	(pop list)))
-    ;; Explain buffer exit options.  If gnuserv-frame is nil, the user
+    ;; Explain buffer exit options.  If local-gnuserv-frame is nil, the user
     ;; can exit via `delete-frame'.  OTOH, if FLAGS are nil and there
     ;; are some buffers, the user can exit via `gnuserv-edit'.
     (if (and (null flags)
 	     (gnuclient-buffers client))
 	(message (substitute-command-keys
 		  "Type \\[gnuserv-edit] to finish edit"))
-      (or gnuserv-frame
+      (or local-gnuserv-frame
 	  (message (substitute-command-keys
 		    "Type \\[delete-frame] to finish edit"))))
-    (when (and (or flags gnuserv-frame)
+    (when (and (or flags local-gnuserv-frame)
 	       (device-on-window-system-p device))
       ;; exit, if on X device, and if either quick, or writing to
-      ;; gnuserv-frame.
+      ;; local-gnuserv-frame.
       (gnuserv-write-to-client (gnuclient-id client) nil))))
 
 
@@ -517,6 +535,38 @@
 		 (y-or-n-p (concat "Save file " buffer-file-name "? ")))
 	    (save-buffer buffer))))
     (gnuserv-buffer-done buffer)))
+
+;;; Example gnuserv-frame functions
+; These should realy make use of the second argument of type x
+(defun gnuserv-frame-main-frame-function (type)
+  "Return a sensible value for the main Emacs frame
+This function is a possible value for `gnuserv-frame'"
+  (when (eq (car type) 'x)
+    (car (frame-list))))
+
+(defun gnuserv-frame-truely-visible-frame-function (type)
+  "Returns a frame if there is one truely visible
+This is meant in the X sense, so it will not return frames that are on another
+visual screen. Totally visible frames are prefered.
+This function is a possible value for `gnuserv-frame'"
+; We should probably also check for frames on the requested X device only  
+  (when (eq (car type) 'x)
+    (cond ((car (filtered-frame-list 'frame-totally-visible-p)))
+	  ((car (filtered-frame-list #'(lambda (frame)
+					       ; eq t as in not 'hidden
+					       (eq t (frame-visible-p frame)))))))))
+
+(defvar gnuserv-special-frame nil
+  "Frame created specially for Server")
+
+(defun gnuserv-frame-create-special-function (type)
+  "Create a special frame for Gnuserv
+This function is a possible value for `gnuserv-frame'"
+  (when (eq (car type) 'x)
+    (cond ((frame-live-p gnuserv-special-frame) gnuserv-special-frame)
+	  ((setq gnuserv-special-frame (make-frame))))))
+  
+  
 
 
 ;;; User-callable functions:

--Multipart_Wed_May_14_21:54:36_1997-1
Content-Type: text/plain; charset=US-ASCII





--Multipart_Wed_May_14_21:54:36_1997-1--

