From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick Drechsler Subject: Re: shortcut keys for mark ups Date: Wed, 07 Jan 2009 21:27:59 +0100 Message-ID: References: <49638861.2050606@cornell.edu> <87sknwz5pe.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LKf0h-0008Tj-NR for emacs-orgmode@gnu.org; Wed, 07 Jan 2009 15:28:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LKf0g-0008TW-JY for emacs-orgmode@gnu.org; Wed, 07 Jan 2009 15:28:15 -0500 Received: from [199.232.76.173] (port=54383 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LKf0g-0008TT-FY for emacs-orgmode@gnu.org; Wed, 07 Jan 2009 15:28:14 -0500 Received: from main.gmane.org ([80.91.229.2]:33623 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LKf0g-00079G-4I for emacs-orgmode@gnu.org; Wed, 07 Jan 2009 15:28:14 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LKf0b-0002Vw-DR for emacs-orgmode@gnu.org; Wed, 07 Jan 2009 20:28:09 +0000 Received: from dslb-084-057-123-202.pools.arcor-ip.net ([84.57.123.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Jan 2009 20:28:09 +0000 Received: from patrick by dslb-084-057-123-202.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Jan 2009 20:28:09 +0000 In-Reply-To: <87sknwz5pe.fsf@gollum.intra.norang.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 " 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