i have org mode set up with typo minor mode and pretty entities enabled by default.

but when i work on programming, these two are totally useless inside the source code blocks i insert into org files. is it possible to disable them for src blocks only?

i don’t understand if there’s a hook or header or something similar for such things? i actually don’t know what kind of object the blocks are.

my only solution so far has been to use local variables to disable the in the whole file individually. but it would make sense to me to disable them universally, but only in the blocks, as no one will need typographic inverted commas in src blocks.

EDIT: here's an image as per comment request. example of typo mode pretty quotes inside and outside of a code block

steps: * install typo mode, and enable typo mode in org buffers with something like (typo-global-mode 1) / (add-hook 'org-mode-hook 'typo-mode) in your init file.

  • in an org buffer, insert a source block with #+begin_src

  • quotes inserted inside the block are prettified by typo mode, and your code parser throws an error.

  • to disable typo (and also pretty entities) i added this to the bottom of my file:

# Local Variables: #
# eval: (typo-mode -1) #
# eval: (org-toggle-pretty-entities) #
# End: #

this disables both for the whole file though, not just for the src block. i thought something similar might be possible for blocks and other such structures. and i would be interested in learning how that works.beg

  • Is it an issue of the face or of editing? Org has various functions/regexps to identify blocks. You may be able to use those along with the Org overlay functions (think links) to change the face within those regions. If it's editing, there's org-edit-special (C-'). Mar 5, 2020 at 21:57
  • i think it is neither. i have edited the face to be fixed-port had and monospace, but typo-mode still works on monospace fonts. typo auto inserts proper typographic quotes, ellipses etc.
    – martian
    Mar 5, 2020 at 22:01
  • ah sorry i was away from emacs when adding prev comment. org-edit-special is an acceptable workaround. though the idea of preventing the minor mode from running over the block still appeals to me. mayb its something for the package itself...
    – martian
    Mar 6, 2020 at 4:11
  • Cool, glad I could find something that moves you forward! If you've got a moment, can you please revise your question with minimal steps to reproduce the issue? Typically, it's frowned upon to post pictures, but I think one might be helpful in this case. I honestly still don't understand what problem you're trying to solve. However, it seems related to things I'm working with, so a clearer question may help me (and others) provide a proper answer. Also, welcome to Emacs SE! :) Mar 6, 2020 at 13:38
  • will do, sure. i only thought to ask because i thought other people may also have such a need/run into same issue (or, as the case may be, every had solved it but me!)
    – martian
    Mar 6, 2020 at 14:06

1 Answer 1


To self-insert the key in the source block:

(defun my-org-mode-hook ()
  "Custom `org-mode' behaviours."
  (typo-mode 1)
  (add-hook 'typo-disable-electricity-functions 'org-in-src-block-p nil :local))

(add-hook 'org-mode-hook 'my-org-mode-hook)

Documentation: *A list of functions to call before an electric key binding is used. If one of the functions returns non-nil, the key self-inserts.

  • thx for this, but i'm not an expert emacser: i don't know what a key is, nor an electric key binding (sorry.) maybe another user does tho?
    – martian
    Mar 30, 2020 at 18:35
  • Key = keyboard key. When a key self-inserts the key press inserts itself and nothing else. Electric key bindings are keys that (when pressed) insert both itself (the opening pair) and the closing pair. What the hook does is it prevents the insertion of special pairs when the point is in a source block.
    – jagrg
    Mar 31, 2020 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.