[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About an example in Emacs Lisp manual
From: |
Xue Fuqiao |
Subject: |
Re: About an example in Emacs Lisp manual |
Date: |
Sun, 10 Feb 2013 23:31:35 +0800 |
On Sun, 10 Feb 2013 15:07:29 +0000
Tom Capey <tom.capey@gmail.com> wrote:
> * Xue Fuqiao writes:
> > In (info "(elisp) Translation Keymaps"):
> > For example, here's how to define `C-c h' to turn the character that
> > follows into a Hyper character:
> > (defun hyperify (prompt)
> > (let ((e (read-event)))
> > (vector (if (numberp e)
> > (logior (lsh 1 24) e)
> > (if (memq 'hyper (event-modifiers e))
> > e
> > (add-event-modifier "H-" e))))))
[...]
> The Hyper modifier bit is the 2^24 bit--(info "(elisp) Other Char Bits").
> If that bit is a 1 then it's on, 0 and it's off.
> (lsh 1 n) returns a value with just the nth bit turned on, and
> all the other bits are turned off, that is, are zero. Thus
> (lsh 1 24) has the 2^24 bit turned on [(= (expt 2 24) (lsh 1 24)) => t],
> the Hyper modifier bit.
> `logior' does a bit-by-bit OR comparision between the number
> with its 24th bit on and `e', looking at both numbers as though
> they were binary representations. In this case we're OR-ing
> `e' against the Hyper bit, and this has the effect of returning
> `e' with the Hyper bit turned on.
Ah, I see. Thanks for your explanation.
> /Tom
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao