[comp.emacs] help - make GNU display-time NOT use a pty

mkhaw@teknowledge-vaxc.UUCP (09/07/87)

On systems that have ptys, GNU prefers to use them for all subprocesses
including the display-time function.  Ultrix appears to allow a maximum
of 96 ptys, and we are running short of them, so I'd like to make
display-time use a pipe instead.

In process.c, it says that if the lisp variable "process-connection-type"
is nil, the interprocess link will be a pipe (and a pty if 't'), but not
knowing lisp, I don't know how to set it nil ONLY FOR THE DISPLAY-TIME
FUNCTION.  I don't want other kinds of subprocesses (like shell buffers)
to be forced to use pipes as well.

I'm hoping that there's some lisp incantation that I can put into
time.el to do the trick.

Thanks,
Mike Khaw
-- 
internet:  mkhaw@teknowledge-vaxc.arpa
usenet:	   {uunet|sun|ucbvax|decwrl|uw-beaver}!mkhaw%teknowledge-vaxc.arpa
USnail:	   Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303

gaynor@topaz.rutgers.edu.UUCP (09/08/87)

Mike Khaw (mkhaw@teknowledge-vaxc.arpa) writes:
> [I want the variable process-connection-type to always be nil when
> the function display-time is evaluated.  How should I do this?]

If you're able to modify time.el, surround the body with a let
statement which temporarily redefines process-connection-type to the
proper value.  So the following defun

;; <- Look!  Semi-colons in their natural habitat!
(defun display-time (<arguments -n- other nasties?>)
  "Hi Mom!"
  <sequence of forms of comprising body of display-time>
)

becomes

;; <- Look!  Semi-colons in their natural habitat!
;;

;; Also, not that `display-time' has been modified so that when
;; evaluated, the variable `process-connection-type' is always nil
;; (hence, the process is always connected with a pipe rather than a
;; pty).  This has been done by surrounding it's body with a `let'
;; expression, in which the varlist temporarily redefines the variable
;; `process-connection-type' to nil.  The body of this `let' statement
;; is the old body of the function.
(defun display-time (args-n-what-not)
  "Hi Mom!"
  (let ((process-connection-type nil)) ;; NEW LINE
    <sequence of forms of comprising body of display-time>
  )                                    ;; NEW LINE
)

If you are not able or don't want to modify time.el, jam this in the
appropriate place(s).  It essentially does the same thing as above,
except dynamically.

Evaluate this form, only after display-time is defined properly.
Once.

;; Modify the function `display-time' so that when evaluated, the
;; variable `process-connection-type' is always nil (hence, the
;; process is always connected with a pipe rather than a pty).  The
;; way we're going to pull this off is to redefine `display-time' by
;; replacing it's body with a `let' expression, in which the varlist
;; temporarily redefines the variable process-connection-type to nil.
;; The body of this `let' statement is the old body of the function.
(let ((fn (symbol-function 'display-time)))
  (rplacd
    (cdr fn)
    (list (append '(let ((process-connection-type nil))) (cdr (cdr fn))))))

Hope this helps.

VOICE: Andy Gaynor (Silver)         PHONE: 201-545-0458
INTERNET: gaynor@topaz.rutgers.edu  ICBM: 40 34 N / 74 45 W
UUCP: ...!<many big boys>!rutgers!topaz.rutgers.edu!gaynor
ROOF: 81 Hassart Street, New Brunswick, NJ  08901
    _____                                       _____
    \   /  "While Bill wrestles the alligator,  \---/
     \d/   I'll poor myself another martini..."  \d/
      V              - Marlin Perkins             V
      |                                           |
    __|__                                       __|__

kyle@xanth.UUCP (09/08/87)

In article <16402@teknowledge-vaxc.ARPA>, mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) writes:
> Ultrix appears to allow a maximum of 96 ptys, and we are running
> short of them, so I'd like to make display-time use a pipe instead.
> ...  I don't want other kinds of subprocesses (like shell buffers)
> to be forced to use pipes as well.

Easy.  You can wrap the body of the display-time function in a let
statement like:

(let ((process-connection-type nil))
   BODY)

or if you want to leave it up to the users you can put

(let ((process-connection-type nil)) (display-time))

into your .emacs .

howie@cunixc.columbia.edu (Howie Kaye) (09/09/87)

I thought this was a problem a long time ago.  Here is a lisp function
to run a program on a pipe.  Then a one line change is necessary in time.el.

(defun start-process-no-pty (name buffer program &rest program-args)
  "Run a process via start-process, but do it on a pipe"
  (let ((temp process-connection-type)
	(x nil)
	(y nil))
    (setq process-connection-type nil)
    (setq x '(start-process name buffer program))
    (setq x (append x program-args))
    (setq y (eval x))
    (setq process-connection-type temp)
    y))

Then in time.el change:

	  (setq display-time-process
		(start-process "display-time" nil
			       "loadst" 
			       "-n" 
			       (int-to-string display-time-interval)))

to:

	  (setq display-time-process
		(start-process-no-pty "display-time" nil
				      "loadst" 
				      "-n" 
				      (int-to-string display-time-interval)))


------------------------------------------------------------
Howie Kaye				howie@columbia.edu
Columbia University 			hlkcu@cuvma.bitnet
Systems Group				...!seismo!columbia!howie