diff --git a/README.org b/README.org index 11ba3b3..2c57593 100644 --- a/README.org +++ b/README.org @@ -8,6 +8,12 @@ This package ships `frowny-mode', which enables inserting a single "(" when after a ":" -- meaning it'll insert :( without closing the parentheses for modes like =electric-pair-mode=, =paredit-mode=, and others. +* Version 0.2 + +Just released: Version 0.2, /now with smileys/! Yes, if you're one of those +happy-go-lucky people who just /has/ to smile all the time, frowny.el is now for +you as well. Go nuts, ya filthy animal. + * Installation I use [[https://github.com/raxod502/straight.el][straight.el]], which looks like this: @@ -42,7 +48,7 @@ There are a (growing?) number of customization options available for I'd recommend replacing it with an =rx= form, like this: #+begin_src emacs-lisp - (setq frowny-eyes (rx (or “:” “:-” “=” “:'-”)))=. + (setq frowny-eyes (rx (or ":" ":-" "=" ":'-")))=. #+end_src - =frowny-eyes-looking-back-limit=: =frowny= uses =looking-back= to determine whether @@ -62,6 +68,3 @@ Of course, you can always customize these options using Emacs's Customize functi modes /not/ to apply frowny to. - I could do a =frowny-prog-mode= that checks whether the point is in a comment or not, and frowny accordingly. -- It's been brought to my attention that there are cases in which a smiley =:)= - might be messed up when using =electric-pair-mode= … so although it pains me, - =frowny= will also support smileys. /blech/ ! diff --git a/frowny.el b/frowny.el index 1a41cea..317f8c6 100644 --- a/frowny.el +++ b/frowny.el @@ -6,7 +6,7 @@ ;; Homepage: https://github.com/duckwork/frowny.el ;; Keywords: convenience -;; Package-Version: 0.1 +;; Package-Version: 0.2 ;; Package-Requires: ((emacs "24.1")) ;;; License: @@ -49,14 +49,29 @@ With an value of t, enable it in all modes." :type '(choice (const :tag "All modes" t) (repeat :tag "Modes" function))) -(defun frowny-self-insert (N) - "Insert a frowny, or insert the character \"(\" N times." - (interactive "p") +(defun frowny--insert-character (character number) + "Insert CHARACTER NUMBER times, depending on frowniness. +Internal: use `frowny-self-insert-frowny' or +`frowny-self-insert-smiley' instead." (cond ((looking-back frowny-eyes frowny-eyes-looking-back-limit) - (dotimes (_ N) - (insert "("))) - (t (self-insert-command N ?\()))) + (dotimes (_ number) + (insert character))) + (t (self-insert-command number character)))) + +(defun frowny-self-insert-frowny (N) + "Insert \"(\" N times." + (interactive "p") + (frowny--insert-character ?\( N)) + +(define-obsolete-function-alias 'frowny-self-insert 'frowny-self-insert-frowny + "0.2" + "Insert a frowny, or insert the character \"(\" N times.") + +(defun frowny-self-insert-smiley (N) + "Insert \")\" N times." + (interactive "p") + (frowny--insert-character ?\) N)) (defun frowny-mode--turn-on () "Turn on function `frowny-mode'." @@ -68,7 +83,8 @@ With an value of t, enable it in all modes." :init t :lighter ":(" :keymap (let ((map (make-sparse-keymap))) - (define-key map "(" #'frowny-self-insert) + (define-key map "(" #'frowny-self-insert-frowny) + (define-key map ")" #'frowny-self-insert-smiley) map)) ;;;###autoload