Endless Parentheses

Ramblings on productivity and technical subjects.

profile for Malabarba on Stack Exchange

Prettify your Quotation Marks

Typography post series

Typography is a long and blurry road, of which I know very little. There are, still, some simple lessons that take you a long a way. Round (Unicode) quotation marks is one of them.

LaTeX already does that for you, but many other prose environments don’t. This snippet inserts “round” quotes for you, bind it to your text-modes.

(define-key org-mode-map "\"" #'endless/round-quotes)
(eval-after-load 'markdown-mode
  '(define-key markdown-mode-map "\""

(defun endless/round-quotes (italicize)
  "Insert “” and leave point in the middle.
With prefix argument ITALICIZE, insert /“”/ instead
\(meant for org-mode).
Inside a code-block, just call `self-insert-command'."
  (interactive "P")
  (if (and (derived-mode-p 'org-mode)
           (org-in-block-p '("src" "latex" "html")))
      (call-interactively #'self-insert-command)
    (if (looking-at "”[/=_\\*]?")
        (goto-char (match-end 0))
      (when italicize
        (if (derived-mode-p 'markdown-mode)
            (insert "__")
          (insert "//"))
        (forward-char -1))
      (insert "“”")
      (forward-char -1))))
comments powered by Disqus