Change emacs org-mode key binding for code block
In org-mode I use <s then TAB to insert a code block. This action will insert a code block like
#+BEGIN_SRC
.
.
.
#+END_SRC
but I want to modify this action to insert something like
#+BEGIN_SRC python -n :results output pp replace :exports both
.
.
.
#+END_SRC
I know it's possible to change default behaviour of :result or :exports in emacs init file but I prefer to change this shortcut behaviour, because it makes me able to change the options in line.
emacs org-mode
add a comment |
In org-mode I use <s then TAB to insert a code block. This action will insert a code block like
#+BEGIN_SRC
.
.
.
#+END_SRC
but I want to modify this action to insert something like
#+BEGIN_SRC python -n :results output pp replace :exports both
.
.
.
#+END_SRC
I know it's possible to change default behaviour of :result or :exports in emacs init file but I prefer to change this shortcut behaviour, because it makes me able to change the options in line.
emacs org-mode
add a comment |
In org-mode I use <s then TAB to insert a code block. This action will insert a code block like
#+BEGIN_SRC
.
.
.
#+END_SRC
but I want to modify this action to insert something like
#+BEGIN_SRC python -n :results output pp replace :exports both
.
.
.
#+END_SRC
I know it's possible to change default behaviour of :result or :exports in emacs init file but I prefer to change this shortcut behaviour, because it makes me able to change the options in line.
emacs org-mode
In org-mode I use <s then TAB to insert a code block. This action will insert a code block like
#+BEGIN_SRC
.
.
.
#+END_SRC
but I want to modify this action to insert something like
#+BEGIN_SRC python -n :results output pp replace :exports both
.
.
.
#+END_SRC
I know it's possible to change default behaviour of :result or :exports in emacs init file but I prefer to change this shortcut behaviour, because it makes me able to change the options in line.
emacs org-mode
emacs org-mode
edited Nov 21 '18 at 14:46
legoscia
28.5k1179110
28.5k1179110
asked Nov 21 '18 at 13:39
shae128shae128
215
215
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Answering my own question based on legoscia's answer.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. Using M-x customize-option and applying changes will add all easy templates to your init file, if you don't like it you can add just one line to your init file to change a template or add one.
In my case I added this line to my emacs init file to add <p then TAB :
(add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python -n :results output pp replace :exports bothn?n#+END_SRC"))
ALL CREDITS GOES TO legoscia
add a comment |
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. (Use M-x customize-option.)
For <s, the default expansion is "#+BEGIN_SRC ?nn#+END_SRC". You can just edit it to include the options you want after BEGIN_SRC. Alternatively, you could add a new template, e.g. <p, that expands to the text you want.
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
add a comment |
just a complement of information.
you are not obliged to define this in your global init file.
you can set default options for any org mode file adding this line (to adapt to your case):
#+PROPERTY: header-args:python :session *mysession* :eval no-export :results raw drawer
at the beginning of your org file.
In your org mode document
#+BEGIN_SRC python :eval never :tangle yes
...
#+END_SRC
will use default option values unless there are overwritten (:eval example here)
Note: if you modify your line
#+PROPERTY: ...
during editing your org mode file, do not forget to C-c C-c to update config.
Extra info: https://org-babel.readthedocs.io/en/latest/header-args/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413338%2fchange-emacs-org-mode-key-binding-for-code-block%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Answering my own question based on legoscia's answer.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. Using M-x customize-option and applying changes will add all easy templates to your init file, if you don't like it you can add just one line to your init file to change a template or add one.
In my case I added this line to my emacs init file to add <p then TAB :
(add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python -n :results output pp replace :exports bothn?n#+END_SRC"))
ALL CREDITS GOES TO legoscia
add a comment |
Answering my own question based on legoscia's answer.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. Using M-x customize-option and applying changes will add all easy templates to your init file, if you don't like it you can add just one line to your init file to change a template or add one.
In my case I added this line to my emacs init file to add <p then TAB :
(add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python -n :results output pp replace :exports bothn?n#+END_SRC"))
ALL CREDITS GOES TO legoscia
add a comment |
Answering my own question based on legoscia's answer.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. Using M-x customize-option and applying changes will add all easy templates to your init file, if you don't like it you can add just one line to your init file to change a template or add one.
In my case I added this line to my emacs init file to add <p then TAB :
(add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python -n :results output pp replace :exports bothn?n#+END_SRC"))
ALL CREDITS GOES TO legoscia
Answering my own question based on legoscia's answer.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. Using M-x customize-option and applying changes will add all easy templates to your init file, if you don't like it you can add just one line to your init file to change a template or add one.
In my case I added this line to my emacs init file to add <p then TAB :
(add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python -n :results output pp replace :exports bothn?n#+END_SRC"))
ALL CREDITS GOES TO legoscia
answered Nov 21 '18 at 18:07
shae128shae128
215
215
add a comment |
add a comment |
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. (Use M-x customize-option.)
For <s, the default expansion is "#+BEGIN_SRC ?nn#+END_SRC". You can just edit it to include the options you want after BEGIN_SRC. Alternatively, you could add a new template, e.g. <p, that expands to the text you want.
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
add a comment |
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. (Use M-x customize-option.)
For <s, the default expansion is "#+BEGIN_SRC ?nn#+END_SRC". You can just edit it to include the options you want after BEGIN_SRC. Alternatively, you could add a new template, e.g. <p, that expands to the text you want.
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
add a comment |
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. (Use M-x customize-option.)
For <s, the default expansion is "#+BEGIN_SRC ?nn#+END_SRC". You can just edit it to include the options you want after BEGIN_SRC. Alternatively, you could add a new template, e.g. <p, that expands to the text you want.
As mentioned in the Easy Templates section of the org-mode manual, you can modify these templates by customizing the variable org-structure-template-alist. (Use M-x customize-option.)
For <s, the default expansion is "#+BEGIN_SRC ?nn#+END_SRC". You can just edit it to include the options you want after BEGIN_SRC. Alternatively, you could add a new template, e.g. <p, that expands to the text you want.
answered Nov 21 '18 at 14:44
legoscialegoscia
28.5k1179110
28.5k1179110
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
add a comment |
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
Thank you, your answer solved my problem, but as it adds all easy template's config to init file I will add another answer based on your answer which will keep init file more readable by adding just one line for new or edited easy template. ALL CREDITS GOES TO @legoscia
– shae128
Nov 21 '18 at 17:52
add a comment |
just a complement of information.
you are not obliged to define this in your global init file.
you can set default options for any org mode file adding this line (to adapt to your case):
#+PROPERTY: header-args:python :session *mysession* :eval no-export :results raw drawer
at the beginning of your org file.
In your org mode document
#+BEGIN_SRC python :eval never :tangle yes
...
#+END_SRC
will use default option values unless there are overwritten (:eval example here)
Note: if you modify your line
#+PROPERTY: ...
during editing your org mode file, do not forget to C-c C-c to update config.
Extra info: https://org-babel.readthedocs.io/en/latest/header-args/
add a comment |
just a complement of information.
you are not obliged to define this in your global init file.
you can set default options for any org mode file adding this line (to adapt to your case):
#+PROPERTY: header-args:python :session *mysession* :eval no-export :results raw drawer
at the beginning of your org file.
In your org mode document
#+BEGIN_SRC python :eval never :tangle yes
...
#+END_SRC
will use default option values unless there are overwritten (:eval example here)
Note: if you modify your line
#+PROPERTY: ...
during editing your org mode file, do not forget to C-c C-c to update config.
Extra info: https://org-babel.readthedocs.io/en/latest/header-args/
add a comment |
just a complement of information.
you are not obliged to define this in your global init file.
you can set default options for any org mode file adding this line (to adapt to your case):
#+PROPERTY: header-args:python :session *mysession* :eval no-export :results raw drawer
at the beginning of your org file.
In your org mode document
#+BEGIN_SRC python :eval never :tangle yes
...
#+END_SRC
will use default option values unless there are overwritten (:eval example here)
Note: if you modify your line
#+PROPERTY: ...
during editing your org mode file, do not forget to C-c C-c to update config.
Extra info: https://org-babel.readthedocs.io/en/latest/header-args/
just a complement of information.
you are not obliged to define this in your global init file.
you can set default options for any org mode file adding this line (to adapt to your case):
#+PROPERTY: header-args:python :session *mysession* :eval no-export :results raw drawer
at the beginning of your org file.
In your org mode document
#+BEGIN_SRC python :eval never :tangle yes
...
#+END_SRC
will use default option values unless there are overwritten (:eval example here)
Note: if you modify your line
#+PROPERTY: ...
during editing your org mode file, do not forget to C-c C-c to update config.
Extra info: https://org-babel.readthedocs.io/en/latest/header-args/
answered Nov 22 '18 at 7:59
Picaud VincentPicaud Vincent
3,5991832
3,5991832
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413338%2fchange-emacs-org-mode-key-binding-for-code-block%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown