Mercurial > emacs
annotate lisp/gnus/gnus-eform.el @ 107978:c168d4537385
Merge from emacs-23
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 19 Apr 2010 11:07:52 -0400 |
parents | 1d1d5d9bd884 |
children | 8d09094063d0 376148b31b5e |
rev | line source |
---|---|
17493 | 1 ;;; gnus-eform.el --- a mode for editing forms for Gnus |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
17493 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
17493 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17493 | 19 ;; GNU General Public License for more details. |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
17493 | 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 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
56 (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
|
57 (set-keymap-parent gnus-edit-form-mode-map emacs-lisp-mode-map) |
17493 | 58 (gnus-define-keys gnus-edit-form-mode-map |
59 "\C-c\C-c" gnus-edit-form-done | |
60 "\C-c\C-k" gnus-edit-form-exit)) | |
61 | |
62 (defun gnus-edit-form-make-menu-bar () | |
63 (unless (boundp 'gnus-edit-form-menu) | |
64 (easy-menu-define | |
65 gnus-edit-form-menu gnus-edit-form-mode-map "" | |
66 '("Edit Form" | |
67 ["Exit and save changes" gnus-edit-form-done t] | |
68 ["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
|
69 (gnus-run-hooks 'gnus-edit-form-menu-hook))) |
17493 | 70 |
71 (defun gnus-edit-form-mode () | |
72 "Major mode for editing forms. | |
73 It is a slightly enhanced emacs-lisp-mode. | |
74 | |
75 \\{gnus-edit-form-mode-map}" | |
76 (interactive) | |
77 (when (gnus-visual-p 'group-menu 'menu) | |
78 (gnus-edit-form-make-menu-bar)) | |
79 (kill-all-local-variables) | |
80 (setq major-mode 'gnus-edit-form-mode) | |
81 (setq mode-name "Edit Form") | |
82 (use-local-map gnus-edit-form-mode-map) | |
83 (make-local-variable 'gnus-edit-form-done-function) | |
84 (make-local-variable 'gnus-prev-winconf) | |
62890
4b7fa3ee8e9e
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-336
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
85 (gnus-run-mode-hooks 'gnus-edit-form-mode-hook)) |
17493 | 86 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
87 (defun gnus-edit-form (form documentation exit-func &optional layout) |
17493 | 88 "Edit FORM in a new buffer. |
89 Call EXIT-FUNC on exit. Display DOCUMENTATION in the beginning | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
90 of the buffer. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
91 The optional LAYOUT overrides the `edit-form' window layout." |
17493 | 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)) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
94 (gnus-configure-windows (or layout 'edit-form)) |
17493 | 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))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
109 (gnus-pp form) |
17493 | 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)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
117 (let ((form (condition-case nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
118 (read (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
119 (end-of-file nil))) |
17493 | 120 (func gnus-edit-form-done-function)) |
121 (gnus-edit-form-exit) | |
122 (funcall func form))) | |
123 | |
124 (defun gnus-edit-form-exit () | |
125 "Kill the current buffer." | |
126 (interactive) | |
127 (let ((winconf gnus-prev-winconf)) | |
128 (kill-buffer (current-buffer)) | |
129 (set-window-configuration winconf))) | |
130 | |
131 (provide 'gnus-eform) | |
132 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
133 ;; arch-tag: ef50678c-2c28-49ef-affc-e53b3b2c0bf6 |
17493 | 134 ;;; gnus-eform.el ends here |