Function: decipher

decipher is an autoloaded, interactive and byte-compiled function defined in decipher.el.gz.

Signature

(decipher)

Documentation

Format a buffer of ciphertext for cryptanalysis and enter Decipher mode.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/play/decipher.el.gz
;;;===================================================================
;;;===================================================================
;; Main entry points:
;;--------------------------------------------------------------------

;;;###autoload
(defun decipher ()
  "Format a buffer of ciphertext for cryptanalysis and enter Decipher mode."
  (interactive)
  ;; Make sure the buffer ends in a newline:
  (goto-char (point-max))
  (or (bolp)
      (insert "\n"))
  ;; See if it's already in decipher format:
  (goto-char (point-min))
  (if (looking-at "^(abcdefghijklmnopqrstuvwxyz   \
ABCDEFGHIJKLMNOPQRSTUVWXYZ   -\\*-decipher-\\*-\n)")
      (message "Buffer is already formatted, entering Decipher mode...")
    ;; Add the alphabet at the beginning of the file
    (insert "(abcdefghijklmnopqrstuvwxyz   \
ABCDEFGHIJKLMNOPQRSTUVWXYZ   -*-decipher-*-\n)\n\n")
    ;; Add lines for the solution:
    (let (begin)
      (while (not (eobp))
        (if (looking-at "^%")
            (forward-line)              ;Leave comments alone
          (delete-horizontal-space)
          (if (eolp)
              (forward-line)            ;Just leave blank lines alone
            (insert ":")                ;Mark ciphertext line
            (setq begin (point))
            (forward-line)
            (if decipher-force-uppercase
                (upcase-region begin (point))) ;Convert ciphertext to uppercase
            (insert ">\n")))))          ;Mark plaintext line
    (delete-blank-lines)                ;Remove any blank lines
    (delete-blank-lines))               ; at end of buffer
  (goto-char (point-min))
  (forward-line 3)
  (decipher-mode))