From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: William Stevenson Newsgroups: gmane.emacs.bugs Subject: bug#10760: 24.0.93; [patch] Convert artist-mode to use define-minor-mode Date: Wed, 08 Feb 2012 07:34:37 +0000 Message-ID: <877gzxzsky.fsf@gmail.com> References: <87fwelztll.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1328686586 25039 80.91.229.3 (8 Feb 2012 07:36:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Feb 2012 07:36:26 +0000 (UTC) To: 10760@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 08 08:36:25 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rv24k-0006aO-KS for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Feb 2012 08:36:24 +0100 Original-Received: from localhost ([::1]:47725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv24j-0000KR-MY for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Feb 2012 02:36:21 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:49451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv24a-00006m-S1 for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:36:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv24Q-0005Wt-04 for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:36:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv24P-0005Wd-UX for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:36:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rv25N-0008DV-Jq for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:37:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87fwelztll.fsf@gmail.com> Resent-From: William Stevenson Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Feb 2012 07:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10760 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.132868658331532 (code B ref -1); Wed, 08 Feb 2012 07:37:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Feb 2012 07:36:23 +0000 Original-Received: from localhost ([127.0.0.1]:59853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rv24j-0008CW-VN for submit@debbugs.gnu.org; Wed, 08 Feb 2012 02:36:22 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37051) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rv24S-0008Bo-Pj for submit@debbugs.gnu.org; Wed, 08 Feb 2012 02:36:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv23N-0005OR-K5 for submit@debbugs.gnu.org; Wed, 08 Feb 2012 02:34:59 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:39968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv23N-0005ON-IV for submit@debbugs.gnu.org; Wed, 08 Feb 2012 02:34:57 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:49324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv23L-0008T8-QK for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:34:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv23J-0005O6-M5 for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:34:55 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:44763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv23J-0005O1-9Q for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 02:34:53 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Rv23G-00063d-PC for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 08:34:50 +0100 Original-Received: from cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com ([86.24.57.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Feb 2012 08:34:50 +0100 Original-Received: from yhvh2000 by cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Feb 2012 08:34:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 331 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) Cancel-Lock: sha1:QmLuG+tvquTcH2NOu4qVcSrNhLM= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:56689 Archived-At: Apologies, an error snuck in to that last diff, a line in the doc was changed uselessly. === modified file 'lisp/textmodes/artist.el' *** lisp/textmodes/artist.el 2012-01-19 07:21:25 +0000 --- lisp/textmodes/artist.el 2012-02-08 07:28:48 +0000 *************** *** 415,427 **** ;; Internal variables ;; - (defvar artist-mode nil - "Non-nil to enable `artist-mode' and nil to disable.") - (make-variable-buffer-local 'artist-mode) - - (defvar artist-mode-name " Artist" - "Name of Artist mode beginning with a space (appears in the mode-line).") - (defvar artist-curr-go 'pen-line "Current selected graphics operation.") (make-variable-buffer-local 'artist-curr-go) --- 415,420 ---- *************** *** 545,606 **** :button (:radio . (eq artist-curr-go ',(nth 2 op)))))) map)) - (defvar artist-mode-map - (let ((map (make-sparse-keymap))) - (setq artist-mode-map (make-sparse-keymap)) - (define-key map [down-mouse-1] 'artist-down-mouse-1) - (define-key map [S-down-mouse-1] 'artist-down-mouse-1) - (define-key map [down-mouse-2] 'artist-mouse-choose-operation) - (define-key map [S-down-mouse-2] 'artist-mouse-choose-operation) - (define-key map [down-mouse-3] 'artist-down-mouse-3) - (define-key map [S-down-mouse-3] 'artist-down-mouse-3) - (define-key map [C-mouse-4] 'artist-select-prev-op-in-list) - (define-key map [C-mouse-5] 'artist-select-next-op-in-list) - (define-key map "\r" 'artist-key-set-point) ; return - (define-key map [up] 'artist-previous-line) - (define-key map "\C-p" 'artist-previous-line) - (define-key map [down] 'artist-next-line) - (define-key map "\C-n" 'artist-next-line) - (define-key map [left] 'artist-backward-char) - (define-key map "\C-b" 'artist-backward-char) - (define-key map [right] 'artist-forward-char) - (define-key map "\C-f" 'artist-forward-char) - (define-key map "<" 'artist-toggle-first-arrow) - (define-key map ">" 'artist-toggle-second-arrow) - (define-key map "\C-c\C-a\C-e" 'artist-select-erase-char) - (define-key map "\C-c\C-a\C-f" 'artist-select-fill-char) - (define-key map "\C-c\C-a\C-l" 'artist-select-line-char) - (define-key map "\C-c\C-a\C-o" 'artist-select-operation) - (define-key map "\C-c\C-a\C-r" 'artist-toggle-rubber-banding) - (define-key map "\C-c\C-a\C-t" 'artist-toggle-trim-line-endings) - (define-key map "\C-c\C-a\C-s" 'artist-toggle-borderless-shapes) - (define-key map "\C-c\C-c" 'artist-mode-off) - (define-key map "\C-c\C-al" 'artist-select-op-line) - (define-key map "\C-c\C-aL" 'artist-select-op-straight-line) - (define-key map "\C-c\C-ar" 'artist-select-op-rectangle) - (define-key map "\C-c\C-aR" 'artist-select-op-square) - (define-key map "\C-c\C-as" 'artist-select-op-square) - (define-key map "\C-c\C-ap" 'artist-select-op-poly-line) - (define-key map "\C-c\C-aP" 'artist-select-op-straight-poly-line) - (define-key map "\C-c\C-ae" 'artist-select-op-ellipse) - (define-key map "\C-c\C-ac" 'artist-select-op-circle) - (define-key map "\C-c\C-at" 'artist-select-op-text-see-thru) - (define-key map "\C-c\C-aT" 'artist-select-op-text-overwrite) - (define-key map "\C-c\C-aS" 'artist-select-op-spray-can) - (define-key map "\C-c\C-az" 'artist-select-op-spray-set-size) - (define-key map "\C-c\C-a\C-d" 'artist-select-op-erase-char) - (define-key map "\C-c\C-aE" 'artist-select-op-erase-rectangle) - (define-key map "\C-c\C-av" 'artist-select-op-vaporize-line) - (define-key map "\C-c\C-aV" 'artist-select-op-vaporize-lines) - (define-key map "\C-c\C-a\C-k" 'artist-select-op-cut-rectangle) - (define-key map "\C-c\C-a\M-w" 'artist-select-op-copy-rectangle) - (define-key map "\C-c\C-a\C-y" 'artist-select-op-paste) - (define-key map "\C-c\C-af" 'artist-select-op-flood-fill) - (define-key map "\C-c\C-a\C-b" 'artist-submit-bug-report) - (define-key map [menu-bar artist] (cons "Artist" artist-menu-map)) - map) - "Keymap for `artist-minor-mode'.") - (defvar artist-replacement-table (make-vector 256 0) "Replacement table for `artist-replace-char'.") --- 538,543 ---- *************** *** 1196,1204 **** ;;; --------------------------------- ;;;###autoload ! (defun artist-mode (&optional state) "Toggle Artist mode. ! With argument STATE, turn Artist mode on if STATE is positive. Artist lets you draw lines, squares, rectangles and poly-lines, ellipses and circles with your mouse and/or keyboard. --- 1133,1141 ---- ;;; --------------------------------- ;;;###autoload ! (define-minor-mode artist-mode "Toggle Artist mode. ! 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. *************** *** 1387,1472 **** 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. 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 and exit ! (defun artist-mode-init () ! "Init Artist mode. This will call the hook `artist-mode-init-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. ! (let ((i 0)) ! (while (< i 256) ! (aset artist-replacement-table i i) ! (setq i (1+ i)))) ! (aset artist-replacement-table ?\n ?\s) ! (aset artist-replacement-table ?\t ?\s) ! (aset artist-replacement-table 0 ?\s) ! ;; More setup ! (make-local-variable 'artist-key-is-drawing) ! (make-local-variable 'artist-key-endpoint1) ! (make-local-variable 'artist-key-poly-point-list) ! (make-local-variable 'artist-key-shape) ! (make-local-variable 'artist-key-draw-how) ! (make-local-variable 'artist-popup-menu-table) ! (make-local-variable 'artist-key-compl-table) ! (make-local-variable 'artist-prev-next-op-alist) ! (make-local-variable 'artist-rb-save-data) ! (make-local-variable 'artist-arrow-point-1) ! (make-local-variable 'artist-arrow-point-2) ! (setq artist-key-is-drawing nil) ! (setq artist-key-endpoint1 nil) ! (setq artist-key-poly-point-list nil) ! (setq artist-key-shape nil) ! (setq artist-popup-menu-table (artist-compute-popup-menu-table artist-mt)) ! (setq artist-key-compl-table (artist-compute-key-compl-table artist-mt)) ! (setq artist-prev-next-op-alist ! (artist-make-prev-next-op-alist artist-key-compl-table)) ! (setq artist-rb-save-data (make-vector 7 0)) ! (setq artist-arrow-point-1 nil) ! (setq artist-arrow-point-2 nil) ! (make-local-variable 'next-line-add-newlines) ! (setq next-line-add-newlines t) ! (setq artist-key-draw-how ! (artist-go-get-draw-how-from-symbol artist-curr-go)) ! (if (and artist-picture-compatibility (not (eq major-mode 'picture-mode))) ! (progn ! (picture-mode) ! (message ""))) ! (run-hooks 'artist-mode-init-hook) ! (artist-mode-line-show-curr-operation artist-key-is-drawing)) ! ! (defun artist-mode-exit () ! "Exit Artist mode. This will call the hook `artist-mode-exit-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)) (defun artist-mode-off () "Turn Artist mode off." --- 1324,1438 ---- Hooks ! Turning the mode on or off runs `artist-mode-hook'. Keymap summary \\{artist-mode-map}" ! :init-value nil :group 'artist :lighter " Artist" ! :keymap ! '(([down-mouse-1] . artist-down-mouse-1) ! ([S-down-mouse-1] . artist-down-mouse-1) ! ([down-mouse-2] . artist-mouse-choose-operation) ! ([S-down-mouse-2] . artist-mouse-choose-operation) ! ([down-mouse-3] . artist-down-mouse-3) ! ([S-down-mouse-3] . artist-down-mouse-3) ! ([C-mouse-4] . artist-select-prev-op-in-list) ! ([C-mouse-5] . artist-select-next-op-in-list) ! ("\r" . artist-key-set-point) ; return ! ([up] . artist-previous-line) ! ("\C-p" . artist-previous-line) ! ([down] . artist-next-line) ! ("\C-n" . artist-next-line) ! ([left] . artist-backward-char) ! ("\C-b" . artist-backward-char) ! ([right] . artist-forward-char) ! ("\C-f" . artist-forward-char) ! ("<" . artist-toggle-first-arrow) ! (">" . artist-toggle-second-arrow) ! ("\C-c\C-a\C-e" . artist-select-erase-char) ! ("\C-c\C-a\C-f" . artist-select-fill-char) ! ("\C-c\C-a\C-l" . artist-select-line-char) ! ("\C-c\C-a\C-o" . artist-select-operation) ! ("\C-c\C-a\C-r" . artist-toggle-rubber-banding) ! ("\C-c\C-a\C-t" . artist-toggle-trim-line-endings) ! ("\C-c\C-a\C-s" . artist-toggle-borderless-shapes) ! ("\C-c\C-c" . artist-mode-off) ! ("\C-c\C-al" . artist-select-op-line) ! ("\C-c\C-aL" . artist-select-op-straight-line) ! ("\C-c\C-ar" . artist-select-op-rectangle) ! ("\C-c\C-aR" . artist-select-op-square) ! ("\C-c\C-as" . artist-select-op-square) ! ("\C-c\C-ap" . artist-select-op-poly-line) ! ("\C-c\C-aP" . artist-select-op-straight-poly-line) ! ("\C-c\C-ae" . artist-select-op-ellipse) ! ("\C-c\C-ac" . artist-select-op-circle) ! ("\C-c\C-at" . artist-select-op-text-see-thru) ! ("\C-c\C-aT" . artist-select-op-text-overwrite) ! ("\C-c\C-aS" . artist-select-op-spray-can) ! ("\C-c\C-az" . artist-select-op-spray-set-size) ! ("\C-c\C-a\C-d" . artist-select-op-erase-char) ! ("\C-c\C-aE" . artist-select-op-erase-rectangle) ! ("\C-c\C-av" . artist-select-op-vaporize-line) ! ("\C-c\C-aV" . artist-select-op-vaporize-lines) ! ("\C-c\C-a\C-k" . artist-select-op-cut-rectangle) ! ("\C-c\C-a\M-w" . artist-select-op-copy-rectangle) ! ("\C-c\C-a\C-y" . artist-select-op-paste) ! ("\C-c\C-af" . artist-select-op-flood-fill) ! ("\C-c\C-a\C-b" . artist-submit-bug-report) ! ([menu-bar artist] . artist-menu-map)) ! (cond ((null artist-mode) ! ;; Turn mode off ! (if (and artist-picture-compatibility (eq major-mode 'picture-mode)) ! (picture-mode-exit)) ! (kill-local-variable 'next-line-add-newlines)) ! ! (t ! ;; Turn mode on ! ;; 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. ! (let ((i 0)) ! (while (< i 256) ! (aset artist-replacement-table i i) ! (setq i (1+ i)))) ! (aset artist-replacement-table ?\n ?\s) ! (aset artist-replacement-table ?\t ?\s) ! (aset artist-replacement-table 0 ?\s) ! ;; More setup ! (make-local-variable 'artist-key-is-drawing) ! (make-local-variable 'artist-key-endpoint1) ! (make-local-variable 'artist-key-poly-point-list) ! (make-local-variable 'artist-key-shape) ! (make-local-variable 'artist-key-draw-how) ! (make-local-variable 'artist-popup-menu-table) ! (make-local-variable 'artist-key-compl-table) ! (make-local-variable 'artist-prev-next-op-alist) ! (make-local-variable 'artist-rb-save-data) ! (make-local-variable 'artist-arrow-point-1) ! (make-local-variable 'artist-arrow-point-2) ! (setq artist-key-is-drawing nil) ! (setq artist-key-endpoint1 nil) ! (setq artist-key-poly-point-list nil) ! (setq artist-key-shape nil) ! (setq artist-popup-menu-table (artist-compute-popup-menu-table artist-mt)) ! (setq artist-key-compl-table (artist-compute-key-compl-table artist-mt)) ! (setq artist-prev-next-op-alist ! (artist-make-prev-next-op-alist artist-key-compl-table)) ! (setq artist-rb-save-data (make-vector 7 0)) ! (setq artist-arrow-point-1 nil) ! (setq artist-arrow-point-2 nil) ! (make-local-variable 'next-line-add-newlines) ! (setq next-line-add-newlines t) ! (setq artist-key-draw-how ! (artist-go-get-draw-how-from-symbol artist-curr-go)) ! (if (and artist-picture-compatibility (not (eq major-mode 'picture-mode))) ! (progn ! (picture-mode) ! (message ""))) ! (artist-mode-line-show-curr-operation artist-key-is-drawing)))) ! (defun artist-mode-off () "Turn Artist mode off." *************** *** 1484,1490 **** (defun artist-mode-line-show-curr-operation (is-drawing) "Show current operation in mode-line. If IS-DRAWING, show that." ! (let ((mtext (concat artist-mode-name "/" (artist-go-get-mode-line-from-symbol artist-curr-go) (if is-drawing "/*" "")))) (setcdr (assq 'artist-mode minor-mode-alist) (list mtext))) --- 1450,1456 ---- (defun artist-mode-line-show-curr-operation (is-drawing) "Show current operation in mode-line. If IS-DRAWING, show that." ! (let ((mtext (concat " Artist/" (artist-go-get-mode-line-from-symbol artist-curr-go) (if is-drawing "/*" "")))) (setcdr (assq 'artist-mode minor-mode-alist) (list mtext)))