[OS X TeX] Re: BibTeX keywords

Joachim Kock kock at math.uqam.ca
Fri Aug 13 21:18:45 CEST 2004


Ok here is the right way to extract the _keywords_ without being
confused about nested braces.  (But this script will only run
from within Alpha, not run from tclsh.)

To use it, paste it into your AlphaPrefs.tcl file (which you access
from "Config -> Preferences"), and restart Alpha.

Now open your bibfile and press Cmd-ctrl-opt-K: this will create a
new window with all the keywords, one per line.

Cheers,
Joachim.



# Build a list of all keywords found in _keywords_ fields of
# frontmost bib file window.  Display result in new window.
proc Bib::getAllKeywords {} {
    set pat {_keywords_\s*=\s*\{}
    set start [minPos]
    set res ""
    while { ![catch { search -r 1 -i 1 $pat $start } pair] } {
        set p0 [lindex $pair 1]
        set p1 [matchIt \{ $p0]
        set txt [getText $p0 $p1]
        foreach keyword [split $txt \;] {
            lappend res [string trim $keyword]
        }
        set start $p1
    }
    if { [llength $res] } {
        new -n "keywords"
        insertText -w "keywords" [join [lsort -unique $res] \r] \r
    } else {
        status::msg "No keywords found"
    }	
}
Bind 'k' <coz> Bib::getAllKeywords "Bib"

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list