54 Commits

Author SHA1 Message Date
Gerd Wachsmuth ee2822394c Fix issue in LookupCharacter
In insert mode, <c-v>O will let you insert ascii keycodes as octal
numbers. Hence, an 'O' must not be preceeded by <c-v>. However, <c-v> is
necessary, if a:char is <c-\>.

Fix #59
2016-07-24 12:20:13 +02:00
Yuchen Ding c7aa5fa063 Fix issue in LookupCharacter
If a:char is a special character (e.g., <c-\>), it could interact with the following <c-g>.
Solution: Insert a:char literally.
2016-06-11 23:10:07 +02:00
Gerd Wachsmuth 5ab742d548 Fix bug with :iab
See http://vi.stackexchange.com/questions/2245/strange-behaviour-of-abbreviations-triggered-with-shiftenter-in-gvimvim-latex.
2016-04-25 22:55:36 +02:00
Gerd Wachsmuth 63b02f05ce New option: g:Imap_GoToSelectMode
This can be used to fix #47.
2016-04-25 22:50:59 +02:00
Gerd Wachsmuth fa6192981e Do not turn on highlighting in IMAP_Jumpfunc.
IMAP_Jumpfunc does not use the search prompt anymore. Thus, it will not have any effect on search highlighting.
2016-04-25 22:50:58 +02:00
Daeyun Shin 392577fc20 Fix: allow function overloading - Add the missing function qualifier (!) to indicate that MultiByteStrpart and MultiByteStrlen can be safely overloaded. See https://github.com/vim-latex/vim-latex/issues/5 2014-11-23 10:36:47 +01:00
LuX 02cce04263 imaps.vim: Add multibyte LHS support
- Add s:MultiByteStrlen() and s:MultiByteStrpart()
- Allow for example IMAP chaining as follows:
call IMAP("\\subset", "⊂", "")
call IMAP("⊂eq", "⊆", "")

References:
https://sourceforge.net/p/vim-latex/patches/5/
2014-11-15 19:08:36 +01:00
TODA Shuta 0ced0c9571 Fix some mappings to avoid unexpected recursive expansion. 2014-11-15 17:31:14 +01:00
Till Maas 3e7695b366 Restore registers with setreg()
Do not use "let @a = _a" to restore registers, since this adds an extra line
feed character to the register.

References:
- http://stackoverflow.com/questions/26896399/why-does-let-modify-the-value-it-assigns
- https://bugzilla.redhat.com/show_bug.cgi?id=1163518

Patch idea by Daniel Wagner <me@dmwit.com>
2014-11-15 16:34:02 +01:00
Till Maas dd2e3daf1e remove remaining SVN/CVS keywords 2014-11-15 15:23:57 +01:00
Michael Ekstrand 1a10ee7cc9 Use noremap for IMAP mappings
The IMAP mappings used plain [inv]map instead of the noremap
versions.  This causes conflicts with other plugins.
2014-05-12 13:31:03 -05:00
Bodo Graumann ce16347c36 Allow to undo IMAP substitution 2012-11-01 00:19:38 +01:00
Philipp Hartwig 8d8d1f4423 imaps: make VEnclose work when ignorecase is set 2011-02-14 20:57:42 +01:00
Till Maas e2f07b8792 remove most svn/CVS keywords 2010-11-12 22:12:38 +01:00
Srinath Avadhanula 059382b7db New: Used one of the advantages of using svn. Liberally used the 'prop*'
commands to do the following:
     1. change the EOL style of all vim files to be just LF.
     2. changed the mime-type of all files to text/plain
     3. removed the executable flag on all files.
     This should hopefully make the repo look better on all platforms etc.
2006-03-20 09:45:45 +00:00
Srinath Avadhanula 3fff75c2a2 Bug: If there is an abbreviation like this:
:iab zzz whatever
     then typing 'z<space>' triggers the abbreviation in the presence of
     latex-suite. (Cristian Rigamonti)
Why: The reg-exp used to find out if a iab existed was faulty.
Fix: Fix the regexp to use an exact match of the previous word.
2006-03-19 04:29:47 +00:00
Srinath Avadhanula 2de1a71275 Bug: Typing
>>> \begin{array}
     >>>    \end{}
     results in
     >>> \begin{array}
     >>> \end{<++>}
     with the cursor at the end (Berta Milan)
Why: When the indentation of a line changes while typing the text returned
     by IMAP_PutTextWithMovement, then IMAP_Mark('go') does not go to the
     same location as set by IMAP_Mark('set'). This causes the cursor to be
     located not before the first placeholder causing the first
     placeholder to be "missed".
Fix: Check to see if the indentation of the line remembered by
     IMAP_Mark('set') has changed and if so, move a little to the left or
     right to adjust for the indentation changing.
