# HG changeset patch # User wenzelm # Date 1497897888 -7200 # Node ID 03dd799fe0423d20a555252dc06aa608ea50110c # Parent e6f808d1307c01e1b9c89fff31772a5ac6edb9fc clarified modules; diff -r e6f808d1307c -r 03dd799fe042 src/Pure/Tools/bibtex.scala --- a/src/Pure/Tools/bibtex.scala Mon Jun 19 20:32:06 2017 +0200 +++ b/src/Pure/Tools/bibtex.scala Mon Jun 19 20:44:48 2017 +0200 @@ -422,4 +422,31 @@ } (chunks.toList, ctxt) } + + + /* completion */ + + def completion(history: Completion.History, rendering: Rendering, caret: Text.Offset, + complete: String => List[String]): Option[Completion.Result] = + { + for { + Text.Info(r, name) <- rendering.citation(rendering.before_caret_range(caret)) + name1 <- Completion.clean_name(name) + + original <- rendering.model.try_get_text(r) + original1 <- Completion.clean_name(Library.perhaps_unquote(original)) + + entries = complete(name1).filter(_ != original1) + if entries.nonEmpty + + items = + entries.sorted.map({ + case entry => + val full_name = Long_Name.qualify(Markup.CITATION, entry) + val description = List(entry, "(BibTeX entry)") + val replacement = quote(entry) + Completion.Item(r, original, full_name, description, replacement, 0, false) + }).sorted(history.ordering).take(rendering.options.int("completion_limit")) + } yield Completion.Result(r, original, false, items) + } } diff -r e6f808d1307c -r 03dd799fe042 src/Tools/jEdit/src/bibtex_jedit.scala --- a/src/Tools/jEdit/src/bibtex_jedit.scala Mon Jun 19 20:32:06 2017 +0200 +++ b/src/Tools/jEdit/src/bibtex_jedit.scala Mon Jun 19 20:44:48 2017 +0200 @@ -35,31 +35,8 @@ if entry.toLowerCase.containsSlice(name.toLowerCase) } yield entry).toList - def completion( - history: Completion.History, - rendering: JEdit_Rendering, - caret: Text.Offset): Option[Completion.Result] = - { - for { - Text.Info(r, name) <- rendering.citation(rendering.before_caret_range(caret)) - name1 <- Completion.clean_name(name) - - original <- rendering.model.try_get_text(r) - original1 <- Completion.clean_name(Library.perhaps_unquote(original)) - - entries = complete(name1).filter(_ != original1) - if entries.nonEmpty - - items = - entries.sorted.map({ - case entry => - val full_name = Long_Name.qualify(Markup.CITATION, entry) - val description = List(entry, "(BibTeX entry)") - val replacement = quote(entry) - Completion.Item(r, original, full_name, description, replacement, 0, false) - }).sorted(history.ordering).take(PIDE.options.int("completion_limit")) - } yield Completion.Result(r, original, false, items) - } + def completion(history: Completion.History, rendering: Rendering, caret: Text.Offset) + : Option[Completion.Result] = Bibtex.completion(history, rendering, caret, complete _) @@ -231,4 +208,3 @@ } } } -