;;; strokes.el --- control Emacs through mouse strokes
-;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: David Bakhash <cadet@alum.mit.edu>
;; Maintainer: FSF
;; 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
;; 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 'mouse)
(defcustom strokes-modeline-string " Strokes"
- "*Modeline identification when Strokes mode is on \(default is \" Strokes\"\)."
+ "Modeline identification when Strokes mode is on \(default is \" Strokes\"\)."
:type 'string
:group 'strokes)
(defcustom strokes-character ?@
- "*Character used when drawing strokes in the strokes buffer.
+ "Character used when drawing strokes in the strokes buffer.
\(The default is `@', which works well.\)"
:type 'character
:group 'strokes)
(defcustom strokes-minimum-match-score 1000
- "*Minimum score for a stroke to be considered a possible match.
+ "Minimum score for a stroke to be considered a possible match.
Setting this variable to 0 would require a perfectly precise match.
The default value is 1000, but it's mostly dependent on how precisely
you manage to replicate your user-defined strokes. It also depends on
:group 'strokes)
(defcustom strokes-grid-resolution 9
- "*Integer defining dimensions of the stroke grid.
+ "Integer defining dimensions of the stroke grid.
The grid is a square grid, where `strokes-grid-resolution' defaults to
`9', making a 9x9 grid whose coordinates go from (0 . 0) on the top
left to ((strokes-grid-resolution - 1) . (strokes-grid-resolution - 1))
:group 'strokes)
(defcustom strokes-file (convert-standard-filename "~/.strokes")
- "*File containing saved strokes for Strokes mode (default is ~/.strokes)."
+ "File containing saved strokes for Strokes mode (default is ~/.strokes)."
:type 'file
:group 'strokes)
"The name of the buffer that the strokes take place in.")
(defcustom strokes-use-strokes-buffer t
- "*If non-nil, the strokes buffer is used and strokes are displayed.
+ "If non-nil, the strokes buffer is used and strokes are displayed.
If nil, strokes will be read the same, however the user will not be
able to see the strokes. This be helpful for people who don't like
the delay in switching to the strokes buffer."
by customizing the group `strokes' via \\[customize-group]."))
(set-buffer standard-output)
(help-mode)
- (print-help-return-message)))
+ (help-print-return-message)))
(defalias 'strokes-report-bug 'report-emacs-bug)
;; 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)
(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"))))
(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
(let ((char (or (car rainbow-chars) ?\.)))
(loop for i from 0 to 2 do
(loop for j from 0 to 2 do
- (goto-line (+ 16 i y))
+ (goto-char (point-min))
+ (forward-line (+ 15 i y))
(forward-char (+ 1 j x))
(delete-char 1)
(insert char)))
(setq rainbow-chars (cdr rainbow-chars)
lift-flag nil))
;; Otherwise, just plot the point...
- (goto-line (+ 17 y))
+ (goto-char (point-min))
+ (forward-line (+ 16 y))
(forward-char (+ 2 x))
(subst-char-in-region (point) (1+ (point)) ?\s ?\*)))
((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))
;;;;;###autoload
;;(defalias 'edit-strokes 'strokes-edit-strokes)
-(eval-when-compile (defvar view-mode-map))
+(defvar view-mode-map)
;;;###autoload
(defun strokes-list-strokes (&optional chronological strokes-map)
(goto-char (point-min))))
(defun strokes-alphabetic-lessp (stroke1 stroke2)
- "T iff command name for STROKE1 is less than STROKE2's in lexicographic order."
+ "Return t if STROKE1's command name precedes STROKE2's in lexicographic order."
(let ((command-name-1 (symbol-name (cdr stroke1)))
(command-name-2 (symbol-name (cdr stroke2))))
(string-lessp command-name-1 command-name-2)))
(eq char ?*)))
;;(defsubst strokes-xor (a b) ### Should I make this an inline function? ###
-;; "T iff one and only one of A and B is non-nil; otherwise, returns nil.
+;; "T if one and only one of A and B is non-nil; otherwise, returns nil.
;;NOTE: Don't use this as a numeric xor since it treats all non-nil
;; values as t including `0' (zero)."
;; (eq (null a) (not (null b))))
(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)
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
;; 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
(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))
;; strokes-decode-buffer does a save-excursion.
(forward-char)))
-(defun strokes-unload-hook ()
+(defun strokes-unload-function ()
+ "Unload the Strokes library."
(strokes-mode -1)
- (remove-hook 'kill-emacs-query-functions 'strokes-prompt-user-save-strokes))
-
-(add-hook 'strokes-unload-hook 'strokes-unload-hook)
+ ;; continue standard unloading
+ nil)
(run-hooks 'strokes-load-hook)
(provide 'strokes)
-;;; arch-tag: 8377f60e-43fb-467a-bbcd-2774f91f833e
+;; arch-tag: 8377f60e-43fb-467a-bbcd-2774f91f833e
;;; strokes.el ends here