[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with #$ and the compiler



But the fact that my code works with #.#$ shows that the name reference is not
needed, doesn't it? I'm not 100% sure, since I'm using advise, so here is the
code. It is a patch of Fred to make it use the Command key instead of the Option
key (because MCL is still unable to deal with foreign keyboards :-().

(defconstant kcode-char-byte (byte 8 0))
(defconstant kcode-meta-byte (byte 1 8))
(defconstant kcode-ctrl-byte (byte 1 9))

(advise event-keystroke
  (let ((msg (first arglist))(mod (second arglist))(code (:do-it)))
    ;; If option down, place the correct keycode
    (unless (zerop (logand mod #$optionKey))
      (setf (ldb kcode-char-byte code) (logand msg #$charCodeMask)))
    ;; Set correct meta and ctrl bits
    (setf (ldb kcode-meta-byte code) (if (zerop (logand mod #$cmdKey)) 0 1)
          (ldb kcode-ctrl-byte code) (if (zerop (logand mod #$controlKey)) 0 1))
    code)
  :when :around :name fred-keyboard-patch)

When I load this source, it works. When I load the binary in a fresh MCL, I
get errors about $optionKey not being bound.
BTW, the documentation for advise is very bad, and the :define-if-undefined
keyword argument does not work at all.
     Daniel Ranson (ranson@lannion.cnet.fr)