annotate lisp/textmodes/scribe.el @ 20349:6ab8801244c2

Add prototypes.
author Andreas Schwab <schwab@suse.de>
date Tue, 25 Nov 1997 13:44:34 +0000
parents 11218164bc54
children 9b831f34ff7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
1 ;;; scribe.el --- scribe mode, and its idiosyncratic commands.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 789
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 789
diff changeset
4
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
5 ;; Maintainer: FSF
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1539
diff changeset
6 ;; Keywords: wp
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
10460
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
8 ;; This file is part of GNU Emacs.
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
9
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
13 ;; any later version.
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
10460
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
18 ;; GNU General Public License for more details.
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
10460
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 11664
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 11664
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 11664
diff changeset
23 ;; Boston, MA 02111-1307, USA.
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
25 ;;; Commentary:
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
26
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
27 ;; A major mode for editing source in written for the Scribe text formatter.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
28 ;; Knows about Scribe syntax and standard layout rules. The command to
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
29 ;; run Scribe on a buffer is bogus; someone interested should fix it.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
30
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
31 ;;; Code:
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defvar scribe-mode-syntax-table nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 "Syntax table used while in scribe mode.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (defvar scribe-mode-abbrev-table nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 "Abbrev table used while in scribe mode.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defvar scribe-fancy-paragraphs nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 "*Non-NIL makes Scribe mode use a different style of paragraph separation.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (defvar scribe-electric-quote nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 "*Non-NIL makes insert of double quote use `` or '' depending on context.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (defvar scribe-electric-parenthesis nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 "*Non-NIL makes parenthesis char ( (]}> ) automatically insert its close
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 if typed after an @Command form.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (defconst scribe-open-parentheses "[({<"
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 "Open parenthesis characters for Scribe.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (defconst scribe-close-parentheses "])}>"
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
53 "Close parenthesis characters for Scribe.
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
54 These should match up with `scribe-open-parenthesis'.")
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (if (null scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (let ((st (syntax-table)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (unwind-protect
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (progn
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (setq scribe-mode-syntax-table (copy-syntax-table
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 text-mode-syntax-table))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (set-syntax-table scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (modify-syntax-entry ?\" " ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (modify-syntax-entry ?\\ " ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (modify-syntax-entry ?@ "w ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (modify-syntax-entry ?< "(> ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (modify-syntax-entry ?> ")< ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (modify-syntax-entry ?[ "(] ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (modify-syntax-entry ?] ")[ ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (modify-syntax-entry ?{ "(} ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (modify-syntax-entry ?} "){ ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (modify-syntax-entry ?' "w "))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (set-syntax-table st))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (defvar scribe-mode-map nil)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (if scribe-mode-map
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (setq scribe-mode-map (make-sparse-keymap))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (define-key scribe-mode-map "\t" 'scribe-tab)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (define-key scribe-mode-map "\e\t" 'tab-to-tab-stop)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (define-key scribe-mode-map "\es" 'center-line)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (define-key scribe-mode-map "\e}" 'up-list)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (define-key scribe-mode-map "\eS" 'center-paragraph)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (define-key scribe-mode-map "\"" 'scribe-insert-quote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (define-key scribe-mode-map "(" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (define-key scribe-mode-map "[" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (define-key scribe-mode-map "{" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (define-key scribe-mode-map "<" 'scribe-parenthesis)
11664
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
90 (define-key scribe-mode-map "\C-c\C-c" 'scribe-chapter)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
91 (define-key scribe-mode-map "\C-c\C-t" 'scribe-section)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
92 (define-key scribe-mode-map "\C-c\C-s" 'scribe-subsection)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
93 (define-key scribe-mode-map "\C-c\C-v" 'scribe-insert-environment)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
94 (define-key scribe-mode-map "\C-c\C-e" 'scribe-bracket-region-be)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
95 (define-key scribe-mode-map "\C-c[" 'scribe-begin)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
96 (define-key scribe-mode-map "\C-c]" 'scribe-end)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
97 (define-key scribe-mode-map "\C-c\C-i" 'scribe-italicize-word)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
98 (define-key scribe-mode-map "\C-c\C-b" 'scribe-bold-word)
966c6625a963 (scribe-chapter): Change to C-c C-c.
Karl Heuer <kwzh@gnu.org>
parents: 10893
diff changeset
99 (define-key scribe-mode-map "\C-c\C-u" 'scribe-underline-word))
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 7
diff changeset
101 ;;;###autoload
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (defun scribe-mode ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 "Major mode for editing files of Scribe (a text formatter) source.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 Scribe-mode is similar text-mode, with a few extra commands added.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 \\{scribe-mode-map}
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 Interesting variables:
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 scribe-fancy-paragraphs
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 Non-nil makes Scribe mode use a different style of paragraph separation.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 scribe-electric-quote
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 Non-nil makes insert of double quote use `` or '' depending on context.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 scribe-electric-parenthesis
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 Non-nil makes an open-parenthesis char (one of `([<{')
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 automatically insert its close if typed after an @Command form."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (kill-all-local-variables)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (use-local-map scribe-mode-map)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (setq mode-name "Scribe")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (setq major-mode 'scribe-mode)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (define-abbrev-table 'scribe-mode-abbrev-table ())
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (setq local-abbrev-table scribe-mode-abbrev-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (make-local-variable 'comment-start)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (setq comment-start "@Comment[")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (make-local-variable 'comment-start-skip)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (setq comment-start-skip (concat "@Comment[" scribe-open-parentheses "]"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (make-local-variable 'comment-column)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (setq comment-column 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (make-local-variable 'comment-end)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (setq comment-end "]")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (make-local-variable 'paragraph-start)
10893
e9418d324071 (scribe-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents: 10460
diff changeset
134 (setq paragraph-start (concat "\\([\n\f]\\)\\|\\(@\\w+["
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 scribe-open-parentheses
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "].*["
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 scribe-close-parentheses
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "]$\\)"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (make-local-variable 'paragraph-separate)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (setq paragraph-separate (if scribe-fancy-paragraphs
10893
e9418d324071 (scribe-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents: 10460
diff changeset
141 paragraph-start "$"))
10460
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
142 (make-local-variable 'sentence-end)
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
143 (setq sentence-end "\\([.?!]\\|@:\\)[]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (make-local-variable 'compile-command)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (setq compile-command (concat "scribe " (buffer-file-name)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (set-syntax-table scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (run-hooks 'text-mode-hook 'scribe-mode-hook))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defun scribe-tab ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (insert "@\\"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; This algorithm could probably be improved somewhat.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; Right now, it loses seriously...
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defun scribe ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "Run Scribe on the current buffer."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (call-interactively 'compile))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (defun scribe-envelop-word (string count)
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
162 "Surround current word with Scribe construct @STRING[...].
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
163 COUNT specifies how many words to surround. A negative count means
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
164 to skip backward."
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (let ((spos (point)) (epos (point)) (ccoun 0) noparens)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (if (not (zerop count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (progn (if (= (char-syntax (preceding-char)) ?w)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (forward-sexp (min -1 count)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (setq spos (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (if (looking-at (concat "@\\w[" scribe-open-parentheses "]"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (forward-char 2)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (skip-chars-backward "\\W")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (forward-char -1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (forward-sexp (max count 1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (setq epos (point))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (while (and (< ccoun (length scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (or (search-forward (char-to-string
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (aref scribe-open-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 epos t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (search-forward (char-to-string
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (aref scribe-close-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 epos t)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (setq ccoun (1+ ccoun))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (if (>= ccoun (length scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (progn (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (insert "@end(" string ")")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (insert "@begin(" string ")"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (insert (aref scribe-close-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (insert "@" string (aref scribe-open-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (forward-char 3)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (skip-chars-forward scribe-close-parentheses))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (defun scribe-underline-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 "Underline COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (scribe-envelop-word "u" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defun scribe-bold-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 "Boldface COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (scribe-envelop-word "b" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (defun scribe-italicize-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 "Italicize COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (scribe-envelop-word "i" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (defun scribe-begin ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (scribe-envelop-word "Begin" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (defun scribe-end ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (scribe-envelop-word "End" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (defun scribe-chapter ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (scribe-envelop-word "Chapter" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defun scribe-section ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (scribe-envelop-word "Section" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (defun scribe-subsection ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (scribe-envelop-word "SubSection" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (defun scribe-bracket-region-be (env min max)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (interactive "sEnvironment: \nr")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (goto-char max)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (insert "@end(" env ")\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (goto-char min)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (insert "@begin(" env ")\n")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (defun scribe-insert-environment (env)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (interactive "sEnvironment: ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (scribe-bracket-region-be env (point) (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (forward-line 1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (insert ?\n)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (forward-char -1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (defun scribe-insert-quote (count)
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
266 "Insert ``, '' or \" according to preceding character.
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
267 If `scribe-electric-quote' is non-NIL, insert ``, '' or \" according
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 to preceding character. With numeric arg N, always insert N \" characters.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 Else just insert \"."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (interactive "P")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (if (or count (not scribe-electric-quote))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (self-insert-command (prefix-numeric-value count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (let (lastfore lastback lastquote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (insert
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (cond
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 ((= (preceding-char) ?\\) ?\")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 ((bobp) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (t
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (setq lastfore (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 "``" (- (point) 1000) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (point)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 lastback (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "''" (- (point) 1000) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (point)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 lastquote (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 "\"" (- (point) 100) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (point))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (if (not lastquote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (cond ((not lastfore) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ((not lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ((> lastfore lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (t "``"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (cond ((and (not lastback) (not lastfore)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ((and lastback (not lastfore) (> lastquote lastback)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ((and lastback (not lastfore) (> lastback lastquote)) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 ((and lastfore (not lastback) (> lastquote lastfore)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 ((and lastfore (not lastback) (> lastfore lastquote)) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 ((and (> lastquote lastfore) (> lastquote lastback)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ((> lastfore lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (t "``")))))))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (defun scribe-parenthesis (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 "If scribe-electric-parenthesis is non-NIL, insertion of an open-parenthesis
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 character inserts the following close parenthesis character if the
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 preceding text is of the form @Command."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (interactive "P")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (self-insert-command (prefix-numeric-value count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (let (at-command paren-char point-save)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (if (or count (not scribe-electric-parenthesis))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (setq point-save (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (skip-chars-backward (concat "^ \n\t\f" scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (setq at-command (and (equal (following-char) ?@)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (/= (point) (1- point-save)))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (if (and at-command
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (setq paren-char
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (string-match (regexp-quote
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (char-to-string (preceding-char)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 scribe-open-parentheses)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (insert (aref scribe-close-parentheses paren-char)))))))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
324
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
325 (provide 'scribe)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
326
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
327 ;;; scribe.el ends here