From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: help regarding babel to set in-buffer specific keybinding Date: Wed, 08 Feb 2012 07:34:45 -0700 Message-ID: <87ty31nzor.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv8v0-0003TI-H2 for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv8uu-0001xq-EH for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:46 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:33112 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rv8uu-0001xc-5Z for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:40 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thomas Alexander Gerds Cc: emacs-orgmode@gnu.org Thomas Alexander Gerds writes: > here is a (beginner) question regarding the following org-file with > buffer-local function and keybinding: > > ,---- > | > | * Lisp header (C-c C-c to activate) > | #+BEGIN_SRC emacs-lisp > | (defun blue-file () > | (interactive) > | (org-table-insert-row 'below) > | (org-table-goto-column 1) > | (insert (format-time-string "%d.%m.%Y")) > | (org-table-goto-column 2) > | (org-table-copy-down 1) > | (org-table-goto-column 3) > | (org-table-copy-down 1) > | (org-table-goto-column 4)) > | (define-key org-mode-map [(meta return)] 'blue-file) > | #+END_SRC > | > | #+RESULTS: > | : blue-file > | > | > | | Date | Staff | Type | Name | Value | > | |------+--------------+-------------+------+-------| > | | | Anders And | consulting | | | > | | | Anders And | supervision | | | > | | | Anders And | teaching | | | > | | | Mickey Mouse | consulting | | | > | | | Mickey Mouse | supervision | | | > | | | Mickey Mouse | teaching | | | > `---- > > now, I would like to tell org to evaluate the lisp code at startup, when > the org-file is opened. can this be achieved? particularly, is there a > startup special line which tells org to evaluate the lisp src block? I > could add a suitable function to org-mode-hook, but is this the > recommended way? > > also, I would like to make org-mode-map buffer-local ... but certainly > this is not an orgmode question. > > suggestions/help are very much appreciated! > > Tomy > There is not currently any support for evaluating specific code blocks on buffer open. You could move your elisp code into a buffer-local-variable block (which can house functions) and which are evaluated when buffers are opened. I believe all changes made in such blocks are buffer local, so that may be your best bet. See [[info:elisp#File%20Local%20Variables][info:elisp#File Local Variables]] or http://www.emacswiki.org/emacs/FileLocalVariables Cheers, -- Eric Schulte http://cs.unm.edu/~eschulte/