emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] paste from clip to code block


From: John Kitchin
Subject: Re: [O] paste from clip to code block
Date: Fri, 17 Apr 2015 11:17:40 -0400

you are right, I meant C-y ;)

I have these templates defined in my setup:

;; * Expansions for blocks
;; add <p for python expansion
(add-to-list 'org-structure-template-alist
             '("p" "#+BEGIN_SRC python\n?\n#+END_SRC" "<src lang=\"python\">\n?\n</src>"))

;; add <por for python expansion with raw output
(add-to-list 'org-structure-template-alist
             '("por" "#+BEGIN_SRC python :results output raw\n?\n#+END_SRC" "<src lang=\"python\">\n?\n</src>"))

;; add <pv for python expansion with value
(add-to-list 'org-structure-template-alist
             '("pv" "#+BEGIN_SRC python :results value\n?\n#+END_SRC" "<src lang=\"python\">\n?\n</src>"))

;; add <el for emacs-lisp expansion
(add-to-list 'org-structure-template-alist
             '("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC" "<src lang=\"emacs-lisp\">\n?\n</src>"))

;; add <sh for shell
(add-to-list 'org-structure-template-alist
             '("sh" "#+BEGIN_SRC sh\n?\n#+END_SRC" "<src lang=\"shell\">\n?\n</src>"))

John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803

On Fri, Apr 17, 2015 at 11:08 AM, Jorge A. Alfaro-Murillo <address@hidden> wrote:
John Kitchin writes:

I like this kind of keyboard shortcut:
For python: <p TAB C-w
For emacs-lisp
<el TAB C-w

I agree, this is the best method. Although probably you mean C-y instead of C-w.

For the record, this requires you to set up `org-structure-template-alist' to include python and emacs-lisp. For example, I use p and E, for python and emacs-lisp, so in my .emacs I have:

#+BEGIN_SRC emacs-lisp
 (eval-after-load "org"
        '(progn
           (add-to-list 'org-structure-template-alist
                        '("E"
                          "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"
                          "<src                           lang=\\"emacs-lisp\\">\n\n?</src>"))
           (add-to-list 'org-structure-template-alist
                        '("p"
                          "#+BEGIN_SRC python\n?\n#+END_SRC"
                          "<src                           lang=\\"python\\">\n\n?</src>"))))
#+END_SRC

I even use the method in message-mode, for writing emails with code, like I just did now =)

Best,

--
Jorge.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]