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: A couple of emacs lisp questions Date: Tue, 21 Dec 2010 10:12:03 -0800 Message-ID: <95C1839A334140008F8D40431F62E23B@us.oracle.com> References: <20101221131820.GA24113@gwsc.vic.edu.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1292955195 11726 80.91.229.12 (21 Dec 2010 18:13:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Dec 2010 18:13:15 +0000 (UTC) To: "'Daniel Dalton'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 21 19:13:11 2010 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.69) (envelope-from ) id 1PV6hu-0005Mt-7w for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 19:13:06 +0100 Original-Received: from localhost ([127.0.0.1]:33584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV6ht-0007iT-IJ for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 13:13:05 -0500 Original-Received: from [140.186.70.92] (port=47932 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV6hL-0007hJ-0C for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:12:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PV6hJ-0004B2-I7 for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:12:30 -0500 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:65309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PV6hJ-0004Ap-B9 for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:12:29 -0500 Original-Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oBLICRTo006748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 21 Dec 2010 18:12:28 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id oBLICMMI002163; Tue, 21 Dec 2010 18:12:25 GMT Original-Received: from abhmt008.oracle.com by acsmt353.oracle.com with ESMTP id 872630331292955119; Tue, 21 Dec 2010 10:11:59 -0800 Original-Received: from dradamslap1 (/10.159.239.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 21 Dec 2010 10:11:58 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <20101221131820.GA24113@gwsc.vic.edu.au> Thread-Index: AcuhEZSc0kUhRnuQRfi5MfFtZFX44wAG0w0g X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:77747 Archived-At: > 1. I need to make 5 or 6 key bindings. I presume the way to do this is > to create a prefix and then put my bindings under this. So perhaps the > prefix could be c-c c-l and then I can create key bindings to trigger > certain functions i.e.e c-c c-l t toggles the functionality on/off. > How would I implement something like this? C-h r i prefix key RET takes you to the Emacs manual node `Prefix Keys', which provides some help. ;; Define a keymap variable for your prefix-key commands: (defvar my-map () "My prefix key.") ;; Define the keymap as a prefix-key command: (define-prefix-command 'my-map) That defines `my-map' as a command whose function definition and whose value are the same, new (empty) keymap. More info: C-h f define-prefix-command C-h v my-map C-h f my-map ;; Bind command `my-map' to a key - the prefix key: (global-set-key "\C-c\C-l" 'my-map) ;; Bind cmds `foo' & `bar' to `a' & `b' following the prefix key: (define-key my-map "a" 'foo) (define-key my-map "b" 'bar) C-h k C-c C-l a -> "C-c C-l a runs the command foo, which is" > How could I record the current key bindings which use c-c c-l as a > prefix, and then restore them upon exit of the latex-access > stuff. I.e. when it is disabled. > Note, that I haven't created a minor or major mode, I'm just > using hooks > and advice as well as interactive functions to make my work available > under emacs. OK, let's start over from a clean slate (new Emacs session, to get rid of bindings etc. we created). You don't want the prefix key defined globally, but just in your (minor) mode. [And you apparently do want to use a prefix key for this stuff, so you won't override some global or major-mode binding with a minor-mode binding. If you didn't care about that, then you could just forget about `C-c C-l' (a prefix key) and bind your commands to any keys you wanted in the minor-mode map.] So you need two keymaps: a minor-mode map and a prefix-key map. ;; Create a keymap for your minor mode, and define the mode. (defvar latax-mode-map (make-sparse-keymap) "LaTeX access minor mode keymap.") (define-minor-mode latax-mode "LaTeX access mode." nil " LaTax" latax-mode-map) ;; Create the prefix-key keymap. (defvar latax-prefix-map nil "LaTeX access mode prefix keymap.") ;; Bind command `latax-prefix-map' to `C-c C-l' in `latex-mode-map': (define-key latax-mode-map "\C-c\C-l" 'latax-prefix-map) ;; Bind other commands in the prefix map: (define-key latax-prefix-map "a" 'forward-char) (define-key latax-prefix-map "b" 'emacs-version) Turn on/off the minor mode: `M-x latax-mode'. > 2. ... The translation in the echo area must be on screen at > all times... and is updated when post-command hook is triggered. > However, this is blocking important emacs messages.... My idea was to > create some kind of minibuffer or window at the bottom of screen so I > wouldn't interrupt the echo area. > I would like the window to shrink/grow depending on how many lines > I need to display. What would the best way of doing this be? Dunno. Sounds like you should just display another buffer (always), and send the output you want there. See `with-current-buffer' and the like. For fitting the window to the buffer, see `resize-temp-buffer-window' and `fit-window-to-buffer'. You can also use a separate frame for the buffer - see `special-display-regexps' and `special-display-buffer-names'. If you do that, you can use `fit-frame' in library `fit-frame.el' to fit the frame to the buffer. http://www.emacswiki.org/emacs/FrameModes#ShrinkWrappedFrames HTH.