Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. (defvar star-state :no-stars)
  2. (defun star-electric ()
  3. (cond
  4. ((and (eq this-command 'self-insert-command)
  5. (eq last-command-event ?*)
  6. (eq star-state :no-stars))
  7. (setq star-state :one-beg-star))
  8. ((and (eq this-command 'self-insert-command)
  9. (eq last-command-event ?*)
  10. (eq star-state :one-beg-star))
  11. (progn (insert "**")
  12. (backward-char 2)
  13. (setq star-state :two-beg-stars)))
  14. ((and (eq this-command 'self-insert-command)
  15. (eq last-command-event ?*)
  16. (eq star-state :two-beg-stars))
  17. (progn
  18. (setq star-state :one-end-star)
  19. (when (looking-at "\s-*\*")
  20. (delete-char -1)
  21. (search-forward "*"))))
  22.  
  23. ((and (eq this-command 'self-insert-command)
  24. (eq last-command 'self-insert-command)
  25. (eq last-command-event ?*)
  26. (eq star-state :one-end-star))
  27. (delete-char -1)
  28. (forward-char 1)
  29. (setq star-state :no-stars))))
  30.  
  31. (add-hook 'post-self-insert-hook 'star-electric)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement