]> code.delx.au - gnu-emacs/blobdiff - lisp/strokes.el
*** empty log message ***
[gnu-emacs] / lisp / strokes.el
index 3f5a5bb3a75f140de90c66b247947de0fa1ba77a..f1121d1fee5e99f7967493557457938086a692a3 100644 (file)
@@ -78,7 +78,7 @@
 
 ;;       however, if you would probably just have the user enter in the
 ;;       stroke interactively and then set the stroke to whatever he/she
-;;       entered. The Lisp function to interactively read a stroke is
+;;       entered.  The Lisp function to interactively read a stroke is
 ;;       `strokes-read-stroke'.  This is especially helpful when you're
 ;;       on a fast computer that can handle a 9x9 stroke grid.
 
 ;; Other: I always have the most beta version of strokes, so if you
 ;;        want it just let me know.
 
+;; Fixme: Use pbm instead of xpm for pixmaps to work generally.
+
 ;;; Code:
 
 ;;; Requirements and provisions...
@@ -433,7 +435,9 @@ or for window START-WINDOW if that is specified."
 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
-documentation for the `strokes-define-stroke' function."
+documentation for the `strokes-define-stroke' function.
+
+See also `strokes-global-set-stroke-string'."
   (interactive
    (list
     (and (or strokes-mode (strokes-mode t))
@@ -442,6 +446,22 @@ documentation for the `strokes-define-stroke' function."
     (read-command "Command to map stroke to: ")))
   (strokes-define-stroke strokes-global-map stroke command))
 
+(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
+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.
+
+Compare `strokes-global-set-stroke'."
+  (interactive
+   (list
+    (and (or strokes-mode (strokes-mode t))
+        (strokes-read-complex-stroke
+         "Draw with mouse button 1 (or 2).  End with button 3..."))
+    (read-string "String to map stroke to: ")))
+  (strokes-define-stroke strokes-global-map stroke string))
+
 ;;(defun global-unset-stroke (stroke); FINISH THIS DEFUN!
 ;;  "delete all strokes matching STROKE from `strokes-global-map',
 ;; letting the user input
@@ -793,7 +813,7 @@ Optional EVENT is acceptable as the starting event of the stroke"
                        (when point
                          (goto-char point)
                          (subst-char-in-region point (1+ point)
-                                               ?\ strokes-character))
+                                               ?\  strokes-character))
                        (push (cdr (mouse-pixel-position))
                              pix-locs)))
                  (setq event (read-event)))
@@ -1006,8 +1026,8 @@ o Strokes are a bit computer-dependent in that they depend somewhat on
   silently--without displaying the strokes.  All variables can be set
   by customizing the group `strokes' via \[customize-group].")
     (set-buffer standard-output)
-    (help-mode))
-  (print-help-return-message))
+    (help-mode)
+    (print-help-return-message)))
 
 (defalias 'strokes-report-bug 'report-emacs-bug)
 
@@ -1317,7 +1337,9 @@ If STROKES-MAP is not given, `strokes-global-map' will be used instead."
      "-------                                     ------")
     (loop for def in strokes-map do
          (let ((stroke (car def))
-               (command-name (symbol-name (cdr def))))
+               (command-name (if (symbolp (cdr def))
+                                 (symbol-name (cdr def))
+                               (prin1-to-string (cdr def)))))
            (strokes-xpm-for-stroke stroke " *strokes-xpm*")
            (newline 2)
            (insert-char ?\  45)
@@ -1325,10 +1347,15 @@ If STROKES-MAP is not given, `strokes-global-map' will be used instead."
            (insert command-name)
            (beginning-of-line)
            (forward-char 45)
-           (insert-image (create-image (with-current-buffer " *strokes-xpm*"
-                                         (buffer-string))
-                                       'xpm t)))
-         finally do (kill-region (1+ (point)) (point-max)))
+           (insert-image
+            (create-image (with-current-buffer " *strokes-xpm*"
+                            (buffer-string))
+                          'xpm t
+                          :color-symbols
+                          `(("foreground"
+                             . ,(frame-parameter nil 'foreground-color))))))
+         finally do (unless (eobp)
+                      (kill-region (1+ (point)) (point-max))))
     (view-buffer "*Strokes List*" nil)
     (set (make-local-variable 'view-mode-map)
         (let ((map (copy-keymap view-mode-map)))
@@ -1498,11 +1525,11 @@ Encode/decode your strokes with \\[strokes-encode-buffer],
 (defsubst strokes-xpm-encode-length-as-string (length)
   "Given some LENGTH in [0,62) do a fast lookup of its encoding."
   (aref strokes-base64-chars length))
-                  
+
 (defsubst strokes-xpm-decode-char (character)
   "Given a CHARACTER, do a fast lookup to find its corresponding integer value."
   (aref strokes-char-table character))
-                  
+
 (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*'."
@@ -1719,7 +1746,10 @@ Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
   (strokes-mode -1)
   (remove-hook 'kill-emacs-query-functions 'strokes-prompt-user-save-strokes))
 
+(add-hook 'strokes-unload-hook 'strokes-unload-hook)
+
 (run-hooks 'strokes-load-hook)
 (provide 'strokes)
 
+;;; arch-tag: 8377f60e-43fb-467a-bbcd-2774f91f833e
 ;;; strokes.el ends here