emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* help regarding babel to set in-buffer specific keybinding
@ 2012-02-08  7:34 Thomas Alexander Gerds
  2012-02-08 14:34 ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Alexander Gerds @ 2012-02-08  7:34 UTC (permalink / raw)
  To: emacs-orgmode


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


--
sent from nil.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help regarding babel to set in-buffer specific keybinding
  2012-02-08  7:34 help regarding babel to set in-buffer specific keybinding Thomas Alexander Gerds
@ 2012-02-08 14:34 ` Eric Schulte
  2012-02-08 16:10   ` Eric S Fraga
  2012-02-09  7:14   ` Thomas Alexander Gerds
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Schulte @ 2012-02-08 14:34 UTC (permalink / raw)
  To: Thomas Alexander Gerds; +Cc: emacs-orgmode

Thomas Alexander Gerds <tagteam@sund.ku.dk> 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help regarding babel to set in-buffer specific keybinding
  2012-02-08 14:34 ` Eric Schulte
@ 2012-02-08 16:10   ` Eric S Fraga
  2012-02-08 23:32     ` Torsten Wagner
  2012-02-09  7:14   ` Thomas Alexander Gerds
  1 sibling, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2012-02-08 16:10 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Thomas Alexander Gerds, emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> Thomas Alexander Gerds <tagteam@sund.ku.dk> writes:

[...]

>> 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?
>> 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.

and I would be uncomfortable having code execute automatically upon
visiting an org file...

however, I would imagine it should be possible to add something to
org-mode-hook that would execute a predefined src code block, e.g. maybe
one named "startup" or probably a bit more specific?  I wouldn't know
the babel invocation required, mind you, but I'm others can help here!

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.92.1
: using Org-mode version 7.8.03 (release_7.8.03.325.g5847)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help regarding babel to set in-buffer specific keybinding
  2012-02-08 16:10   ` Eric S Fraga
@ 2012-02-08 23:32     ` Torsten Wagner
  0 siblings, 0 replies; 5+ messages in thread
From: Torsten Wagner @ 2012-02-08 23:32 UTC (permalink / raw)
  To: emacs-orgmode, Eric Schulte, Thomas Alexander Gerds

[-- Attachment #1: Type: text/plain, Size: 1927 bytes --]

Hmmm,
Recently I started to use source code blocks as a kind of init for a
certain task,  set variables,  modify stuff.  That is,  execution of a
source code block once at the beginning, e.g.  after opening an org file.
Thus, I was thinking about automatically execution too.
Would it help if there would be a approval necessary by the user.  A list
of trusted organisation files could be compared to execute a start block
without approval.
Sure there are still possible attack scenarios but that's what you pay for
more comfort ;)
Totti
On Feb 9, 2012 2:28 AM, "Eric S Fraga" <e.fraga@ucl.ac.uk> wrote:

> Eric Schulte <eric.schulte@gmx.com> writes:
>
> > Thomas Alexander Gerds <tagteam@sund.ku.dk> writes:
>
> [...]
>
> >> 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?
> >> 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.
>
> and I would be uncomfortable having code execute automatically upon
> visiting an org file...
>
> however, I would imagine it should be possible to add something to
> org-mode-hook that would execute a predefined src code block, e.g. maybe
> one named "startup" or probably a bit more specific?  I wouldn't know
> the babel invocation required, mind you, but I'm others can help here!
>
> --
> : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.92.1
> : using Org-mode version 7.8.03 (release_7.8.03.325.g5847)
>
>
>

[-- Attachment #2: Type: text/html, Size: 2471 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: help regarding babel to set in-buffer specific keybinding
  2012-02-08 14:34 ` Eric Schulte
  2012-02-08 16:10   ` Eric S Fraga
@ 2012-02-09  7:14   ` Thomas Alexander Gerds
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Alexander Gerds @ 2012-02-09  7:14 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


this works. thanks for the hint!

Eric Schulte <eric.schulte@gmx.com> writes:

> Thomas Alexander Gerds <tagteam@sund.ku.dk> 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,
--
Thomas A. Gerds -- Assoc. Prof. Department of Biostatistics
University of Copenhagen, Øster Farimagsgade 5, 1014 Copenhagen, Denmark
Office: CSS-15.2.07 (Gamle Kommunehospital)
tel: 35327914 (sec: 35327901) 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-09  7:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08  7:34 help regarding babel to set in-buffer specific keybinding Thomas Alexander Gerds
2012-02-08 14:34 ` Eric Schulte
2012-02-08 16:10   ` Eric S Fraga
2012-02-08 23:32     ` Torsten Wagner
2012-02-09  7:14   ` Thomas Alexander Gerds

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).