forked from emacsmirror/auctex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bib-cite.el
2334 lines (2175 loc) · 103 KB
/
bib-cite.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file. -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1999, 2001, 2003-2005, 2014-2022 Free Software Foundation, Inc.
;; Author: Peter S. Galbraith <[email protected]>
;; Created: 06 July 1994
;; Version: 3.28 (Feb 23 2005)
;; Keywords: bibtex, cite, auctex, emacs
;;; This file is not part of GNU Emacs.
;; This package is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This package is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;; LCD Archive Entry:
;; bib-cite|Peter Galbraith|[email protected]|
;; Display \cite, \ref or \label / Extract refs from BiBTeX file.|
;; 21-May-1997|3.01|~/misc/bib-cite.el.gz|
;; ----------------------------------------------------------------------------
;;; Commentary:
;; This minor-mode is used in various TeX modes to display or edit references
;; associated with \cite commands, or matching \ref and \label commands.
;; New versions of this package (if they exist) may be found at:
;; https://people.debian.org/~psg/elisp/bib-cite.el
;; and in AUCTeX's Git archive at
;; https://git.savannah.gnu.org/cgit/auctex.git
;; Operating Systems:
;; Works in unix, DOS and OS/2. Developped under Linux.
;; AUCTeX users:
;; AUCTeX is a super-charged LaTeX mode for emacs. Get it at:
;;
;; https://ftp.gnu.org/pub/gnu/auctex/
;;
;; WWW users may want to check out the AUCTeX page at
;; https://www.gnu.org/software/auctex/
;;
;; bib-cite.el is included in the AUCTeX distribution. Therefore, if
;; you use AUCTeX and didn't obtained bib-cite.el separately, make sure
;; that you are actually using the more recent version.
;; RefTeX users:
;; RefTeX is a package with similar functions to bib-cite.
;; http://www.astro.uva.nl/~dominik/Tools/reftex/
;; RefTeX is bundled and preinstalled with Emacs since version 20.2.
;; It was also bundled with XEmacs 19.16--20.x.
;;
;; I suggest that you use RefTeX to help you type-in text as it's functions
;; are better suited to this task than bib-cite, and use bib-cite's features
;; when you proof-read the text.
;; If you wish bib-cite to use RefTeX's reftex-view-crossref command to
;; display and find \label's and \cite bibliography entries, set the variable
;; bib-cite-use-reftex-view-crossref to t.
;; MS-DOS users:
;; Multifile documents are supported by bib-cite by using etags (TAGS files)
;; which contains a bug for MSDOS (at least for emacs 19.27 it does).
;; Get the file
;; https://people.debian.org/~psg/elisp/bib-cite.etags-bug-report
;; to see what patches to make to etags.c to fix it.
;; Description:
;; ~~~~~~~~~~~
;; This package is used in various TeX modes to display or edit references
;; associated with \cite commands, or matching \eqref, \ref and \label
;; commands (so I actually overstep BiBTeX bounds here...).
;;
;; These are the functions:
;;
;; bib-display bib-display-mouse
;; - Display citation, \ref or \label under point
;; bib-find bib-find-mouse
;; - Edit citation, \ref or \label under point
;; bib-find-next - Find next occurrence of a \ref or \eqref
;; bib-make-bibliography - Make BiBTeX file containing only cite keys used.
;; bib-apropos - Search BiBTeX source files for keywords.
;; bib-etags - Refreshes (or builds) the TAGS files for
;; multi-file documents.
;; bib-create-auto-file - Used in bibtex-mode to create cite key
;; completion .el file for AUCTeX.
;; bib-highlight-mouse - Highlight \cite, \ref and \label commands in
;; green when the mouse is over them.
;; About Cite Commands and related functions:
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; Various flavors of \cite commands are allowed (as long as they contain
;; the word `cite') and they may optionally have bracketed [] options.
;; Bibtex Cross-references are displayed, and @string abbreviations are
;; substituted or included.
;;
;; The \cite text is found (by emacs) in the bibtex source files listed in the
;; \bibliography command. The BiBTeX files can be located in a search path
;; defined by an environment variable (typically BIBINPUTS, but you can change
;; this).
;;
;; All citations used in a buffer can also be listed in a new bibtex buffer by
;; using bib-make-bibliography. This is useful to make a bibtex file for a
;; document from a large bibtex database. In this case, cross-references are
;; included, as well as the @string commands used. The @string abbreviations
;; are not substituted.
;;
;; The bibtex files can also be searched for entries matching a regular
;; expression using bib-apropos.
;; Usage instructions:
;; ~~~~~~~~~~~~~~~~~~
;; bib-display Bound to Mouse-3 when specially highlighted.
;; In Hyperbole, bound to the Assist key.
;; Bound to `\C-c b d'
;;
;; bib-display will show the bibtex entry or the corresponding label or
;; ref commands from anywhere within a document.
;; With cursor on the \cite command itslef
;; -> display all citations of the cite command from the BiBTeX source.
;; With cursor on a particular cite key within the brackets
;; -> display that citation's text from the BiBTeX source file(s).
;;
;; Example:
;;
;; \cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94}
;; ^Cursor -> Display-all-citations ^Cursor -> Display-this-citation
;;
;; With cursor on a \label command
;; -> Display first matching \ref command in the document
;; With cursor on a \ref command
;; -> Display environment associated with the matching \label command.
;;
;; Finding a ref or label within a multi-file document requires a TAGS file,
;; which is automatically generated for you. This enables you to then use
;; any tags related emacs features.
;;
;; bib-find Bound to Mouse-2 when specially highlighted.
;; In Hyperbole, bound to the Action key.
;; Bound to `\C-c b f'
;;
;; bib-find will select the buffer and move point to the BiBTeX source file
;; at the proper citation for a cite command, or move point to anywhere
;; within a document for a label or ref command. The ref chosen is the
;; first occurrance within a document (using a TAGS file). If point is
;; moved within the same buffer, mark is set before the move and a message
;; stating so is given. If point is moved to another file, this is done in
;; a new window using tag functions.
;;
;; The next occurrence of a \ref or \eqref command may be found by invoking
;; bib-find-next, usually bound to `C-c b n'.
;;
;; For multi-file documents, you must be using AUCTeX (so that bib-cite can
;; find the master file) and all \input and \include commands must be first
;; on a line (not preceeded by any non-white text).
;;
;; bib-make-bibliography: Bound to `\C-c b m'
;;
;; Extract citations used in the current document from the \bibliography{}
;; file(s). Put them into a new suitably-named buffer. In a AUCTeX
;; multi-file document, the .aux files are used to find the cite keys (for
;; speed). You will be warned if these are out of date.
;;
;; This buffer is not saved to a file. It is your job to save it to whatever
;; name you wish. Note that AUCTeX has a unique name space for LaTeX and
;; BiBTeX files, so you should *not* name the bib file associated with
;; example.tex as example.bib! Rather, name it something like
;; example-bib.bib.
;;
;; bib-apropos: Bound to `\C-c b a'
;;
;; Searches the \bibliography{} file(s) for entries containing a keyword and
;; display them in the *help* buffer. You can trim down your search by using
;; bib-apropos in the *Help* buffer after the first invocation. the current
;; buffer is also searched for keyword matches if it is in bibtex-mode.
;;
;; It doesn't display cross-references nor does it substitute or display
;; @string commands used. It could easily be added, but it's faster this
;; way. Drop me a line if this would be a useful addition.
;;
;; If you find yourself entering a cite command and have forgotten which key
;; you want, but have entered a few initial characters as in `\cite{Gal',
;; then invoke bib-apropos. It will take that string (in this case `Gal') as
;; an initial response to the apropos prompt. You are free to edit it, or
;; simply press carriage return.
;;
;; bib-etags: Bound to `\C-c b e'
;;
;; Creates a TAGS file for AUCTeX's multi-file document (or refreshes it).
;; This is used by bib-find when editing multi-file documents. The TAGS file
;; is created automatically, but it isn't refreshed automatically. So if
;; bib-find can't find something, try running bib-etags again.
;;
;; bib-create-auto-file:
;;
;; Use this when editing a BiBTeX buffer to generate the AUCTeX .el file
;; which tell emacs about all its cite keys. I've added this command to
;; bibtex-mode pull-down menu.
;;
;; bib-highlight-mouse: Bound to `\C-c b h'
;;
;; Highlights \cite, \ref and \label commands in green when the mouse is over
;; them. By default, a call to this function is added to LaTeX-mode-hook
;; (via bib-cite-initialize) if you set bib-highlight-mouse-t to true. But
;; you may want to run this command to refresh the highlighting for newly
;; edited text.
;; Installation instructions:
;; ~~~~~~~~~~~~~~~~~~~~~~~~~
;; bib-cite is a minor-mode, so you could invoke it in a LaTeX-mode hook.
;; e.g. If you are using AUCTeX (https://www.gnu.org/software/auctex/), you
;; could use:
;;
;; (autoload 'turn-on-bib-cite "bib-cite")
;; (add-hook 'LaTeX-mode-hook 'turn-on-bib-cite)
;;
;; If you are using Emacs' regular LaTeX-mode, use instead:
;;
;; (autoload 'turn-on-bib-cite "bib-cite")
;; (add-hook 'latex-mode-hook 'turn-on-bib-cite)
;;
;; bib-cite can be used with AUCTeX, or stand-alone. If used with AUCTeX on a
;; multi-file document (and AUCTeX's parsing is used), then all \bibliography
;; commands in the document will be found and used.
;; ---
;; The following variable can be unset (like shown) to tell bib-cite to
;; not give advice messages about which commands to use to find the next
;; occurrence of a search:
;;
;; (setq bib-novice nil)
;; ---
;; If you wish bib-cite to use RefTeX's reftex-view-crossref command to
;; display and find \label's and \cite bibliography entries, set the variable
;; bib-cite-use-reftex-view-crossref to t:
;;
;; (setq bib-cite-use-reftex-view-crossref t)
;; ---
;; The following variable determines whether we will attempt to highlight
;; citation, ref and label commands in green when they are under the
;; mouse. When highlighted, the mouse keys work to call bib-display
;; (bound to [mouse-3]) and bib-find (bound to [mouse-2]). If you use a
;; mode other than LaTeX-mode, you'll want to call bib-highlight-mouse with
;; a hook (See how we do this at the end of this file with the add-hook
;; command).
;;
;; (setq bib-highlight-mouse-t nil)
;; ---
;; The variable bib-switch-to-buffer-function sets the function used to
;; select buffers (if they differ from the original) in bib-cite commands
;; bib-make-bibliography, bib-display, bib-find
;; You may use `switch-to-buffer' `switch-to-buffer-other-window' or
;; `switch-to-buffer-other-frame'.
;; ---
;; If you use DOS or OS/2, you may have to set the following variable:
;;
;; (setq bib-dos-or-os2-variable t)
;;
;; if bib-cite.el fails to determine that you are using DOS or OS/2.
;; Try `C-h v bib-dos-or-os2-variable' to see if it needs to be set manually.
;; ---
;; bib-cite needs to call the etags program with its output file option
;; and also with the append option (usually -a).
;; I figured that DOS and OS/2 would use "etags /o=" instead of the unix
;; variant "etags -o ", but users have reported differently. So while the
;; unix notation is used here, you can reset it if you need to like so:
;;
;; (setq bib-etags-command "etags /r='/.*\\\(eq\|page\|[fvF]\)ref.*/' /o=")
;; (setq bib-etags-append-command
;; "etags /r='/.*\\\(eq\|page\|[fvF]\)ref.*/' /a /o=")
;; ---
;; For multi-file documents, a TAGS file is generated by etags.
;; By default, its name is TAGS. You can change this like so:
;;
;; (setq bib-etags-filename "TAGSLaTeX")
;; ---
;; If your environment variable to find BiBTeX files is not BIBINPUTS, then
;; reset it with the following variable (here, assuming it's TEXBIB instead):
;;
;; (setq bib-bibtex-env-variable "TEXBIB")
;;
;; Note that any directory ending in a double slash will cause bib-cite to
;; search recursively through subdirectories for your .bib files. This can
;; be slow, so use this judiciously.
;; e.g. setenv BIBINPUTS .:/home/psg/LaTeX/bibinputs//
;; -> all directories below /home/psg/LaTeX/bibinputs/ will be
;; searched.
;;
;; If your bibtex setup works but Emacs can't see the environment variable
;; correctly (Check `C-h v process-environment'), then customize the
;; variable `bib-cite-inputs' (e.g. `M-x customize-variable bib-cite-imputs')
;;
;; ---
;; If you do not wish bib-display to substitute @string abbreviations,
;; then set the following variable like so:
;;
;; (setq bib-substitute-string-in-display nil)
;; ---
;; Warnings are given when @string abbreviations are not defined in your bib
;; files. The exception is for months, usually defined in style files. If you
;; use other definitions in styles file (e.g. journals), then you may add them
;; to the `bib-substitute-string-in-display' list variable.
;; If you find circumstances in which this package fails, please let me know.
;; Things for me to do in later versions:
;; - treat @Strings correctly, not just in isolation.
;; - use `kpsewhich -expand-path='$BIBINPUTS'` instead of BIBINPUTS.
;; - [email protected] (Jose Manuel Valenca) wants:
;; - prompt for \cite as well as \label and \ref
;; (and use AUCTeX's completion list)
;; - implement string concatenation, with #[ \t\n]*STRING_NAME
;; - Create new command to substitute @string text in any bibtex buffer.
;; ----------------------------------------------------------------------------
;;; Change log:
;; V3.28 Feb 23 2005 - Ralf Angeli
;; - Some doc fixes in the commentary section.
;; V3.27 Feb 09 2005 - PSG
;; - Patch from Peter Heslin. TeX-master can now have symbol values.
;; V3.26 Aug 06 2004 - Reiner Steib
;; - Changed URL of AUCTeX. Use "AUCTeX", not "auc-tex" (skipped Change log).
;; V3.25 Feb 15 2004 - PSG
;; - Check existence of font-lock-unset-defaults; no longer defined in CVS
;; Emacs. Thanks to Adrian Lanz for reporting the problem.
;; V3.24 Oct 28 2003 - PSG
;; - bib-cite-file-directory-p: new function to replace ff-paths code.
;; V3.23 Oct 09 2003 - PSG
;; - some checkdoc cleanup; not yet complete.
;; V3.22 Sep 17 2003 - PSG
;; - bib-cite-aux-inputs: new defcustom.
;; - minor cleanup for `match-string'.
;; V3.21 Sep 08 2003 - PSG
;; - Ripping out off-topic imenu code.
;; V3.20 Aug 14 2003 - PSG
;; - psg-checkfor-file-list: Allow for relative directoties as entries in
;; BIBINPUTS.
;; - bib-cite-inputs: new defcustom equivalent to BIBINPUTS.
;; - bib-label-help-echo-format: fixed defcustom.
;; - psg-list-env: code cleanup.
;; - trailing whitespace cleanup.
;; V3.19 Apr 06 2003 - PSG
;; Remove code that ran when defcustom not present.
;; Remove hilit19 obsolete code.
;; V3.18 Mar 27 2003 - Bruce Ravel <[email protected]>
;; Play well with the varioref and fancyref latex styles (vref, fref, Fref).
;; V3.17 May 01 2001 - (RCS V1.38)
;; - XEmacs has imenu after all.
;; V3.16 Dec 20 99 - (RCS V1.37)
;; - Added customize support.
;; V3.15 Dec 20 99 - (RCS V1.36)
;; - Removed stupid debugging code that I had left in.
;; V3.14 Dec 20 99 -
;; - New variable bib-ref-regexp for \ref regexp to match \label constructs
;; and added \pageref. (RCS V1.34)
;; - Edited bib-etags-command snd bib-etags-append-command to match.
;; V3.13 Dec 20 99 - (RCS V1.32)
;; - License changed to GPL.
;; - Kai Engelhardt <[email protected]> bib-master-file takes .ltx extension
;; - imenu--create-LaTeX-index-for-document and bib-document-TeX-files
;; edited to accept .ltx extension.
;; - Michael Steiner <[email protected]> added journals to @string
;; abbrevs and contributed `member-cis' to complaces @strings in a
;; case-insensitive manner.
;; V3.12 Dec 10 98 - Bruce Ravel <[email protected]> (RCS V1.30)
;; Fixed bib-label-help.
;; V3.11 Oct 06 98 - PSG (RCS V1.29)
;; Quote \ character fot replace-match;
;; Applies to: @String{JGR = "J. Geophys.\ Res."}
;; V3.10 Sep 21 98 - Matt Hodges <[email protected]> (RCS V1.28)
;; Removed instance of expand-file-name due to new behaviour in Emacs-20.3.
;; V3.09 Sep 09 98 - PSG (RCS V1.27)
;; Added support for \eqref; Added bib-find-next.
;; V3.08 Aug 20 98 - PSG (RCS V1.26)
;; Fixed imenu bug (prev-pos (point-max))
;; V3.07 Nov 20 97 - Christoph Wedler <[email protected]> (RCS V1.24)
;; bib-ext-list variable made permanent-local, otherwise VC registration
;; would use two extents for each reference etc. This was not a visible bug.
;; V3.06 Nov 12 97 - PSG (RCS V1.23)
;; Support use of reftex's reftex-view-crossref command.
;; V3.05 Nov 12 97 - Vladimir Alexiev <[email protected]> (RCS V1.22)
;; regexp-quote the bibliography keys so a key like galbraith+kelley97 works
;; V3.04 Aug 25 97 - Christoph Wedler <[email protected]> (RCS V1.20)
;; (bib-highlight-mouse): Would bug out on detached extents,
;; e.g. when killing a whole citation.
;; V3.03 Jul 16 97 - Christoph Wedler <[email protected]> (RCS V1.18)
;; turn-on-bib-cite back to non-interactive.
;; V3.02 Jul 11 97 - Christoph Wedler <[email protected]> (RCS V1.17)
;; * auctex/bib-cite.el (turn-on-bib-cite): Make interactive.
;; Argument to `bib-cite-minor-mode' is 1.
;; (bib-label-help-echo-format): New variable.
;; (bib-label-help-echo): New function.
;; (bib-label-help): Addition argument format.
;; (bib-highlight-mouse): Set extent property `help-echo' for XEmacs.
;; V3.01 May 22 97 - Diego Calvanese <[email protected]> (RCS V1.16)
;; bib-make-bibliography handles commas separated citations in aux files.
;; V3.00 May 16 97 - Peter Galbraith (RCS V1.15)
;; bib-cite is now a minor mode.
;; V2.32 Apr 30 97 - Anders Stenman <[email protected]> (RCS V1.14)
;; - Support for balloon-help.
;; V2.31 Mar 20 97 - Christoph Wedler <[email protected]> (RCS V1.12)
;; - Better fontification of help buffer as bibtex or latex for XEmacs.
;; V2.30 Feb 10 97 - Peter Galbraith (RCS V1.11)
;; - Better fontification of help buffer as bibtex or latex.
;; V2.29 Jan 29 97 - Peter Galbraith (RCS V1.10)
;; - imenu looks for `\label{stuff}' instead of `\label'
;; V2.28 Jan 22 97 - Peter Galbraith (RCS V1.9)
;; - Bug in bib-create-auto-file.
;; V2.27 Dec 31 96 - Peter Galbraith (RCS V1.8)
;; - allow spaces between cite keys.
;; - Vladimir Alexiev <[email protected]>
;; Allow () delimiters as well as {}.
;; Better check on bibtex-menu
;; Erase *bibtex-bibliography* buffer.
;; V2.26 Sep 24 96 - Peter Galbraith (RCS V1.7)
;; imenu bug fix.
;; V2.25 Sep 23 96 - Anders Stenman <[email protected]> (RCS V1.6)
;; XEmacs bib-cite-fontify-help-as-latex bug fix.
;; V2.24 Aug 19 96 - Peter Galbraith (RCS V1.3)
;; XEmacs bug fix, minor defvars - Vladimir Alexiev <[email protected]>
;; V2.23 Aug 13 96 - Peter Galbraith (RCS V1.2)
;; XEmacs - Add bib-cite entries to bibtex-mode popup menu.
;; V2.22 July 22 96 - Peter Galbraith (RCS V1.1)
;; local-map has `m' for bib-make-bibliography instead of `b'
;; set-buffer-menubar in XEmacs so that menu disappears after use.
;; V2.21 July 12 96 - Peter Galbraith
;; Define `\C-c b' keymap for both plain tex and auctex, in XEmacs and emacs.
;; Separate menu-bar menu in gnu emacs.
;; font-lock support for bib-display'ed citations (bibtex fontification)
;; and for matching \ref{} and \labels (latex fontification).
;; buffer-substring-no-properties in bib-apropos
;; (bug in completing-read with mouse faces)
;; imenu-sort-function made local and nil.
;; imenu--LaTeX-name-and-position fixed for section name containing "\"
;; Various other things... (whitespace within label strings, etc...)
;; V2.20 June 25 96 - Peter Galbraith
;; imenu fixed for emacs-19.31.
;; V2.19 May 13 96
;; PSG:
;; - @string substitution fixed; bib-edit-citation fixed when buffer exists;
;; Christoph Wedler <[email protected]>:
;; - Added bib-switch-to-buffer-function
;; - (setq tags-always-exact nil) for xemacs
;; - removed eval-after-load foe xemacs
;; V2.18 May 06 96 - PSG
;; New eval-after-load from Fred Devernay <[email protected]>
;; V2.17 May 03 96 - PSG
;; Fixed bug introduced in V2.16, reported by Dennis Dams <[email protected]>
;; V2.16 May 02 96 - Vladimir Alexiev <[email protected]>
;; - somewhat compatible with Hyperbole by binding bib-find and bib-display to
;; the Action and Assist keys inside the bib-highlight-mouse-keymap.
;; - makes more liberal provisions for users with a tty.
;; V2.15 Apr 09 96 -
;; - fix "Buffer read-only" error caused by mouse-face text properties
;; patch by Piet van Oostrum <[email protected]>
;; - Use tmm non-X menu, patch by Vladimir Alexiev <[email protected]>
;; - input{file.txt} would not work.
;; bug report: David Kastrup <[email protected]>
;; V2.14 Feb 26 96 - PSG - define eval-after-load for xemacs
;; Frederic Devernay's <[email protected]> suggestion.
;; V2.13 Feb 08 96 - Peter Galbraith - Fixed recursive use of bib-apropos.
;; V2.12 Jan 19 96 - Peter Galbraith
;; emacs-19.30's [down-mouse-1] is defined (rather than [mouse-1]), so
;; bib-highlight-mouse-keymap now has [down-mouse-1] defined to override it.
;; V2.11 Nov 21 95 - Peter Galbraith
;; - Fixed bib-create-auto-file when bib file loaded before LaTeX file.
;; - Michal Mnuk's better imenu labels menu <[email protected]>
;; - [mouse-1] and [mouse-2] key defs for highlighted regions.
;; - Improve X menus.
;; - Skip over style files in bib-document-TeX-files.
;; - Add menus and mouse highlighting for xemacs
;; Anders Stenman <[email protected]> Dima Barsky <[email protected]>
;; - Check bib-use-imenu before calling LaTeX-hook-setq-imenu.
;; From: Kurt Hornik <[email protected]>
;; - Remove mouse face properties before inserting new ones.
;; From: Peter Whaite <[email protected]>
;; V2.10 Aug 17 95 - Peter Galbraith - fatal bugs in bib-make-bibliography.
;; V2.09 Jul 19 95 - Peter Galbraith
;; - Had introduced bug in search-directory-tree. synced with ff-paths.el.
;; V2.08 Jul 13 95 - Peter Galbraith
;; Fred Douglis <[email protected]> says etags should be required
;; V2.07 Jul 04 95 - Peter Galbraith
;; - Minor changes with filename manipulations (careful with DOS...)
;; - Problem if auc-tex not already loaded -> LaTeX-mode-map
;; V2.06 Jul 03 95 - Peter Galbraith - Added recursion through BIBINPUTS path.
;; V2.05 Jun 22 95 - Peter Galbraith Bug: Hanno Wirth <[email protected]>
;; bib-get-citations would truncate @String{KEY ="J. {\"u} Res."}
;; V2.04 Jun 19 95 - Peter Galbraith -
;; - use bibtex-mode syntax table in bib buffer, else bib-apropos truncates
;; an article if it contains an unbalanced closing parenthesis.
;; - bib-highlight-mouse would mark a buffer modified
;; V2.03 May 16 95 - Peter Galbraith -
;; auc-tec menu compatible with old "AUC TeX" pull-down name
;; V2.02 May 10 95 - Peter Galbraith -
;; bug report by Bodo Huckestein <[email protected]> (getenv env) under DOS
;; V2.01 Mar 27 95 - Peter Galbraith - No imenu on xemacs; check BIBINPUT also
;; V2.00 Mar 27 95 - Peter Galbraith
;; - bib-find and bib-display replace bib-edit-citation and
;; bib-display-citation
;; - bib-apropos now take initial guess from start of cite argument at point.
;; - Multi-file support for bib-make-bibliography using .aux files.
;; - \label and \ref functionality for bib-find and bib-display:
;; - \label may appear within an \begin\end or to label a (sub-)section.
;; - Cursor on \label, goto first \ref, set next i-search to pattern.
;; - Cursor on \ref, goto \label or display it's environment or section.
;; - Works on hidden code!
;; V1.08 Jan 16 95 - Peter Galbraith
;; bib-apropos can be used within *Help* buffer to trim a search.
;; V1.07 Dec 13 94 - Peter Galbraith
;; - Fixed: multi-line @string commands in non-inserted display.
;; - Fixed: quoted \ character in @string commands.
;; - BiBTeX comments should not affect bib-cite
;; - Fixed bib-apropos (from Christoph Wedler <[email protected]>)
;; Faster now, and avoids infinite loops.
;; - Added bib-edit-citation to edit a bibtex files about current citation.
;; - Allow space and newlines between citations: \cite{ entry1, entry2}
;; - Added bib-substitute-string-in-display, bib-string-ignored-warning
;; and bib-string-regexp.
;; - bib-display-citation (from Markus Stricker <[email protected]>)
;; Could not find entry with trailing spaces
;; V1.06 Nov 20 94 - Peter Galbraith
;; - Fixed bib-apropos for:
;; hilighting without invoking bibtex mode.
;; display message when no matches found.
;; would search only last bib file listed (forgot to `goto-char 1')
;; - Fixed bib-make-bibliography that would only see first citation in a
;; multi-key \cite command (found by Michail Rozman <[email protected]>
;; - bib-make-bibliography didn't see \cite[A-Z]* commands.
;; Found by Richard Stanton <[email protected]>
;; **************************************************
;; - * Completely rewritten code to support crossrefs *
;; **************************************************
;; - autodetection of OS/2 and DOS for bib-dos-or-os2-variable
;; - Created bib-display-citation-mouse
;; - bib-apropos works in bibtex-mode on the current buffer
;; - bibtex entry may have comma on next line (!)
;; @ARTICLE{Kiryati-91
;; , YEAR = {1991 }
;; ...
;; V1.05 Nov 02 94 - Peter Galbraith
;; - bug fix by [email protected] (Jan Rossmann)
;; for (boundp 'TeX-check-path) instead of fboundp. Thanks!
;; - Translate environment variable set by bib-bibtex-env-variable.
;; (suggested by Richard Stanton <[email protected]>)
;; - add bib-dos-or-os2-variable to set environment variable path separator
;; - Add key-defs for any tex-mode and auc-tex menu-bar entries.
;; [in auc-tec TeX-mode-map is common to both TeX and LaTeX at startup
;; (but TeX-mode-map is only copied to LaTeX-mode-map at initilisation)
;; in plain emacs, use tex-mode-map for both TeX and LaTeX.]
;; - Add key def for bibtex-mode to create auc-tex's parsing file.
;; - Fix bugs found by <[email protected]>
;; - fix bib-get-citation for options
;; - fix bib-get-citation for commas preceeded citation command
;; - better regexp for citations and their keys.
;; - Added @string support for any entry (not just journal entries).
;; (I had to disallow numbers in @string keys because of years.
;; Is that ok?)
;; - added bib-apropos
;; V1.04 Oct 24 94 - Peter Galbraith
;; - Don't require dired-aux, rather define the function we need from it.
;; - Regexp-quote the re-search for keys.
;; - Name the bib-make-bibliography buffer diffently than LaTeX buffer
;; because auc-tex's parsing gets confused if same name base is used.
;; V1.03 Oct 24 94 - Peter Galbraith - require dired-aux for dired-split
;; V1.02 Oct 19 94 - Peter Galbraith
;; - If using auc-tex with parsing activated, use auc-tex's functions
;; to find all \bibliography files in a multi-file document.
;; - Find bib files in pwd, BIBINPUTS environment variable path and
;; TeX-check-path elisp variable path.
;; - Have the parser ignore \bibliography that is on a commented `%' line.
;; (patched by Karl Eichwalder <[email protected]>)
;; - Allow for spaces between entry type and key in bib files:
;; (e.g @Article{ key} )
;; (suggested by Nathan E. Doss <[email protected]>)
;; - Allows options in \cite command (e.g. agu++ package \cite[e.g.][]{key})
;; - Includes @String{} abbreviations for `journal' entries
;; V1.01 July 07 94 - Peter Galbraith - \bibliography command may have list of
;; BibTeX files. All must be readable.
;; V1.00 July 06 94 - Peter Galbraith - Created
;; ----------------------------------------------------------------------------
;;; Code:
(require 'tex)
(require 'latex)
(eval-when-compile
(require 'cl-lib))
;; Silence the compiler:
(declare-function reftex-view-crossref "ext:reftex-dcr"
(&optional arg auto-how fail-quietly))
(declare-function outline-show-entry "ext:outline" ())
(defgroup bib-cite nil
"bib-cite, LaTeX minor-mode to display \\cite, \\ref and \\label commands."
:group 'tex)
(defcustom bib-cite-use-reftex-view-crossref nil
"Non-nil means, RefTeX will be used to find cross references.
When this variable is non-nil, both `bib-find' and `bib-display' will
call a function in RefTeX to find or display the cross reference of a
\\ref or \\cite macro at point."
:type 'boolean)
(defcustom bib-novice t
"Give advice to novice users about what commands to use next."
:type 'boolean)
(defcustom bib-switch-to-buffer-function #'switch-to-buffer
"Function used to select buffers if they differ from the original.
You may use `switch-to-buffer' `switch-to-buffer-other-window' or
`switch-to-buffer-other-frame'."
:type '(choice (function-item switch-to-buffer)
(function-item switch-to-buffer-other-window)
(function-item switch-to-buffer-other-frame)))
(defcustom bib-highlight-mouse-t t
"Call bib-highlight-mouse from `LaTeX-mode-hook' to add green highlight."
:type 'boolean)
(defcustom bib-bibtex-env-variable "BIBINPUTS"
"Environment variable setting the path where BiBTeX input files are found.
BiBTeX 0.99b manual says this should be TEXBIB.
Another version says it should BSTINPUTS. I don't know anymore!
The colon character (:) is the default path separator in unix, but you may
use semi-colon (;) for DOS or OS/2 if you set `bib-dos-or-os2-variable' to t."
:type 'string)
(defcustom bib-cite-inputs nil
"List of directories to search for .bib files.
This is in addition to those listed in the environment variable specified by
`bib-bibtex-env-variable'."
:type '(repeat (file :format "%v")))
(defcustom bib-cite-aux-inputs nil
"List of directories to search for .aux files.
MiKTeX has the LaTeX option -aux-directory to store .aux files in an alternate
directory. You may set this variable to let bib-cite find these .aux files."
:type '(repeat (file :format "%v")))
(defcustom bib-dos-or-os2-variable (or (equal 'emx system-type)
(equal 'ms-dos system-type))
;; Under OS/2 system-type equals emx
;; Under DOS system-type equals ms-dos
"Whether you use DOS or OS/2 for bib-make-bibliography/bib-display.
It tells `bib-make-bibliography' and `bib-display' to translate
the BIBINPUTS environment variable using the \";\" character as
a path separator and to translate DOS' backslash to slash.
e.g. Use a path like \"c:\\emtex\\bibinput;c:\\latex\\bibinput\"
\(You can change the environment variable which is searched by
setting the elisp variable `bib-bibtex-env-variable')"
:type 'boolean)
(defcustom bib-etags-command "etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -o "
"Variable for the etags command and its output option.
In unix, this is usually \"etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -o \"
\(we use the -r option to tell etags to list AMS-LaTeX's \\eqref command.)
In DOS and OS/2, this *may* be different, e.g. using slashes like \"etags /o=\"
If so, set it this variable."
:type 'string)
(defcustom bib-etags-append-command "etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -a -o "
"Variable for the etags command and its append and output option.
In unix, this is usually \"etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -a -o \"
In DOS and OS/2, this *may* be \"etags /a /o=\" If so, set it this variable."
:type 'string)
(defcustom bib-etags-filename "TAGS"
"Variable for the filename generated by etags, by defaults this TAGS.
but you may want to change this to something like TAGSLaTeX such that it can
coexist with some other tags file in your master file directory."
:type 'string)
(defcustom bib-ref-regexp "\\\\\\(eq\\|page\\|[fvF]\\)?ref"
"Regular expression for \\ref LaTeX commands that have a matching \\label.
without the curly bracket.
If you change this variable and you use multi-file documents, make sure you
also edit the variables `bib-etags-command' and `bib-etags-append-command'."
:type 'regexp)
(defcustom bib-substitute-string-in-display t
"Determines if `bib-display' will substitute @string definitions.
If t, then the @string text is substituted.
If nil, the text is not substituted but the @string entry is included."
:type 'boolean)
(defcustom bib-string-ignored-warning
'("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "sept" "oct" "nov"
"dec" "acmcs" "acta" "cacm" "ibmjrd" "ibmjs" "ieeese" "ieeetcad"
"ieeetc" "ipl" "jacm" "jcss" "scp" "sicomp" "tcs" "tocs" "tods" "tog"
"toms" "toois" "toplas" )
"@string abbreviations for which a warning is not given if not defined.
These are usually month abbreviations (or journals) defined in a style file."
:type '(repeat (string :tag "Entry")))
;;<<<<<<User-Modifiable variables end here.
(defvar bib-ref-regexpc (concat bib-ref-regexp "{")
"Regular expression for \\ref LaTeX commands that have a matching \\label.
A opening curly bracket is appended to the regexp.")
(defvar bib-cite-minor-mode nil)
(defvar bib-highlight-mouse-keymap (make-sparse-keymap)
"Keymap for mouse bindings in highlighted texts in bicite.")
(defvar bib-cite-minor-mode-menu nil)
;;;###autoload
(defun bib-cite-minor-mode (arg)
"Toggle bib-cite mode.
When bib-cite mode is enabled, citations, labels and refs are highlighted
when the mouse is over them. Clicking on these highlights with [mouse-2]
runs `bib-find', and [mouse-3] runs `bib-display'."
(interactive "P")
(set (make-local-variable 'bib-cite-minor-mode)
(if arg
(> (prefix-numeric-value arg) 0)
(not bib-cite-minor-mode)))
(cond
(bib-cite-minor-mode ;Setup the minor-mode
;; Christoph Wedler's <[email protected]> suggestion for xemacs
;; Added for version 2.19
(if (boundp 'tags-always-exact)
(progn
(set (make-local-variable 'tags-always-exact) nil)))
;; mouse overlay
(if bib-highlight-mouse-t
(progn
(bib-cite-setup-highlight-mouse-keymap)
(bib-highlight-mouse)
(add-hook 'after-change-functions
#'bib-cite-setup-mouse-function nil t))))
(t
;;;Undo the minor-mode
;; mouse overlay
(remove-hook 'after-change-functions #'bib-cite-setup-mouse-function t)
(let ((before-change-functions) (after-change-functions))
;; FIXME This detroys all mouse-faces and local-maps!
;; FIXME Hope no other package is using them in this buffer!
(remove-text-properties (point-min) (point-max)
'(mouse-face t local-map t))))))
;;This must be eval'ed when the LaTeX mode is in use.
;; bib-highlight-mouse-keymap is a local variable so each buffer can have it's
;; own.
(defun bib-cite-setup-highlight-mouse-keymap ()
"Set up the bib-cite text in the current buffer to be clickable."
(set (make-local-variable 'bib-highlight-mouse-keymap)
;; First, copy the local keymap so we don't have `disappearing' menus
;; when the mouse is moved over a \ref, \label or \cite command.
;; FIXME: Check out (mouse-major-mode-menu) to see how it grabs the local
;; menus to display. Maybe on `highlighted' commands we could
;; only display the bib-cite stuff (or a subset of it).
(let ((m (copy-keymap (current-local-map))))
(define-key m [down-mouse-3] #'bib-display-mouse)
(define-key m [mouse-2] #'bib-find-mouse)
m)))
;;;###autoload
(defun turn-on-bib-cite ()
"Unconditionally turn on Bib Cite mode."
(bib-cite-minor-mode 1))
(defun bib-cite-setup-mouse-function (beg end _old-len)
(save-excursion
(save-match-data
(save-restriction
(narrow-to-region
(progn (goto-char beg) (beginning-of-line) (point))
(progn (goto-char end) (forward-line 1) (point)))
(bib-highlight-mouse)))))
(defvar bib-cite-minor-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-cba" #'bib-apropos)
(define-key map "\C-cbb" #'bib-make-bibliography)
(define-key map "\C-cbd" #'bib-display)
(define-key map "\C-cbe" #'bib-etags)
(define-key map "\C-cbf" #'bib-find)
(define-key map "\C-cbn" #'bib-find-next)
(define-key map "\C-cbh" #'bib-highlight-mouse)
map)
"Bib-cite minor-mode keymap.")
(easy-menu-define
bib-cite-minor-mode-menu bib-cite-minor-mode-map "Menu keymap for bib-cite."
'("BCite"
["Make BibTeX bibliography buffer" bib-make-bibliography t]
["Display citation or matching \\ref or \\label" bib-display t]
["Find BibTeX citation or matching \\ref or \\label" bib-find t]
["Search apropos BibTeX files" bib-apropos t]
["Build TAGS file for multi-file document" bib-etags (bib-master-file)]
["Refresh \\cite, \\ref and \\label mouse highlight"
bib-highlight-mouse t]))
;; Install ourselves:
(or (assq 'bib-cite-minor-mode minor-mode-alist)
(setq minor-mode-alist
(cons '(bib-cite-minor-mode " BCite") minor-mode-alist)))
(or (assq 'bib-cite-minor-mode minor-mode-map-alist)
(setq minor-mode-map-alist
(cons (cons 'bib-cite-minor-mode bib-cite-minor-mode-map)
minor-mode-map-alist)))
;; Following from bibtex.el
(defvar
bib-cite-bibtex-font-lock-keywords
'(("^\\( \\|\t\\)*\\(@[A-Za-z]+\\)[ \t]*[({]\\([][A-Za-z0-9.:;?!`'()/*@_+=|<>-]+\\)?"
(2 font-lock-function-name-face)
(3 font-lock-reference-face nil t))
;; reference type and reference label
("^[ \t]*\\(OPT[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*\\)[ \t]*="
1 font-lock-comment-face)
;; optional field names (treated as comments)
("^[ \t]*\\([^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*\\)[ \t]*="
1 font-lock-variable-name-face)
;; field names
"Default expressions to fontify in BibTeX mode."))
(defvar bib-cite-bibtex-mode-syntax-table
(let ((st (make-syntax-table)))
;; [alarson:19920214.1004CST] make double quote a string quote
(modify-syntax-entry ?\" "\"" st)
(modify-syntax-entry ?$ "$$ " st)
(modify-syntax-entry ?% "< " st)
(modify-syntax-entry ?' "w " st)
(modify-syntax-entry ?@ "w " st)
(modify-syntax-entry ?\\ "\\" st)
(modify-syntax-entry ?\f "> " st)
(modify-syntax-entry ?\n "> " st)
(modify-syntax-entry ?~ " " st)
st))
;; Code from bibtex.el ends
;; @string starts with a letter and does not contain any of ""#%'(),={}
;; Here we do not check that the field contains only one string field and
;; nothing else.
(defvar bib-string-regexp
"^[, \t]*[a-zA-Z]+[ \t]*=[ \t]*\\([a-zA-Z][^#%'(),={}\" \t\n]*\\)"
"Regular expression for field containing a @string.")
(defun bib-cite--kind ()
(save-excursion
(if (not (looking-at "\\\\"))
(search-backward "\\" nil t))
(if (looking-at bib-ref-regexpc)
'ref
(if (looking-at "\\\\label{")
'label
'cite))))
(defun bib-display ()
"Display BibTeX citation or matching \\ref or \\label command under point.
If text under cursor is a \\cite command, then display its BibTeX info from
\\bibliography input file.
Example with cursor located over cite command or arguments:
\\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94}
^Display-all-citations ^Display-this-citation
If text under cursor is a \\ref command, then display environment associated
with its matching \\label command.
If text under cursor is a \\label command, then display the text around
the first matching \\ref command.
The user is prompted for a \\label or \\ref is nothing suitable is found under
the cursor. The first prompt is for a label. If you answer with an empty
string, a second prompt for a ref will be given.
A TAGS file is created and used for multi-file documents under auctex."
(interactive)
(let ((kind (bib-cite--kind)))
(cond
;; reftex doesn't handle label->ref
((and bib-cite-use-reftex-view-crossref
(memq kind '(ref cite)))
;;;FIXME: reftex doesn't want point on \ref or \cite part, but on keyword
(require 'reftex)
(reftex-view-crossref nil))
((eq kind 'cite)
(bib-display-citation))
(t
(bib-display-label)))))
(defun bib-find ()
"Edit BibTeX citation or find matching \\ref or \\label command under point.
For multi-entry cite commands, the cursor should be on the actual cite key
desired (otherwise a random entry will be selected).
e.g.: \\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94}
^Display-this-citation
If text under cursor is a \\ref command, then point is moved to its matching
\\label command.
If text under cursor is a \\label command, then point is moved to the first
matching \\ref command.
The user is prompted for a \\label or \\ref is nothing suitable is found under
the cursor. The first prompt is for a label. If you answer with an empty
string, a second prompt for a ref will be given.
A TAGS file is created and used for multi-file documents under auctex."
(interactive)
(let ((kind (bib-cite--kind)))
(cond
;; reftex doesn't handle label->ref
((and bib-cite-use-reftex-view-crossref
(memq kind '(ref cite)))
(require 'reftex)
(reftex-view-crossref t))
((eq kind 'cite)
(bib-edit-citation))
(t
(bib-find-label)))))
(defvar bib-cite-search-ring nil
"Bib-cite intenal variable to hold last \\ref or \\eqref find.")
(defun bib-find-next (&optional prev-p)
"Find next occurrence of a \\ref or \\eqref.
This is made necessary because we now use a regexp to find tags in multi-file
documents, and the Emacs command `find-tag' doesn't allow to interactively
find the next occurrence of a regexp."
(interactive "P")
(if (bib-master-file) ;Multi-file document
;; FIXME: `find-tag' is replaced by `xref-find-definitions' in
;; Emacs 25.1. AUCTeX should track this change, sometime ...
(find-tag t (if prev-p '- t) t)
(if bib-cite-search-ring
;;FIXME: Should first make sure I move off initial \ref{}.
(let ((regexp (concat bib-ref-regexpc bib-cite-search-ring "}")))
(if prev-p
(if (not (re-search-backward regexp nil t))
(message "No previous occurrence of reference %s"
bib-cite-search-ring))
(if (not (re-search-forward regexp nil t))
(message "No next occurrence of reference %s"
bib-cite-search-ring))))
(message "Sorry, no previous reference to find. Use bib-find?"))))
(defun bib-display-mouse (EVENT)
"Display BibTeX citation or matching \\ref or \\label under mouse EVENT.
See bib-display."
(interactive "e")
(mouse-set-point EVENT)
(bib-display))
(defun bib-find-mouse (EVENT)
"Edit BibTeX citation or find matching \\ref or \\label under mouse EVENT.
See bib-find."
(interactive "e")
(mouse-set-point EVENT)
(bib-find))
(defun bib-apropos ()
"Display BibTeX entries containing a keyword from bibliography file.
The files specified in the \\bibliography command are searched unless
the current buffer is in `bibtex-mode' or is the Help buffer. In those
cases, *it* is searched. This allows you to trim down a search further
by using bib-apropos sequentially."
;;(interactive "sBibTeX apropos: ")
(interactive)
(let* ((keylist (and (boundp 'TeX-mode-p)
(or TeX-mode-p
(eq major-mode 'bibtex-mode)) ;Avoid error in FRAMEPOP
(fboundp 'LaTeX-bibitem-list) ;Use this if using auctex
(LaTeX-bibitem-list)))
(keyword (bib-apropos-keyword-at-point))
(keyword (completing-read "BiBTeX apropos: " keylist nil nil keyword))
(the-text)(key-point)(start-point)
(new-buffer-f (and (not (string-match "^bib" mode-name))
(not (string-equal "*Help*" (buffer-name)))))
(bib-buffer (or (and new-buffer-f (bib-get-bibliography nil))
(current-buffer))))
(with-current-buffer bib-buffer
(goto-char (point-min))
(while (and (re-search-forward "^[ \t]*@" nil t)
(re-search-forward keyword nil t))
(setq key-point (point)) ;To make sure this is within entry
(re-search-backward "^[ \t]*@" nil t)
(setq start-point (point))
(forward-list 1)
(if (< (point) key-point) ;And this is that test...
(goto-char key-point) ;Not within entry, skip it.