[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: po editor which makes use of "previous" feature



On Du, 23 ian 11, 13:09:13, Andrei Popescu wrote:
> 
> I've been working on a solution for vim. There are two things to 
> support:
> 
> Highlighting of differences
> ---------------------------
> 
> See this thread on googlegroups:
> http://groups.google.com/group/vim_use/browse_thread/thread/cc8d2a76690a27dc#
> 
> Personally I like this solution (with two minor additions of my own):
 
[snip]

> > Modifications are now highlighted in the new string -- but not in 
> > the old string.
> 
> Unfortunately at the time I lost interest in a proper implementation 
> (most likely as a patch to the po.vim ftplugin), but know with the 
> release notes I'll badly need this again.

Attached a patch for po.vim, maybe it helps somebody.

Regards,
Andrei
-- 
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
From a2ee06ca8be0a818c1b7b9bbb246b3e793c61723 Mon Sep 17 00:00:00 2001
From: Andrei Popescu <andreimpopescu@gmail.com>
Date: Sun, 30 Jan 2011 11:04:42 +0200
Subject: [PATCH] first version of a patch to highlight changes in fuzzy strings

---
 .vim/ftplugin/po.vim |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/.vim/ftplugin/po.vim b/.vim/ftplugin/po.vim
index 452d71d..039325b 100644
--- a/.vim/ftplugin/po.vim
+++ b/.vim/ftplugin/po.vim
@@ -415,4 +415,25 @@ fu! <SID>OpenSourceFile()
    endif
 endf
 
+" This copies everything to a new, hidden buffer, so we can use the builtin
+" diff capabilities of vim. Built on an idea of J�Kr�r from the vim
+" users mailing list
+fu! DiffPreviousString()
+    %yank
+    new
+    put!
+    " this replaces the current msgid with the old one, so that diff
+    " can highlight the changes. Currently doesn't work with
+    " msgids that are only in one (the first) line
+    %s/^\(#| msgid ""\n\(\_.\{-\}\n\)msgid ""\n\)\(\_.\{-\}\n\)\(msgstr ""\)/\=submatch(1).substitute(submatch(2), '#| ', '', 'g').submatch(4)/
+    nohls
+    diffthis
+    hide
+    diffthis
+    set fdc=0
+    set nofen
+endf
+
+command DiffMsgid call DiffPreviousString()
+
 unlet gui
-- 
1.7.2.3

Attachment: signature.asc
Description: Digital signature


Reply to: