From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Elston Newsgroups: gmane.emacs.help Subject: Re: Emacs-Lisp Q: Minor mode keymap Date: Fri, 27 Apr 2007 13:15:04 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <1334m92mubf66bd@corp.supernews.com> References: <1332jm5qdlpdnaf@corp.supernews.com> <1334doc4rfi19b4@corp.supernews.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1177706103 25334 80.91.229.12 (27 Apr 2007 20:35:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2007 20:35:03 +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 Apr 27 22:35:02 2007 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 1HhX9h-00042O-LG for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 22:35:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhXFa-00025D-5D for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 16:41:06 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!xs4all!newsfeed.bit.nl!213.239.142.2.MISMATCH!feed.xsnews.nl!border-1.ams.xsnews.nl!sn-xt-ams-06!sn-xt-ams-03!sn-post-ams-01!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) In-Reply-To: <1334doc4rfi19b4@corp.supernews.com> Original-X-Complaints-To: abuse@supernews.com Original-Lines: 104 Original-Xref: shelby.stanford.edu gnu.emacs.help:147694 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:43297 Archived-At: Never mind. I just noticed in abbrev.el the following 2 lines: (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) So I changed my define-key calls like so: (define-key bibs-map "\C-cbg" 'bibs-get-bible-ref) (define-key bibs-map "\C-cbv" 'bibs-find-vrs-num) (define-key bibs-map "\C-cbf" 'bibs-fix-quotes) and it works like I wanted it to. Simple, really, when you know the 'trick'. :) Mark * Mark Elston wrote (on 4/27/2007 10:49 AM): > * Sebastian Meisel wrote (on 4/27/2007 12:25 AM): >> Mark Elston schrieb: >>> >>> What I would like to do is package these functions as a minor >>> mode with its own keymap and use \C-b in the LaTeX-mode-map >>> used in AucTeX. Creating the minor mode map is pretty easy. >>> I assume that from there I do something like: >>> >>> (define-prefix-command my-mode-map) >>> >>> or something similar. >>> >>> But from there, I don't see what to do. Do I have to modify my >>> .emacs to get the binding correct? Can't I do it in the minor >>> mode file? >> Put something like that in your mode file: >> >> (defvar YOUR-mode-map >> (let ((map (make-sparse-keymap))) >> (define-key map "YOURKEYS" 'YOURFUN) >> ... >> map) >> "Keymap for YOUR-mode.") >> >> (define-YOUR-mode >> "MY mode DOESSOMETHING. >> Basic Commands >> ===== ======== >> \\[YOURFUN]\tDOESSOMETHING. >> ... >> " >> :lighter "THISSHALLFILLMYENTIREMODELINETOSHOWMYMODEISON" >> :keymap YOUR-mode-map) >> <---- >> >> Replace the uppercase parts ;-) > > Let me be a little more clear about what I am trying to accomplish. > > I understand how to create a keymap and how to use define-minor-mode > to create a mode that makes use of my keymap. > > What I wanted to do was to assign my keymap to the \C-b key in the > LaTeX-mode-map in AucTeX. Is there a way of doing that in my minor > mode package or do I need to add something to my .emacs to accomplish > this? > > This is what I have so far but I haven't found a way of getting > what I am looking for yet. > > ------------------------------------------------------------------------ > > (defvar bibs-map nil "\ > Keymap containing bindings to the Bibs functions.") > > (define-prefix-command 'bibs-map) ;;; <---Is this necessary? > > (define-key bs-map "g" 'bibs-get-ref) > (define-key bs-map "v" 'bibs-find-v-num) > (define-key bs-map "f" 'bibs-fix-quotes) > > (define-minor-mode bibs-mode > "" > ;; Initial Value > nil > ;; The indicator for the mode line > " Bibs" > ;; The minor mode bindings > 'bs-map > (...) ;;; <------ Is there something I can put here > ;;; to associate the (unused) \C-b key in AucTeX > ;;; LaTeX-mode-map as a prefix key for bibs-map? > ) > > > ------------------------------------------------------------------------ > > Alternatively, I could (if necessary) put something in my .emacs that > associates bibs-map with the \C-b in LaTeX-mode-map. I just don't know > how to do that. > > Also, when I toggle off bibs-mode it should remove the keymap from the > \C-b prefix key in LaTeX-mode-map, right? Again, how do I do that? > > Mark