From: William Stevenson <yhvh2000@gmail.com>
To: 10760@debbugs.gnu.org
Subject: bug#10760: 24.0.93; [patch] Convert artist-mode to use define-minor-mode
Date: Thu, 09 Feb 2012 04:15:15 +0000 [thread overview]
Message-ID: <87lioctzfw.fsf@gmail.com> (raw)
In-Reply-To: <87fwelztll.fsf@gmail.com>
Stefan Monnier <monnier@iro.umontreal.ca> 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."
next prev parent reply other threads:[~2012-02-09 4:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 7:12 bug#10760: 24.0.93; [patch] Convert artist-mode to use define-minor-mode William Stevenson
2012-02-08 7:34 ` William Stevenson
2012-02-08 19:25 ` Stefan Monnier
2012-02-09 4:15 ` William Stevenson [this message]
2012-02-09 22:01 ` Stefan Monnier
2012-02-11 2:22 ` William Stevenson
2012-02-13 20:57 ` Stefan Monnier
2012-04-11 11:57 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lioctzfw.fsf@gmail.com \
--to=yhvh2000@gmail.com \
--cc=10760@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.