Emacs Gänsefüßchen Mode

Just Gänsefüßchen. As soon as I posted this, someone brought the much more serious typographical mode typo.el to my attention, which does much more.

English

This is a 30 line emacs minor mode that binds the "-key to german typographical quotes. There is an additional function replace-Gänsefüßchen that replaces quotes in region with Gänsefüßchen.

Deutsch

Hier ein Minor Mode der die "-Taste mit deutschen Gänsefüßchen belegt und eine extra Funktion replace-Gänsefüßchen, die doppelte Anführungszeichen durch deutsche Gänsefüßchen ersetzt.

Demo

„Na endlich“, murmelte er, „Gänsefüßchen!“

Emacs

(defun insert-Gänsefüßchen ()
  (interactive)
  (let ((preceding (preceding-char) ))
    (if (or (eq preceding 10)
            (eq preceding 32))
        (insert-and-inherit  "„")
      (insert-and-inherit "“"))))

(defun replace-Gänsefüßchen ()
  "Replace double quotes in region with Gänsefüßchen."
  (interactive)
  (let ((point (point))
        (mark (mark)))
    (when (and mark (> point mark))
      (exchange-point-and-mark))
    (while (search-forward "\x22" (mark) t)
      (replace-match "" nil t)
      (insert-Gänsefüßchen))
    (goto-char point)))

(define-minor-mode Gänsefüßchen-Mode
  "Use Gänsefüßchen instead of quotes."
  :init-value nil
  :lighter " “"
  :keymap '(([?\"] . insert-Gänsefüßchen)))