[gedit-plugins] synctex: use regex to support AucTex declaration for master files
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] synctex: use regex to support AucTex declaration for master files
- Date: Fri, 5 Jun 2015 09:32:51 +0000 (UTC)
commit b7871d8180edd5bfe428ea853bf7115f75a8aac3
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Fri May 29 16:25:11 2015 -0700
synctex: use regex to support AucTex declaration for master files
When editing LaTeX files, the plugin looks for '% mainfile:' keyword
in the text. However, when the files are shared with emacs users,
this become duplicated information because AucTex supports
'%%% TeX-master: "filename"'.
This patch allows to use either way. It is also lenient with spaces
and number of percentage symbol.
plugins/synctex/synctex/synctex.py | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/plugins/synctex/synctex/synctex.py b/plugins/synctex/synctex/synctex.py
index 21c327b..5636f33 100644
--- a/plugins/synctex/synctex/synctex.py
+++ b/plugins/synctex/synctex/synctex.py
@@ -3,6 +3,7 @@
# synctex.py - Synctex support with Gedit and Evince.
#
# Copyright (C) 2010 - José Aliste <jose aliste gmail com>
+# Copyright (C) 2015 - Germán Poo-Caamaño <gpoo gnome org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,6 +26,7 @@ import dbus.mainloop.glib
import logging
import gettext
import os
+import re
from gpdefs import *
try:
@@ -58,14 +60,18 @@ def apply_style (style, tag):
Pango.Underline.NONE)
apply_style_prop(tag, style, "strikethrough")
-def parse_modeline(line):
- index = line.find("mainfile:")
+def parse_modeline(text):
+ gedit_r = re.search(r'%+\s*mainfile:\s*(.*)$', text,
+ re.IGNORECASE)
+ auctex_r = re.search(r'%+\s*TeX-master:\s*"(.*)"$', text,
+ re.IGNORECASE)
+ if gedit_r:
+ return gedit_r.group(1)
+ elif auctex_r:
+ return auctex_r.group(1)
+ else:
+ return None
- if line.startswith("%") and index > 0:
- # Parse the modeline.
- return line[index + len("mainfile:"):].strip()
-
- return None
class SynctexViewHelper:
def __init__(self, view, window, plugin):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]