![[Home]](https://www.emacswiki.org/images/logo218x38.png)
Artist is an Emacs lisp package that allows you to draw lines, rectangles, squares, poly-lines, ellipses and circles by using your mouse and/or keyboard. The shapes are made up with the ascii characters |, -, / and \.
It is part of Emacs (though you may need to add a require statement for it) and can also be retrieved from http://www.lysator.liu.se/~tab/artist/.
You will use the mouse for drawing and painting if you are running Emacs in an X-window, as in other graphics programs. But you can also use artist-mode when you are running on a terminal. To see how it works, type:
M-x artist-mode RET C-c C-a p RET RET
and move the TextCursor around – you are drawing a poly-line.
Look at the artist-mode documentation (C-h m RET) for full explanation.
Beta version of xemacs port could be found at Lisp:artist-xmas.el
What exactly is the beta in it? It seems to work quite well. One minor issue I noticed is that when you have line numbers turned on via setnu-mode the point where drawing takes place is shifted by the appropriate space to the left of the MousePointer. – StefanKamphausen
It’s beta because it is not checked well. Function artist-mouse-draw-poly still has some problems. I’ll try to fix your issue when I have time.
I use InteractivelyDoThings to change drawing operations and settings:
;;; integrate ido with artist-mode (defun artist-ido-select-operation (type) "Use ido to select a drawing operation in artist-mode" (interactive (list (ido-completing-read "Drawing operation: " (list "Pen" "Pen Line" "line" "straight line" "rectangle" "square" "poly-line" "straight poly-line" "ellipse" "circle" "text see-thru" "text-overwrite" "spray-can" "erase char" "erase rectangle" "vaporize line" "vaporize lines" "cut rectangle" "cut square" "copy rectangle" "copy square" "paste" "flood-fill")))) (artist-select-operation type))
(defun artist-ido-select-settings (type) "Use ido to select a setting to change in artist-mode" (interactive (list (ido-completing-read "Setting: " (list "Set Fill" "Set Line" "Set Erase" "Spray-size" "Spray-chars" "Rubber-banding" "Trimming" "Borders")))) (if (equal type "Spray-size") (artist-select-operation "spray set size") (call-interactively (artist-fc-get-fn-from-symbol (cdr (assoc type '(("Set Fill" . set-fill) ("Set Line" . set-line) ("Set Erase" . set-erase) ("Rubber-banding" . rubber-band) ("Trimming" . trimming) ("Borders" . borders) ("Spray-chars" . spray-chars))))))))
(add-hook 'artist-mode-init-hook (lambda () (define-key artist-mode-map (kbd "C-c C-a C-o") 'artist-ido-select-operation) (define-key artist-mode-map (kbd "C-c C-a C-c") 'artist-ido-select-settings)))
—
You can define custom quick-actions specific to artist mode by attaching it to the artist-mode-hook like so:
(add-hook 'artist-mode-hook (lambda () (local-set-key (kbd "<f1>") 'org-mode) (local-set-key (kbd "<f2>") 'artist-select-op-pen-line) ; f2 = pen mode (local-set-key (kbd "<f3>") 'artist-select-op-line) ; f3 = line (local-set-key (kbd "<f4>") 'artist-select-op-square) ; f4 = rectangle (local-set-key (kbd "<f5>") 'artist-select-op-ellipse) ; f5 = ellipse (local-set-key (kbd "C-z") 'undo) ))
—
One should note that artist mode doesn’t seem to function well in org-mode when headers are collapsed. As a workaround, show all headers before activating artist mode:
(global-set-key (kbd "C-<f1>") (lambda() (interactive) (show-all) (artist-mode)))
Or consider simply org-narrow before editing in artist-mode:
C-x n e # narrow to an element C-x n w # widen back to the whole page
Note: If using the keyboard to draw, use C-u RET to stop drawing.
See Also: PictureMode