masukomi / vim-markdown-folding

Fold markdown documents by section.
250 stars 43 forks source link

E121: Undefined variable: b:undo_ftplugin #15

Closed lqueryvg closed 5 years ago

lqueryvg commented 9 years ago

I get the following whenever I edit a markdown file:

Error detected while processing /home/John/dotfiles/.vim/bundle/vim-markdown-folding/after/ftplugin/markdown/folding.vim:
line  121:
E121: Undefined variable: b:undo_ftplugin

Might I suggest that you check if b:undo_ftplugin exists before appending to it ?

The following fixes the problem for me:

--- folding.vim.old     2014-11-24 11:38:31.562848600 +0000
+++ folding.vim 2014-11-24 11:38:43.174823200 +0000
@@ -114,6 +114,7 @@
   \ : 'StackedMarkdownFolds()'

 " Teardown {{{1
+if !exists("b:undo_ftplugin") | let b:undo_ftplugin = '' | endif
 let b:undo_ftplugin .= '
   \ | setlocal foldmethod< foldtext< foldexpr<
   \ | delcommand FoldToggle
nelstrom commented 9 years ago

I want to look into this a bit further. I thought that Vim would initialize the b:undo_ftplugin to a blank string anyway. Looking at Vim's documentation for undo_ftplugin, it suggests setting it as follows:

let b:undo_ftplugin = "setlocal fo< com< tw< commentstring<"
    \ . "| unlet b:match_ignorecase b:match_words b:match_skip"

Perhaps I should use = to assign, rather than .= to append.

rachidbch commented 8 years ago

I have exactly the same problem. With this hack the problem is gone so please let us know if you find that something can go wrong the hack. I' let you know here how it goes for me with the modif.

Thx

AmaruCoder commented 8 years ago

I have been experiencing this issue too. Is it there a new release?

chriad commented 8 years ago

I have the same issue! The change suggested by lqueryvg doesn't work for me. Is it ok to just delete the 'Teardown' part of the script?

nikolaussucher commented 6 years ago

Simply deleting the "delcommand FoldToggle" solves the problem for me. This does not appear to cause any problems. When I switch between buffers with and without markdown files, the FoldToggle command is only available in the markdown buffers and "foldmethod", "foldtext", and "foldexpr" are correctly reset upon switching from buffers with markdown files to buffers without markdown files.

kaiec commented 6 years ago

FWIW, for me, the proposed change by @lqueryvg works.

masukomi commented 5 years ago

I've merged in fixes for this. It should be fixed in the current version. Please reopen this issue if you are still experiencing this problem .