From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Capey Newsgroups: gmane.emacs.help Subject: Re: About an example in Emacs Lisp manual Date: Sun, 10 Feb 2013 15:07:29 +0000 Message-ID: <87zjzcmclq.fsf@madasafish.co.uk> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1360527345 608 80.91.229.3 (10 Feb 2013 20:15:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Feb 2013 20:15:45 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Xue Fuqiao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 10 21:16:02 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U4dJh-0002TP-NJ for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Feb 2013 21:16:01 +0100 Original-Received: from localhost ([::1]:47587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4dJO-0006jr-GF for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Feb 2013 15:15:42 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4YVG-0006A5-FD for help-gnu-emacs@gnu.org; Sun, 10 Feb 2013 10:07:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4YVD-000068-PN for help-gnu-emacs@gnu.org; Sun, 10 Feb 2013 10:07:38 -0500 Original-Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:51377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4YVD-000063-HQ for help-gnu-emacs@gnu.org; Sun, 10 Feb 2013 10:07:35 -0500 Original-Received: by mail-we0-f172.google.com with SMTP id x10so4182056wey.31 for ; Sun, 10 Feb 2013 07:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=8wQKxoKqciW1yvD+EwQ/Q5kKXGKl57QZSIZe1V+ZvoM=; b=0N7Apz63N/LUSksNnKmwkCZ7F7Qm91v7czhJkiWw8v+2sx0kR1zgNEBSCoKIMK6BJj b/tq0t5TNWVCaeb8UB/LZDIbhqkhAP1PGL3ijwoiHD3pn/NEyDXSjB7kWDdl7TebdjNH oJ5rv/WvWeZt/XDU60zWSIxunKdz9bGHRcUxoK4iNGfTH7yJn12StYzWcpj2ILcUS+gl WP3Ckv26gBJG+hMxemxSpuFf3Xnvga1rjOhZrpaKAtHq3w6VpZ3g3YGiZiIY36gRHcaI JdUdCfY0FEC+xEKlRpvE+YOzoVOxU43GGOTKVuCsPLp5O4hvyRDI/fLlLh44r2jti5Uo yFGA== X-Received: by 10.180.90.147 with SMTP id bw19mr11467501wib.28.1360508853969; Sun, 10 Feb 2013 07:07:33 -0800 (PST) Original-Received: from battistini (host-92-19-78-145.as13285.net. [92.19.78.145]) by mx.google.com with ESMTPS id l3sm27221036wiy.8.2013.02.10.07.07.32 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 10 Feb 2013 07:07:33 -0800 (PST) In-Reply-To: (Xue Fuqiao's message of "Sun, 10 Feb 2013 22:19:25 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22c X-Mailman-Approved-At: Sun, 10 Feb 2013 15:15:37 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89043 Archived-At: * 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)))))) [...] > In the first `defun' form, if `e' is a number, > (vector (logior (lsh 1 24) e)) will be returned. I don't > understand what the meaning of the bitwise-or and bit-shifting > functions are here. 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. /Tom --