Created
September 21, 2011 12:56
-
-
Save AdrienLemaire/1231961 to your computer and use it in GitHub Desktop.
Mupdf hack to open pdf directly to the (sub)*section you're editing from vim in Latex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Function: OpenPdfToSection | |
function! OpenPdfToSection() | |
let g:my_section = substitute(getline(search('\\\(sub\)\?section', 'bn')), '\\\%(sub\)\?section{\([^}]\+\)}', '\1', '') | |
" some weird trailing space can appear, remove them | |
let g:my_section = substitute(g:my_section, "^ *", "", "g") | |
let g:Tex_ViewRuleComplete_pdf = 'mupdf -f "'.g:my_section.'" -r 102 $*.pdf' | |
call Tex_ViewLaTeX() | |
" reinitialize the variable to keep <leader>lv working | |
let g:Tex_ViewRuleComplete_pdf = 'mupdf -r 102 $*.pdf' | |
endfunction | |
map <Leader>lg :call OpenPdfToSection()<CR> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from 7a82202a845e3e447500ec55c549b024c46d61f1 Mon Sep 17 00:00:00 2001 | |
From: Tor Andersson <[email protected]> | |
Date: Wed, 21 Sep 2011 12:40:05 +0200 | |
Subject: [PATCH] Add command line flag to search for a string. | |
--- | |
apps/x11_main.c | 11 ++++++++++- | |
1 files changed, 10 insertions(+), 1 deletions(-) | |
diff --git a/apps/x11_main.c b/apps/x11_main.c | |
index c2aef91..4fb788b 100644 | |
--- a/apps/x11_main.c | |
+++ b/apps/x11_main.c | |
@@ -86,6 +86,7 @@ static char copylatin1[1024 * 16] = ""; | |
static char copyutf8[1024 * 48] = ""; | |
static Time copytime; | |
static char *filename; | |
+static char *initial_search = NULL; | |
static pdfapp_t gapp; | |
static int closing = 0; | |
@@ -555,7 +556,7 @@ int main(int argc, char **argv) | |
int width = -1; | |
int height = -1; | |
- while ((c = fz_getopt(argc, argv, "p:r:b:A")) != -1) | |
+ while ((c = fz_getopt(argc, argv, "p:r:f:b:A")) != -1) | |
{ | |
switch (c) | |
{ | |
@@ -563,6 +564,7 @@ int main(int argc, char **argv) | |
case 'r': resolution = atoi(fz_optarg); break; | |
case 'A': accelerate = 0; break; | |
case 'b': fz_set_aa_level(atoi(fz_optarg)); break; | |
+ case 'f': initial_search = fz_optarg; break; | |
default: usage(); | |
} | |
} | |
@@ -597,6 +599,13 @@ int main(int argc, char **argv) | |
pdfapp_open(&gapp, filename, fd, 0); | |
+ if (initial_search) | |
+ { | |
+ strcpy(gapp.search, initial_search); | |
+ gapp.searchdir = 1; | |
+ pdfapp_onkey(&gapp, 'n'); | |
+ } | |
+ | |
FD_ZERO(&fds); | |
FD_SET(x11fd, &fds); | |
-- | |
1.7.6.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment