From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: confusion on keymap's forms in doc Date: Thu, 30 Oct 2008 21:26:33 -0600 Message-ID: References: <98fd48a8-2178-48fe-b8a9-c01f3c35bc3e@f37g2000pri.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1225423631 32465 80.91.229.12 (31 Oct 2008 03:27:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2008 03:27:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 31 04:28:13 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KvkgE-0005cQ-TY for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Oct 2008 04:28:11 +0100 Original-Received: from localhost ([127.0.0.1]:47882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kvkf7-00046n-Ma for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Oct 2008 23:27:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kvkem-00043w-U6 for help-gnu-emacs@gnu.org; Thu, 30 Oct 2008 23:26:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kvkel-00042w-Hp for help-gnu-emacs@gnu.org; Thu, 30 Oct 2008 23:26:39 -0400 Original-Received: from [199.232.76.173] (port=51808 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kvkel-00042k-9t for help-gnu-emacs@gnu.org; Thu, 30 Oct 2008 23:26:39 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:34574 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kvkel-00078B-24 for help-gnu-emacs@gnu.org; Thu, 30 Oct 2008 23:26:39 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Kvkef-0003oE-6L for help-gnu-emacs@gnu.org; Fri, 31 Oct 2008 03:26:33 +0000 Original-Received: from c-67-161-145-183.hsd1.co.comcast.net ([67.161.145.183]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 31 Oct 2008 03:26:33 +0000 Original-Received: from kevin.d.rodgers by c-67-161-145-183.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 31 Oct 2008 03:26:33 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 123 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-67-161-145-183.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.17 (Macintosh/20080914) In-Reply-To: <98fd48a8-2178-48fe-b8a9-c01f3c35bc3e@f37g2000pri.googlegroups.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59282 Archived-At: Xah wrote: > here's something unclear to me: > > According to the manual > http://xahlee.org/elisp/Format-of-Keymaps.html > > quote: > « > Each keymap is a list whose CAR is the symbol `keymap'. The remaining > elements of the list define the key bindings of the keymap. > > ... > > Here as an example is the local keymap for Lisp mode, a sparse > keymap. It defines bindings for and , plus `C-c C-l', > `M-C-q', and `M-C-x'. > > lisp-mode-map > => > (keymap > (3 keymap > ;; C-c C-z > (26 . run-lisp)) > (27 keymap > ;; `M-C-x', treated as ` C-x' > (24 . lisp-send-defun) > keymap > ;; `M-C-q', treated as ` C-q' > (17 . indent-sexp)) > ;; This part is inherited from `lisp-mode-shared-map'. > keymap > ;; > (127 . backward-delete-char-untabify) > (27 keymap > ;; `M-C-q', treated as ` C-q' > (17 . indent-sexp)) > (9 . lisp-indent-line)) > » > > if we look at the lisp-mode-map example above, it has 5 items. (not > counting the first item “keymap”, and the third item ‘keymap’ is > probably typo orphaned from above comment line”) That keymap symbol is not a typo. The actual underlying structure is: (keymap (3 …) (27 …) . (keymap (127 …) (27 …) (9 …))) Note the dot after the 3rd element, (27 …) See the "Lists and Cons Cells" and "Dotted Pair Notation" nodes of the Emacs Lisp manual. > If we look at the item > > (3 keymap > ;; C-c C-z > (26 . run-lisp)) > > this does not seem to be one of the form specified for allowed > elements in a keymap. The doc says the following form is allowed: > > « > (type . binding) > (t . binding) > char-table > string > » > > Should the doc add a form “(type . keymap)”? Or change this: `(TYPE . BINDING)' This specifies one binding, for events of type TYPE. Each ordinary binding applies to events of a particular "event type", which is always a character or a symbol. *Note Classifying Events::. In this kind of binding, BINDING is a command. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to: In this kind of binding, BINDING is a command or a keymap. See "Prefix Keys". > also, in: > http://xahlee.org/elisp/Inheritance-and-Keymaps.html > it says: > > «A keymap can inherit the bindings of another keymap, which we call > the parent keymap. Such a keymap looks like this: > > (keymap bindings... . parent-keymap) > » > > if i understand it correctly, when expanded, such a keymap looks like > this: > > (keymap > element-1 > element-2 > element-3 > ... > element-n > symbolOfParentKeymap > ) > > So, effectively, such a keymap is effectively having a > symbolOfParentKeymap appended to the original keymap list. Is that > right? I don't think so. I think the actual keymap value of the symbol is spliced into the inheriting keymap: (keymap binding-1 binding-2 binding-3 … binding-n . (keymap …)) Note the warning a few paragraphs later: The proper way to construct a keymap with a parent is to use `set-keymap-parent'; if you have code that directly constructs a keymap with a parent, please convert the program to use `set-keymap-parent' instead. -- Kevin Rodgers Denver, Colorado, USA