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: Sun, 7 Dec 2008 09:33:08 -0800 Message-ID: <004b01c95891$df3403c0$0200a8c0@us.oracle.com> References: <878wqtcqt6.fsf@emacs.Arch.net><003b01c95837$ee8b1e30$0200a8c0@us.oracle.com> 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 1228671239 5257 80.91.229.12 (7 Dec 2008 17:33:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Dec 2008 17:33:59 +0000 (UTC) To: "'Kevin Rodgers'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 07 18:35:03 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 1L9NX1-0005w4-Az for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Dec 2008 18:34:59 +0100 Original-Received: from localhost ([127.0.0.1]:50035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9NVq-0006XE-85 for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Dec 2008 12:33:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9NV7-0006JR-99 for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 12:33:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9NV5-0006IX-Hh for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 12:33:00 -0500 Original-Received: from [199.232.76.173] (port=35723 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9NV5-0006IS-E5 for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 12:32:59 -0500 Original-Received: from acsinet12.oracle.com ([141.146.126.234]:54614) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9NV5-0002QW-4W for help-gnu-emacs@gnu.org; Sun, 07 Dec 2008 12:32:59 -0500 Original-Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by acsinet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB7HWawq027830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 7 Dec 2008 17:32:37 GMT Original-Received: from acsmt702.oracle.com (acsmt702.oracle.com [141.146.40.80]) by acsinet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB7HXGMS016894; Sun, 7 Dec 2008 17:33:17 GMT Original-Received: from dradamslap1 (/24.23.165.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Dec 2008 09:32:52 -0800 X-Mailer: Microsoft Office Outlook 11 thread-index: AclYgHuhUEu2lXKpRgCXOm8hVLfRoAADk67w X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 In-Reply-To: X-Source-IP: acsmt702.oracle.com [141.146.40.80] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A010201.493C08C6.0043: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:60425 Archived-At: > >> I used (concat (symbol-name major-mode) "-map") to get > >> current keymap, but it failed for LaTeX mode. Are there > >> other methode to get current keymap. > > > > If I enter a buffer, do `M-x latex-mode', > > then M-: (concat (symbol-name major-mode) "-map") > > it returns "latex-mode-map". What did you want? > > > > That's the name of a symbol whose value is the latex mode > > keymap. If you want the keymap itself, then you want this: > > > > (symbol-value ; Value of > > (intern ; Symbol whose name is > > (concat (symbol-name major-mode) "-map"))) > > > > However, (current-local-map) gives you the same thing, and > > it works regardless of the name of the symbol. > > > > (eq (symbol-value > > (intern > > (concat (symbol-name major-mode) "-map"))) > > (current-local-map)) > > > > => t > > A different way to find the symbol, instead of relying on its name: > > (when (current-local-map) > (let ((result nil)) > (mapatoms (function (lambda (symbol) > (when (and (boundp symbol) > (eq (symbol-value symbol) > (current-local-map))) > (push symbol result))))) > result)) Yes. To be clear, I didn't mean to suggest that one should use the map-variable's name, or that the above `eq' sexp would always return t. What I meant was that, for _LaTeX_ mode, the two expressions are `eq'. I should have made that clear. My point was to _not_ rely on the name, but to use `current-local-map' instead. Most uses of keymaps never require knowing the map variable itself; its value can be used directly. But if for some reason one needs the map variable, then the code you provided is the way to go.