+;;;###autoload
+(defun nato-region (beg end)
+ "Convert all text in a given region to NATO phonetic alphabet."
+ ;; Copied from morse-region. -- ashawley 2009-02-10
+ (interactive "*r")
+ (if (integerp end)
+ (setq end (copy-marker end)))
+ (save-excursion
+ (let ((sep "")
+ str nato)
+ (goto-char beg)
+ (while (< (point) end)
+ (setq str (downcase (buffer-substring (point) (1+ (point)))))
+ (cond ((looking-at "\\s-+")
+ (goto-char (match-end 0))
+ (setq sep ""))
+ ((setq nato (assoc str nato-alphabet))
+ (delete-char 1)
+ (insert sep (cdr nato))
+ (setq sep "-"))
+ (t
+ (forward-char 1)
+ (setq sep "")))))))
+
+;;;###autoload
+(defun denato-region (beg end)
+ "Convert NATO phonetic alphabet in region to ordinary ASCII text."
+ ;; Copied from unmorse-region. -- ashawley 2009-02-10
+ (interactive "*r")
+ (if (integerp end)
+ (setq end (copy-marker end)))
+ (save-excursion
+ (let (str paren nato)
+ (goto-char beg)
+ (while (< (point) end)
+ (if (null (looking-at "[a-z]+"))
+ (forward-char 1)
+ (setq str (buffer-substring (match-beginning 0) (match-end 0)))
+ (if (null (setq nato (rassoc (capitalize str) nato-alphabet)))
+ (goto-char (match-end 0))
+ (replace-match
+ (if (string-equal "(" (car nato))
+ (if (setq paren (null paren)) "(" ")")
+ (car nato)) t)
+ (if (looking-at "-")
+ (delete-char 1))))))))
+