Thread: [Vim-latex-devel] IMAP with multibyte lhs
Brought to you by:
srinathava,
tmaas
From: <com...@fr...> - 2010-06-28 17:49:43
|
Hello! is there a chance that IMAP (the wonderfull function shipped with imaps.vim) will accept multitbyte (unicode) characters in lhs strings in the future? This is for use in a personal script which would convert on the fly LaTeX macros for math symbols in their corresponding unicode characters, as unilatex.vim from Jos van den Oever, but based on IMAP instead of imap. Since IMAP applies immediately this requires in some cases to chain IMAP mappings as follows (I hope the UTF-8 characters below will be readable for you, they represent \subset and \subseteq): call IMAP("\\subset", "⊂", "") call IMAP("⊂eq", "⊆", "") This does not work with my version of imaps.vim, which is puzzled by the multibyte caracters in the lhs (more than 3 caracters are cancelled when ⊂eq is replaced by ⊆). Version number: imaps.vim 997 2006-03-20 09:45:45Z srinathava $ VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Dec 1 2008) I have succeeded to modify imaps.vim so that it accepts unicode characters in lhs and the above commands work, without disturbing the latex-suite (apparently). I can post it here if you are interested, but it's only a trick, not a patch: I do not understand enough how imaps.vim (and the latex-suite) works to be sure that this solution will work properly in other contexts than mine. Best regards, LuX. |
From: Bodo G. <ma...@bo...> - 2010-06-28 18:48:10
Attachments:
signature.asc
|
Hello LuX, hello list I too have been looking for such a feature but without success so far. Vims imap / iab commands don't support unicode in my setup. I understand you have made that possible? I really would be interested in how, and maybe I could apply this to IMAP... btw, why do you want to replace it this way? I myself have those unicode symbols accessible via my keyboard (neo-layout.org) and would like to replace them with the latex-command: „call IMAP("∃", "\exists", "tex");“. But could not imagine the use of the other direction... Best regards, Bodo Am Mon, 28 Jun 2010 19:33:09 +0200 schrieb com...@fr...: | | Hello! | | is there a chance that IMAP (the wonderfull function shipped with | imaps.vim) will accept multitbyte (unicode) characters in lhs strings | in the future? | | This is for use in a personal script which would convert on the fly | LaTeX macros for math symbols in their corresponding unicode | characters, as unilatex.vim from Jos van den Oever, but based on IMAP | instead of imap. Since IMAP applies immediately this requires in some | cases to chain IMAP mappings as follows (I hope the UTF-8 characters | below will be readable for you, they represent \subset and \subseteq): | | call IMAP("\\subset", "⊂", "") | call IMAP("⊂eq", "⊆", "") | | This does not work with my version of imaps.vim, which is puzzled by | the multibyte caracters in the lhs (more than 3 caracters are | cancelled when ⊂eq is replaced by ⊆). Version number: | | imaps.vim 997 2006-03-20 09:45:45Z srinathava $ | VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Dec 1 2008) | | I have succeeded to modify imaps.vim so that it accepts unicode | characters in lhs and the above commands work, without disturbing the | latex-suite (apparently). I can post it here if you are interested, | but it's only a trick, not a patch: I do not understand enough how | imaps.vim (and the latex-suite) works to be sure that this solution | will work properly in other contexts than mine. | | Best regards, | LuX. | | | ------------------------------------------------------------------------------ | This SF.net email is sponsored by Sprint | What will you do first with EVO, the first 4G phone? | Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first | _______________________________________________ | Vim-latex-devel mailing list | Vim...@li... | https://lists.sourceforge.net/lists/listinfo/vim-latex-devel |
From: <com...@fr...> - 2010-06-28 21:11:54
|
Hello Bodo, > Message de Bodo Graumann: Mon 28/06/10, 20:47:57 +0200 > I too have been looking for such a feature but without success so far. > Vims imap / iab commands don't support unicode in my setup. I > understand you have made that possible? I really would be interested in > how, and maybe I could apply this to IMAP... So at least one person except me is interested. :-) I did not succeed (and did not try) to modify imap / iab, but IMAP itself. IMAP accepts multibyte characters in the lhs but works wrongly with it, as I reported in my first post. The reason of the problem is that IMAP uses strlen() and strpart() functions of vim, which change strings byte per byte instead of character per character. I just filled this gap by writing analogous functions dealing with strings character by character and replaced strlen and strpart by my functions in various places. And it works! > btw, why do you want to replace it this way? I myself have those > unicode symbols accessible via my keyboard (neo-layout.org) and would > like to replace them with the latex-command: „call IMAP("∃", "\exists", > "tex");“. But could not imagine the use of the other direction... I do not have such keys in my keyboard, I have a plane qwerty keyboard. What I wanted is an easy access to mathematical unicode symbols from my keyboard, not necessarily for LaTeX, but for mail, plain text, whatever. For example I can type in this mail: ∀ ε ≤ 1, ∃ ζ ∈ ℂ… and so on. (Apparently these characters are displayed properly on the web site, I hope it is the same for your mail viewer.) You may say that this is of limited use. Well, I use it with some of my colleagues and I like it, but I agree that it is sort of a game. What I really wanted actually was that when I open a tex file all the LaTeX macros that it contains for mathematical symbols are converted to UTF8 glyphs which represent them, and when I save the file the UTF8 characters are converted back. So that I have a more "wysiwyg" LaTeX editor, with much more compact and readable formulas, but still have plain ascii LaTeX file, which latex can compile without problem. The plugin unilatex.vim does exactly this, but I experienced some problems with it (it makes non-reversible conversions between UTF8 and LaTeX) and missed some features such as the possibility at some point to see what are the actual macros I typed before continuing. So I needed a function doing conversions for some parts of the file at any moment, not only when loading and saving the file. And moreover I wanted to use IMAP mappings instead of imap mappings as provided by unilatex.vim. So I wrote my own plugin. I would like to share it with other people, and I would prefer it to be fully compatible with the IMAP function coming with imaps.vim (and the latex-suite), instead of replacing it with my own version of IMAP which would not be compatible with the official one. I'll send you my modified version of imaps.vim in the next post, so that you can test it if you want. You just have to move your imaps.vim to imaps.vim.bak, say, in order to disable it, and save my variant in your directory for vim's plugins (~/.vim/plugin in Linux) with name imaps_modified.vim if you want. Best regards, LuX. |
From: Kay S. <kay...@ma...> - 2010-06-29 20:05:10
|
On Mon, Jun 28, 2010 at 11:11:44PM +0200, com...@fr... wrote: > I do not have such keys in my keyboard, I have a plane qwerty keyboard. > What I wanted is an easy access to mathematical unicode symbols from > my keyboard, not necessarily for LaTeX, but for mail, plain text, > whatever. For example I can type in this mail: ∀ ε ≤ 1, ∃ ζ ∈ ℂ… and > so on. (Apparently these characters are displayed properly on > the web site, I hope it is the same for your mail viewer.) Have you tried snipMate? I use it to map some of my ALT Gr + xx keys to special unicode characters. > What I really wanted actually was that when I open a tex file all the > LaTeX macros that it contains for mathematical symbols are converted > to UTF8 glyphs which represent them, and when I save the file the UTF8 > characters are converted back. So that I have a more "wysiwyg" LaTeX > editor, with much more compact and readable formulas, but still have > plain ascii LaTeX file, which latex can compile without problem. I use the ucs (mathletters) package in LaTex. So LaTex can compile UTF-8 characters. This is just a workaround for missing unicode support. But it works for me. Kind regards, Kay -- Kay Smarczewski Web: http://www.smarti.info Jabber: ka...@ja... |
From: <com...@fr...> - 2010-06-29 21:46:05
|
Hello Kay! > Message de Kay Smarczewski: mar 29/06/10, 21:22:36 +0200 > Have you tried snipMate? I use it to map some of my ALT Gr + xx keys > to special unicode characters. Thank you for this suggestion. I didn't know snipmate, it looks pretty powerful. But it doesn't seem to be really devoted to LaTeX macros and unicode characters. I don't want to add NEW shortcuts to access SOME mathematical unicode characters. I want to access EVERY mathematical symbol just by typing the USUAL (for me) corresponding LaTeX macro, not even followed by <TAB> (as snipmate requires) nor anything special. With other words I want to continue typing LaTeX as I always did, it's only what I SEE in vim that I want to change. There are several vim scripts devoted to this goal, and the best I found is undoubtedly unilatex.vim. It just requires some improvement to fit my taste, like using IMAP instead of imap, that's all. > I use the ucs (mathletters) package in LaTex. So LaTex can compile > UTF-8 characters. This is just a workaround for missing unicode > support. But it works for me. On their web site it is written: Due to time restrictions, I am not able to maintain this package anymore. New maintainer welcome. This is typically the kind of problem which makes me very shy on using special LaTeX packages. It happens also that some LaTex files are rejected by preprint servers when they require non standard packages. But most of all I DO LIKE that latex files remain plain ascii. It's only when I'm working on them that I would like to see symbols instead of macros, otherwise I think it's safer to keep this kind of files in plane ascii. Some of my colleagues used inputenc simply to type french accented characters directly in their latex files, but when the default encoding of our system moved from latin1 to utf-8 they experienced some problems: typically they copy and paste between old an new files --not with vim, which deals pretty well with this-- resulting in some cases in completely unrecoverable files where every accented character is replaced by a question mark (this happened to a friend of mine with a document which was something like 100 pages long… he was furious!). And eventually I want to be able to share my LaTeX sources with foreign colleagues without wondering which encoding is used and which package are available in their system. Thanks again for your kind interest but actually my question concerned IMAP, not really what I want to use it for. Best regards, LuX. |
From: Bodo G. <ma...@bo...> - 2010-07-10 11:43:01
|
Hi, Just wanted to send some note on my progress. First of all thx a lot to LuX, that patch works wonderfully for my current use. Also I have succeeded in using unicode-characters in math mode by defining: \catcode`\Σ=\active \defΣ{\sum} for the characters I want to use (those that are available on my neo keyboard layout) ucs didn't work for me — might be because I use xelatex I think saving my texsources as utf8 is good enough. Even if I would try to save it as plain ASCII, I would end up with your problem, LuX and I don't think converting those tex commands to their unicode representation in vim would be a good thing. If you need to give the file to someone without utf8 capabilities, you could still write a small filter, that replaces all the unicode-characters with the latex commands... best regards Bodo On Tue, Jun 29, 2010 at 9:22 PM, Kay Smarczewski < kay...@ma...> wrote: > On Mon, Jun 28, 2010 at 11:11:44PM +0200, com...@fr... wrote: > > I do not have such keys in my keyboard, I have a plane qwerty keyboard. > > What I wanted is an easy access to mathematical unicode symbols from > > my keyboard, not necessarily for LaTeX, but for mail, plain text, > > whatever. For example I can type in this mail: ∀ ε ≤ 1, ∃ ζ ∈ ℂ… and > > so on. (Apparently these characters are displayed properly on > > the web site, I hope it is the same for your mail viewer.) > Have you tried snipMate? I use it to map some of my ALT Gr + xx keys > to special unicode characters. > > > What I really wanted actually was that when I open a tex file all the > > LaTeX macros that it contains for mathematical symbols are converted > > to UTF8 glyphs which represent them, and when I save the file the UTF8 > > characters are converted back. So that I have a more "wysiwyg" LaTeX > > editor, with much more compact and readable formulas, but still have > > plain ascii LaTeX file, which latex can compile without problem. > I use the ucs (mathletters) package in LaTex. So LaTex can compile > UTF-8 characters. This is just a workaround for missing unicode > support. But it works for me. > > Kind regards, > > Kay > > -- > Kay Smarczewski > Web: http://www.smarti.info > Jabber: ka...@ja... > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Vim-latex-devel mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vim-latex-devel > -- NOTHING IS REAL |
From: <com...@fr...> - 2010-07-16 19:57:45
|
Hello! > Message de Bodo Graumann: Sat 10/07/10, 13:42:51 +0200 > First of all thx a lot to LuX, that patch works wonderfully for my current > use. Good news. :-) > I think saving my texsources as utf8 is good enough. > Even if I would try to save it as plain ASCII, I would end up with your > problem, LuX > and I don't think converting those tex commands to their unicode > representation in vim would be a good thing. > If you need to give the file to someone without utf8 capabilities, you could > still write a small filter, > that replaces all the unicode-characters with the latex commands... I do like to use this feature of automatic conversion between LaTeX macros and unicode characters. Note that it is an improvement of an existing vim script which has been downloaded 1430 times or so, hence I guess that other people could appreciate it too: http://www.vim.org/scripts/script.php?script_id=284 But of course this is a question of taste. Thank you for the feed back anyway. However I still don't know the answer to my initial question: ---> Is there a chance that IMAP (the official IMAP, shipped with imaps.vim, not my own variant of course) will accept multibyte (unicode) characters in lhs strings in the future? If anyone knows the answer, I would be pleased to hear about it. Thanks, LuX. |