[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: shortcut keys for mark ups
From: |
Patrick Drechsler |
Subject: |
[Orgmode] Re: shortcut keys for mark ups |
Date: |
Wed, 07 Jan 2009 21:27:59 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (Windows/20081209) |
Bernt Hansen schrieb:
[snipped nice code]
How can I extend this function to wrap the current selection into a
#+BEGIN_SRC
...code...
#+END_SRC
string while also interactively asking the user for a language string?
-----------------------------------------------------------------
;; ============================================================
;; Puts current selection between #+BEGIN_SRC and #+END_SRC
;; and ask for language
;; ============================================================
;; TODO:
;; 1. Retrieve beginning (C-SPACE) and
;; end of selection (current position)
;; 2. Ask for language and insert that string
;; after `#+BEGIN_SRC '
(defun my-wrap-src ()
(interactive)
(save-excursion
(beginning-of-line)
(insert "#+BEGIN_SRC\n")
(end-of-line)
(insert "\n#+END_SRC")))
(define-key org-mode-map (kbd "<f9> s") 'my-wrap-src)
-----------------------------------------------------------------
Example org code before function call:
-----------------------------------------------------------------
* Sample Code
public class Bla {
public static void main(String[] args) {
System.out.println("Hello");
}
}
-----------------------------------------------------------------
With the code above:
- Mark the region: C-SPACE on the letter `p' of the string `public' and
moving the cursor behind the last closing curly bracket.
- String after being asked for a language: `java'
Example org code after function call:
-----------------------------------------------------------------
* Sample Code
#+BEGIN_SRC java
public class Bla {
public static void main(String[] args) {
System.out.println("Hello");
}
}
#+END_SRC
-----------------------------------------------------------------
TIA,
Patrick