# NEdit Macros for BibTeX # # Version 1.0, tested with NEdit 5.4. # # http://volker.dnsalias.net/soft/nedit/ # # Load this file by starting nedit with: # # nedit -import # # Then, check that the macros were loaded correctly, and choose Save Defaults # from the Preferences menu. The new patterns will now be incorporated into # your own .nedit file, so the next time you start NEdit, you will no longer # need to use -import. # # # The key bindings are active for language mode "BibTeX KW". # # Copyright (C) 2004 by Volker Kuhlmann , # Released under the same license as NEdit itself, # or, at your option, under the GNU General Public Licence, Version 2. # # ChangeLog: # 1.0, 16 Jan 2004 original version # Key: Shift+Ctrl+N # Action: Scrolls the start of the next BibTeX entry to the top of the window. # define bibtex_scroll_next_entry { # Scroll next BibTeX entry to top of window end_of_line() find("@\\w+\\s*\\{", "forward", "regex", "nowrap") beginning_of_selection() scroll_to_line($line) beginning_of_line() } # Key: Shift+Ctrl+P # Action: Scrolls the start of the previous BibTeX entry to the top of the # window. # define bibtex_scroll_previous_entry { re="@\\w+\\s*\\{" beginning_of_line() # If cursor is inside an entry, scroll to the entry before, i.e. scroll # back twice unless cursor is on start of entry start = $cursor search("\n", $cursor) # only examine one line for efficiency if ( search_string(get_range(start, $search_end), re, 0, "regex") != 0 ) { find(re, "backward", "regex", "nowrap") } find(re, "backward", "regex", "nowrap") beginning_of_selection() scroll_to_line($line) beginning_of_line() } # Key: Shift-Ctrl-J # Action: Re-format BibTeX entry by running it through bibtool. Re-formats # the selection if there is one, the current entry otherwise. # bibtool is by Gerd Neugebauer, available from CTAN in # /tex-archive/biblio/bibtex/utils/bibtool/ # define bibtex_format_entry { bibtool="bibtool" if ($selection_start == -1) { pos = $cursor if ($column == 0) forward_character() backward_paragraph() start = $cursor forward_paragraph() end = $cursor - 1 if (end == start + 1) end = start set_cursor_pos(pos) newentry = shell_command(bibtool, get_range(start,end)) replace_range(start, end, newentry) end = start + length(newentry) if (pos > end) pos = end set_cursor_pos(pos) } else { if ($selection_left == -1) { start = $selection_start newentry = shell_command(bibtool, get_selection()) replace_selection(newentry) end = start + length(newentry) select(start, end) set_cursor_pos(end) } else { dialog("Operation doesn't currently support rectangular\n" \ "selections. Would this even make sense?") } } }