home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / modes / cmushell.patch / text0000.txt < prev   
Encoding:
Text File  |  1990-07-22  |  4.2 KB  |  122 lines

  1. In the same vein of comint/cmushell hacks, I've been experimenting
  2. with setting my own personal process filters, and munging the
  3. environment.  The following patch adds hooks to allow this to happen,
  4. and it also deletes the first definition for comint-update-env (2 were
  5. shipped):
  6.  
  7. *** comint.el.~1~    Tue Jun 12 14:03:18 1990
  8. --- comint.el    Wed Jun 13 10:10:45 1990
  9. ***************
  10. *** 88,93 ****
  11. --- 88,95 ----
  12.   
  13.   ;;; comint-mode-hook is the comint mode hook. Basically for your keybindings.
  14.   ;;; comint-load-hook is run after loading in this package.
  15. + ;;; comint-exec-hook is run after the process is started.
  16. + ;;; comint-env-hook is run just before the process is started to change env.
  17.   
  18.   
  19.   ;;; Buffer Local Variables:
  20. ***************
  21. *** 154,159 ****
  22. --- 156,168 ----
  23.   (defvar comint-mode-hook '()
  24.     "Called upon entry into comint-mode")
  25.   
  26. + (defvar comint-exec-hook '()
  27. +   "Called when the comint process is started")
  28. + (defvar comint-env-hook '()
  29. +   "Called just before the comint process is started to change the environment,
  30. + which is in the local variable process-environment")
  31.   (defvar comint-mode-map nil)
  32.   
  33.   (defun comint-mode ()
  34. ***************
  35. *** 281,287 ****
  36.     "Fires up a process in buffer for comint modes.
  37.   Blasts any old process running in the buffer. Doesn't set the buffer mode.
  38.   You can use this to cheaply run a series of processes in the same comint
  39. ! buffer."
  40.     (save-excursion
  41.       (set-buffer buffer)
  42.       (let ((proc (get-buffer-process buffer)))    ; Blast any old process.
  43. --- 290,302 ----
  44.     "Fires up a process in buffer for comint modes.
  45.   Blasts any old process running in the buffer. Doesn't set the buffer mode.
  46.   You can use this to cheaply run a series of processes in the same comint
  47. ! buffer.
  48. ! Upon entry, comint-exec-hook is run just after creating the process (to
  49. ! allow the establishment of a process filter), and comint-env-hook is run
  50. ! just before creating the process, to allow munging the environment passed
  51. ! to the child process."
  52.     (save-excursion
  53.       (set-buffer buffer)
  54.       (let ((proc (get-buffer-process buffer)))    ; Blast any old process.
  55. ***************
  56. *** 293,301 ****
  57.                          (screen-width))
  58.                      "TERM=emacs"
  59.                      "EMACS=t")))
  60. !        (proc (apply 'start-process name buffer command switches)))
  61.         (make-variable-buffer-local 'comint-ptyp)
  62.         (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
  63.         ;; Jump to the end, and set the process mark.
  64.         (goto-char (point-max))
  65.         (set-marker (process-mark proc) (point)))
  66. --- 308,320 ----
  67.                          (screen-width))
  68.                      "TERM=emacs"
  69.                      "EMACS=t")))
  70. !        proc)
  71. !       (run-hooks 'comint-env-hook)
  72. !       (setq proc (apply 'start-process name buffer command switches))
  73.         (make-variable-buffer-local 'comint-ptyp)
  74.         (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
  75. +       (run-hooks 'comint-exec-hook)
  76.         ;; Jump to the end, and set the process mark.
  77.         (goto-char (point-max))
  78.         (set-marker (process-mark proc) (point)))
  79. ***************
  80. *** 316,343 ****
  81.   
  82.   ;; This is just (append new old-env) that compresses out shadowed entries.
  83.   ;; It's also pretty ugly, mostly due to elisp's horrible iteration structures.
  84. - (defun comint-update-env (old-env new)
  85. -   (let ((ans (reverse new))
  86. -     (vars (mapcar (function (lambda (vv)
  87. -             (and (string-match "^[^=]*=" vv)
  88. -                  (substring vv 0 (match-end 0)))))
  89. -               new)))
  90. -     (while old-env
  91. -       (let* ((vv (car old-env)) ; vv is var=value
  92. -          (var (and (string-match "^[^=]*=" vv)
  93. -                (substring vv 0 (match-end 0)))))
  94. -     (setq old-env (cdr old-env))
  95. -     (catch 'already
  96. -       (if var
  97. -           (let ((vars vars))
  98. -         (while vars
  99. -           (let ((nvar (car vars)))
  100. -             (setq vars (cdr vars))
  101. -             (if (and nvar (string= var nvar)) (throw 'already nil))))))
  102. -       (setq vars (cons var vars))
  103. -       (setq ans (cons vv ans)))))
  104. -     (nreverse ans)))
  105.   (defun comint-update-env (old-env new)
  106.     (let ((ans (reverse new))
  107.       (vars (mapcar (function (lambda (vv)
  108. --- 335,340 ----
  109. --
  110. Michael Meissner    email: meissner@osf.org        phone: 617-621-8861
  111. Open Software Foundation, 11 Cambridge Center, Cambridge, MA
  112.  
  113. Catproof is an oxymoron, Childproof is nearly so
  114.  
  115.  
  116.