From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: How to get current keymap Date: Sat, 6 Dec 2008 22:35:18 -0800 Message-ID: <003501c95835$f94bdfa0$0200a8c0@us.oracle.com> References: <878wqtcqt6.fsf@emacs.Arch.net> <873ah0v9j1.fsf@emacs.Arch.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1228631845 26972 80.91.229.12 (7 Dec 2008 06:37:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Dec 2008 06:37:25 +0000 (UTC) To: "'netawater'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 07 07:38:29 2008 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 1L9DHg-0004XX-Jg for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Dec 2008 07:38:28 +0100 Original-Received: from localhost ([127.0.0.1]:37018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9DGV-0006Vy-Ed for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Dec 2008 01:37:15 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9DG0-0006Uf-EB for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 01:36:44 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9DFy-0006U9-PV for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 01:36:43 -0500 Original-Received: from [199.232.76.173] (port=47451 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9DFy-0006U6-Fr for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 01:36:42 -0500 Original-Received: from acsinet11.oracle.com ([141.146.126.233]:60360) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9DFy-0001wb-21 for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 01:36:42 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by acsinet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB76a34K015232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 7 Dec 2008 06:36:04 GMT Original-Received: from acsmt705.oracle.com (acsmt705.oracle.com [141.146.40.83]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB76ZCsV016077; Sun, 7 Dec 2008 06:35:13 GMT Original-Received: from dradamslap1 (/24.23.165.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 06 Dec 2008 22:35:03 -0800 X-Mailer: Microsoft Office Outlook 11 thread-index: AclYLltIuCD5koJ+SwCcTo53x3DK8QABE3SQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 In-Reply-To: <873ah0v9j1.fsf@emacs.Arch.net> X-Source-IP: acsmt705.oracle.com [141.146.40.83] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.493B6E99.00FE:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) 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:60407 Archived-At: > I want to get current mode's keymap, some modes do not have > keymap, but current keymap always exists. I need define a > key for my function in it and my function > can be always active for that mode. If you want to define a key for only a specific (major or minor) mode, then use that mode's keymap. If that mode doesn't have a keymap, then it is less straightforward to define a key for only that mode. You can define a key in some map that is accessible from that keymap, so the key will be active in that mode, but then that key binding will also hold outside that mode - unless you take pains to bind and unbind the key when, say, the mode is entered and exited. To see all maps accessible currently, you can use functions `current-active-maps' and `accessible-keymaps'. See the Elisp manual, nodes Active Keymaps and Scanning Keymaps. Remember that there are several levels of priority for keymaps: minor mode maps (in order), then (major mode) local map, then global map (and there are some more levels). If you define a key in a local map, it's possible it gets shadowed by a minor-mode binding. To make sense of what's happening, before you try to bind a key examine the existing bindings in the current minor modes and major mode, as well as the global bindings. Command `describe-keymap' (bound to `C-h M-k') in library help-fns+.el shows you the bindings for a given map. http://www.emacswiki.org/emacs/HelpPlus