Skip to content

julian-hoch/5009-region

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DIN 5009 Spelling Alphabet Conversion for Emacs

Purpose

This package provides functions to convert text to the German spelling alphabet defined by DIN 5009 (e.g., “A” becomes “Anton”) and back again within Emacs.

Features

  • Convert entire strings to DIN 5009 representation (din5009-string).
  • Convert DIN 5009 phonetic strings back to standard German spelling (de5009-string).
  • Interactive command din5009-region to convert the selected region to the DIN 5009 spelling alphabet.
  • Interactive command de5009-region to convert text formatted according to the DIN 5009 spelling alphabet back to regular text in the selected region.
  • Handles standard letters, numbers, umlauts, Eszett, common punctuation, and the digraph “ch” and trigraph “sch”.
  • Customizable separator string (default: “-“) via din5009-separator.
  • Includes a test runner command din5009-run-tests.

Installation

  1. Clone this repository or download 5009-region.el.
  2. Add the directory containing 5009-region.el to your Emacs load-path.
  3. Add (require '5009-region) to your Emacs configuration file (e.g., init.el).

Usage

Load the package using (require '5009-region).

You can customize the separator used between words:

(setq din5009-separator " ") ; Use space as separator

Examples

;; Convert a string
(din5009-string "Hallo Welt!")
;; => "Heinrich-Anton-Ludwig-Ludwig-Otto Wilhelm-Emil-Ludwig-Theodor-Ausrufezeichen"

(din5009-string "Ökonomie für ch/sch")
;; => "Ökonom-Kaufmann-Otto-Nordpol-Otto-Martha-Ida-Emil Friedrich-Übermut-Richard Charlotte-Schrägstrich-Schule"

(din5009-string "Text mit 123")
;; => "Theodor-Emil-Xanthippe-Theodor Martha-Ida-Theodor Eins-Zwei-Drei"

;; Convert back from DIN 5009
(de5009-string "Heinrich-Anton-Ludwig-Ludwig-Otto Welt Ausrufezeichen")
;; => "hallo Welt !"

(de5009-string "Ökonom-Kaufmann-Otto-Nordpol-Otto-Martha-Ida-Emil für Charlotte Schrägstrich Schule")
;; => "ökonomie für ch / sch"

(de5009-string "Theodor-Emil-Xanthippe-Theodor mit Eins-Zwei-Drei")
;; => "text mit 123"

;; Using region commands
;; Select text in a buffer and run:
M-x din5009-region
M-x de5009-region

To run the included tests: M-x din5009-run-tests

Embark Integration

If you want to quickly call the conversion functions using Embark, you can add the following to your Emacs configuration (if you use general; otherwise, you can use the keymap directly):

(general-define-key
       :keymaps 'embark-encode-map
       "/" 'din5009-region
       "?" 'de5009-region)

This will allow you to encode and decode using (by default) the shortcuts > / for encoding and > ? for decoding. This is convenient for me, since I trigger embark with C->, but you might choose different keys. It is also similar to the existing bindings for morse-region (> .) and unmorse-region (> -).

License

This package is distributed under the terms of the GNU General Public License version 3 or later (GPL-3.0-or-later).

Contributing

Contributions are welcome! Please ensure any pull requests include tests.

About

Convert plain text to DIN 5009 spelling alphabet and back

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published