Mercurial > emacs
annotate lisp/gnus/gnus-eform.el @ 61263:56619c3aaf99
(fancy-splash-text): Shorten default text of
"Emacs Tutorial" line. Also, if the current language env
indicates an available tutorial file other than TUTORIAL,
extract its title and append it to the line in parentheses.
(fancy-splash-insert): If arg is a thunk, funcall it.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Mon, 04 Apr 2005 07:41:58 +0000 |
parents | 55fd4f77387a |
children | 4b7fa3ee8e9e cce1c0ee76ee |
rev | line source |
---|---|
17493 | 1 ;;; gnus-eform.el --- a mode for editing forms for Gnus |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2004 |
31716
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))) | |
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 | |
52401 | 133 ;;; arch-tag: ef50678c-2c28-49ef-affc-e53b3b2c0bf6 |
17493 | 134 ;;; gnus-eform.el ends here |