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: Thu, 09 Feb 2012 04:15:15 +0000 Message-ID: <87lioctzfw.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 1328760963 15324 80.91.229.3 (9 Feb 2012 04:16:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Feb 2012 04:16:03 +0000 (UTC) To: 10760@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 09 05:16:02 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 1RvLQQ-0008R4-12 for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Feb 2012 05:16:02 +0100 Original-Received: from localhost ([::1]:60478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLQP-0005zQ-Gq for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Feb 2012 23:16:01 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLQM-0005zH-2s for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvLQK-0002on-Od for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:58 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLQK-0002oe-N2 for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RvLRN-0007v1-JZ for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:17: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: Thu, 09 Feb 2012 04:17: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.132876100630412 (code B ref -1); Thu, 09 Feb 2012 04:17:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Feb 2012 04:16:46 +0000 Original-Received: from localhost ([127.0.0.1]:33080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvLR8-0007uS-2b for submit@debbugs.gnu.org; Wed, 08 Feb 2012 23:16:46 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35204) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvLR5-0007uF-2p for submit@debbugs.gnu.org; Wed, 08 Feb 2012 23:16:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvLPv-0002jK-97 for submit@debbugs.gnu.org; Wed, 08 Feb 2012 23:15:32 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:53765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLPv-0002jG-7c for submit@debbugs.gnu.org; Wed, 08 Feb 2012 23:15:31 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLPu-0005qo-3x for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvLPs-0002iv-NC for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:30 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:52798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvLPs-0002ip-GE for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2012 23:15:28 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RvLPq-0008Ht-Sn for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2012 05:15:26 +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 ; Thu, 09 Feb 2012 05:15:26 +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 ; Thu, 09 Feb 2012 05:15:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 119 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:82bBUHHGJ6xOjnQJAaPZf2BTHw0= 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:56706 Archived-At: Stefan Monnier writes: >> - (defvar artist-mode-map > > The keymap does not have to be defined within the call to > define-minor-mode (actually I recommend you don't do that in general), > so you can leave the (defvar artist-mode-map ...) untouched. I did :keymap artist-mode-map. >> ! (defun artist-mode-init () > [...] >> ! (defun artist-mode-exit () > > You can also keep these functions. This will significantly reduce the > size of your patch and will make it much easier to figure out what is > really changed (and hence, whether or not the change is safe). Done. >> ! :init-value nil :group 'artist :lighter " Artist" > > You should use artist-mode-name here. Done. > > Stefan "who actually prefers `diff -u' format" Me too, serves me right for reading the manual :B In summary: Updated artist-mode to use define-minor-mode. As a consequence, artist-mode-init-hook and artist-mode-exit-hook were removed from artist-mode-init and artist-mode-exit, because d-m-m creates artist-mode-hook, and runs it when the mode is turned on or off. Documentation was updated to reflect this. === modified file 'lisp/textmodes/artist.el' --- lisp/textmodes/artist.el 2012-01-19 07:21:25 +0000 +++ lisp/textmodes/artist.el 2012-02-09 03:00:37 +0000 @@ -1196,9 +1196,9 @@ ;;; --------------------------------- ;;;###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. @@ -1387,36 +1387,24 @@ 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. @@ -1458,15 +1446,13 @@ (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'." + "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."