2004-05-30 07:35:40 +00:00
Srinath Avadhanula 88d15e913d Bug: when 'ignorecase' is set, then typing 'etB' triggers an error.
Why: With 'ignorecase' set, 'etB' matches 'ETB', therefore, LookupCharacter
     assumes that a map exists for 'etB' and tries to find the value of
     s:Map_Tex_etB which doesn't exist.
Fix: Force matching case with the \C pattern.
2004-05-04 20:50:11 +00:00
Srinath Avadhanula 8911aa61ca Meta-bug! A bug in the debugging function. 2003-12-04 00:06:06 +00:00
Srinath Avadhanula 7401953921 Bug: When &enc==utf8 and g:Imap_PlaceHolder* settings are not lower-ascii,
then we would get an error when we used any of the IMAP functions!
Why: A silly little bug. An extra quote
2003-11-26 05:45:46 +00:00
Srinath Avadhanula 86fb6cddeb New: the g:Imap_FreezeImap function temporarily pauses any macro expansion. 2003-11-14 10:37:56 +00:00
Srinath Avadhanula 6411382543 Bug: Sometimes a Tex_LastSearchPattern not found error is generated (Eugene
Minkovskii)
2003-11-13 08:53:43 +00:00
Srinath Avadhanula 7d2bd15843 Bug: @/ would sometimes change from its previous value when using
IMAP_Jumpfunc().
Why: s:RemoveLastHistoryItem sets @/ to the last search item in the @/
     history, but @/ is not necessarily always the last item in the @/
     history.
Fix: Remember @/ in Tex_LastSearchPattern and then restore it.
2003-09-06 20:07:25 +00:00
Srinath Avadhanula 3b3fa0ceb1 Bug: IMAP_Jumpfunc() and VEnclose() do not work with &selection =
'exclusive' (Jannie Hofmeyr, Pierre Antoine Champin)
Fix: Select one more character in 'exclusive' mode. (suggested by Pierre
     Antoine Champin).
2003-06-19 01:21:33 +00:00
Srinath Avadhanula 4eac530584 Bug: If an abbreviatin contains \ or " characters, then the abbreviation is
not expanded properly. (D. MacAlpine)
Fix: Those characters need to be escaped before the quoting.
2003-03-25 19:11:40 +00:00
Srinath Avadhanula 66b86d3fbc Bug: Incorrect detection of abbreviations. If there was (were)
abbreviations starting with the letter 'a', then typing 'a<space>'
     would trigger an expansion.
Cause: The :iab command also echoes for partial completions.
Solution: Check more thoroughly whether a word is an abbreviation LHS or
          not.
