annotate lisp/textmodes/scribe.el @ 26088:b7aa6ac26872

Add support for large files, 64-bit Solaris, system locale codings. * Makefile.in (emacs): Set the LC_ALL environment variable to "C" when dumping, so that the dumped Emacs doesn't have stray locale info. (dired.o): Depend on systime.h. (editfns.o): Depend on coding.h. * alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c, dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c, keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c, unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c, w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Include <config.h> before any system include files. * alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c, m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Do not include <stdlib.h>, as <config.h> does this now. * callproc.c (Fcall_process): Synchronize messages locale before invoking strerror. Decode resulting string with locale-coding-system. * coding.c (Vlocale_coding_system): New var. (syms_of_coding): Adjust to above change. (emacs_strerror): New function. * coding.h (emacs_strerror, Vlocale_coding_system): New decls. * config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING, HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN, HAVE_STRSIGNAL): New macros. (BITS_PER_LONG): Default to 64 if _LP64 is defined. <stdlib.h>: Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't. * dired.c: Include "systime.h". (Ffile_attributes): Do not cast s.st_size to int; this loses information if int is 32 bits but st_size and EMACS_INT are larger. Treat large device numbers like large inode numbers. * dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available. * editfns.c: Include coding.h. (emacs_strftime): Remove decl. (emacs_strftimeu): New decl. (emacs_memftimeu): Renamed from emacs_memftime; new arg UT. Use emacs_strftimeu instead of emacs_strftime. (Fformat_time_string): Convert format string using Vlocale_coding_system, and convert result back. Synchronize time locale before invoking lower level function. Invoke emacs_memftimeu, passing ut, instead of emacs_memftime. * emacs.c: Include <locale.h> if HAVE_SETLOCALE is defined. (Vmessages_locale, Vprevious_messages_locale, Vtime_locale, Vprevious_time_locale): New variables. (main): Invoke setlocale early, so that initial error messages are localized properly. But skip locale-setting if LC_ALL is "C". Fix up locale when it's safe to do so. (fixup_locale): Moved here from xterm.c. (synchronize_locale, synchronize_time_locale, synchronize_messages_locale): New functions. (syms_of_emacs): Accommodate above changes. * fileio.c (report_file_error): Convert strerror output according to Vlocale_coding_system. (Finsert_file_contents): Check for arithmetic overflow in computations that depend on file size. Report IO errors with emacs_strerror, not strerror. * fns.c (Fgethash): Declare dflt parameter. * gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H is defined; that's config.h's job. * lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64, default these values to long, BITS_PER_LONG, and unsigned long. (VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT. (PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int. (code_convert_string_norecord, fixup_locale, synchronize_messages_locale, synchronize_time_locale, emacs_open, emacs_close, emacs_read, emacs_write): New decls. All Emacs callers of open, close, read, write changed to use emacs_open, emacs_close, emacs_read, emacs_write. * lread.c (file_offset, file_tell): New macros. All uses of ftell changed to file_tell. (saved_doc_string_position, prev_saved_doc_string_position): Now of type file_offset. (init_lread): Do not fix locale here; fixup_locale now does this. * m/amdahl.h, s/usg5-4.h: (NSIG): Remove. (NSIG_MINIMUM): New macro. * m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h, m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/umips.h, s/usg5-4.h: (SIGIO): Do not undef. (BROKEN_SIGIO): New macro. * m/ustation.h: (SIGTSTP): Do not undef. (BROKEN_SIGTSTP): New macro. * s/gnu-linux.h: (SIGPOLL, SIGURG): Do not undef. (BROKEN_SIGPOLL, BROKEN_SIGURG): New macros. * s/ptx4.h: (SIGINFO): Do not undef. (BROKEN_SIGINFO): New macros. * m/delta.h, s/ptx.h, s/template.h: Doc fix. * mktime.c, strftime.c: Update to glibc 2.1.2 version, with some Emacs-related changes merged. * print.c (float_to_string): Prepend "-" to representation of a NaN if the NaN is negative. * process.c (sys_siglist): Omit if HAVE_STRSIGNAL. (wait_reading_process_input): Use emacs_strerror, not strerror. * process.c (status_message, sigchld_handler): Synchronize locale, then use strsignal istead of sys_siglist. * w32proc.c (sys_wait): Likewise. * s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h, s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h, s/usg5-2.h, s/usg5-3.h, s/xenix.h: (open, close, read, write, INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove. * s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros. * sysdep.c (sys_read, sys_write, read, write, sys_close, close, sys_open, open): Remove. (emacs_open, emacs_close, emacs_read, emacs_write): Always define; the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO macros are no longer used. (emacs_open): Renamed from sys_open. Merge BSD4_1 version. (emacs_close): Renamed from sys_close. (emacs_read): Renamed from sys_read. (emacs_write): Renamed from sys_write. (sys_siglist): Do not declare if HAVE_STRSIGNAL. (dup2): Do not print error on failure; the real dup2 doesn't. (strsignal): New function, defined if !HAVE_STRSIGNAL. * syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO is defined. (SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise. (NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM. (strsignal): Declare if !HAVE_STRSIGNAL. * unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros. (ElfW): Define in terms of ElfExpandBitsW. * w32proc.c (sys_siglist): Remove decl. * xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply with ANSI C. (display_string): Declare face_string_pos arg. * xfns.c (Fx_show_tip): Declare timeout param. * xterm.c: No need to include locale.h. (x_alloc_lighter_color, x_setup_relief_color): Pass arg as double, not float, for compatibility with ANSI C. (fixup_locale): Move to emacs.c. (x_term_init): Do not setlocale or fixup locale; the main program does this now.
author Paul Eggert <eggert@twinsun.com>
date Tue, 19 Oct 1999 07:25:11 +0000
parents 9b831f34ff7d
children 3e37953dc2d5
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
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
33 (defgroup scribe nil
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
34 "Scribe mode."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
35 :prefix "scribe-"
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
36 :group 'wp)
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
37
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (defvar scribe-mode-syntax-table nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 "Syntax table used while in scribe mode.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (defvar scribe-mode-abbrev-table nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 "Abbrev table used while in scribe mode.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
44 (defcustom scribe-fancy-paragraphs nil
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
45 "*Non-NIL makes Scribe mode use a different style of paragraph separation."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
46 :type 'boolean
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
47 :group 'scribe)
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
49 (defcustom scribe-electric-quote nil
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
50 "*Non-NIL makes insert of double quote use `` or '' depending on context."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
51 :type 'boolean
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
52 :group 'scribe)
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
54 (defcustom scribe-electric-parenthesis nil
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 "*Non-NIL makes parenthesis char ( (]}> ) automatically insert its close
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
56 if typed after an @Command form."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
57 :type 'boolean
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18383
diff changeset
58 :group 'scribe)
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (defconst scribe-open-parentheses "[({<"
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 "Open parenthesis characters for Scribe.")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defconst scribe-close-parentheses "])}>"
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
64 "Close parenthesis characters for Scribe.
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
65 These should match up with `scribe-open-parenthesis'.")
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (if (null scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (let ((st (syntax-table)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (unwind-protect
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (progn
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (setq scribe-mode-syntax-table (copy-syntax-table
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 text-mode-syntax-table))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (set-syntax-table scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (modify-syntax-entry ?\" " ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (modify-syntax-entry ?\\ " ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (modify-syntax-entry ?@ "w ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (modify-syntax-entry ?< "(> ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (modify-syntax-entry ?> ")< ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (modify-syntax-entry ?[ "(] ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (modify-syntax-entry ?] ")[ ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (modify-syntax-entry ?{ "(} ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (modify-syntax-entry ?} "){ ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (modify-syntax-entry ?' "w "))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (set-syntax-table st))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (defvar scribe-mode-map nil)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (if scribe-mode-map
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 nil
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (setq scribe-mode-map (make-sparse-keymap))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (define-key scribe-mode-map "\t" 'scribe-tab)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (define-key scribe-mode-map "\e\t" 'tab-to-tab-stop)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (define-key scribe-mode-map "\es" 'center-line)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (define-key scribe-mode-map "\e}" 'up-list)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (define-key scribe-mode-map "\eS" 'center-paragraph)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (define-key scribe-mode-map "\"" 'scribe-insert-quote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (define-key scribe-mode-map "(" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (define-key scribe-mode-map "[" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (define-key scribe-mode-map "{" 'scribe-parenthesis)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (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
101 (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
102 (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
103 (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
104 (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
105 (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
106 (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
107 (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
108 (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
109 (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
110 (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
111
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 7
diff changeset
112 ;;;###autoload
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (defun scribe-mode ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 "Major mode for editing files of Scribe (a text formatter) source.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 Scribe-mode is similar text-mode, with a few extra commands added.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 \\{scribe-mode-map}
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 Interesting variables:
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 scribe-fancy-paragraphs
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 Non-nil makes Scribe mode use a different style of paragraph separation.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 scribe-electric-quote
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 Non-nil makes insert of double quote use `` or '' depending on context.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 scribe-electric-parenthesis
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 Non-nil makes an open-parenthesis char (one of `([<{')
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 automatically insert its close if typed after an @Command form."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (kill-all-local-variables)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (use-local-map scribe-mode-map)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (setq mode-name "Scribe")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (setq major-mode 'scribe-mode)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (define-abbrev-table 'scribe-mode-abbrev-table ())
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (setq local-abbrev-table scribe-mode-abbrev-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (make-local-variable 'comment-start)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (setq comment-start "@Comment[")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (make-local-variable 'comment-start-skip)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (setq comment-start-skip (concat "@Comment[" scribe-open-parentheses "]"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (make-local-variable 'comment-column)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (setq comment-column 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (make-local-variable 'comment-end)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (setq comment-end "]")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (make-local-variable 'paragraph-start)
10893
e9418d324071 (scribe-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents: 10460
diff changeset
145 (setq paragraph-start (concat "\\([\n\f]\\)\\|\\(@\\w+["
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 scribe-open-parentheses
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "].*["
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 scribe-close-parentheses
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 "]$\\)"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (make-local-variable 'paragraph-separate)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (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
152 paragraph-start "$"))
10460
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
153 (make-local-variable 'sentence-end)
b2e37a1d2347 (scribe-mode): Treat @: as a sentence end.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
154 (setq sentence-end "\\([.?!]\\|@:\\)[]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (make-local-variable 'compile-command)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (setq compile-command (concat "scribe " (buffer-file-name)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (set-syntax-table scribe-mode-syntax-table)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (run-hooks 'text-mode-hook 'scribe-mode-hook))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (defun scribe-tab ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (insert "@\\"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; This algorithm could probably be improved somewhat.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;; Right now, it loses seriously...
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (defun scribe ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 "Run Scribe on the current buffer."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (call-interactively 'compile))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (defun scribe-envelop-word (string count)
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
173 "Surround current word with Scribe construct @STRING[...].
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
174 COUNT specifies how many words to surround. A negative count means
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
175 to skip backward."
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (let ((spos (point)) (epos (point)) (ccoun 0) noparens)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (if (not (zerop count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (progn (if (= (char-syntax (preceding-char)) ?w)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (forward-sexp (min -1 count)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (setq spos (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (if (looking-at (concat "@\\w[" scribe-open-parentheses "]"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (forward-char 2)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (skip-chars-backward "\\W")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (forward-char -1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (forward-sexp (max count 1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (setq epos (point))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (while (and (< ccoun (length scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (or (search-forward (char-to-string
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (aref scribe-open-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 epos t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (search-forward (char-to-string
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (aref scribe-close-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 epos t)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (setq ccoun (1+ ccoun))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (if (>= ccoun (length scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (progn (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (insert "@end(" string ")")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (insert "@begin(" string ")"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (insert (aref scribe-close-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (goto-char spos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (insert "@" string (aref scribe-open-parentheses ccoun))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (goto-char epos)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (forward-char 3)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (skip-chars-forward scribe-close-parentheses))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (defun scribe-underline-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 "Underline COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (scribe-envelop-word "u" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (defun scribe-bold-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 "Boldface COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (scribe-envelop-word "b" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (defun scribe-italicize-word (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 "Italicize COUNT words around point by means of Scribe constructs."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (interactive "p")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (scribe-envelop-word "i" count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (defun scribe-begin ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (scribe-envelop-word "Begin" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (defun scribe-end ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (scribe-envelop-word "End" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (defun scribe-chapter ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (scribe-envelop-word "Chapter" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (defun scribe-section ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (scribe-envelop-word "Section" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (defun scribe-subsection ()
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (interactive)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (insert "\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (scribe-envelop-word "SubSection" 0)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (re-search-forward (concat "[" scribe-open-parentheses "]")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (defun scribe-bracket-region-be (env min max)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (interactive "sEnvironment: \nr")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (goto-char max)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (insert "@end(" env ")\n")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (goto-char min)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (insert "@begin(" env ")\n")))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (defun scribe-insert-environment (env)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (interactive "sEnvironment: ")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (scribe-bracket-region-be env (point) (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (forward-line 1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (insert ?\n)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (forward-char -1))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (defun scribe-insert-quote (count)
1539
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
277 "Insert ``, '' or \" according to preceding character.
5677f906bf78 Dox fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
278 If `scribe-electric-quote' is non-NIL, insert ``, '' or \" according
7
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 to preceding character. With numeric arg N, always insert N \" characters.
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 Else just insert \"."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (interactive "P")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (if (or count (not scribe-electric-quote))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (self-insert-command (prefix-numeric-value count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (let (lastfore lastback lastquote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (insert
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (cond
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ((= (preceding-char) ?\\) ?\")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 ((bobp) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (t
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (setq lastfore (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 "``" (- (point) 1000) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (point)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 lastback (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 "''" (- (point) 1000) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (point)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 lastquote (save-excursion (and (search-backward
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "\"" (- (point) 100) t)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (point))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (if (not lastquote)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (cond ((not lastfore) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ((not lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ((> lastfore lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (t "``"))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (cond ((and (not lastback) (not lastfore)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ((and lastback (not lastfore) (> lastquote lastback)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 ((and lastback (not lastfore) (> lastback lastquote)) "``")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ((and lastfore (not lastback) (> lastquote lastfore)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ((and lastfore (not lastback) (> lastfore lastquote)) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ((and (> lastquote lastfore) (> lastquote lastback)) "\"")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ((> lastfore lastback) "''")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (t "``")))))))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (defun scribe-parenthesis (count)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 "If scribe-electric-parenthesis is non-NIL, insertion of an open-parenthesis
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 character inserts the following close parenthesis character if the
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 preceding text is of the form @Command."
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (interactive "P")
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (self-insert-command (prefix-numeric-value count))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (let (at-command paren-char point-save)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (if (or count (not scribe-electric-parenthesis))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 nil
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 (forward-char -1)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (setq point-save (point))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (skip-chars-backward (concat "^ \n\t\f" scribe-open-parentheses))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (setq at-command (and (equal (following-char) ?@)
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (/= (point) (1- point-save)))))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (if (and at-command
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (setq paren-char
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (string-match (regexp-quote
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (char-to-string (preceding-char)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 scribe-open-parentheses)))
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (save-excursion
9a0ef3f9c6aa Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (insert (aref scribe-close-parentheses paren-char)))))))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
335
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
336 (provide 'scribe)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
337
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
338 ;;; scribe.el ends here