I have written a functionality that inserts the word end at end of blocks in a lua major mode. How i do it is to check if a space character has been typed, if yes is the word before the space for example
function, if yes print the end. Now adding my funcionality to
post-self-insert-hook will change its hooks-list in all modes and buffers. How can i specify it to happen only in lua-mode?
Here is my code in my init.el:
(add-hook 'lua-mode-hook 'mein-lua-mode-hook) (defun put-end () "print end of blocks" (interactive) (backward-char) (when (member (thing-at-point 'word) '("function")) (progn (save-excursion (insert " " "end")) (forward-char)))) (defun spacep () (if (and (derived-mode-p 'lua-mode)(member (char-before) '(13 32))) (put-end))) (defun mein-lua-mode-hook () "Tastaturanbindungen fuer das Lua-Mode" ;;; some other things come here (add-hook 'post-self-insert-hook 'spacep))
I have corrected my code.Now it works only in lua mode but i can type space only if the last word is function. I now the problem is the
spacep but how can i correct it?