Skip to content

Commit

Permalink
Allow for lisp operators working differently - know about (+
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Jun 18, 2011
1 parent 287dd88 commit 7a419b4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions smart-operator.el
Expand Up @@ -122,6 +122,15 @@ when `only-where' is 'middle, we will not insert space."




;;; Fine Tunings ;;; Fine Tunings
(defun smart-operator-lispy (op)
"We're in a Lisp-ish mode, so let's look for parenthesis.
Meanwhile, if not found after ( operators are more likely to be function names,
so let's not get too insert-happy."
(if (save-excursion
(backward-char 1)
(looking-at "\("))
(smart-operator-insert op 'after)
(smart-operator-insert op 'middle)))


(defun smart-operator-< () (defun smart-operator-< ()
"See `smart-operator-insert'." "See `smart-operator-insert'."
Expand All @@ -142,6 +151,9 @@ when `only-where' is 'middle, we will not insert space."
(eq major-mode 'sgml-mode)) (eq major-mode 'sgml-mode))
(insert "<>") (insert "<>")
(backward-char)) (backward-char))
((or (memq major-mode '(emacs-lisp-mode))
(memq major-mode '(lisp-mode)))
(smart-operator-lispy "<"))
(t (t
(smart-operator-insert "<")))) (smart-operator-insert "<"))))


Expand Down Expand Up @@ -222,6 +234,9 @@ when `only-where' is 'middle, we will not insert space."
(smart-operator-insert "*" 'before)) (smart-operator-insert "*" 'before))
(t (t
(smart-operator-insert "*")))) (smart-operator-insert "*"))))
((or (memq major-mode '(emacs-lisp-mode))
(memq major-mode '(lisp-mode)))
(smart-operator-lispy "*"))
(t (t
(smart-operator-insert "*")))) (smart-operator-insert "*"))))


Expand All @@ -231,6 +246,9 @@ when `only-where' is 'middle, we will not insert space."
(cond ((and c-buffer-is-cc-mode (looking-back " - ")) (cond ((and c-buffer-is-cc-mode (looking-back " - "))
(delete-char -3) (delete-char -3)
(insert "->")) (insert "->"))
((or (memq major-mode '(emacs-lisp-mode))
(memq major-mode '(lisp-mode)))
(smart-operator-lispy ">"))
(t (t
(smart-operator-insert ">")))) (smart-operator-insert ">"))))


Expand All @@ -244,6 +262,9 @@ when `only-where' is 'middle, we will not insert space."
(delete-horizontal-space))) (delete-horizontal-space)))
(smart-operator-insert "+" 'middle) (smart-operator-insert "+" 'middle)
(indent-according-to-mode)) (indent-according-to-mode))
((or (memq major-mode '(emacs-lisp-mode))
(memq major-mode '(lisp-mode)))
(smart-operator-lispy "+"))
(t (t
(smart-operator-insert "+")))) (smart-operator-insert "+"))))


Expand All @@ -257,6 +278,9 @@ when `only-where' is 'middle, we will not insert space."
(delete-horizontal-space))) (delete-horizontal-space)))
(smart-operator-insert "-" 'middle) (smart-operator-insert "-" 'middle)
(indent-according-to-mode)) (indent-according-to-mode))
((or (memq major-mode '(emacs-lisp-mode))
(memq major-mode '(lisp-mode)))
(smart-operator-lispy "-"))
(t (t
(smart-operator-insert "-")))) (smart-operator-insert "-"))))


Expand Down

0 comments on commit 7a419b4

Please sign in to comment.