Function: decipher-set-map
decipher-set-map is a byte-compiled function defined in
decipher.el.gz.
Signature
(decipher-set-map CIPHER-CHAR PLAIN-CHAR &optional NO-UNDO)
Source Code
;; Defined in /usr/src/emacs/lisp/play/decipher.el.gz
;;--------------------------------------------------------------------
;; Mapping ciphertext and plaintext:
;;--------------------------------------------------------------------
(defun decipher-set-map (cipher-char plain-char &optional no-undo)
;; Associate a ciphertext letter with a plaintext letter
;; CIPHER-CHAR must be an uppercase or lowercase letter
;; PLAIN-CHAR must be a lowercase letter (or a space)
;; NO-UNDO if non-nil means do not record undo information
;; Any existing associations for CIPHER-CHAR or PLAIN-CHAR will be erased.
(setq cipher-char (upcase cipher-char))
(or (and (>= cipher-char ?A) (<= cipher-char ?Z))
(error "Bad character")) ;Cipher char must be uppercase letter
(or no-undo
(decipher-add-undo (decipher-get-undo cipher-char plain-char)))
(let ((cipher-string (char-to-string cipher-char))
(plain-string (char-to-string plain-char))
case-fold-search ;Case is significant
mapping bound)
(save-excursion
(goto-char (point-min))
(if (setq mapping (rassoc cipher-char decipher-alphabet))
(progn
(setcdr mapping ?\s)
(search-forward-regexp (concat "^([a-z]*"
(char-to-string (car mapping))))
(decipher-insert ?\s)
(beginning-of-line)))
(if (setq mapping (assoc plain-char decipher-alphabet))
(progn
(if (/= ?\s (cdr mapping))
(decipher-set-map (cdr mapping) ?\s t))
(setcdr mapping cipher-char)
(search-forward-regexp (concat "^([a-z]*" plain-string))
(decipher-insert cipher-char)
(beginning-of-line)))
(search-forward-regexp (concat "^([a-z]+ [A-Z]*" cipher-string))
(decipher-insert plain-char)
(setq case-fold-search t ;Case is not significant
cipher-string (downcase cipher-string))
(let ((font-lock-fontify-region-function #'ignore))
;; insert-and-inherit will pick the right face automatically
(while (search-forward-regexp "^:" nil t)
(setq bound (point-at-eol))
(while (search-forward cipher-string bound 'end)
(decipher-insert plain-char)))))))