]> code.delx.au - gnu-emacs/blobdiff - lisp/strokes.el
* lisp/simple.el (save-mark-and-excursion): Add declare forms.
[gnu-emacs] / lisp / strokes.el
index 2c3c3bc6dd4bdd59ee4bb0bdfcb67b17eb6f0366..5a2020d3ca0fff43766cd692fe6aadcbaf0645f9 100644 (file)
@@ -1,9 +1,9 @@
 ;;; strokes.el --- control Emacs through mouse strokes
 
-;; Copyright (C) 1997, 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: David Bakhash <cadet@alum.mit.edu>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: lisp, mouse, extensions
 
 ;; This file is part of GNU Emacs.
 
 ;; > M-x strokes-prompt-user-save-strokes
 
-;; and it will save your strokes in ~/.strokes, or you may wish to change
-;; this by setting the variable `strokes-file'.
+;; and it will save your strokes in your `strokes-file'.
 
 ;; Note that internally, all of the routines that are part of this
 ;; package are able to deal with complex strokes, as they are a superset
@@ -203,7 +202,7 @@ static char * stroke_xpm[] = {
 \"P    c #FFFF0000FFFF\",
 \".    c #45458B8B0000\",
 /* pixels */\n"
-  "The header to all xpm buffers created by strokes.")
+  "The header to all XPM buffers created by strokes.")
 
 ;;; user variables...
 
