(makunbound 'ligatureth-map) (defconst ligatureth-map '(("AE" . "Æ") ("IJ" . "IJ") ;; ("LJ" . "LJ") ;; ("Lj" . "Lj") ;; ("NJ" . "NJ") ;; ("Nj" . "Nj") ;; ("OE" . "Œ") ("STH". "SÞ") ("STh". "SÞ") ("Sth". "Sþ") ("TH" . "Þ") ("ae" . "æ") ("ff" . "ff") ("ffi". "ffi") ("ffl". "ffl") ("fi" . "fi") ("fl" . "fl") ("ij" . "ij") ("lj" . "lj") ("nj" . "nj") ;; ("oe" . "œ") ("sth". "sþ") ("sTh". "sÞ") ("sTH". "sÞ") ("th" . "þ"))) (makunbound 'ligatureth-map-noeth) (defconst ligatureth-map-noeth (apply 'append (mapcar (lambda (e) (if (string-match "þ" (cdr e)) nil (list e))) ligatureth-map))) (defvar ligatureth-replacement-map ligatureth-map) (setq ligatureth-replacement-map ligatureth-map) ;;(setq ligatureth-replacement-map ligatureth-map-noeth) (defun ligatureth-replacement (text) (or (cdr-safe (assoc text ligatureth-replacement-map)) (if (eq (aref text 0) ?s) (if (eq (aref text 1) ?t) (format "ſt%s" (substring text 2)) (if (eq (aref text 1) ?s) (format "ſſ%s" (substring text 2)) (format "ſ%s" (substring text 1)) )) ) text)) (defun ligatureth-filter (target) (let ((case-fold-search t)) (replace-regexp-in-string "ſſ\\>" "ſs" (replace-regexp-in-string "AE\\|s?th\\|f\\(?:f[il]\\|[fil]\\)\\|[iln]j\\|oe\\|s[a-z]" 'ligatureth-replacement target nil t)))) ;;(ligatureth-filter (shell-command-to-string "fortune -l")) ;;(ligatureth-filter "aesthetic earliest neurasthenia enjoy does messing") (defun erc-ligatureth-filter-a (symbol) (set symbol (ligatureth-filter (symbol-value symbol)) )) (defun erc-ligatureth-filter-b (text) (setq str (ligatureth-filter text))) (defun erc-bracket-bracket (text) (setq str (concat "[" text "]"))) ;; (remove-hook 'erc-send-pre-hook 'erc-ligatureth-filter-b) ;;(add-hook 'erc-send-pre-hook 'erc-bracket-bracket) ;;(remove-hook 'erc-send-pre-hook 'erc-bracket-bracket) ;;(let ((str (concat "aesthetic earliest mediaeval effluent assess " ;; "neurasthenia rijndael messing "))) ;; (run-hook-with-args 'erc-send-pre-hook str) str) (add-hook 'erc-send-pre-hook 'erc-ligatureth-filter-b) ;; (remove-hook 'erc-send-pre-hook 'erc-ligatureth-filter-b)