(defvar sd-econv-fields '("trs" "trw" "trp" "tre") "*") (defvar sd-ag-fields '("SXII" "SIXp" "SXIIIn1" "SXIIIe") "*") (defvar sd-vowels '("A" "a" "E" "e" "I" "i" "O" "o" "U" "u" "y") "*") (defvar sd-vowels-til '("Ä" "ä" "Ë" "ë" "Ï" "ï" "Ö" "ö" "Ü" "ü" "ÿ") "*") (defun sd-til (vowels vowels-til) "Converts all sequences of #+Vowel to Vowel with ¨ (trema) Vowels are each one of a,A,e,E,i,I,o,O,u,U,y, converted to ä,Ä,ë,Ë,ï,Ï,ö,Ö,ü,Ü,ÿ. #Y is not converted yet." (interactive "vList of vowels: vList of corresponding nasalyzed vowels: ") (setq vowels (eval vowels)) (setq vowels-til (eval vowels-til)) (setq case-fold-search nil) (while vowels (setq vowel (car vowels) vowels (cdr vowels) vowel-til (car vowels-til) vowels-til (cdr vowels-til)) (goto-char (point-min)) (while (search-forward (concat "#" vowel) nil t) (replace-match vowel-til t t)) (goto-char (point-min)) (while (search-forward (concat "~" vowel) nil t) (replace-match vowel-til t t)))) (defun sd-econv-AG-fields (econv-fields ag-fields) "Converts econv-generated files to Advanced Glossing (Syntax) files. Converts the field markers in ECONV-FIELDS to the corresponding entries in AG-FIELDS" (interactive "vList of Transcriber Fields: vList of corresponding AG Fields: ") (setq econv-fields (eval econv-fields)) (setq ag-fields (eval ag-fields)) (while econv-fields (setq econv-field (car econv-fields) econv-fields (cdr econv-fields) ag-field (car ag-fields) ag-fields (cdr ag-fields)) (goto-char (point-min)) (while (search-forward-regexp (concat "^\\\\" econv-field "\\>") nil t) (replace-match (concat "\\" ag-field) t t))) (goto-char (point-min)) (while (search-forward-regexp "\\(\\\\_sh +v.\\.0 +... +\\)econv" nil t) (replace-match "\\_sh v3.0 400 AG-syntax" nil t))) (defun sd-conv-econv-ag () "Converts econv Shoebox files to AG-Syntax Shoebox files. Calls sd-econv-AG-fields and sd-til with default arguments." (interactive) (sd-til 'sd-vowels 'sd-vowels-til) (sd-econv-AG-fields 'sd-econv-fields 'sd-ag-fields) (if (not (equal (file-name-extension (buffer-file-name)) "txt")) (save-buffer) (setq file-name (concat (file-name-sans-extension (buffer-file-name)) ".sdb")) (write-file file-name t)))