Mercurial > emacs
annotate lisp/gnus/gnus-eform.el @ 44361:bb4d8a7cff31
Update to use new tutorial facility.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Wed, 03 Apr 2002 09:37:48 +0000 |
parents | 9968f55ad26e |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
17493 | 1 ;;; gnus-eform.el --- a mode for editing forms for Gnus |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
17493 | 4 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 6 ;; Keywords: news |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
29 (require 'gnus) | |
30 (require 'gnus-win) | |
31 | |
32 ;;; | |
33 ;;; Editing forms | |
34 ;;; | |
35 | |
36 (defgroup gnus-edit-form nil | |
37 "A mode for editing forms." | |
38 :group 'gnus) | |
39 | |
40 (defcustom gnus-edit-form-mode-hook nil | |
41 "Hook run in `gnus-edit-form-mode' buffers." | |
42 :group 'gnus-edit-form | |
43 :type 'hook) | |
44 | |
45 (defcustom gnus-edit-form-menu-hook nil | |
46 "Hook run when creating menus in `gnus-edit-form-mode' buffers." | |
47 :group 'gnus-edit-form | |
48 :type 'hook) | |
49 | |
50 ;;; Internal variables | |
51 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
52 (defvar gnus-edit-form-buffer "*Gnus edit form*") |
17493 | 53 (defvar gnus-edit-form-done-function nil) |
54 | |
55 (defvar gnus-edit-form-mode-map nil) | |
56 (unless gnus-edit-form-mode-map | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
57 (setq gnus-edit-form-mode-map (make-sparse-keymap)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
58 (set-keymap-parent gnus-edit-form-mode-map emacs-lisp-mode-map) |
17493 | 59 (gnus-define-keys gnus-edit-form-mode-map |
60 "\C-c\C-c" gnus-edit-form-done | |
61 "\C-c\C-k" gnus-edit-form-exit)) | |
62 | |
63 (defun gnus-edit-form-make-menu-bar () | |
64 (unless (boundp 'gnus-edit-form-menu) | |
65 (easy-menu-define | |
66 gnus-edit-form-menu gnus-edit-form-mode-map "" | |
67 '("Edit Form" | |
68 ["Exit and save changes" gnus-edit-form-done t] | |
69 ["Exit" gnus-edit-form-exit t])) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
70 (gnus-run-hooks 'gnus-edit-form-menu-hook))) |
17493 | 71 |
72 (defun gnus-edit-form-mode () | |
73 "Major mode for editing forms. | |
74 It is a slightly enhanced emacs-lisp-mode. | |
75 | |
76 \\{gnus-edit-form-mode-map}" | |
77 (interactive) | |
78 (when (gnus-visual-p 'group-menu 'menu) | |
79 (gnus-edit-form-make-menu-bar)) | |
80 (kill-all-local-variables) | |
81 (setq major-mode 'gnus-edit-form-mode) | |
82 (setq mode-name "Edit Form") | |
83 (use-local-map gnus-edit-form-mode-map) | |
84 (make-local-variable 'gnus-edit-form-done-function) | |
85 (make-local-variable 'gnus-prev-winconf) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
86 (gnus-run-hooks 'gnus-edit-form-mode-hook)) |
17493 | 87 |
88 (defun gnus-edit-form (form documentation exit-func) | |
89 "Edit FORM in a new buffer. | |
90 Call EXIT-FUNC on exit. Display DOCUMENTATION in the beginning | |
91 of the buffer." | |
92 (let ((winconf (current-window-configuration))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
93 (set-buffer (gnus-get-buffer-create gnus-edit-form-buffer)) |
17493 | 94 (gnus-configure-windows 'edit-form) |
95 (gnus-edit-form-mode) | |
96 (setq gnus-prev-winconf winconf) | |
97 (setq gnus-edit-form-done-function exit-func) | |
98 (erase-buffer) | |
99 (insert documentation) | |
100 (unless (bolp) | |
101 (insert "\n")) | |
102 (goto-char (point-min)) | |
103 (while (not (eobp)) | |
104 (insert ";;; ") | |
105 (forward-line 1)) | |
106 (insert ";; Type `C-c C-c' after you've finished editing.\n") | |
107 (insert "\n") | |
108 (let ((p (point))) | |
109 (pp form (current-buffer)) | |
110 (insert "\n") | |
111 (goto-char p)))) | |
112 | |
113 (defun gnus-edit-form-done () | |
114 "Update changes and kill the current buffer." | |
115 (interactive) | |
116 (goto-char (point-min)) | |
117 (let ((form (read (current-buffer))) | |
118 (func gnus-edit-form-done-function)) | |
119 (gnus-edit-form-exit) | |
120 (funcall func form))) | |
121 | |
122 (defun gnus-edit-form-exit () | |
123 "Kill the current buffer." | |
124 (interactive) | |
125 (let ((winconf gnus-prev-winconf)) | |
126 (kill-buffer (current-buffer)) | |
127 (set-window-configuration winconf))) | |
128 | |
129 (provide 'gnus-eform) | |
130 | |
131 ;;; gnus-eform.el ends here |