Bump version to 24.0.94
[bpt/emacs.git] / lisp / strokes.el
index 75278f6..8b5aa7a 100644 (file)
@@ -1,7 +1,6 @@
 ;;; strokes.el --- control Emacs through mouse strokes
 
-;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009  Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2012  Free Software Foundation, Inc.
 
 ;; Author: David Bakhash <cadet@alum.mit.edu>
 ;; Maintainer: FSF
@@ -719,6 +718,14 @@ Returns the corresponding match as (COMMAND . SCORE)."
          nil))
     nil))
 
+(defsubst strokes-fill-current-buffer-with-whitespace ()
+  "Erase the contents of the current buffer and fill it with whitespace."
+  (erase-buffer)
+  (loop repeat (frame-height) do
+       (insert-char ?\s (1- (frame-width)))
+       (newline))
+  (goto-char (point-min)))
+
 ;;;###autoload
 (defun strokes-read-stroke (&optional prompt event)
   "Read a simple stroke (interactively) and return the stroke.
@@ -736,6 +743,11 @@ Optional EVENT is acceptable as the starting event of the stroke."
          ;; display the stroke as it's being read
          (save-window-excursion
            (set-window-configuration strokes-window-configuration)
+           ;; The frame has been resized, so we need to refill the
+           ;; strokes buffer so that the strokes canvas is the whole
+           ;; visible buffer.
+           (unless (> 1 (abs (- (line-end-position) (window-width))))
+             (strokes-fill-current-buffer-with-whitespace))
            (when prompt
              (message "%s" prompt)
              (setq event (read-event))
@@ -1000,7 +1012,7 @@ If you'd like to create graphical files with strokes, you'll have to
 be running a version of Emacs with XPM support.  You use the binding
 to `strokes-compose-complex-stroke' to start drawing your strokes.
 These are just complex strokes, and thus continue drawing with mouse-1
-or mouse-2 and end with mouse-3.  Then the stroke image gets inserted
+or mouse-2 and   end with mouse-3.  Then the stroke image gets inserted
 into the buffer.  You treat it somewhat like any other character,
 which you can copy, paste, delete, move, etc.  When all is done, you
 may want to send the file, or save it.  This is done with
@@ -1030,15 +1042,7 @@ o Strokes are a bit computer-dependent in that they depend somewhat on
     (help-mode)
     (help-print-return-message)))
 
-(defalias 'strokes-report-bug 'report-emacs-bug)
-
-(defsubst strokes-fill-current-buffer-with-whitespace ()
-  "Erase the contents of the current buffer and fill it with whitespace."
-  (erase-buffer)
-  (loop repeat (frame-height) do
-       (insert-char ?\s (1- (frame-width)))
-       (newline))
-  (goto-char (point-min)))
+(define-obsolete-function-alias 'strokes-report-bug 'report-emacs-bug "24.1")
 
 (defun strokes-window-configuration-changed-p ()
   "Non-nil if the `strokes-window-configuration' frame properties changed.
@@ -1055,19 +1059,18 @@ This is based on the last time `strokes-window-configuration' was updated."
           ;; don't try to update strokes window configuration
           ;; if window is dedicated or a minibuffer
           nil)
-         ((or (interactive-p)
+         ((or (called-interactively-p 'interactive)
               (not (buffer-live-p (get-buffer strokes-buffer-name)))
               (null strokes-window-configuration))
           ;; create `strokes-window-configuration' from scratch...
           (save-excursion
             (save-window-excursion
-              (get-buffer-create strokes-buffer-name)
+              (set-buffer (get-buffer-create strokes-buffer-name))
               (set-window-buffer current-window strokes-buffer-name)
               (delete-other-windows)
               (fundamental-mode)
               (auto-save-mode 0)
-              (if (featurep 'font-lock)
-                  (font-lock-mode 0))
+              (font-lock-mode 0)
               (abbrev-mode 0)
               (buffer-disable-undo (current-buffer))
               (setq truncate-lines nil)
@@ -1092,7 +1095,7 @@ This is based on the last time `strokes-window-configuration' was updated."
   (cond ((and (file-exists-p strokes-file)
              (file-readable-p strokes-file))
         (load-file strokes-file))
-       ((interactive-p)
+       ((called-interactively-p 'interactive)
         (error "Trouble loading user-defined strokes; nothing done"))
        (t
         (message "No user-defined strokes, sorry"))))
@@ -1107,7 +1110,7 @@ This is based on the last time `strokes-window-configuration' was updated."
            (setq strokes-global-map nil)
            (strokes-load-user-strokes)
            (if (and (not (equal current strokes-global-map))
-                    (or (interactive-p)
+                    (or (called-interactively-p 'interactive)
                         (yes-or-no-p "Save your strokes? ")))
                (progn
                  (require 'pp)         ; pretty-print variables
@@ -1202,7 +1205,7 @@ the stroke as a character in some language."
                  ((strokes-lift-p point)
                   ;; a lift--tell the loop to X out the next point...
                   (setq lift-flag t))))
-      (when (interactive-p)
+      (when (called-interactively-p 'interactive)
        (pop-to-buffer " *strokes-xpm*")
        ;;      (xpm-mode 1)
        (goto-char (point-min))
@@ -1383,8 +1386,12 @@ If STROKES-MAP is not given, `strokes-global-map' will be used instead."
 
 ;;;###autoload
 (define-minor-mode strokes-mode
-  "Toggle Strokes global minor mode.\\<strokes-mode-map>
-With ARG, turn strokes on if and only if ARG is positive.
+  "Toggle Strokes mode, a global minor mode.
+With a prefix argument ARG, enable Strokes mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+\\<strokes-mode-map>
 Strokes are pictographic mouse gestures which invoke commands.
 Strokes are invoked with \\[strokes-do-stroke].  You can define
 new strokes with \\[strokes-global-set-stroke].  See also
@@ -1536,8 +1543,7 @@ Encode/decode your strokes with \\[strokes-encode-buffer],
 (defun strokes-xpm-to-compressed-string (&optional xpm-buffer)
   "Convert XPM in XPM-BUFFER to compressed string representing the stroke.
 XPM-BUFFER defaults to ` *strokes-xpm*'."
-  (save-excursion
-    (set-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*")))
+  (with-current-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))
     (goto-char (point-min))
     (search-forward "/* pixels */")    ; skip past header junk
     (forward-char 2)
@@ -1620,8 +1626,7 @@ Optional BUFFER defaults to the current buffer.
 Optional FORCE non-nil will ignore the buffer's read-only status."
   (interactive)
   ;;  (interactive "*bStrokify buffer: ")
-  (save-excursion
-    (set-buffer (setq buffer (get-buffer (or buffer (current-buffer)))))
+  (with-current-buffer (setq buffer (get-buffer (or buffer (current-buffer))))
     (when (or (not buffer-read-only)
              force
              inhibit-read-only
@@ -1630,7 +1635,7 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
       (let ((inhibit-read-only t))
        (message "Strokifying %s..." buffer)
        (goto-char (point-min))
-       (let (ext string image)
+       (let (string image)
          ;; The comment below is what I'd have to do if I wanted to
          ;; deal with random newlines in the midst of the compressed
          ;; strings.  If I do this, I'll also have to change
@@ -1669,8 +1674,7 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
   ;; buffer is killed?
   ;;  (interactive "*bUnstrokify buffer: ")
   (interactive)
-  (save-excursion
-    (set-buffer (setq buffer (or buffer (current-buffer))))
+  (with-current-buffer (setq buffer (or buffer (current-buffer)))
     (when (or (not buffer-read-only)
              force
              inhibit-read-only
@@ -1706,9 +1710,8 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
 (defun strokes-xpm-for-compressed-string (compressed-string &optional bufname)
   "Convert the stroke represented by COMPRESSED-STRING into an XPM.
 Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
-  (save-excursion
-    (or bufname (setq bufname " *strokes-xpm*"))
-    (set-buffer (get-buffer-create bufname))
+  (or bufname (setq bufname " *strokes-xpm*"))
+  (with-current-buffer (get-buffer-create bufname)
     (erase-buffer)
     (insert compressed-string)
     (goto-char (point-min))
@@ -1754,5 +1757,4 @@ Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
 (run-hooks 'strokes-load-hook)
 (provide 'strokes)
 
-;; arch-tag: 8377f60e-43fb-467a-bbcd-2774f91f833e
 ;;; strokes.el ends here