diff options
| -rw-r--r-- | lisp/ravi-init-cpp.el | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el index 7e69bec..4ebdd84 100644 --- a/lisp/ravi-init-cpp.el +++ b/lisp/ravi-init-cpp.el @@ -449,17 +449,10 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named (defadvice c-electric-brace (after ravi/do-not-activate-region activate) (deactivate-mark)) - (defmacro ravi/fake-send-key (key-to-bind char-to-bind) - (let ((command (key-binding key-to-bind))) - (setq last-command-event char-to-bind) - (setq this-command command) - (call-interactively command)) - ) - - (defun ravi/insert-closing-delimiter() - (interactive) + (defun ravi/insert-closing-delimiter(arg) + (interactive "p") (if (c-in-literal) - (self-insert-command) + (self-insert-command arg) (progn ;; Find nearest unmatched opening delimiter (let (brace-type) @@ -472,10 +465,10 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named (t (setq brace-type 'brace-type-none)) )) (cond - ((eq brace-type 'brace-type-brace) (ravi/fake-send-key "}" ?\})) - ((eq brace-type 'brace-type-paren) (ravi/fake-send-key ")" ?\))) + ((eq brace-type 'brace-type-brace) (setq unread-command-events (listify-key-sequence "}"))) + ((eq brace-type 'brace-type-paren) (setq unread-command-events (listify-key-sequence ")"))) ; Uncommenting the line below would lead to infinite recursion - ;((eq 'brace-type 'brace-type-square) (ravi/fake-send-key "]" ?\])) + ;((eq 'brace-type 'brace-type-square) (setq unread-command-events (listify-key-sequence "]"))) (t (self-insert-command 1)) ) )))) |
