previous ] [ start page ] [ next ]

There is not much to do to set up Emacs for editing in a German language environment. You'll just have to make sure, that Emacs is configured for 8 bit display or any character above ASCII 127 will be presented in octal notation by default. See section "fundamental display setup" in my site-start.el on how to achieve this.

You also may find the following code snippets of some use. Please don't save this page to disk. There are hyperlinks provided to download the elisp code shown below.

Mule independent codepage switching

The Internet made it necessary to have the ISO-8859-1 character set available. The following uses iso-pc.el from Carsten Leonhardt. It works with Emacs 19.xx as well as with Emacs 20.6.

You may also want to put CODEPAGE=437,1004 in your config.sys and you will be able to not only switch codepages in Emacs with chcp 1004 and chcp 437 respectively, but system-wide. (Codepage 1004 is not equal to but very similar to the ISO-8859-1 character set)

;;; Set ISO-8859-1 character set up for correct use with mails, postings etc.
;; (require 'iso-syntax)  ;; for version 19.xx
(require 'iso-pc)

(defun my-show-current-code-page ()
  "Show active codepage"
  (if (equal (current-code-page) '1004)
      (message (concat "Active codepage is " (current-code-page) " \(ISO-8859-1\)"))
    (message (concat "Active codepage is " (current-code-page) " \(PC\)"))))

(defun my-toggle-code-page ()
  "Toggle codepage between 850 \(PC\) and 1004 \(ISO-8859-1\)"
  (if (equal (current-code-page) '1004)
      (set-code-page '850)
    (set-code-page '1004))
  (message (concat "Using codepage " (current-code-page))))

(defun my-toggle-charset ()
  "Toggle codepage between 850 \(PC\) and 1004 \(ISO-8859-1\)"
  (if window-system
(global-set-key [f9] 'my-toggle-charset)
(global-set-key [C-f9] 'my-show-current-code-page)

(defun my-iso-chars-enable ()
  "Enables the ISO-8859-1 charset."
  (if window-system (set-code-page '1004) (iso-pc-enable))
  (message (concat "Using ISO-8859-1 charset.")))
(defun my-iso-chars-disable ()
  "Disables the ISO-8859-1 charset."
  (if window-system (set-code-page '850) (iso-pc-disable))
  (message (concat "Using PC charset.")))

Download snippets.

Replace German umlaute with HTML character entries

I personally find it very unsuitable to think of HTML character entities when I write a HTML document. With the following function which can be bound to a key, you don't have to care about umlaute. Just type as you are used to, then call the function when your document is ready to be published.
The function assumes you are using ISO-8859-1 as standard coding scheme.

(defun german-to-html ()
   "Replace german umlauts with HTML token in current buffer"
   (goto-char (point-min))
   (perform-replace "Ä" "Ä" nil nil nil)
   (goto-char (point-min))
   (perform-replace "ä" "ä" nil nil nil)
   (goto-char (point-min))
   (perform-replace "Ö" "Ö" nil nil nil)
   (goto-char (point-min))
   (perform-replace "ö" "ö" nil nil nil)
   (goto-char (point-min))
   (perform-replace "Ü" "Ü" nil nil nil)
   (goto-char (point-min))
   (perform-replace "ü" "ü" nil nil nil)
   (goto-char (point-min))
   (perform-replace "ß" "ß" nil nil nil)))

Download snippets.

German calendar setup

Emacs comes with a calendar which is usuable for a lot of things including an appointment schedule. The following elisp code makes the calendar "speak" German. Put it in your site-start.el or .emacs file.

;;; Ulrich Müller, Inst. für Kernphysik, Univ. Mainz, D-55099 Mainz
;;;, Tel. +49 6131 39-5812, Fax -2964

(setq calendar-week-start-day 1)        ; Monday
(setq european-calendar-style t)
(setq calendar-time-display-form
      '(24-hours ":" minutes (and time-zone (concat " (" time-zone ")"))))
(setq calendar-day-name-array
      ["Sonntag" "Montag" "Dienstag" "Mittwoch"
       "Donnerstag" "Freitag" "Samstag"])
(setq calendar-month-name-array
      ["Januar" "Februar" "März" "April" "Mai" "Juni"
       "Juli" "August" "September" "Oktober" "November" "Dezember"])
(setq solar-n-hemi-seasons
      '("Frühlingsanfang" "Sommeranfang" "Herbstanfang" "Winteranfang"))
(setq general-holidays
      '((holiday-fixed 1 1 "Neujahr")
        (holiday-fixed 5 1 "1. Mai")
        (holiday-fixed 10 3 "Tag der Deutschen Einheit")))
(setq christian-holidays
        (holiday-float 12 0 -4 "1. Advent" 24)
        (holiday-float 12 0 -3 "2. Advent" 24)
        (holiday-float 12 0 -2 "3. Advent" 24)
        (holiday-float 12 0 -1 "4. Advent" 24)
        (holiday-fixed 12 25 "1. Weihnachtstag")
        (holiday-fixed 12 26 "2. Weihnachtstag")
        (holiday-fixed 1 6 "Heilige Drei Könige")
        ;; Date of Easter calculation taken from holidays.el.
        (let* ((century (1+ (/ displayed-year 100)))
               (shifted-epact (% (+ 14 (* 11 (% displayed-year 19))
                                    (- (/ (* 3 century) 4))
                                    (/ (+ 5 (* 8 century)) 25)
                                    (* 30 century))
               (adjusted-epact (if (or (= shifted-epact 0)
                                       (and (= shifted-epact 1)
                                            (< 10 (% displayed-year 19))))
                                   (1+ shifted-epact)
               (paschal-moon (- (calendar-absolute-from-gregorian
                                 (list 4 19 displayed-year))
               (easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))
            (lambda (l)
              (list (calendar-gregorian-from-absolute (+ easter (car l)))
                    (nth 1 l)))
              ;;(-48 "Rosenmontag")
              ( -2 "Karfreitag")
              (  0 "Ostersonntag")
              ( +1 "Ostermontag")
              (+39 "Christi Himmelfahrt")
              (+49 "Pfingstsonntag")
              (+50 "Pfingstmontag")
              ;;(+60 "Fronleichnam")
        ;;(holiday-fixed 8 15 "Mariä Himmelfahrt")
        (holiday-fixed 11 1 "Allerheiligen")
        ;;(holiday-float 11 3 1 "Buß- und Bettag" 16)
        (holiday-float 11 0 1 "Totensonntag" 20)))
(setq calendar-holidays
      (append general-holidays local-holidays other-holidays
              christian-holidays solar-holidays))

;;; adapt this to your location
(setq calendar-latitude 52.3)
(setq calendar-longitude -13.2)
(setq calendar-location-name "Berlin")
(setq mark-diary-entries-in-calendar t)
(setq mark-holidays-in-calendar t)
(setq calendar-mark-today "<")

(add-hook 'today-visible-calendar-hook 'calendar-mark-today)

;;; Appointment setup
(add-hook 'diary-hook 'appt-make-list)
(setq display-time-24hr-format t)
(display-time)  ;; on mode line

Download snippets.

previous ] [ start page ] [ next ]

Oliver Heidelbach <ohei@snafu> is not responsible for the content of this page.
[Tue Oct 23 22:44:11 2001]