annotate lisp/obsolete/scribe.el @ 109635:fc7a8c411aa3

Add declarations to header files. * src/keyboard.h (xmalloc_widget_value, digest_single_submenu): Remove declarations, menu.h has them. (QCbutton, QCtoggle, QCradio, QClabel, extra_keyboard_modifiers) (Vinput_method_function, Qinput_method_function) (Qevent_symbol_element_mask, last_event_timestamp): * src/dispextern.h (Voverflow_newline_into_fringe): * src/font.h (QCantialias, Qp, syms_of_ftfont, syms_of_xfns) (syms_of_ftxfont, syms_of_xftfont, syms_of_bdffont) (syms_of_w32font, syms_of_nsfont): * src/fontset.h (find_font_encoding, Qlatin): * src/frame.h (Qtooltip, Qrun_hook_with_args, Vmenu_bar_mode) (Vtool_bar_mode, set_frame_menubar): * src/ftfont.h (ftfont_font_format, ftfont_get_fc_charset): * src/xterm.h (Qx_gtk_map_stock): * src/keymap.h (meta_prefix_char): Add declarations. * src/lisp.h: Remove HAVE_SHM code, unused. (QCmap, QCrehash_size, QCrehash_threshold, QCsize, QCtest) (QCweakness, Qabove_handle, Qbackquote, Qbar, Qbelow_handle) (Qborder, Qbottom, Qbox, Qcircular_list, Qcomma, Qcomma_at) (Qcomma_dot, Qcursor, Qdefault, Qdown, Qend_scroll, Qeq, Qeql) (Qequal, Qfile_exists_p, Qfont_param, Qfringe, Qfunction) (Qfunction_documentation, Qhandle, Qhbar, Qheader_line, Qhollow) (Qidentity, Qleft_margin, Qmenu, Qmenu_bar_update_hook) (Qmode_line_inactive, Qmouse, Qoverriding_local_map) (Qoverriding_terminal_local_map, Qratio, Qregion, Qright_margin) (Qscroll_bar, Qtool_bar, Qtop, Qup, Qvertical_border, Qwhen) (Qwindow_scroll_functions, Vafter_load_alist) (Vauto_save_list_file_name, Vface_alternative_font_family_alist) (Vface_alternative_font_registry_alist, Vface_font_rescale_alist) (Vface_ignored_fonts, Vinhibit_redisplay, Vminibuffer_list) (Vprint_length, Vprint_level, Vscalable_fonts_allowed) (Vshell_file_name, Vsystem_name, Vwindow_scroll_functions) (Vwindow_system_version, Vx_no_window_manager, initial_argc) (initial_argv, last_nonmenu_event, load_in_progress) (noninteractive_need_newline, scroll_margin): Add declarations.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 05 Aug 2010 16:15:24 -0700
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; scribe.el --- scribe mode, and its idiosyncratic commands
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
101110
bf139d0bd1ac Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 101110
diff changeset
4 ;; 2009, 2010 Free Software Foundation, Inc.
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5
101110
bf139d0bd1ac Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
6 ;; Author: William Sommerfeld
bf139d0bd1ac Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
7 ;; (according to ack.texi)
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8 ;; Maintainer: FSF
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
9 ;; Keywords: wp
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
10
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
12
94667
43d30a1ea764 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94000
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94667
43d30a1ea764 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94000
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
43d30a1ea764 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94000
diff changeset
16 ;; (at your option) any later version.
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
22
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94667
43d30a1ea764 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94000
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
26 ;;; Commentary:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27
94000
ee22366f2a68 Add a comment giving version of obsolescence.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
28 ;; This file has been obsolete since Emacs 22.1.
ee22366f2a68 Add a comment giving version of obsolescence.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
29
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30 ;; A major mode for editing source in written for the Scribe text formatter.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
31 ;; Knows about Scribe syntax and standard layout rules. The command to
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
32 ;; run Scribe on a buffer is bogus; someone interested should fix it.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
33
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
34 ;;; Code:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
35
65189
2b9801f22b5e (compile-command): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
36 (defvar compile-command)
2b9801f22b5e (compile-command): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
37
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
38 (defgroup scribe nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
39 "Scribe mode."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
40 :prefix "scribe-"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
41 :group 'wp)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
42
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
43 (defvar scribe-mode-syntax-table nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
44 "Syntax table used while in scribe mode.")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
45
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
46 (defvar scribe-mode-abbrev-table nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
47 "Abbrev table used while in scribe mode.")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
48
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
49 (defcustom scribe-fancy-paragraphs nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
50 "*Non-nil makes Scribe mode use a different style of paragraph separation."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
51 :type 'boolean
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
52 :group 'scribe)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
53
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
54 (defcustom scribe-electric-quote nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
55 "*Non-nil makes insert of double quote use `` or '' depending on context."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
56 :type 'boolean
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
57 :group 'scribe)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
58
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
59 (defcustom scribe-electric-parenthesis nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60 "*Non-nil makes parenthesis char ( (]}> ) automatically insert its close
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 if typed after an @Command form."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62 :type 'boolean
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
63 :group 'scribe)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65 (defconst scribe-open-parentheses "[({<"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66 "Open parenthesis characters for Scribe.")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 (defconst scribe-close-parentheses "])}>"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69 "Close parenthesis characters for Scribe.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70 These should match up with `scribe-open-parenthesis'.")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72 (if (null scribe-mode-syntax-table)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 (let ((st (syntax-table)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74 (unwind-protect
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 (progn
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
76 (setq scribe-mode-syntax-table (copy-syntax-table
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
77 text-mode-syntax-table))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
78 (set-syntax-table scribe-mode-syntax-table)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
79 (modify-syntax-entry ?\" " ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80 (modify-syntax-entry ?\\ " ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81 (modify-syntax-entry ?@ "w ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 (modify-syntax-entry ?< "(> ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 (modify-syntax-entry ?> ")< ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
84 (modify-syntax-entry ?[ "(] ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
85 (modify-syntax-entry ?] ")[ ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
86 (modify-syntax-entry ?{ "(} ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
87 (modify-syntax-entry ?} "){ ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
88 (modify-syntax-entry ?' "w "))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
89 (set-syntax-table st))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
90
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
91 (defvar scribe-mode-map nil)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93 (if scribe-mode-map
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
95 (setq scribe-mode-map (make-sparse-keymap))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
96 (define-key scribe-mode-map "\t" 'scribe-tab)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
97 (define-key scribe-mode-map "\e\t" 'tab-to-tab-stop)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
98 (define-key scribe-mode-map "\es" 'center-line)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
99 (define-key scribe-mode-map "\e}" 'up-list)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
100 (define-key scribe-mode-map "\eS" 'center-paragraph)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
101 (define-key scribe-mode-map "\"" 'scribe-insert-quote)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
102 (define-key scribe-mode-map "(" 'scribe-parenthesis)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103 (define-key scribe-mode-map "[" 'scribe-parenthesis)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
104 (define-key scribe-mode-map "{" 'scribe-parenthesis)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
105 (define-key scribe-mode-map "<" 'scribe-parenthesis)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
106 (define-key scribe-mode-map "\C-c\C-c" 'scribe-chapter)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
107 (define-key scribe-mode-map "\C-c\C-t" 'scribe-section)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
108 (define-key scribe-mode-map "\C-c\C-s" 'scribe-subsection)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
109 (define-key scribe-mode-map "\C-c\C-v" 'scribe-insert-environment)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 (define-key scribe-mode-map "\C-c\C-e" 'scribe-bracket-region-be)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
111 (define-key scribe-mode-map "\C-c[" 'scribe-begin)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
112 (define-key scribe-mode-map "\C-c]" 'scribe-end)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
113 (define-key scribe-mode-map "\C-c\C-i" 'scribe-italicize-word)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
114 (define-key scribe-mode-map "\C-c\C-b" 'scribe-bold-word)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
115 (define-key scribe-mode-map "\C-c\C-u" 'scribe-underline-word))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
116
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
117 ;;;###autoload
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
118 (define-derived-mode scribe-mode text-mode "Scribe"
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
119 "Major mode for editing files of Scribe (a text formatter) source.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
120 Scribe-mode is similar to text-mode, with a few extra commands added.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
121 \\{scribe-mode-map}
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
122
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
123 Interesting variables:
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
124
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
125 `scribe-fancy-paragraphs'
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
126 Non-nil makes Scribe mode use a different style of paragraph separation.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
127
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
128 `scribe-electric-quote'
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
129 Non-nil makes insert of double quote use `` or '' depending on context.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
130
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
131 `scribe-electric-parenthesis'
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
132 Non-nil makes an open-parenthesis char (one of `([<{')
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
133 automatically insert its close if typed after an @Command form."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
134 (set (make-local-variable 'comment-start) "@Comment[")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
135 (set (make-local-variable 'comment-start-skip) (concat "@Comment[" scribe-open-parentheses "]"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
136 (set (make-local-variable 'comment-column) 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
137 (set (make-local-variable 'comment-end) "]")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
138 (set (make-local-variable 'paragraph-start)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
139 (concat "\\([\n\f]\\)\\|\\(@\\w+["
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 scribe-open-parentheses
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141 "].*["
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 scribe-close-parentheses
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 "]$\\)"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144 (set (make-local-variable 'paragraph-separate)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145 (if scribe-fancy-paragraphs paragraph-start "$"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146 (set (make-local-variable 'sentence-end)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
147 "\\([.?!]\\|@:\\)[]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
148 (set (make-local-variable 'compile-command)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
149 (concat "scribe " (buffer-file-name))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
150
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
151 (defun scribe-tab ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
152 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
153 (insert "@\\"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
154
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
155 ;; This algorithm could probably be improved somewhat.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
156 ;; Right now, it loses seriously...
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
157
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
158 (defun scribe ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
159 "Run Scribe on the current buffer."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
160 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
161 (call-interactively 'compile))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
162
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
163 (defun scribe-envelop-word (string count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
164 "Surround current word with Scribe construct @STRING[...].
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
165 COUNT specifies how many words to surround. A negative count means
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
166 to skip backward."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
167 (let ((spos (point)) (epos (point)) (ccoun 0) noparens)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
168 (if (not (zerop count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
169 (progn (if (= (char-syntax (preceding-char)) ?w)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
170 (forward-sexp (min -1 count)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
171 (setq spos (point))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
172 (if (looking-at (concat "@\\w[" scribe-open-parentheses "]"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
173 (forward-char 2)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
174 (goto-char epos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
175 (skip-chars-backward "\\W")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
176 (forward-char -1))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
177 (forward-sexp (max count 1))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
178 (setq epos (point))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
179 (goto-char spos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
180 (while (and (< ccoun (length scribe-open-parentheses))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
181 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
182 (or (search-forward (char-to-string
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
183 (aref scribe-open-parentheses ccoun))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
184 epos t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
185 (search-forward (char-to-string
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
186 (aref scribe-close-parentheses ccoun))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
187 epos t)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
188 (setq ccoun (1+ ccoun))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
189 (if (>= ccoun (length scribe-open-parentheses))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
190 (progn (goto-char epos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
191 (insert "@end(" string ")")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
192 (goto-char spos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
193 (insert "@begin(" string ")"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
194 (goto-char epos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
195 (insert (aref scribe-close-parentheses ccoun))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
196 (goto-char spos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
197 (insert "@" string (aref scribe-open-parentheses ccoun))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
198 (goto-char epos)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
199 (forward-char 3)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
200 (skip-chars-forward scribe-close-parentheses))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
201
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
202 (defun scribe-underline-word (count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
203 "Underline COUNT words around point by means of Scribe constructs."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
204 (interactive "p")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
205 (scribe-envelop-word "u" count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
206
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
207 (defun scribe-bold-word (count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
208 "Boldface COUNT words around point by means of Scribe constructs."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
209 (interactive "p")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
210 (scribe-envelop-word "b" count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
211
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
212 (defun scribe-italicize-word (count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
213 "Italicize COUNT words around point by means of Scribe constructs."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
214 (interactive "p")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
215 (scribe-envelop-word "i" count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
216
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
217 (defun scribe-begin ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
218 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
219 (insert "\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
220 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
221 (scribe-envelop-word "Begin" 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
222 (re-search-forward (concat "[" scribe-open-parentheses "]")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
223
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
224 (defun scribe-end ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
225 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
226 (insert "\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
227 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
228 (scribe-envelop-word "End" 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
229 (re-search-forward (concat "[" scribe-open-parentheses "]")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
230
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
231 (defun scribe-chapter ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
232 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
233 (insert "\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
234 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
235 (scribe-envelop-word "Chapter" 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
236 (re-search-forward (concat "[" scribe-open-parentheses "]")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
237
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
238 (defun scribe-section ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
239 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
240 (insert "\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
241 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
242 (scribe-envelop-word "Section" 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
243 (re-search-forward (concat "[" scribe-open-parentheses "]")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
244
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
245 (defun scribe-subsection ()
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
246 (interactive)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
247 (insert "\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
248 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
249 (scribe-envelop-word "SubSection" 0)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
250 (re-search-forward (concat "[" scribe-open-parentheses "]")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
251
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
252 (defun scribe-bracket-region-be (env min max)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
253 (interactive "sEnvironment: \nr")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
254 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
255 (goto-char max)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
256 (insert "@end(" env ")\n")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
257 (goto-char min)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
258 (insert "@begin(" env ")\n")))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
259
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
260 (defun scribe-insert-environment (env)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
261 (interactive "sEnvironment: ")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
262 (scribe-bracket-region-be env (point) (point))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
263 (forward-line 1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
264 (insert ?\n)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
265 (forward-char -1))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
266
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
267 (defun scribe-insert-quote (count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
268 "Insert ``, '' or \" according to preceding character.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
269 If `scribe-electric-quote' is non-nil, insert ``, '' or \" according
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
270 to preceding character. With numeric arg N, always insert N \" characters.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
271 Else just insert \"."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
272 (interactive "P")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
273 (if (or count (not scribe-electric-quote))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
274 (self-insert-command (prefix-numeric-value count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
275 (let (lastfore lastback lastquote)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
276 (insert
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
277 (cond
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
278 ((= (preceding-char) ?\\) ?\")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
279 ((bobp) "``")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
280 (t
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
281 (setq lastfore (save-excursion (and (search-backward
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
282 "``" (- (point) 1000) t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
283 (point)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
284 lastback (save-excursion (and (search-backward
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
285 "''" (- (point) 1000) t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
286 (point)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
287 lastquote (save-excursion (and (search-backward
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
288 "\"" (- (point) 100) t)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
289 (point))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
290 (if (not lastquote)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
291 (cond ((not lastfore) "``")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
292 ((not lastback) "''")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
293 ((> lastfore lastback) "''")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
294 (t "``"))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
295 (cond ((and (not lastback) (not lastfore)) "\"")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
296 ((and lastback (not lastfore) (> lastquote lastback)) "\"")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
297 ((and lastback (not lastfore) (> lastback lastquote)) "``")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
298 ((and lastfore (not lastback) (> lastquote lastfore)) "\"")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
299 ((and lastfore (not lastback) (> lastfore lastquote)) "''")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
300 ((and (> lastquote lastfore) (> lastquote lastback)) "\"")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
301 ((> lastfore lastback) "''")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
302 (t "``")))))))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
303
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
304 (defun scribe-parenthesis (count)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
305 "If scribe-electric-parenthesis is non-nil, insertion of an open-parenthesis
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
306 character inserts the following close parenthesis character if the
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
307 preceding text is of the form @Command."
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
308 (interactive "P")
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
309 (self-insert-command (prefix-numeric-value count))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
310 (let (at-command paren-char point-save)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
311 (if (or count (not scribe-electric-parenthesis))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
312 nil
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
313 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
314 (forward-char -1)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
315 (setq point-save (point))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
316 (skip-chars-backward (concat "^ \n\t\f" scribe-open-parentheses))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
317 (setq at-command (and (equal (following-char) ?@)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
318 (/= (point) (1- point-save)))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
319 (if (and at-command
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
320 (setq paren-char
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
321 (string-match (regexp-quote
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
322 (char-to-string (preceding-char)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
323 scribe-open-parentheses)))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
324 (save-excursion
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
325 (insert (aref scribe-close-parentheses paren-char)))))))
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
326
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
327 (provide 'scribe)
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
328
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79715
diff changeset
329 ;; arch-tag: 64f454c4-7544-4ea2-9d14-f0b668f2cdc6
51342
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
330 ;;; scribe.el ends here