27 September 2011

Trilinos GCC Warnings patch

If anyone else is as tired as I am of spurious warnings when compiling Epetra, Teuchos, and Belos modules in Trilinos with -Wall -Wextra, I have created a patchfile that corrects the deficient code.

21 September 2011

Fully integrated LaTeX in Macvim

I've been less than pleased with TeXShop on Lion. I do most of my editing in Vim using Vim-LaTeX, but I compile with TeXShop. Most importantly, I sometimes use SyncTeX to jump between my compiled document and source.

To switch away from TeXShop, I want both an integrated compiler and an external editor with SyncTeX. Skim with this configuration fit the bill. Yet Vim-LaTeX won't play nicely with my dissertation, which uses a file for each chapter and the TeXShop convention of

% !TEX root = ../thesis.tex

to denote the true TeX file. The solution involves this feature of Vim-LaTeX, and the following function I wrote:

" Look for main file by looking in the first 20 lines, same as TeXShop, for:
" % !TEX root = [filename].tex
" Author: Seth R. Johnson
let g:Tex_MainFileExpression = 'SRJMainFile(modifier)'

function! SRJMainFile(fmod)
    let s:Tex_Match = '\v^\s*\%\s+!TEX\s+root\s+\=\s+\zs(.*\.tex)\ze\s*$'
    let s:lnum = 1
    while s:lnum < 20
        let s:basefile = matchstr( getline(s:lnum), s:Tex_Match)
        if !empty(s:basefile)
        let s:lnum += 1

    if !empty(s:basefile)
        let s:origdir = fnameescape(getcwd())
        let s:newdir = fnameescape(expand('%:p:h'))
        exec 'cd'.s:newdir
        let s:basefile = fnamemodify(s:basefile, a:fmod) 
        exec 'cd'.s:origdir
        let s:basefile = expand('%'.a:fmod)

    return s:basefile

" Command-R will write, open for viewing, compile, go to the end of the quickfix, hide the
" preview, switch back to main window
map <D-r> :w<cr><leader>lv<leader>llG<C-w>p:q<cr>
imap <D-r> <ESC><D-r>
" Inverse search
nnoremap <D-S-LeftMouse> <leader>ls

Now typing \ll in my individual chapter files will compile the true thesis. Typing \lv will open the thesis in Skim, \ls will jump from the TeX source to the corresponding output line, and command-shift-clicking in Skim will cause MacVim to jump to the appropriate source line. Command-R is a shortcut to compile and view.

UPDATE 2011/9/25: I've uploaded my vim scripts to GitHub.

UPDATE 2011/9/27: Modify the "reverse lookup" in Skim to be --remote-silent +":silent %line" "%file" to avoid the obnoxious Press ENTER to continue prompt in Vim.

15 September 2011

Making a "lite" git repository

I've had my research in a git repository for more than a year and a half. Because most of my computational experiments are small (i.e., single processor rather than supercluster), I've stored a number of results in the repository rather than in a separate directory. Well, 18 months and many obsolete and regenerated results later, my repository is rather bloated. Preferring to only modify my thesis, figures, and related files on my new MacBook Air, I chose to create a new "thesis" repository.

To preserve the history of modifications I'd already performed, git filter-branch is the way to go. (Stack Overflow was helpful in finding out the details.) The only sticking point was in getting the large HDF5 files to be removed in garbage collection (git gc): removing .git/refs/original and expiring the reflog.


git clone --no-hardlinks /Users/seth/_research thesis
cd thesis
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch \
   research_* _testproblems* _python* meeting_notes* *.h5 *.silo \
   .gitignore .gitxattr_json anisotropic_ss ideas_include technotes" \
   --prune-empty -- --all
git remote rm origin
rm -rf .git/refs/original/
git reflog expire --expire=0 --all
git gc --prune=now

Anyhow, I now have a nice, clean, 20MB repository suitable for putting on an ultraportable and for later uploading to GitHub/elsewhere to serve mankind.

14 September 2011

Vim and TeX keywords

After updating my vim installation, my command set iskeyword+=: in ~/.vim/after/ftplugin/tex.vim stopped functioning. (This was recommended by the Vim-LaTeX project.) My auto-completion for chapter references chap:intro and equations eq:blahBlah was broken because the colon was no longer interpreted as a command character.

To make a long story short, I found the :verbose set isk command which told me the last file to set iskeyword:


Somehow, that syntax file is hard-wired to reset iskeyword. The solution is to add the following line or equivalent:

let g:tex_isk='48-57,a-z,A-Z,192-255,:'