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")
-
- ; these are directly mapped now
- ;(define-key amiga-map "A" [up])
- ;(define-key amiga-map "B" [down])
- ;(define-key amiga-map "D" [left])
- ;(define-key amiga-map "C" [right])
- ;(define-key amiga-map "0~" [f1])
- ;(define-key amiga-map "1~" [f2])
- ;(define-key amiga-map "2~" [f3])
- ;(define-key amiga-map "3~" [f4])
- ;(define-key amiga-map "4~" [f5])
- ;(define-key amiga-map "5~" [f6])
- ;(define-key amiga-map "6~" [f7])
- ;(define-key amiga-map "7~" [f8])
- ;(define-key amiga-map "8~" [f9])
- ;(define-key amiga-map "9~" [f10])
- ;(define-key amiga-map "10~" [S-f1])
- ;(define-key amiga-map "11~" [S-f2])
- ;(define-key amiga-map "12~" [S-f3])
- ;(define-key amiga-map "13~" [S-f4])
- ;(define-key amiga-map "14~" [S-f5])
- ;(define-key amiga-map "15~" [S-f6])
- ;(define-key amiga-map "16~" [S-f7])
- ;(define-key amiga-map "17~" [S-f8])
- ;(define-key amiga-map "18~" [S-f9])
- ;(define-key amiga-map "19~" [S-f10])
-
- (define-key global-map [help] 'info)
-
- (define-key global-map [S-left] [prior])
- (define-key global-map [S-right] [next])
- (define-key global-map [S-down] 'scroll-up)
- (define-key global-map [S-up] 'scroll-down)
- (define-key global-map [C-left] 'forward-sexp)
- (define-key global-map [C-right] 'backward-sexp)
- (define-key global-map [C-down] 'scroll-down-1)
- (define-key global-map [C-up] 'scroll-up-1)
-
- ; CHFIXME: use default emacs binding?
- (define-key global-map [M-up] [begin])
- (define-key global-map [M-down] [end])
- (define-key global-map [M-left] 'beginning-of-line)
- (define-key global-map [M-right] 'end-of-line)
-
- ; Keypad sequences
- (setq amiga-keypad-map (make-sparse-keymap))
- (define-key amiga-map "K" amiga-keypad-map)
- (define-key amiga-keypad-map "[" "[")
- (define-key amiga-keypad-map "]" "]")
- (define-key amiga-keypad-map "{" "{")
- (define-key amiga-keypad-map "}" "}")
- (define-key amiga-keypad-map "/" [kp-divide])
- (define-key amiga-keypad-map "*" [kp-multiply])
- (define-key amiga-keypad-map "-" [kp-subtract])
- (define-key amiga-keypad-map "+" [kp-add])
- (define-key amiga-keypad-map "." [kp-decimal])
- (define-key amiga-keypad-map [RET] [kp-enter])
- (define-key amiga-keypad-map [0] [kp-0])
- (define-key amiga-keypad-map [1] [kp-1])
- (define-key amiga-keypad-map [2] [kp-2])
- (define-key amiga-keypad-map [3] [kp-3])
- (define-key amiga-keypad-map [4] [kp-4])
- (define-key amiga-keypad-map [5] [kp-5])
- (define-key amiga-keypad-map [6] [kp-6])
- (define-key amiga-keypad-map [7] [kp-7])
- (define-key amiga-keypad-map [8] [kp-8])
- (define-key amiga-keypad-map [9] [kp-9])
-
- (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))
-
- (defun unfocus-frame ()
- "A dummy, used by general mouse.el."
- (interactive))
-
-
- (defun window-frame (w)
- "Return the frame object that window WINDOW is on."
- (interactive)
- (selected-frame))
-
- ;; ARexx stuff
-
- ;;; This function needs to be re-written to handle rexx returned results.
- ;;;
- (setq amiga-arexx-processing nil)
- (setq amiga-arexx-errors nil)
-
- (defvar amiga-arexx-failat 5
- "Return level from which arexx commands returns cause errors")
-
- ;;
- ;; process incoming rexx messages
- ;;
- (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-next-msg))
- (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 (MSGID) to complete.
- Also processes any pending ARexx requests during this interval.
- returns the result list associated with this id, which takes the
- form: (msgid result-code error-or-string)
- ``error-or-string'' depends on ``result-code''.
- if ``result-code'' is 0 the command finished successfully and
- ``error-or-string'' will be a string or nil, otherwise the command
- returned with an error and ``error-or-string'' will be an interger
- that is the secondary error code of the arexx command."
- (amiga-arexx-process)
- (while (not (amiga-arexx-check-command id))
- (amiga-arexx-wait)
- (amiga-arexx-process))
- (amiga-arexx-get-msg-results id))
-
- (defconst amiga-arexx-error-messages
- ["No cause"
- "Program not found"
- "Execution halted"
- "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 the command to return. If the arexx command fails an error will
- be caused.
-
- If you would like to get result strings and errors (ie. not cause
- a lisp error) use: (amiga-arexx-do-command-with-results)"
- (interactive "sARexx command:
- P")
- (let ((id (amiga-arexx-send-command str as-file)))
- (if (not id)
- (error "Failed to send arexx command.")
- (let ((reslist (amiga-arexx-wait-command id)))
- (let ((rc (nth 1 reslist)) (second (nth 2 reslist)))
- (if (> rc 0)
- (progn ; error
- (let ((error-message
- (if (< second (length amiga-arexx-error-messages))
- (aref amiga-arexx-error-messages second)
- (format nil "Unknown error %d" second))))
- (error "Arexx command failed, level %d, cause %s" rc error-message))
- reslist)
- second))))))
-
- (defun amiga-arexx-do-command-with-results (str as-file)
- "Sends ARexx command STR (like amiga-arexx-do-command).
- If AS-FILE is true, STR is an arexx command, otherwise it is a file name.
- Waits for the command to return.
-
- The return value is one of three things:
- - the command executed succesfully: nil or a result string.
- - the command failed: a list of the form (RC ERROR-CODE)
- where RC is the severity and ERROR-CODE is the secondary error."
- (interactive "sARexx command:
- P")
- (let ((id (amiga-arexx-send-command str as-file)))
- (if (not id)
- (error "Failed to send arexx command.")
- (let ((reslist (amiga-arexx-wait-command id)))
- (let ((rc (nth 1 reslist)) (second (nth 2 reslist)))
- (if (and rc (> rc 0))
- (list rc second)
- second))))))
-
- (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)
-
- (defun safe-amiga-paste ()
- "Paste from the amiga clipboard, trapping any errors."
- (if amiga-new-clip
- nil)
- (condition-case nil
- (amiga-paste)
- (error nil)))
-
- (defun check-clipboard ()
- "If there is anything new in the clipboard, add it to the emacs kill ring.
- Returns t if there was something added, nil otherwise."
- (let (added)
- (if amiga-new-clip
- (let ((str (safe-amiga-paste)))
- (setq amiga-new-clip nil)
- (if str
- (progn
- (kill-add str)
- (setq added t)
- (setq kill-ring-yank-pointer kill-ring)))))
- added))
-
- (defun update-clipboard (str &optional dummy)
- (amiga-cut str)
- (setq amiga-new-clip nil))
-
- (setq interprogram-cut-function 'update-clipboard)
- (setq interprogram-paste-function 'safe-amiga-paste)
-