Mercurial > emacs
annotate lisp/gnus/score-mode.el @ 40093:479353d8bc19
(invisible_text_between_p): Put prototype inside #if 0 because unused.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Sat, 20 Oct 2001 20:26:18 +0000 |
parents | 9968f55ad26e |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
17493 | 1 ;;; score-mode.el --- mode for editing Gnus score files |
2 ;; Copyright (C) 1996 Free Software Foundation, Inc. | |
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, mail |
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 (eval-when-compile (require 'cl)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
29 (require 'mm-util) ; for mm-auto-save-coding-system |
17493 | 30 |
31 (defvar gnus-score-mode-hook nil | |
32 "*Hook run in score mode buffers.") | |
33 | |
34 (defvar gnus-score-menu-hook nil | |
35 "*Hook run after creating the score mode menu.") | |
36 | |
37 (defvar gnus-score-edit-exit-function nil | |
38 "Function run on exit from the score buffer.") | |
39 | |
40 (defvar gnus-score-mode-map nil) | |
41 (unless gnus-score-mode-map | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
42 (setq gnus-score-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
|
43 (set-keymap-parent gnus-score-mode-map emacs-lisp-mode-map) |
17493 | 44 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-exit) |
45 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date) | |
46 (define-key gnus-score-mode-map "\C-c\C-p" 'gnus-score-pretty-print)) | |
47 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
48 (defvar score-mode-syntax-table |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
49 (let ((table (copy-syntax-table lisp-mode-syntax-table))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
50 (modify-syntax-entry ?| "w" table) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
51 table) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
52 "Syntax table used in score-mode buffers.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
53 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 ;; We need this to cope with non-ASCII scoring. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
55 (defvar score-mode-coding-system mm-auto-save-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
56 |
17493 | 57 ;;;###autoload |
58 (defun gnus-score-mode () | |
59 "Mode for editing Gnus score files. | |
60 This mode is an extended emacs-lisp mode. | |
61 | |
62 \\{gnus-score-mode-map}" | |
63 (interactive) | |
64 (kill-all-local-variables) | |
65 (use-local-map gnus-score-mode-map) | |
66 (gnus-score-make-menu-bar) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
67 (set-syntax-table score-mode-syntax-table) |
17493 | 68 (setq major-mode 'gnus-score-mode) |
69 (setq mode-name "Score") | |
70 (lisp-mode-variables nil) | |
71 (make-local-variable 'gnus-score-edit-exit-function) | |
72 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook)) | |
73 | |
74 (defun gnus-score-make-menu-bar () | |
75 (unless (boundp 'gnus-score-menu) | |
76 (easy-menu-define | |
77 gnus-score-menu gnus-score-mode-map "" | |
78 '("Score" | |
79 ["Exit" gnus-score-edit-exit t] | |
80 ["Insert date" gnus-score-edit-insert-date t] | |
81 ["Format" gnus-score-pretty-print t])) | |
82 (run-hooks 'gnus-score-menu-hook))) | |
83 | |
84 (defun gnus-score-edit-insert-date () | |
85 "Insert date in numerical format." | |
86 (interactive) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
87 (princ (time-to-days (current-time)) (current-buffer))) |
17493 | 88 |
89 (defun gnus-score-pretty-print () | |
90 "Format the current score file." | |
91 (interactive) | |
92 (goto-char (point-min)) | |
93 (let ((form (read (current-buffer)))) | |
94 (erase-buffer) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
95 (let ((emacs-lisp-mode-syntax-table score-mode-syntax-table)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
17493
diff
changeset
|
96 (pp form (current-buffer)))) |
17493 | 97 (goto-char (point-min))) |
98 | |
99 (defun gnus-score-edit-exit () | |
100 "Stop editing the score file." | |
101 (interactive) | |
102 (unless (file-exists-p (file-name-directory (buffer-file-name))) | |
103 (make-directory (file-name-directory (buffer-file-name)) t)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
104 (let ((coding-system-for-write score-mode-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
105 (save-buffer)) |
17493 | 106 (bury-buffer (current-buffer)) |
107 (let ((buf (current-buffer))) | |
108 (when gnus-score-edit-exit-function | |
109 (funcall gnus-score-edit-exit-function)) | |
110 (when (eq buf (current-buffer)) | |
111 (switch-to-buffer (other-buffer (current-buffer)))))) | |
112 | |
113 (provide 'score-mode) | |
114 | |
115 ;;; score-mode.el ends here |