From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#10760: 24.0.93; [patch] Convert artist-mode to use define-minor-mode Date: Thu, 09 Feb 2012 17:01:42 -0500 Message-ID: References: <87fwelztll.fsf@gmail.com> <87lioctzfw.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1328824924 1257 80.91.229.3 (9 Feb 2012 22:02:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Feb 2012 22:02:04 +0000 (UTC) Cc: 10760@debbugs.gnu.org To: William Stevenson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 09 23:02:03 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 1Rvc42-0007VG-Qo for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Feb 2012 23:02:03 +0100 Original-Received: from localhost ([::1]:46862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvc41-00053l-QU for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Feb 2012 17:02:01 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:51334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvc3v-00052G-KX for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2012 17:01:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvc3u-0001iD-3n for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2012 17:01:55 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvc3u-0001i3-1B for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2012 17:01:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rvc50-0003Gs-FX for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2012 17:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Feb 2012 22:03:02 +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 Original-Received: via spool by 10760-submit@debbugs.gnu.org id=B10760.132882497612560 (code B ref 10760); Thu, 09 Feb 2012 22:03:02 +0000 Original-Received: (at 10760) by debbugs.gnu.org; 9 Feb 2012 22:02:56 +0000 Original-Received: from localhost ([127.0.0.1]:34128 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rvc4u-0003GW-5m for submit@debbugs.gnu.org; Thu, 09 Feb 2012 17:02:56 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:55448) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rvc4q-0003GM-Tg for 10760@debbugs.gnu.org; Thu, 09 Feb 2012 17:02:54 -0500 Original-Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q19M1gYb030597; Thu, 9 Feb 2012 17:01:42 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 936A3130009; Thu, 9 Feb 2012 17:01:42 -0500 (EST) In-Reply-To: <87lioctzfw.fsf@gmail.com> (William Stevenson's message of "Thu, 09 Feb 2012 04:15:15 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4127=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4127> : streams <727188> : uri <1062795> 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:56743 Archived-At: >> 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. Looks good, please install, and thank you, Stefan > === 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."