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