2003-03-25 08:20:11 +00:00
Srinath Avadhanula 7b5feffb4d Bug: iabs break when latex-suite is triggered.
(Preben Randhol, Sanip P Deshmukh)
Cause: If a mapping ends in a letter (say '\'), then abbreviations are not
    triggered by that letter. For example, if we have
        imap \ <C-r>='\'<CR>
        iab 12 twelve
    Then typing 12\ doesn't expand to twelve\.
    (Strangely enough "imap \ ?" doesn't have this problem and we get
    twelve?. Vim bug?)
    This problem is aggravated by the fact that latex-suite "protects"
    most letters to avoid expansions such as ``2 -> `\sqrt{}
Solution: After checking for mappings ending in a letter, if that letter is
    not in 'iskeyword', then also check whether the previous word has
    an abbreviation. Since vim does not have the equivalent of
    mapcheck() for abbreviations, this is complicated (maybe even hacky).
2003-02-05 23:29:04 +00:00
Srinath Avadhanula fae6eb53cf - Bug: imaps do not work on default win32 installations of vim because
:behave mswin
       is set, which in turn sets &selection=inclusive. This makes
       IMAP_Jumpfunc() skip selecting the last character of
       Imap_PlaceHolderEnd. (Sumit Bhardwaj)
  Solution: Temporarily set &selection = exclusive in IMAP_Jumpfunc().
2003-02-05 04:12:28 +00:00
Srinath Avadhanula 9186e9ff31 . Adding in the header instead of the Last Change: Wed Jan 08 04:00 PM 2003 PST
revision tag is necessary in a file, imo.
  NOTE: This wont cause spurious revisions, problems in merging etc.
2003-01-09 00:57:58 +00:00
Srinath Avadhanula ae67765d27 - always use the blackhole register to do yanks/substitutions etc,
otherwise the user's unnamed register gets eaten up.
2003-01-08 23:50:12 +00:00
Srinath Avadhanula 4e55f84086 - removing an unnecessary line from a previous version. 2003-01-07 20:53:38 +00:00
Srinath Avadhanula dadc582f31 - Description of arguments to IMAP_Jumpfunc().
- IMAP_Jumpfunc() is now able to handle <+placeholders
  withlinebreaks+>
- Bug: If we were selecting in the backward direction, and we want to move
       backwards, then 2 <Plug>IMAP_JumpBack's are needed. i.e, if we have
	   <+1+> <+2+> <+3+>
	   and we do (with <C-k> mapped to <Plug>IMAP_JumpBack)
	   <C-j><C-j><C-k>, from before <+1+>, then we remain in <+2+>.
	   (Bug pointed out by LH)
  Cause: In visual mode, <Plug>IMAP_JumpBack deselects the text but remains
         at the end of the selection. (this is default vim behavior).
		 Therefore searching back for the placeholder start character lands
		 us up in the template.
  Solution: In visual mode, make <Plug>IMAP_JumpBack goto `< after
            deselecting text. This strategy also leads to considerable
			simplification at other places.
2003-01-07 19:43:41 +00:00
Benji Fisher e3c015dde6 * Improve s:PutTextWithMovement() by using a new helper function, IMAP_Mark(),
to position the cursor instead of adding a marker string and searching for it.
The marker would cause serious trouble if it occurred anywhere in the inserted
text, and minor trouble if it was too long and caused an unwanted line break.

* Fix a bug (mea culpa) in s:LookupCharacter() and IMAP_list().  If there was
a global map for "foo" and a local (filetype) map for "bozo" then these
functions would look at the last character, "o", see that there were local
maps ending in "o", and only look for local maps.
2003-01-07 18:27:47 +00:00
Benji Fisher 0380892159 This is another attempt to deal with encoding problems.
* Do not make a call to iconv() when it is not needed.  This is important when
vim is compiled with -iconv.
* Wrap the call to iconv, and the test for whether it is needed, in a new,
heavily commented, helper function, s:Iconv().
2003-01-05 14:01:21 +00:00
Srinath Avadhanula 5b23165397 Since IMAP() is used so often, we do not want the Debug statements to cause
a memory leak. Otherwise the debug string will get generally very huge on
long usage of latex-suite/imaps.
2003-01-04 00:44:56 +00:00
Srinath Avadhanula 712e3aeaf4 Bug: call IMAP('""', '"<++>"<++>', '<+', '+>') doesnt work.
In general, any mapping ending in double quote doesn't work.
Cause: Double quotes need to be escaped in the call to LookupCharacter().
2003-01-03 08:42:16 +00:00
Srinath Avadhanula c7b5c38d4b Unfortunately, have to repeat Tex_Debug* functions here in case this plugin
is used without latex-suite... Script bloat! Maybe when all of the imaps
bugs are removed (!) we can remove these functions...
2003-01-03 08:22:23 +00:00
Srinath Avadhanula aadde81912 . Remove mappings for jumping back. The user can still choose to use this
functionality by uncommenting lines in the texrc (that modification coming
  soon).
2002-12-31 19:20:02 +00:00
Srinath Avadhanula 9d2773507b 1. Problem: When the user tries to trigger an abbreviation near the eol,
the marker string being too long triggers a line break.
   Therefore, just for the time being check to see if phs != phe, and if
   so, then use phs.phs as the marker (improbable string).
   We would like ultimately to completeley get over this hack and use
   movement instead.

2. Problem: The <C-K> map for jumping back was interfering with the
   dictionary completion mode of vim. Therefore change default mapping for
   jumping back to <S-C-J> instead of <C-K>. Ofcourse this makes it
   invisible to non-gui users (I think).

3. Tried to do the "right" thing for mapping. First provide a number of
   mappings using <plug>. These mappings call IMAP_Jumpfunc() in various
   ways. Various <plug> mappings for various modes have been provided.
   After this, we map the default keys to the <plug> mappings checking for
   hasmapto() each time. This provides for a robust and easy user
   customization. Initially, the user had to do something like:
        inoremap <C-J> <C-r>=IMAP_Jumpfunc('', 0)<CR>
   in his .vimrc to be able to override our mapping. Now he will do
        inoremap <C-J> <Plug>IMAP_JumpForward
   Doing this also has the advantage that changes in IMAP_Jumpfunc() will
   not affect the user customization.
   NOTE: This <plug> things were inspired by looking at the excellent
   cvscommand.vim plugin I've begun using...
2002-12-31 09:21:01 +00:00
Srinath Avadhanula bcd3de1886 Bug: When we trigger a mapping near the end of the line, things go bad.
Cause: The "marker" or the "very improbable string" which is used by
       IMAP_PutTextWithMovement() to mark the beginning of the left-hand side
       contains spaces! This causes expansions near the end of a line to
       trigger line breaks (if 'fo' contains t, which is default and tw != 0),
       so that the marker text is broken across lines...  Havoc ensues.
Solution: remove spaces from marker text.
2002-12-30 10:54:49 +00:00
Srinath Avadhanula f74228789f Bug: The mappings in latex-suite effect only the first .tex file being
edited.
Cause: In a recent chage, when IMAP(lhs, rhs, ft) is called with a
       a:ft != '', then it sets the mapping to be buffer local.  This
       breaks latex-suite which calls the IMAP() functions only once when
       it is first started, not for every buffer. Changing things so that
       the mappings are called with every filetype event will be
       1. quite time consuming
       2. kind of inefficient in that a _lot_ of lines will need to be
          resourced with every filetype event.

So until a better solution presents itself, make all maps created by
IMAP() global (not buffer-local).
2002-12-24 12:51:06 +00:00
Srinath Avadhanula 3a3d98c113 . changed the script local s:PlaceHolderStart/End() functions to global
IMAP_GetPlaceHolderStart/End() functions. They need to be visible to
  templates.vim.

. changed fun! and endfun to function! and endfunction
  (another one of those consistent coding thingies)
2002-12-23 02:01:49 +00:00
Benji Fisher 45b579b67f Bug fix in using the \V modifier in search.
In \V  mode, beginning of line is matched by \^
2002-12-22 14:12:02 +00:00
Benji Fisher 3e07be2f73 This is an attempt to deal with the encoding problems. If it is
successful, then IMAP() should work, regardless of the encoding, even when the
place holders are funky (i.e., outside the 7-bit ASCII range).
2002-12-22 03:39:06 +00:00
Srinath Avadhanula e6c185cad6 This is a merge from the b-newimaps branch. The branch was started when a
need to robustify imaps.vim was felt. Before, it had a big dependence on
"funky" characters. Since imaps.vim affected a lot of files, this commit
has a lot of modified files.

Briefly, it changes the <<, >> and the <a-umlaut> characters throughout
latex-suite to 'unfunky' characters.
<< --- <+
>> --- +>
<a-umlaut> --- <++>

The syntax of IMAP and IMAP_PutTextWithMovement was also changed to accept
2 new optional arguments which specify the placeholder characters in the
a:rhs. This allows scriptwriters to generate long term maps which will not
depend on the internals of imaps.vim

The b-newimaps tip at the time of this merge has been tagged as
b-newimaps-merge-sa-1
2002-12-22 03:01:11 +00:00
Benji Fisher d8f98f338b I replaced
IMAP() with Tex_IMAP()
and
	IMAP_PutTextWithMovement() with Tex_PutTextWithMovement()
This is a preliminary step before rewriting these two functions.
2002-12-13 17:24:36 +00:00
Srinath Avadhanula 874d0b753a Changing encoding from one locale to the next causes huge ugly screen
flickers. Therefore only change encoding if the original encoding is not
latin1. This will at least cause it to be smoother on machines using latin1
encoding.

The problem ofcourse will still be there for other locales. Therefore, look
for a more long term solution which does not require the encoding to be
changed back and forth with each imap execution.

If only someone had told me at the beginning not to use ascii > 127
characters!! I think in the next major rev, we will have to undertake a
major overhaul of all the macros to not use any of the higher ascii
characters. Maybe modify IMAP() to allow for multiple character placeholder
characters... (maybe '{+' and '+}' like in cream).

This will instantly remove all the internationalization and localization
problems.
2002-12-07 00:43:41 +00:00
Benji Fisher a7c49a1c04 1.7:Use a (local) variable s:RemoveLastHistoryItem instead of a (global)
function SAImaps_RemoveLastHistoryItem().  Also, clean up some comment
lines from a previous change to this file.

NOTE: This is a changed log message using the cvs admin command.
.
2002-12-06 16:20:00 +00:00
Srinath Avadhanula ad0dbe7490 A very difficult fix for the encoding problem...
Bug: When 'encoding' is set to utf8, then macros dont work. i.e, typing
	() results in (�)�� with the cursor placed at the end.
Cause: The behavior of vim changes according to the current encoding.
Solution:
	1. When latex-suite is first called, temporarily set encoding to
	   latin1, source all the files and then reset it to the original
	   value. This ensures that the scripts rely on a consistent encoding
	   scheme.
	2. Whenever we do encoding specific stuff, then switch back to latin1,
	   do our stuff and then switch back.

	This is complicated by the fact that while inserting text (using the
	Imap_PutText...() function), we need to insert the placeholders in the
	curret locale, not latin1, otherwise the user will see things like <ab>
	and <bb> instead of � and �. Therefore, the jump function needs to
	account for the fact that the characters are no longer in latin1...

TODO: Document these changes asap otherwise I will completeley forget why I
      did what I did...
2002-12-02 13:09:16 +00:00
Benji Fisher efd8fd14a2 I fixed a problem where using $$ (for example) would trash the search
history.  I commented out a line, and added a comment, in case this
depends on version and patch number of vim; I think this should work
with vim any vim 6.0+.  Please test.  If this change is correct, it
should be possible to simplify the code a bit.
2002-11-12 18:24:01 +00:00