[133] in Coldmud discussion meeting

root meeting help first previous next last

alpha 0.1 cold emacs-list code for mud.el

daemon@ATHENA.MIT.EDU (Sat Jan 1 05:15:57 1994 )

To: coldstuff@MIT.EDU
Date: Sat, 01 Jan 1994 04:04:07 -0600
From: Adam Harris <harris@cs.uchicago.edu>


Here's the code I've developed for emac to let me do local
editing of programs, a la C-C C-V in mud.el for MOOs.
I know it's rough and nasty, but it works for me.

If you would like to see some other function implemented for cold,
ask me and maybe I'll try to tackle it.  Or if you've developed
better code, I'd like to have it! ;)

Instructions:  insert the following lines in your mud.el, or
have it be required in mud.el.  I actually use mud-telnet.el, but
it should work for either.

  Also, I've created a $commands object which intercepts the
suffix/prefix strings and ignores them.  It's trivially easy to
do.  I don't know what LambdaMOO does for it's local editing and
prefix/suffix stuff, but maybe something along these lines will
make it into ColdWorld.

-adam
----------------------cut here-----------------------

;;; cold -- by adam harris, harris@cs.uchicago.edu
;;;  Jan 1, 1994  0.1 alpha
; based on MOO stuff, even uses moo-filter

(defun define-cold-mode-commands ()
  (define-key (current-local-map) "\^c\^v" 'cold-get-method-listing)
  (define-key (current-local-map) "\^c\^d" 'cold-get-description))

(defvar cold-mode-hook '(define-cold-mode-commands))
(defvar cold-filter-hook
  '(moo-filter mud-check-page mud-check-reconnect
	       mud-fill-lines))
; prefixes have nasty counter-effect of making "I don't understand" stuff
; but it's just temporary until the cold core changes to accomodate these
; command strings
; NB: Changing these can break the code!
(setq moo-prefix "===COLD-Prefix===" 
      moo-suffix "===COLD-Suffix===")
(defvar cold-delim-string nil)
(defvar cold-delim-regexp nil)
(defvar cold-object nil)
			  

(defun cold-do-fetch (prompt object-fmt command-fmt fixer)
  (setq cold-object (format object-fmt (read-string prompt))
	moo-state 'waiting
	moo-fixer fixer
	mud-current-process (get-buffer-process (current-buffer))
	moo-buffer (get-buffer-create cold-object))
  (moo-set-delimiter moo-suffix)
  (pop-to-buffer moo-buffer)
  (erase-buffer)
  (mud-send-string (concat (format command-fmt cold-object) "\n"
			   moo-prefix "\n")
		   mud-current-process)
  (mud-send-string (concat moo-suffix "\n") mud-current-process)
)


(defun cold-get-method-listing ()
  "Fetch the COLD code for a verb"
  "--we can't use do-fetch because of the way this stuff is organized"
  "  and we need separate vars for object and method -- bleech"
  (interactive)
  (setq cold-object (format "%s" (read-string "Edit which method? "))
	tmpval (string-match "[.]" cold-object)
	theobj (substring cold-object 0 tmpval)
	themethod (substring cold-object (+ tmpval 1))
	moo-state 'waiting
	moo-fixer 'cold-fix-listing
	mud-current-process (get-buffer-process (current-buffer))
	moo-buffer (get-buffer-create cold-object))
  (moo-set-delimiter moo-suffix)
  (pop-to-buffer moo-buffer)
  (erase-buffer)
  (mud-send-string (concat 
		    "@list " themethod " on " theobj "\n"
		    moo-prefix "\n")
		   mud-current-process)
  (mud-send-string (concat moo-suffix "\n") mud-current-process)
)


(defun cold-get-description()
  "Fetch the description of some object."
  "  which is perfectly useless"
  (interactive)
  (moo-do-fetch "Edit description of what object: "
                "%s"
                "@show %s.description"
                'cold-fix-description)
)


(defun cold-fix-description ()
  "Useless function to fix up the description results.  You can't re-set stuff"
  "this way..."
  (let ((start (point)))
    (search-forward "\"")
    (delete-region start (point)))
  (search-forward "\"")
  (backward-char)
  (delete-region (point-max) (point))
  (save-excursion)
)


(defun cold-fix-listing ()
  "Clean up a verb listing in cold"
  (interactive)
  (if (looking-at "ERROR")
    (delete-region (point-min) (point-max))
    )
  (beginning-of-buffer)
  "Replace theobj with real object defining the method"
  (if (search-forward-regexp "^.+defined on \\(.*\\)):" (point-max) t)
      (replace-match (concat "@program " themethod " on \\1"))
    "else"
    (insert (concat "@program " themethod " on " theobj "\n"))
    )
  "Kill the prefix line (only for world's w/o proper filters)"
  (if (search-forward-regexp "\\(===COLD-Prefix===\\|I don't understand that.\\)\n" nil nil)
      (replace-match "")
    )
  (goto-char (point-max))
  (insert ".")
)