Mercurial > emacs
annotate lisp/textmodes/bib-mode.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | 213978acbc1e |
| children | 10e417efb12a |
| rev | line source |
|---|---|
|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; bib-mode.el --- bib-mode, major mode for editing bib files. |
|
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
| 845 | 3 ;; Copyright (C) 1989 Free Software Foundation, Inc. |
| 4 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
5 ;; Maintainer: FSF |
|
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
6 ;; Keywords: bib |
|
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
7 |
| 187 | 8 ;; This file is part of GNU Emacs. |
| 9 | |
| 10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 11 ;; it under the terms of the GNU General Public License as published by | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
| 187 | 13 ;; any later version. |
| 14 | |
| 15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 ;; GNU General Public License for more details. | |
| 19 | |
| 20 ;; You should have received a copy of the GNU General Public License | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
24 ;;; Code: |
| 187 | 25 |
| 26 ;; Bib-Mode | |
| 27 ;; GNU Emacs code to help maintain databases compatible with (troff) | |
| 28 ;; refer and lookbib. The file bib-file should be set to your | |
| 29 ;; bibliography file. Keys are automagically inserted as you type, | |
| 30 ;; and appropriate keys are presented for various kinds of entries. | |
| 31 | |
| 32 (defvar bib-file "~/my-bibliography.bib" | |
| 33 "Default name of file used by `addbib'.") | |
| 34 | |
| 35 (defvar unread-bib-file "~/to-be-read.bib" | |
| 36 "Default name of file used by `unread-bib' in Bib mode.") | |
| 37 | |
| 38 (defvar bib-mode-map (copy-keymap text-mode-map)) | |
| 39 (define-key bib-mode-map "\C-M" 'return-key-bib) | |
| 40 (define-key bib-mode-map "\C-c\C-u" 'unread-bib) | |
| 41 (define-key bib-mode-map "\C-c\C-@" 'mark-bib) | |
| 42 (define-key bib-mode-map "\e`" 'abbrev-mode) | |
| 43 (defvar bib-mode-abbrev-table nil | |
| 44 "Abbrev table used in Bib mode") | |
| 45 | |
| 46 (defun addbib () | |
| 47 "Set up editor to add to troff bibliography file specified | |
| 48 by global variable `bib-file'. See description of `bib-mode'." | |
| 49 (interactive) | |
| 50 (find-file bib-file) | |
| 51 (goto-char (point-max)) | |
| 52 (bib-mode) | |
| 53 ) | |
| 54 | |
| 55 (defun bib-mode () | |
| 56 "Mode for editing `lookbib' style bibliographies. | |
| 57 Hit RETURN to get next % field key. | |
| 58 If you want to ignore this field, just hit RETURN again. | |
| 59 Use `text-mode' to turn this feature off. | |
| 60 | |
| 61 journal papers: A* T D J V N P K W X | |
| 62 articles in books & proceedings: A* T D B E* I C P K W X | |
| 63 tech reports: A* T D R I C K W X | |
| 64 books: A* T D I C K W X | |
| 65 | |
| 66 Fields: | |
| 67 | |
| 68 A uthor T itle D ate J ournal | |
| 69 V olume N umber P age K eywords | |
| 70 B in book or proceedings E ditor C ity & state | |
| 71 I nstitution, school, or publisher | |
| 72 R eport number or 'phd thesis' or 'masters thesis' or 'draft' or | |
| 73 'unnumbered' or 'unpublished' | |
| 74 W here can be found locally (login name, or ailib, etc.) | |
| 75 X comments (not used in indexing) | |
| 76 | |
| 77 \\[unread-bib] appends current entry to a different file (for example, | |
| 78 a file of papers to be read in the future), given by the value of the | |
| 79 variable `unread-bib-file'. | |
| 80 \\[mark-bib] marks current or previous entry. | |
| 81 Abbreviations are saved in `bib-mode-abbrev-table'. | |
| 82 Hook can be stored in `bib-mode-hook'. | |
| 83 Field keys given by variable `bib-assoc'. | |
| 84 | |
| 85 Commands: | |
| 86 \\{bib-mode-map} | |
| 87 " | |
| 88 (interactive) | |
| 89 (text-mode) | |
| 90 (use-local-map bib-mode-map) | |
| 91 (setq mode-name "Bib") | |
| 92 (setq major-mode 'bib-mode) | |
| 93 (define-abbrev-table 'bib-mode-abbrev-table ()) | |
| 94 (setq local-abbrev-table bib-mode-abbrev-table) | |
| 95 (abbrev-mode 1) | |
| 96 (run-hooks 'bib-mode-hook) | |
| 97 ) | |
| 98 | |
| 99 (defconst bib-assoc '( | |
| 100 (" *$" . "%A ") | |
| 101 ("%A ." . "%A ") | |
| 102 ("%A $" . "%T ") | |
| 103 ("%T " . "%D ") | |
| 104 ("%D " . "%J ") | |
| 105 ("%J ." . "%V ") | |
| 106 ("%V " . "%N ") | |
| 107 ("%N " . "%P ") | |
| 108 ("%P " . "%K ") | |
| 109 ("%K " . "%W ") | |
| 110 ("%W " . "%X ") | |
| 111 ("%X " . "") | |
| 112 ("%J $" . "%B ") | |
| 113 ("%B ." . "%E ") | |
| 114 ("%E ." . "%E ") | |
| 115 ("%E $" . "%I ") | |
| 116 ("%I " . "%C ") | |
| 117 ("%C " . "%P ") | |
| 118 ("%B $" . "%R ") | |
| 119 ("%R " . "%I ") | |
| 120 ) | |
| 121 | |
| 122 "Describes bibliographic database format. A line beginning with | |
| 123 the car of an entry is followed by one beginning with the cdr. | |
| 124 ") | |
| 125 | |
| 126 (defun bib-find-key (slots) | |
| 127 (cond | |
| 128 ((null slots) | |
| 129 (if (bobp) | |
| 130 "" | |
| 131 (progn (previous-line 1) (bib-find-key bib-assoc)))) | |
| 132 ((looking-at (car (car slots))) | |
| 133 (cdr (car slots))) | |
| 134 (t (bib-find-key (cdr slots))) | |
| 135 )) | |
| 136 | |
| 137 | |
| 138 (defvar bib-auto-capitalize t | |
| 139 "*True to automatically capitalize appropriate fields in Bib mode.") | |
| 140 | |
| 141 (defconst bib-capitalized-fields "%[AETCBIJR]") | |
| 142 | |
| 143 (defun return-key-bib () | |
| 144 "Magic when user hits return, used by `bib-mode'." | |
| 145 (interactive) | |
| 146 (if (eolp) | |
| 147 (let (empty new-key beg-current end-current) | |
| 148 (beginning-of-line) | |
| 149 (setq empty (looking-at "%. $")) | |
| 150 (if (not empty) | |
| 151 (progn | |
| 152 (end-of-line) | |
| 153 (newline) | |
| 154 (forward-line -1) | |
| 155 )) | |
| 156 (end-of-line) | |
| 157 (setq end-current (point)) | |
| 158 (beginning-of-line) | |
| 159 (setq beg-current (point)) | |
| 160 (setq new-key (bib-find-key bib-assoc)) | |
| 161 (if (and (not empty) bib-auto-capitalize | |
| 162 (looking-at bib-capitalized-fields)) | |
| 163 (save-excursion | |
| 164 (capitalize-title-region (+ (point) 3) end-current))) | |
| 165 (goto-char beg-current) | |
| 166 (if empty | |
| 167 (kill-line nil) | |
| 168 (forward-line 1) | |
| 169 ) | |
| 170 (insert-string new-key)) | |
| 171 (newline))) | |
| 172 | |
| 173 (defun mark-bib () | |
| 174 "Set mark at beginning of current or previous bib entry, point at end." | |
| 175 (interactive) | |
| 176 (beginning-of-line nil) | |
| 177 (if (looking-at "^ *$") (re-search-backward "[^ \n]" nil 2)) | |
| 178 (re-search-backward "^ *$" nil 2) | |
| 179 (re-search-forward "^%") | |
| 180 (beginning-of-line nil) | |
| 181 (push-mark (point)) | |
| 182 (re-search-forward "^ *$" nil 2) | |
| 183 (next-line 1) | |
| 184 (beginning-of-line nil)) | |
| 185 | |
| 186 (defun unread-bib () | |
| 187 "Append current or previous entry to file of unread papers | |
| 188 named by variable `unread-bib-file'." | |
| 189 (interactive) | |
| 190 (mark-bib) | |
| 191 (if (get-file-buffer unread-bib-file) | |
| 192 (append-to-buffer (get-file-buffer unread-bib-file) (mark) (point)) | |
| 193 (append-to-file (mark) (point) unread-bib-file))) | |
| 194 | |
| 195 | |
| 196 (defvar capitalize-title-stop-words | |
| 197 (concat | |
| 198 "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|" | |
| 199 "by\\|with\\|that\\|its") | |
| 200 "Words not to be capitialized in a title (unless they're the first word | |
| 201 in the title).") | |
| 202 | |
| 203 (defvar capitalize-title-stop-regexp | |
| 204 (concat "\\(" capitalize-title-stop-words "\\)\\(\\b\\|'\\)")) | |
| 205 | |
| 206 (defun capitalize-title-region (begin end) | |
| 207 "Like `capitalize-region', but don't capitalize stop words, except the first." | |
| 208 (interactive "r") | |
| 209 (let ((case-fold-search nil) (orig-syntax-table (syntax-table))) | |
| 210 (unwind-protect | |
| 211 (save-restriction | |
| 212 (set-syntax-table text-mode-syntax-table) | |
| 213 (narrow-to-region begin end) | |
| 214 (goto-char (point-min)) | |
| 215 (if (looking-at "[A-Z][a-z]*[A-Z]") | |
| 216 (forward-word 1) | |
| 217 (capitalize-word 1)) | |
| 218 (while (re-search-forward "\\<" nil t) | |
| 219 (if (looking-at "[A-Z][a-z]*[A-Z]") | |
| 220 (forward-word 1) | |
| 221 (if (let ((case-fold-search t)) | |
| 222 (looking-at capitalize-title-stop-regexp)) | |
| 223 (downcase-word 1) | |
| 224 (capitalize-word 1))) | |
| 225 )) | |
| 226 (set-syntax-table orig-syntax-table)))) | |
| 227 | |
| 228 | |
| 229 (defun capitalize-title (s) | |
| 230 "Like `capitalize', but don't capitalize stop words, except the first." | |
| 231 (save-excursion | |
| 232 (set-buffer (get-buffer-create "$$$Scratch$$$")) | |
| 233 (erase-buffer) | |
| 234 (insert s) | |
| 235 (capitalize-title-region (point-min) (point-max)) | |
| 236 (buffer-string))) | |
| 584 | 237 |
| 238 (provide 'bib-mode) | |
| 239 | |
|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
240 ;;; bib-mode.el ends here |
