home *** CD-ROM | disk | FTP | other *** search
- (global-set-key "\C-z" 'amiga-iconify)
- (setq amiga-map (make-keymap))
- (global-set-key "\C-x\C-^" amiga-map)
-
- (load "amiga-mouse")
- (load "amiga-menu")
-
- (define-key amiga-map "A" 'previous-line)
- (define-key amiga-map "B" 'next-line)
- (define-key amiga-map "D" 'backward-char)
- (define-key amiga-map "C" 'forward-char)
- (define-key amiga-map "?~" 'info)
- (define-key amiga-map "T" 'scroll-down)
- (define-key amiga-map "S" 'scroll-up)
- (define-key amiga-map " @" 'forward-word)
- (define-key amiga-map " A" 'backward-word)
- (define-key amiga-map "\M-A" 'beginning-of-buffer)
- (define-key amiga-map "\M-B" 'end-of-buffer)
- (define-key amiga-map "\M-D" 'beginning-of-line)
- (define-key amiga-map "\M-C" 'end-of-line)
- (define-key amiga-map "\M- \M-@" 'forward-sexp)
- (define-key amiga-map "\M- \M-A" 'backward-sexp)
- (define-key amiga-map "\M-T" 'scroll-down-1)
- (define-key amiga-map "\M-S" 'scroll-up-1)
- ; Keypad sequences are handled like normal ones
- (define-key amiga-map "K" 'do-nothing)
-
- (defun do-nothing () (interactive))
-
- (defun scroll-down-1 ()
- "Move up one line on screen"
- (interactive)
- (scroll-down 1))
-
- (defun scroll-up-1 ()
- "Move down one line on screen"
- (interactive)
- (scroll-up 1))
-
- ;; ARexx stuff
-
- (setq amiga-arexx-processing nil)
- (setq amiga-arexx-errors nil)
- (defvar amiga-arexx-failat 5
- "Return level from which arexx commands returns cause errors")
-
- (defun amiga-arexx-process ()
- (interactive)
- (if (not amiga-arexx-processing)
- (progn
- (setq amiga-arexx-processing t)
- (condition-case nil ; Avoid blocking of processing in case of bugs
- (let (arexxcmd)
- (while (setq arexxcmd (amiga-arexx-get-event))
- (if (listp arexxcmd)
- (setq amiga-arexx-errors (cons arexxcmd amiga-arexx-errors))
- (let ((rc 0) result)
- (condition-case err ; detect errors in arexx command
- (let ((expr (car (read-from-string arexxcmd))))
- (setq result (prin1-to-string (eval expr))))
- (error (progn
- (setq rc 20)
- (setq result (prin1-to-string err)))))
- (amiga-arexx-reply rc result)))))
- (error nil))
- (setq amiga-arexx-processing nil))))
-
- (defun amiga-arexx-wait-command (id)
- "Waits for a pending ARexx commands to complete.
- Also processes any pending ARexx requests during this interval."
- (amiga-arexx-process)
- (while (amiga-arexx-check-command id)
- (amiga-arexx-wait)
- (amiga-arexx-process)))
-
- (defconst amiga-arexx-error-messages
- ["No cause"
- "Program not found"
- "Execution galted"
- "Insufficient memory"
- "Invalid character"
- "Unmatched quote"
- "Unterminated comment"
- "Clause too long"
- "Invalid token"
- "Symbol or string too long"
- "Invalid message packet"
- "Command string error"
- "Error return from function"
- "Host environment not found"
- "Requested library not found"
- "Function not found"
- "Function did not return value"
- "Wrong number of arguments"
- "Invalid argument to function"
- "Invalid PROCEDURE"
- "Unexpected THEN or WHEN"
- "Unexpected ELSE or OTHERWISE"
- "Unexpected BREAK, LEAVE or ITERATE"
- "Invalid statement in SELECT"
- "Missing or multiple THEN"
- "Missing OTHERWISE"
- "Missing or unexpected END"
- "Symbol mismatch"
- "Invalid DO syntax"
- "Incomplete IF or SELECT"
- "Label not found"
- "Symbol expected"
- "Symbol or string expected"
- "Invalid keyword"
- "Required keyword missing"
- "Extraneous characters"
- "Keyword conflict"
- "Invalid template"
- "Invalid TRACE request"
- "Unitialized variable"
- "Invalid variable name"
- "Invalid expression"
- "Unbalanced parentheses"
- "Nesting limit exceeded"
- "Invalid expression result"
- "Expression required"
- "Boolean value not 0 or 1"
- "Arithmetic conversion error"
- "Invalid operand"
- ]
- "The arexx error messages, sorted by number")
-
- (defun amiga-arexx-do-command (str as-file)
- "Sends ARexx command STR (like amiga-arexx-send-command).
- If AS-FILE is true, STR is an arexx command, otherwise it is a file name.
- Waits for all pending arexx commands to complete (including this one) before
- returning."
- (interactive "sARexx command:
- P")
- (let ((id (amiga-arexx-send-command str as-file)))
- (amiga-arexx-wait-command id)
- (let ((err (assq id amiga-arexx-errors)))
- (if err
- (let ((severity (car (cdr err))))
- (setq amiga-arexx-errors (delq err amiga-arexx-errors))
- (if (>= severity amiga-arexx-failat)
- (let* ((error-code (car (cdr (cdr err))))
- (error-message
- (if (< error-code (length amiga-arexx-error-messages))
- (aref amiga-arexx-error-messages error-code)
- (format nil "Unknown error %d" error-code))))
- (error "Arexx command failed, level %d, cause %s"
- severity error-message))))))))
-
- (define-key amiga-map "X" 'amiga-arexx-process)
- (setq amiga-arexx-initialized t) ;; ARexx commands can now be processed.
-
- (defun amiga-wb-process ()
- "Process all pending workbench events, ie load all files requested"
- (interactive)
- (let (file)
- (condition-case nil
- (while (setq file (amiga-get-wb-event t))
- (condition-case nil
- (find-file file)
- (error nil)))
- (error nil))))
-
- (define-key amiga-map "W" 'amiga-wb-process)
- (setq amiga-wb-initialized t) ;; WB events can now be processed.
-
- (setq completion-ignore-case t)
- ;; Default is no numbered versions on Amiga, because directory searches are too
- ;; slow.
- (setq version-control 'never)
-