From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eduard Wiebe Newsgroups: gmane.emacs.devel Subject: Re: [patch] convert footnote.el to use define-minor-mode Date: Sun, 14 Dec 2008 00:46:14 +0100 Message-ID: <8663lnprjt.fsf@nirvana.pusto.de> References: <86d4fx82jd.fsf@nirvana.pusto.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1229212063 16847 80.91.229.12 (13 Dec 2008 23:47:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Dec 2008 23:47:43 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 14 00:48:47 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LBeE2-0005QD-O7 for ged-emacs-devel@m.gmane.org; Sun, 14 Dec 2008 00:48:47 +0100 Original-Received: from localhost ([127.0.0.1]:59990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LBeCr-0007O7-5g for ged-emacs-devel@m.gmane.org; Sat, 13 Dec 2008 18:47:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LBeBs-0006QW-Uu for emacs-devel@gnu.org; Sat, 13 Dec 2008 18:46:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LBeBr-0006OM-Iw for emacs-devel@gnu.org; Sat, 13 Dec 2008 18:46:32 -0500 Original-Received: from [199.232.76.173] (port=44913 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LBeBr-0006O4-Aq for emacs-devel@gnu.org; Sat, 13 Dec 2008 18:46:31 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:43250 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LBeBq-0005e9-MP for emacs-devel@gnu.org; Sat, 13 Dec 2008 18:46:31 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LBeBk-0000BN-Gv for emacs-devel@gnu.org; Sat, 13 Dec 2008 23:46:24 +0000 Original-Received: from e182125144.adsl.alicedsl.de ([85.182.125.144]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Dec 2008 23:46:24 +0000 Original-Received: from usenet by e182125144.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Dec 2008 23:46:24 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 159 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e182125144.adsl.alicedsl.de User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) Cancel-Lock: sha1:tY+Q84XRAZ+YLVOlZ3eXAIGZfgw= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106890 Archived-At: --=-=-= Stefan Monnier writes: >> * mail/footnote.el (footnote-mode): Use define-minor-mode >> (footnote-prefix): Use defcustom > > Looks very good, thank you. Except you've renamed footnote-prefix to > footnote-mode-prefix, which doesn't seem to be worth the trouble (of > and ChangeLog text should end with "."). Stefan, thank you for comments. 2008-12-14 Eduard Wiebe * mail/footnote.el (footnote-mode): Use define-minor-mode. (footnote-prefix): Use defcustom. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=footnote.el.diff diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el index 506f6e7..a7b372b 100644 --- a/lisp/mail/footnote.el +++ b/lisp/mail/footnote.el @@ -45,15 +45,6 @@ :version "21.1" :group 'message) -(defcustom footnote-mode-line-string " FN" - "String to display in modes section of the mode-line." - :group 'footnote) - -(defcustom footnote-mode-hook nil - "Hook functions run when footnote-mode is activated." - :type 'hook - :group 'footnote) - (defcustom footnote-narrow-to-footnotes-when-editing nil "If non-nil, narrow to footnote text body while editing a footnote." :type 'boolean @@ -84,8 +75,12 @@ displaying footnotes." :type 'integer :group 'footnote) -(defvar footnote-prefix [(control ?c) ?!] - "*When not using `message-mode', the prefix to bind in `mode-specific-map'") +(defcustom footnote-prefix "\C-c!" + "Prefix key to use for Footnote command in Footnote minor mode. +The value of this variable is checked as part of loading Footnote mode. +After that, changing the prefix key requires manipulating keymaps." + :type 'string + :group 'footnote) ;;; Interface variables that probably shouldn't be changed @@ -143,10 +138,6 @@ has no effect on buffers already displaying footnotes." (defvar footnote-mouse-highlight 'highlight "Text property name to enable mouse over highlight.") -(defvar footnote-mode nil - "Variable indicating whether footnote minor mode is active.") -(make-variable-buffer-local 'footnote-mode) - ;;; Default styles ;;; NUMERIC (defconst footnote-numeric-regexp "[0-9]+" @@ -743,47 +734,31 @@ being set it is automatically widened." (widen)) (goto-char (cadr (assq note footnote-pointer-marker-alist)))))) -(defvar footnote-mode-map nil - "Keymap used for footnote minor mode.") - -;; Set up our keys -(unless footnote-mode-map - (setq footnote-mode-map (make-sparse-keymap)) - (define-key footnote-mode-map "a" 'Footnote-add-footnote) - (define-key footnote-mode-map "b" 'Footnote-back-to-message) - (define-key footnote-mode-map "c" 'Footnote-cycle-style) - (define-key footnote-mode-map "d" 'Footnote-delete-footnote) - (define-key footnote-mode-map "g" 'Footnote-goto-footnote) - (define-key footnote-mode-map "r" 'Footnote-renumber-footnotes) - (define-key footnote-mode-map "s" 'Footnote-set-style)) - -(defvar footnote-minor-mode-map nil - "Keymap used for binding footnote minor mode.") - -(unless footnote-minor-mode-map - (define-key global-map footnote-prefix footnote-mode-map)) +(defvar footnote-mode-map + (let ((map (make-sparse-keymap)) + (prefix-map (make-sparse-keymap))) + (define-key map footnote-prefix prefix-map) + (define-key prefix-map "a" 'Footnote-add-footnote) + (define-key prefix-map "b" 'Footnote-back-to-message) + (define-key prefix-map "c" 'Footnote-cycle-style) + (define-key prefix-map "d" 'Footnote-delete-footnote) + (define-key prefix-map "g" 'Footnote-goto-footnote) + (define-key prefix-map "r" 'Footnote-renumber-footnotes) + (define-key prefix-map "s" 'Footnote-set-style) + map)) ;;;###autoload -(defun footnote-mode (&optional arg) +(define-minor-mode footnote-mode "Toggle footnote minor mode. -\\ This minor mode provides footnote support for `message-mode'. To get started, play around with the following keys: -key binding ---- ------- -\\[Footnote-add-footnote] Footnote-add-footnote -\\[Footnote-back-to-message] Footnote-back-to-message -\\[Footnote-delete-footnote] Footnote-delete-footnote -\\[Footnote-goto-footnote] Footnote-goto-footnote -\\[Footnote-renumber-footnotes] Footnote-renumber-footnotes -\\[Footnote-cycle-style] Footnote-cycle-style -\\[Footnote-set-style] Footnote-set-style +\\{footnote-mode-map} " - (interactive "*P") + :init-value nil + :lighter " FN" + :keymap footnote-mode-map + :group 'footnote ;; (filladapt-mode t) - (setq footnote-mode - (if (null arg) (not footnote-mode) - (> (prefix-numeric-value arg) 0))) (when footnote-mode ;; (Footnote-setup-keybindings) (make-local-variable 'footnote-style) @@ -808,14 +783,7 @@ key binding (unless (assoc bullet-regexp filladapt-token-table) (setq filladapt-token-table (append filladapt-token-table - (list (list bullet-regexp 'bullet))))))) - - (run-hooks 'footnote-mode-hook))) - -(unless (assq 'footnote-mode minor-mode-alist) - (setq minor-mode-alist - (cons '(footnote-mode footnote-mode-line-string) - minor-mode-alist))) + (list (list bullet-regexp 'bullet))))))))) (provide 'footnote) --=-=-= -- Eduard Wiebe --=-=-=--