Add 2010 to copyright years.
[bpt/emacs.git] / lisp / play / decipher.el
index 88b5f2a..897832d 100644 (file)
@@ -1,27 +1,25 @@
 ;;; decipher.el --- cryptanalyze monoalphabetic substitution ciphers
 ;;
-;; Copyright (C) 1995, 1996, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 ;;
 ;; Author: Christopher J. Madsen <chris_madsen@geocities.com>
 ;; Keywords: games
 ;;
 ;; This file is part of GNU Emacs.
 ;;
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-;;
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
-;;
+
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 ;;
   :group 'games)
 
 (defcustom decipher-force-uppercase t
-  "*Non-nil means to convert ciphertext to uppercase.
+  "Non-nil means to convert ciphertext to uppercase.
 nil means the case of the ciphertext is preserved.
 This variable must be set before typing `\\[decipher]'."
   :type 'boolean
@@ -108,7 +106,7 @@ This variable must be set before typing `\\[decipher]'."
 
 
 (defcustom decipher-ignore-spaces nil
-  "*Non-nil means to ignore spaces and punctuation when counting digrams.
+  "Non-nil means to ignore spaces and punctuation when counting digrams.
 You should set this to nil if the cipher message is divided into words,
 or t if it is not.
 This variable is buffer-local."
@@ -276,7 +274,8 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ   -*-decipher-*-\n)\n\n")
             (insert ">\n")))))          ;Mark plaintext line
     (delete-blank-lines)                ;Remove any blank lines
     (delete-blank-lines))               ; at end of buffer
-  (goto-line 4)
+  (goto-char (point-min))
+  (forward-line 3)
   (decipher-mode))
 
 ;;;###autoload
@@ -352,7 +351,7 @@ The most useful commands are:
                (t
                 (error "Bad location")))))
           (let (goal-column)
-            (previous-line 1)))
+            (forward-line -1)))
       (let ((char-a (following-char))
             (char-b (decipher-last-command-char)))
         (or (and (not (= ?w (char-syntax char-a)))
@@ -682,8 +681,7 @@ ciphertext."
   (interactive (list (upcase (following-char))))
   (decipher-analyze)
   (let (start end)
-    (save-excursion
-      (set-buffer (decipher-stats-buffer))
+    (with-current-buffer (decipher-stats-buffer)
       (goto-char (point-min))
       (or (re-search-forward (format "^%c: " cipher-char) nil t)
           (error "Character `%c' is not used in ciphertext" cipher-char))
@@ -731,8 +729,7 @@ START-REGEXP matches the first line to display.
 END-REGEXP matches the line after that which ends the display.
 The ending line is included in the display unless it is blank."
   (let (start end)
-    (save-excursion
-      (set-buffer (decipher-stats-buffer))
+    (with-current-buffer (decipher-stats-buffer)
       (goto-char (point-min))
       (re-search-forward start-regexp)
       (beginning-of-line)
@@ -927,9 +924,8 @@ Creates the statistics buffer if it doesn't exist."
                                                   (aref decipher--after  i)))
                     freq-list)
               total-chars (+ total-chars (aref decipher--freqs i)))))
-    (save-excursion
-      ;; Switch to statistics buffer, creating it if necessary:
-      (set-buffer (decipher-stats-buffer t))
+    ;; Switch to statistics buffer, creating it if necessary:
+    (with-current-buffer (decipher-stats-buffer t)
       ;; This can't happen, but it never hurts to double-check:
       (or (eq major-mode 'decipher-stats-mode)
           (error "Buffer %s is not in Decipher-Stats mode" (buffer-name)))
@@ -1025,8 +1021,7 @@ if it can't, it signals an error."
    ;; See if decipher-stats-buffer exists:
    ((and (bufferp decipher-stats-buffer)
          (buffer-name decipher-stats-buffer))
-    (or (save-excursion
-          (set-buffer decipher-stats-buffer)
+    (or (with-current-buffer decipher-stats-buffer
           (eq major-mode 'decipher-stats-mode))
         (error "Buffer %s is not in Decipher-Stats mode"
                (buffer-name decipher-stats-buffer)))
@@ -1042,8 +1037,7 @@ if it can't, it signals an error."
                 ;; We just lost track of the statistics buffer:
                 (get-buffer stats-name)
               (generate-new-buffer stats-name))))
-    (save-excursion
-      (set-buffer decipher-stats-buffer)
+    (with-current-buffer decipher-stats-buffer
       (decipher-stats-mode))
     decipher-stats-buffer)
    ;; Give up:
@@ -1053,22 +1047,21 @@ if it can't, it signals an error."
 
 (provide 'decipher)
 
-;;;(defun decipher-show-undo-list ()
-;;;  "Display the undo list (for debugging purposes)."
-;;;  (interactive)
-;;;  (with-output-to-temp-buffer "*Decipher Undo*"
-;;;    (let ((undo-list decipher-undo-list)
-;;;          undo-rec undo-map)
-;;;      (save-excursion
-;;;        (set-buffer "*Decipher Undo*")
-;;;        (while (setq undo-rec (pop undo-list))
-;;;          (or (consp (car undo-rec))
-;;;              (setq undo-rec (list undo-rec)))
-;;;          (insert ?\()
-;;;          (while (setq undo-map (pop undo-rec))
-;;;            (insert (cdr undo-map) (car undo-map) ?\ ))
-;;;          (delete-backward-char 1)
-;;;          (insert ")\n"))))))
-
-;;; arch-tag: 8f094d88-ffe1-4f99-afe3-a5e81dd939d9
+;;(defun decipher-show-undo-list ()
+;;  "Display the undo list (for debugging purposes)."
+;;  (interactive)
+;;  (with-output-to-temp-buffer "*Decipher Undo*"
+;;    (let ((undo-list decipher-undo-list)
+;;          undo-rec undo-map)
+;;      (with-current-buffer "*Decipher Undo*"
+;;        (while (setq undo-rec (pop undo-list))
+;;          (or (consp (car undo-rec))
+;;              (setq undo-rec (list undo-rec)))
+;;          (insert ?\()
+;;          (while (setq undo-map (pop undo-rec))
+;;            (insert (cdr undo-map) (car undo-map) ?\ ))
+;;          (delete-backward-char 1)
+;;          (insert ")\n"))))))
+
+;; arch-tag: 8f094d88-ffe1-4f99-afe3-a5e81dd939d9
 ;;; decipher.el ends here