#57 Handle multiple bib files and \cite{} suggestions

open
nobody
Editing (15)
5
2014-08-14
2011-11-11
Khaled Ahsan
No

I have multiple number of .bib files in a particular location and they are included as --

\bibliography{%
/usr/local/share/mybibs/Formal_Analysis,%
/usr/local/share/mybibs/TSP,%
/usr/local/share/mybibs/GridSched_Basic%
}

the plugin can't read the bib entries when they are specified like this.
the log messages are --

2011-11-10 20:11:11,203 DEBUG BibTeXDocumentCache - Cache fault for 'file:///media/Data/GMU_Courses/CS580/Projects/Reports/%09/usr/local/share/mybibs/Formal_Analysis.bib'
2011-11-10 20:11:11,203 DEBUG LaTeXCompletionHandler - Failed to provide BibTeX completion due to IOError

which I guess the plugin tries to read the .bib files from the current location where the tex file is.

Is it possible to add such a feature that can read multiple bib files and
when I try to write "\cite{..." the plugin will give me the possible bib entry suggestions (in a drop down floating menu) from the bib files ?

eagerly waiting for this feature !

regards.

Discussion

  • Hi,

    The plugin does support multiple bib files, the problem seems to lie in the location of the files.
    This simplest workaround for you before this is fixed in the plugin, is to create symbolic links from your .bib files to the directory where your .tex files lies:
    Assuming you're in a terminal in the directory of your .tex file:
    ln -s /usr/local/share/mybibs/Formal_Analysis.bib Formal_Analysis.bib
    ln -s /usr/local/share/mybibs/TSP.bib TSP.bib
    ln -s /usr/local/share/mybibs/GridSched_Basic.bib GridSched_Basic.bib

    Alternatively, you may simply use relative paths to your files:
    \bibliography{../../../../../../usr/local/share/mybibs/TSP.bib}

     
  • Khaled Ahsan
    Khaled Ahsan
    2011-11-11

    well, actually I have around 50 bib files in mybibs folder and I have a lot of tex documents in different folders. It is quite a daunting task to create 50 symbolic links in each of them. Is there any way around? I was looking for a similar bibliography handling mechanism like winedt.

     
  • Actually I tested your code (I mean, multiple bibliographies with absolute file paths) with my version of the plugin, and it works perfectly.
    Which version are you using?

    Could you try separately 1) with only one bib, with absolute path, 2) multiple bibs, with relative path ?

     
  • Also try removing any tab or space at the beginning of the lines, as this seems to be the problem (%09 means "tab").

     
  • Ok, this should solve the problem:

    In file (where_your_plugin_lies)/GeditLaTeXPlugin/src/latex/outline.py

    replace line 28:
    from os.path import basename
    by
    from os.path import basename,exists

    and line 211
    self._outline.bibliographies.append(File("%s/%s.bib" % (node.file.dirname, bib)))
    by
    bib = bib.strip()
    if not File.is_absolute(bib):
    bib = "%s/%s" % (node.file.dirname, bib)
    # a bib file may be specified without the extension
    potential_extensions = ["", ".bib"]
    for ext in potential_extensions:
    if exists(bib + ext):
    self._outline.bibliographies.append(File(bib + ext))
    break

    And in the same directory, in file validator.py

    replace line 195
    for target in value.split(","):
    by
    for target in value.split(","):
    target = target.strip()

    Does that work for you?

     
  • Khaled Ahsan
    Khaled Ahsan
    2012-02-02

    Hi,
    Thank you for your suggestions. But still it does not work although tried all your options. Do you have any other solution? and sorry for my late response. and here is the debug output from gedit ---

    Script started on Thu 02 Feb 2012 02:16:21 AM EST
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ lsrm -rf LaTe
    eXPlugin-0.2/
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ f LaTeXPlugin-0.2.tar.gz 
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ rf LaTeXPlugin-0.2/
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ ls

    gedit final
    l_report.tex &
    [1] 4787
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ 2012-02-02 02:16:39,551 DEBUG resources - Initializing resource locating
    2012-02-02 02:16:39,680 DEBUG Preferences - <value key='BibtexExtensions'> not found
    2012-02-02 02:16:39,705 DEBUG JobManager - Created JobManager instance 149077196
    2012-02-02 02:16:39,710 DEBUG GeditLaTeXPlugin - activate
    2012-02-02 02:16:39,711 DEBUG WindowContext - init
    /home/khaled/.gnome2/gedit/plugins/GeditLaTeXPlugin/src/base/decorators.py:232: GtkWarning: IA__gtk_accel_label_set_accel_closure: assertion `gtk_accel_group_from_accel_closure (accel_closure) != NULL' failed
    menu.add(gtk_action.create_menu_item())
    2012-02-02 02:16:39,800 DEBUG GeditWindowDecorator - _init_tab_decorators: initialized 0 decorators
    2012-02-02 02:16:39,895 DEBUG GeditWindowDecorator - active_tab_changed
    2012-02-02 02:16:39,895 DEBUG GeditTabDecorator - Created <GeditLaTeXPlugin.src.base.decorators.GeditTabDecorator object at 0x8e7f2ec>
    2012-02-02 02:16:39,895 DEBUG GeditWindowDecorator - ---------- ADJUST: None
    2012-02-02 02:16:39,900 DEBUG GeditWindowDecorator - No window-scope views for this extension
    2012-02-02 02:16:39,900 DEBUG GeditWindowDecorator - _set_selected_bottom_view: 0
    2012-02-02 02:16:39,900 DEBUG GeditWindowDecorator - _set_selected_side_view: 0
    2012-02-02 02:16:39,960 DEBUG GeditWindowDecorator - tab_added
    2012-02-02 02:16:39,960 WARNING GeditWindowDecorator - There is already a decorator for tab <gedit.Tab object at 0x8e79fa4 (GeditTab at 0x84c88a0)>
    2012-02-02 02:16:40,465 DEBUG GeditTabDecorator - loaded
    2012-02-02 02:16:40,490 DEBUG GeditTabDecorator - _adjust_editor: URI has changed
    2012-02-02 02:16:40,491 DEBUG LaTeXCompletionHandler - init
    2012-02-02 02:16:40,492 DEBUG LanguageModelFactory - Pickled object found: /home/khaled/.gnome2/gedit/plugins/GeditLaTeXPlugin/latex.pkl
    2012-02-02 02:16:40,694 DEBUG CompletionDistributor - init
    2012-02-02 02:16:40,697 DEBUG WindowContext - Created view LaTeXOutlineView
    2012-02-02 02:16:40,698 DEBUG WindowContext - Created view IssueView
    2012-02-02 02:16:40,698 DEBUG LaTeXEditor - init(file:///media/Data/GMU_Courses/CS580/Projects/Reports/final_report.tex)
    2012-02-02 02:16:40,703 DEBUG LaTeXEditor - Parsing document...
    2012-02-02 02:16:40,704 DEBUG IssueView - init
    2012-02-02 02:16:40,708 DEBUG IssueView - init finished
    2012-02-02 02:16:40,873 INFO LaTeXEditor - LaTeXParser.parse: 0.150000
    2012-02-02 02:16:40,873 DEBUG LaTeXEditor - Parsed 28155 bytes of content
    2012-02-02 02:16:40,885 DEBUG LaTeXOutlineView - set_outline
    2012-02-02 02:16:40,885 DEBUG LaTeXOutlineView - init
    2012-02-02 02:16:40,904 DEBUG LaTeXValidator - validate
    2012-02-02 02:16:41,022 DEBUG LanguageModel - set_newcommands:
    2012-02-02 02:16:41,026 DEBUG LaTeXEditor - Parsing finished
    2012-02-02 02:16:41,032 DEBUG GeditWindowDecorator - ---------- ADJUST: .tex
    2012-02-02 02:16:41,058 DEBUG GeditWindowDecorator - _set_selected_bottom_view: 0
    2012-02-02 02:16:41,058 DEBUG GeditWindowDecorator - _set_selected_side_view: 0
    2012-02-02 02:16:50,130 DEBUG LaTeXCompletionHandler - complete: '\cite{'
    2012-02-02 02:16:50,131 DEBUG PrefixModelParser - <command name="cite"><mandatory></mandatory></command>
    2012-02-02 02:16:50,131 DEBUG LaTeXCompletionHandler - Generated 0 proposals
    2012-02-02 02:16:50,131 DEBUG SnippetCompletionHandler - complete(\cite{)
    2012-02-02 02:16:52,777 DEBUG GeditTabDecorator - saved
    2012-02-02 02:16:52,778 DEBUG LaTeXEditor - Parsing document...
    2012-02-02 02:16:52,974 INFO LaTeXEditor - LaTeXParser.parse: 0.150000
    2012-02-02 02:16:52,975 DEBUG LaTeXEditor - Parsed 28163 bytes of content
    2012-02-02 02:16:52,990 DEBUG LaTeXOutlineView - set_outline
    2012-02-02 02:16:53,003 DEBUG LaTeXValidator - validate
    2012-02-02 02:16:53,027 DEBUG LanguageModel - set_newcommands:
    2012-02-02 02:16:53,029 DEBUG LaTeXEditor - Parsing finished
    2012-02-02 02:16:55,521 DEBUG GeditWindowDecorator - tab_removed
    2012-02-02 02:16:55,524 DEBUG Editor - destroy
    2012-02-02 02:16:55,524 DEBUG TemplateDelegate - destroy
    2012-02-02 02:16:55,530 DEBUG CompletionDistributor - Properly destroyed <GeditLaTeXPlugin.src.base.completion.CompletionDistributor object at 0x930848c>
    2012-02-02 02:16:55,531 DEBUG GeditTabDecorator - Properly destroyed <GeditLaTeXPlugin.src.base.decorators.GeditTabDecorator object at 0x8e7f2ec>
    2012-02-02 02:16:55,531 DEBUG LaTeXEditor - Properly destroyed <GeditLaTeXPlugin.src.latex.editor.LaTeXEditor object at 0x8e7f7ec>
    2012-02-02 02:16:55,531 DEBUG LaTeXCompletionHandler - Properly destroyed <GeditLaTeXPlugin.src.latex.completion.LaTeXCompletionHandler object at 0x8e98d2c>
    2012-02-02 02:16:55,542 DEBUG LaTeXOutlineView - Properly destroyed <LaTeXOutlineView object at 0x938443c (GtkVBox at 0x8ed8a80)>
    2012-02-02 02:16:55,542 DEBUG IssueView - Properly destroyed <IssueView object at 0x93844dc (GtkHBox at 0x8ed8ad8)>
    2012-02-02 02:16:55,578 DEBUG GeditLaTeXPlugin - deactivate
    2012-02-02 02:16:55,589 DEBUG WindowContext - Properly destroyed <GeditLaTeXPlugin.src.base.WindowContext object at 0x8e762cc>
    2012-02-02 02:16:55,589 DEBUG GeditWindowDecorator - Properly destroyed <GeditLaTeXPlugin.src.base.decorators.GeditWindowDecorator object at 0x8e3206c>
    2012-02-02 02:16:55,589 DEBUG ToolView - Properly destroyed <ToolView object at 0x8e796bc (GtkHBox at 0x8ed8818)>
    2012-02-02 02:16:55,590 DEBUG View - Properly destroyed <LaTeXSymbolMapView object at 0x93f0504 (GtkVBox at 0x8ee99b8)>
    ^C
    [1]+ Done gedit final_report.tex
    ]0;khaled@khaled-toshiba: /media/Data/GMU_Courses/CS580/Projects/Reportskhaled@khaled-toshiba:/media/Data/GMU_Courses/CS580/Projects/Reports$ exit
    exit

    Script done on Thu 02 Feb 2012 02:17:02 AM EST