Changeset 8711


Ignore:
Timestamp:
03/05/05 04:05:41 (16 years ago)
Author:
piso
Message:

DEFINE-KEY: accept Lisp characters as key designators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/j/LispAPI.java

    r8684 r8711  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id: LispAPI.java,v 1.61 2005-03-03 14:01:41 piso Exp $
     5 * $Id: LispAPI.java,v 1.62 2005-03-05 04:05:41 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    994994    // ### define-key keymap key definition => generalized-boolean
    995995    private static final Primitive DEFINE_KEY =
    996         new Primitive("define-key", PACKAGE_J, true, "keymap key definition")
     996        new Primitive("define-key", PACKAGE_J, true,
     997                      "keymap key-designator definition")
    997998    {
    998999        public LispObject execute(LispObject first, LispObject second,
     
    10011002        {
    10021003            KeyMap keymap = checkKeymap(first);
    1003             String keyText = second.getStringValue();
     1004            if (!(second instanceof LispCharacter ||
     1005                  second instanceof AbstractString))
     1006                return signal(new TypeError(second,
     1007                                            list2(Symbol.OR,
     1008                                                  list2(Symbol.CHARACTER,
     1009                                                        Symbol.STRING))));
    10041010            Object command;
    10051011            if (third instanceof AbstractString) {
     
    10121018                command = third;
    10131019            }
    1014             return keymap.mapKey(keyText, command) ? T : NIL;
     1020            if (second instanceof LispCharacter)
     1021                keymap.mapKey(((LispCharacter)second).value, command);
     1022            else
     1023                keymap.mapKey(second.getStringValue(), command);
     1024            return T;
    10151025        }
    10161026    };
Note: See TracChangeset for help on using the changeset viewer.