@@ -222,7 +221,7 @@ static char * stroke_xpm[] = {
 
 (defcustom strokes-character ?@
   "Character used when drawing strokes in the strokes buffer.
-\(The default is `@', which works well.\)"
+\(The default is `@', which works well.)"
   :type 'character
   :group 'strokes)
 
@@ -261,7 +260,8 @@ WARNING: Changing the value of this variable will gravely affect the
   :group 'strokes)
 
 (defcustom strokes-file (locate-user-emacs-file "strokes" ".strokes")
-  "File containing saved strokes for Strokes mode (default is ~/.strokes)."
+  "File containing saved strokes for Strokes mode."
+  :version "24.4"                       ; added locate-user-emacs-file
   :type 'file
   :group 'strokes)
 
@@ -284,16 +284,15 @@ This is set properly in the function `strokes-update-window-configuration'.")
 
 (defvar strokes-last-stroke nil
   "Last stroke entered by the user.
-Its value gets set every time the function
-`strokes-fill-stroke' gets called,
-since that is the best time to set the variable.")
+Its value gets set every time the function `strokes-fill-stroke'
+gets called, since that is the best time to set the variable.")
 
 (defvar strokes-global-map '()
   "Association list of strokes and their definitions.
 Each entry is (STROKE . COMMAND) where STROKE is itself a list of
 coordinates (X . Y) where X and Y are lists of positions on the
-normalized stroke grid, with the top left at (0 . 0).  COMMAND is the
-corresponding interactive function.")
+normalized stroke grid, with the top left at (0 . 0).  COMMAND is
+the corresponding interactive function.")
 
 (defvar strokes-load-hook nil
   "Functions to be called when Strokes is loaded.")
@@ -349,7 +348,7 @@ corresponding interactive function.")
   (* x x))
 
 (defsubst strokes-distance-squared (p1 p2)
-  "Gets the distance (squared) between to points P1 and P2.
+  "Compute the distance (squared) between to points P1 and P2.
 P1 and P2 are cons cells in the form (X . Y)."
   (let ((x1 (car p1))
        (y1 (cdr p1))
@@ -424,8 +423,9 @@ or for window START-WINDOW if that is specified."
   (interactive)
   (let ((command (cdar strokes-global-map)))
     (if (y-or-n-p
-        (format "Really delete last stroke definition, defined to `%s'? "
-                command))
+        (format-message
+         "Really delete last stroke definition, defined to `%s'? "
+         command))
        (progn
          (setq strokes-global-map (cdr strokes-global-map))
          (message "That stroke has been deleted"))
@@ -434,9 +434,9 @@ or for window START-WINDOW if that is specified."
 ;;;###autoload
 (defun strokes-global-set-stroke (stroke command)
   "Interactively give STROKE the global binding as COMMAND.
-Operated just like `global-set-key', except for strokes.
-COMMAND is a symbol naming an interactively-callable function.  STROKE
-is a list of sampled positions on the stroke grid as described in the
+Works just like `global-set-key', except for strokes.  COMMAND is
+a symbol naming an interactively-callable function.  STROKE is a
+list of sampled positions on the stroke grid as described in the
 documentation for the `strokes-define-stroke' function.
 
 See also `strokes-global-set-stroke-string'."
@@ -450,7 +450,7 @@ See also `strokes-global-set-stroke-string'."
 
 (defun strokes-global-set-stroke-string (stroke string)
   "Interactively give STROKE the global binding as STRING.
-Operated just like `global-set-key', except for strokes.  STRING
+Works just like `global-set-key', except for strokes.  STRING
 is a string to be inserted by the stroke.  STROKE is a list of
 sampled positions on the stroke grid as described in the
 documentation for the `strokes-define-stroke' function.
@@ -476,7 +476,7 @@ Compare `strokes-global-set-stroke'."
 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution)
   "Map POSITION to a new grid position.
 Do so based on its STROKE-EXTENT and GRID-RESOLUTION.
-STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\).
+STROKE-EXTENT is a list ((XMIN . YMIN) (XMAX . YMAX)).
 If POSITION is a `strokes-lift', then it is itself returned.
 Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'.
 The grid is a square whose dimension is [0,GRID-RESOLUTION)."
@@ -651,7 +651,7 @@ NOTE: This is where the global variable `strokes-last-stroke' is set."
                                                    y))))))))))
 
 (defun strokes-rate-stroke (stroke1 stroke2)
-  "Rates STROKE1 with STROKE2 and return a score based on a distance metric.
+  "Rate STROKE1 with STROKE2 and return a score based on a distance metric.
 Note: the rating is an error rating, and therefore, a return of 0
 represents a perfect match.  Also note that the order of stroke
 arguments is order-independent for the algorithm used here."
@@ -857,6 +857,9 @@ Optional EVENT is acceptable as the starting event of the stroke."
 The command will be executed provided one exists for that stroke,
 based on the variable `strokes-minimum-match-score'.
 If no stroke matches, nothing is done and return value is nil."
+  ;; FIXME: Undocument return value.  It is not documented for all cases,
+  ;; and doesn't allow differentiating between no stroke matches and
+  ;; command-execute returning nil, anyway.
   (let* ((match (strokes-match-stroke stroke strokes-global-map))
         (command (car match))
         (score (cdr match)))
@@ -866,8 +869,8 @@ If no stroke matches, nothing is done and return value is nil."
          ((null strokes-global-map)
           (if (file-exists-p strokes-file)
               (and (y-or-n-p
-                    (format "No strokes loaded.  Load `%s'? "
-                            strokes-file))
+                    (format-message "No strokes loaded.  Load `%s'? "
+                                    strokes-file))
                    (strokes-load-user-strokes))
             (error "No strokes defined; use `strokes-global-set-stroke'")))
          (t
@@ -969,8 +972,8 @@ and you can enter in any arbitrary stroke.  Remember: The strokes
 package lets you program in simple and complex (multi-lift) strokes.
 The only difference is how you *invoke* the two.  You will most likely
 use simple strokes, as complex strokes were developed for
-Chinese/Japanese/Korean.  So the shifted middle mouse button (S-mouse-2) will
-invoke the command `strokes-do-stroke'.
+Chinese/Japanese/Korean.  So the shifted middle mouse button (S-mouse-2)
+will invoke the command `strokes-do-stroke'.
 
 If ever you define a stroke which you don't like, then you can unset
 it with the command
@@ -991,11 +994,10 @@ down, then use a prefix argument:
 
 > C-u M-x strokes-list-strokes
 
-Your strokes are stored as you enter them.  They get saved in a file
-called ~/.strokes, along with other strokes configuration variables.
-You can change this location by setting the variable `strokes-file'.
-You will be prompted to save them when you exit Emacs, or you can save
-them with
+Your strokes are stored as you enter them.  They get saved into the
+file specified by the `strokes-file' variable, along with other strokes
+configuration variables.  You will be prompted to save them when you
+exit Emacs, or you can save them with
 
 > M-x strokes-prompt-user-save-strokes
 
@@ -1010,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
@@ -1148,7 +1150,7 @@ Returns value of `strokes-use-strokes-buffer'."
          (not strokes-use-strokes-buffer))))
 
 (defun strokes-xpm-for-stroke (&optional stroke bufname b/w-only)
-  "Create an XPM pixmap for the given STROKE in buffer ` *strokes-xpm*'.
+  "Create an XPM pixmap for the given STROKE in buffer \" *strokes-xpm*\".
 If STROKE is not supplied, then `strokes-last-stroke' will be used.
 Optional BUFNAME to name something else.
 The pixmap will contain time information via rainbow dot colors
@@ -1319,8 +1321,8 @@ the stroke as a character in some language."
 ;;;###autoload
 (defun strokes-list-strokes (&optional chronological strokes-map)
   "Pop up a buffer containing an alphabetical listing of strokes in STROKES-MAP.
-With CHRONOLOGICAL prefix arg \(\\[universal-argument]\) list strokes
-chronologically by command name.
+With CHRONOLOGICAL prefix arg (\\[universal-argument]) list strokes chronologically
+by command name.
 If STROKES-MAP is not given, `strokes-global-map' will be used instead."
   (interactive "P")
   (setq strokes-map (or strokes-map
@@ -1387,8 +1389,8 @@ If STROKES-MAP is not given, `strokes-global-map' will be used instead."
 (define-minor-mode strokes-mode
   "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.
+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.
@@ -1541,7 +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*'."
+XPM-BUFFER defaults to \" *strokes-xpm*\"."
   (with-current-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))
     (goto-char (point-min))
     (search-forward "/* pixels */")    ; skip past header junk
@@ -1708,7 +1710,7 @@ 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*'\)"
+Store XPM in buffer BUFNAME if supplied (default is \" *strokes-xpm*\")"
   (or bufname (setq bufname " *strokes-xpm*"))
   (with-current-buffer (get-buffer-create bufname)
     (erase-buffer)