;;; artist.el --- draw ascii graphics with your mouse
-;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
;; Author: Tomas Abrahamsson <tab@lysator.liu.se>
;; Maintainer: Tomas Abrahamsson <tab@lysator.liu.se>
;; Variables
(defconst artist-version "1.2.6")
-(defconst artist-maintainer-address "tab@lysator.liu.se")
+(defconst artist-maintainer-address "tab@lysator.liu.se, bug-gnu-emacs@gnu.org")
(defvar x-pointer-crosshair)
(defvar artist-pointer-shape (if (eq window-system 'x) x-pointer-crosshair nil)
- "*If in X Windows, use this pointer shape while drawing with the mouse.")
+ "If in X Windows, use this pointer shape while drawing with the mouse.")
(defcustom artist-text-renderer-function 'artist-figlet
;; This is a defvar, not a defcustom, since the custom
;; package shows lists of characters as a lists of integers,
;; which is confusing
- "*Characters (``color'') to use when spraying.
+ "Characters (``color'') to use when spraying.
They should be ordered from the ``lightest'' to the ``heaviest''
since spraying replaces a light character with the next heavier one.")
(defvar artist-spray-new-char ?.
- "*Initial character to use when spraying.
+ "Initial character to use when spraying.
This character is used if spraying upon a character that is not in
`artist-spray-chars'. The character defined by this variable should
be in `artist-spray-chars', or spraying will behave strangely.")
("Text" artist-select-op-text-overwrite text-ovwrt)
("Ellipse" artist-select-op-circle circle)
("Poly-line" artist-select-op-straight-poly-line spolyline)
- ("Rectangle" artist-select-op-square square)
+ ("Square" artist-select-op-square square)
+ ("Rectangle" artist-select-op-rectangle rectangle)
("Line" artist-select-op-straight-line s-line)
("Pen" artist-select-op-pen-line pen-line)))
(define-key map (vector (nth 2 op))
;;; ---------------------------------
;;;###autoload
-(defun artist-mode (&optional state)
+(define-minor-mode artist-mode
"Toggle Artist mode.
-With argument STATE, turn Artist mode on if STATE is positive.
+With argument ARG, turn Artist mode on if ARG is positive.
Artist lets you draw lines, squares, rectangles and poly-lines,
ellipses and circles with your mouse and/or keyboard.
Hooks
- When entering artist-mode, the hook `artist-mode-init-hook' is called.
- When quitting artist-mode, the hook `artist-mode-exit-hook' is called.
+ Turning the mode on or off runs `artist-mode-hook'.
Keymap summary
\\{artist-mode-map}"
- (interactive)
- (if (setq artist-mode
- (if (null state) (not artist-mode)
- (> (prefix-numeric-value state) 0)))
- (artist-mode-init)
- (artist-mode-exit)))
-
-;; insert our minor mode string
-(or (assq 'artist-mode minor-mode-alist)
- (setq minor-mode-alist
- (cons '(artist-mode artist-mode-name)
- minor-mode-alist)))
-
-;; insert our minor mode keymap
-(or (assq 'artist-mode minor-mode-map-alist)
- (setq minor-mode-map-alist
- (cons (cons 'artist-mode artist-mode-map)
- minor-mode-map-alist)))
-
+ :init-value nil :group 'artist :lighter artist-mode-name
+ :keymap artist-mode-map
+ (cond ((null artist-mode)
+ ;; Turn mode off
+ (artist-mode-exit))
+ (t
+ ;; Turn mode on
+ (artist-mode-init))))
;; Init and exit
(defun artist-mode-init ()
- "Init Artist mode. This will call the hook `artist-mode-init-hook'."
+ "Init Artist mode. This will call the hook `artist-mode-hook'."
;; Set up a conversion table for mapping tabs and new-lines to spaces.
;; the last case, 0, is for the last position in buffer/region, where
;; the `following-char' function returns 0.
(progn
(picture-mode)
(message "")))
- (run-hooks 'artist-mode-init-hook)
(artist-mode-line-show-curr-operation artist-key-is-drawing))
+(declare-function picture-mode-exit "picture" (&optional nostrip))
+
(defun artist-mode-exit ()
- "Exit Artist mode. This will call the hook `artist-mode-exit-hook'."
+ "Exit Artist mode. This will call the hook `artist-mode-hook'."
(if (and artist-picture-compatibility (eq major-mode 'picture-mode))
(picture-mode-exit))
- (kill-local-variable 'next-line-add-newlines)
- (run-hooks 'artist-mode-exit-hook))
+ (kill-local-variable 'next-line-add-newlines))
(defun artist-mode-off ()
"Turn Artist mode off."
;;
(defmacro artist-funcall (fn &rest args)
"Call function FN with ARGS, if FN is not nil."
- (list 'if fn (cons 'funcall (cons fn args))))
+ `(if ,fn (funcall ,fn ,@args)))
(defun artist-uniq (l)
"Remove consecutive duplicates in list L. Comparison is done with `equal'."
;;
(defmacro artist-put-pixel (point-list x y)
"In POINT-LIST, store a ``pixel'' at coord X,Y."
- (list 'setq point-list
- (list 'append point-list (list 'list (list 'artist-new-coord x y)))))
+ `(setq ,point-list
+ (append ,point-list (list (artist-new-coord ,x ,y)))))
;; Calculate list of points using eight point algorithm
;; return a list of coords