annotate lisp/=sc-elec.el @ 34791:88b250e19382

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Thu, 21 Dec 2000 15:58:48 +0000
parents 5180778aedcb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1744
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; -*- Mode: Emacs-Lisp -*-
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; sc-elec.el -- Version 2.3
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; ========== Introduction ==========
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; This file contains sc-electric mode for viewing reference headers.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; It is loaded automatically by supercite.el when needed.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; ========== Disclaimer ==========
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This software is distributed in the hope that it will be useful,
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; but WITHOUT ANY WARRANTY. No author or distributor accepts
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; responsibility to anyone for the consequences of using it or for
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; whether it serves any particular purpose or works at all, unless he
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; says so in writing.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; Some of this software was written as part of the supercite author's
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; official duty as an employee of the United States Government and is
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; thus in the public domain. You are free to use that particular
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; software as you wish, but WITHOUT ANY WARRANTY WHATSOEVER. It
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; would be nice, though if when you use any of this code, you give
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; due credit to the author.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Other parts of this code were written by other people. Wherever
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; possible, credit to that author, and the copy* notice supplied by
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; the author are included with that code. In all cases, the spirit,
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; if not the letter of the GNU General Public Licence applies.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; ========== Author (unless otherwise stated) ==========
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; NAME: Barry A. Warsaw USMAIL: Century Computing, Inc.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; TELE: (301) 593-3330 1014 West Street
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; UUCP: uunet!cen.com!bwarsaw Laurel, MD 20707
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; INET: bwarsaw@cen.com
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; Want to be on the Supercite mailing list?
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Send articles to:
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; INET: supercite@anthem.nlm.nih.gov
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; UUCP: uunet!anthem.nlm.nih.gov!supercite
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; Send administrivia (additions/deletions to list, etc) to:
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; INET: supercite-request@anthem.nlm.nih.gov
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; UUCP: uunet!anthem.nlm.nih.gov!supercite-request
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (provide 'sc-elec)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; ======================================================================
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; set up vars for major mode
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (defconst sc-electric-bufname "*sc-erefs*"
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 "*Supercite's electric buffer name.")
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defvar sc-electric-mode-hook nil
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 "*Hook for sc-electric-mode.")
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; ======================================================================
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; sc-electric-mode
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (defun sc-electric-mode (&optional arg)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 "Quasi major mode for viewing supercite reference headers.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 Commands are: \\{sc-electric-mode-map}
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 Sc-electric-mode is not intended to be run interactively, but rather
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 accessed through supercite's electric reference feature. See
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 sc-insert-reference for more details. Optional ARG is the initial
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 header style to use, unless not supplied or invalid, in which case
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 sc-preferred-header-style is used."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (let ((gal sc-gal-information)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (sc-eref-style (if arg ;; assume passed arg is okay
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 arg
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (if (and (natnump sc-preferred-header-style)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (sc-valid-index-p sc-preferred-header-style))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 sc-preferred-header-style
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 0))))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (get-buffer-create sc-electric-bufname)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; set up buffer and enter command loop
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (save-excursion
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (save-window-excursion
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (pop-to-buffer sc-electric-bufname)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (kill-all-local-variables)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (setq sc-gal-information gal
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 buffer-read-only t
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 mode-name "Supercite-Electric-References"
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 major-mode 'sc-electric-mode)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (use-local-map sc-electric-mode-map)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (sc-eref-show sc-eref-style)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (run-hooks 'sc-electric-mode-hook)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (recursive-edit)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (if sc-eref-style
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (condition-case nil
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (eval (nth sc-eref-style sc-rewrite-header-list))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (error nil)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; now restore state
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (kill-buffer sc-electric-bufname)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; ======================================================================
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; functions for electric mode
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (defun sc-eref-index (index)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 "Check INDEX to be sure it is a valid index into sc-rewrite-header-list.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 If sc-electric-circular-p is non-nil, then list is considered circular
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 so that movement across the ends of the list wraparound."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (let ((last (1- (length sc-rewrite-header-list))))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (cond ((sc-valid-index-p index) index)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ((< index 0)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (if sc-electric-circular-p last
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (progn (error "No preceding reference headers in list.") 0)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ((> index last)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (if sc-electric-circular-p 0
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (progn (error "No following reference headers in list.") last)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 )
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (defun sc-eref-show (index)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 "Show reference INDEX in sc-rewrite-header-list."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (setq sc-eref-style (sc-eref-index index))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (save-excursion
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (set-buffer sc-electric-bufname)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (let ((ref (nth sc-eref-style sc-rewrite-header-list))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (buffer-read-only nil))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (erase-buffer)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (goto-char (point-min))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (condition-case err
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (progn
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (set-mark (point-min))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (eval ref)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (message "Showing reference header %d." sc-eref-style)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (goto-char (point-max))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 )
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (void-function
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (progn (message
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "Symbol's function definition is void: %s (Header %d)"
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (symbol-name (car (cdr err)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 sc-eref-style)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (beep)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ))))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; ======================================================================
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; interactive commands
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (defun sc-eref-next ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "Display next reference in other buffer."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (sc-eref-show (1+ sc-eref-style)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (defun sc-eref-prev ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 "Display previous reference in other buffer."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (sc-eref-show (1- sc-eref-style)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (defun sc-eref-setn ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 "Set reference header selected as preferred."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (setq sc-preferred-header-style sc-eref-style)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (message "Preferred reference style set to header %d." sc-eref-style))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (defun sc-eref-goto (refnum)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 "Show reference style indexed by REFNUM.
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 If REFNUM is an invalid index, don't go to that reference and return
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 nil."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (interactive "NGoto Reference: ")
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (if (sc-valid-index-p refnum)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (sc-eref-show refnum)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (error "Invalid reference: %d. (Range: [%d .. %d])"
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 refnum 0 (1- (length sc-rewrite-header-list)))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (defun sc-eref-jump ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 "Set reference header to preferred header."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (sc-eref-show sc-preferred-header-style))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (defun sc-eref-abort ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 "Exit from electric reference mode without inserting reference."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (setq sc-eref-style nil)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (exit-recursive-edit))
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (defun sc-eref-exit ()
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 "Exit from electric reference mode and insert selected reference."
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (interactive)
5180778aedcb entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (exit-recursive-edit))