Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defvar star-state :no-stars)
- (defun star-electric ()
- (cond
- ((and (eq this-command 'self-insert-command)
- (eq last-command-event ?*)
- (eq star-state :no-stars))
- (setq star-state :one-beg-star))
- ((and (eq this-command 'self-insert-command)
- (eq last-command-event ?*)
- (eq star-state :one-beg-star))
- (progn (insert "**")
- (backward-char 2)
- (setq star-state :two-beg-stars)))
- ((and (eq this-command 'self-insert-command)
- (eq last-command-event ?*)
- (eq star-state :two-beg-stars))
- (progn
- (setq star-state :one-end-star)
- (when (looking-at "\s-*\*")
- (delete-char -1)
- (search-forward "*"))))
- ((and (eq this-command 'self-insert-command)
- (eq last-command 'self-insert-command)
- (eq last-command-event ?*)
- (eq star-state :one-end-star))
- (delete-char -1)
- (forward-char 1)
- (setq star-state :no-stars))))
- (add-hook 'post-self-insert-hook 'star-electric)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement