; -*- coding: utf-8 -*- (defvar iks-list '( (?Ĉ . "Cx") (?ĉ . "cx") (?Ĝ . "Gx") (?ĝ . "gx") (?Ĥ . "Hx") (?ĥ . "hx") (?Ĵ . "Jx") (?ĵ . "jx") (?Ŝ . "Sx") (?ŝ . "sx") (?Ŭ . "Ux") (?ŭ . "ux") (?— . "-") (?æ . "ae") (?ø . "o") (?ö . "o") (?¹ . "^1") (?² . "^2") (?³ . "^3") (?⁴ . "^4") (?⁵ . "^5") (?⁶ . "^6") (?⁷ . "^7") )) (defun 8>x (&optional begin end) "Translate UTF-8 region into the X-notation." (interactive) (let* ((beg (point-min)) (end (point-max)) (coding buffer-file-coding-system)) (if (or (not coding) (eq (coding-system-type coding) t)) (setq coding default-buffer-file-coding-system)) (save-excursion (goto-char end) (while (> (point) beg) (forward-char -1) (setq end (point)) (let ((char (following-char)) sgm) (if (and (>= char 128) (setq sgm (assoc char iks-list))) (progn (delete-char 1) (insert (cdr sgm)) (goto-char end)) )) ) ))) (defun 5x () "Translate UTF-8 region into the ISO-8859-5 & X-notation." (interactive) (let* ((beg (point-min)) (end (point-max)) (coding buffer-file-coding-system)) (if (or (not coding) (eq (coding-system-type coding) t)) (setq coding 'iso-8859-5)) (save-excursion (goto-char end) (while (> (point) beg) (forward-char -1) (setq end (point)) (let ((char (following-char))) (if (>= char 128) (if (>= char ?Ё) (progn (delete-char 1) (insert-char (- char (if (< char ?р) 296608 296640)) 1 ) (forward-char -1) ) (let ((sgm (assoc char iks-list))) (if (null sgm) (error "Mankas ikso por %c" char) (progn (delete-char 1) (insert (cdr sgm))))) ) ) )) ) )) (defun h>x () "Translate chirkau => cxirkaux" (interactive) (goto-char (point-min)) (while (re-search-forward "[cghjs]h" nil t) (progn (delete-char -1) (insert "x"))) (goto-char (point-min)) (while (re-search-forward "[ae]u" nil t) (insert "x"))) (defun x>8 (from to) "Translate cxirkaux => ĉirkaŭ" (interactive "r") (goto-char to) (while (re-search-backward "\\([cghjsu]x\\)" from t) (let ((cx (match-string 1))) (replace-match (char-to-string (car (rassoc cx iks-list))) t t nil 1)))) ;======== Dictionary.el: (autoload 'dictionary-search "dictionary" "Ask for a word and search it in all dictionaries" t) (autoload 'dictionary-match-words "dictionary" "Ask for a word and search all matching words in the dictionaries" t) (autoload 'dictionary "dictionary" "Create a new dictionary buffer" t) (global-set-key "\C-cs" 'dictionary-search) (global-set-key "\C-cm" 'dictionary-match-words) (setq dictionary-server "localhost") (defun ch8>x (ch) "Translate Unicode ch into X-notation" (if (< ch 128) (char-to-string ch) (let ((sgm (assoc ch iks-list))) (if sgm (cdr sgm) (char-to-string ch))))) (defadvice dictionary-do-search (before dictionary-do-search-asciize (word dictionary) activate) "Dict-search the ASCIIzed word" (setq word (mapconcat 'ch8>x word "")) ) (defadvice dictionary-search (before dictionary-search-utf8 (word &optional dictionary) activate) "Search the UTF-8 `word'" (interactive (list (read-string "Search word: " (thing-at-point 'sexp)) (if current-prefix-arg (read-string "Dictionary: " dictionary-default-dictionary) dictionary-default-dictionary)))) (provide 'iksismo)