Skip to content

Commit

Permalink
Rename -out-forward to -right, and -out-backward to -left
Browse files Browse the repository at this point in the history
* lispy.el (lispy-out-forward): declare obsolete in 0.21.0.
(lispy-out-backward): declare obsolete in 0.21.0.
(lispy-out-forward-nostring): declare obsolete in 0.21.0.
  • Loading branch information
abo-abo committed Jan 19, 2015
1 parent 5d3e942 commit f75b674
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lispy-pkg.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(define-package "lispy" "0.17.0"
(define-package "lispy" "0.21.0"
"vi-like Paredit"
'((helm "1.5.3")
(ace-jump-mode "2.0")
Expand Down
20 changes: 10 additions & 10 deletions lispy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,26 @@ Insert KEY if there's no command."
(should (string= (lispy-with "(foo)\n;; (foo bar\n;; tanf)|" "[")
"|(foo)\n;; (foo bar\n;; tanf)")))

(ert-deftest lispy-out-forward ()
(ert-deftest lispy-right ()
(should (string= (lispy-with "(|(a) (b) (c))" "l")
"((a) (b) (c))|"))
(should (string= (lispy-with "(|(a) (b) (c))" "ll")
"((a) (b) (c))|"))
(should (string= (lispy-with "(|(a) (b) (c))" (lispy-out-forward 1))
(should (string= (lispy-with "(|(a) (b) (c))" (lispy-right 1))
"((a) (b) (c))|"))
(should (string= (lispy-with "(|(a) (b) (c))"
(lispy-out-forward 1)
(lispy-out-forward 1))
(lispy-right 1)
(lispy-right 1))
"((a) (b) (c))|"))
(should (string= (lispy-with "((|a) (b) (c))" (lispy-out-forward 1))
(should (string= (lispy-with "((|a) (b) (c))" (lispy-right 1))
"((a)| (b) (c))"))
(should (string= (lispy-with "((|a) (b) (c))"
(lispy-out-forward 1)
(lispy-out-forward 1))
(lispy-right 1)
(lispy-right 1))
"((a) (b) (c))|"))
(should (string= (lispy-with "((|a) (b) (c))" (lispy-out-forward 2))
(should (string= (lispy-with "((|a) (b) (c))" (lispy-right 2))
"((a) (b) (c))|"))
(should (string= (lispy-with "((a) \"(|foo)\" (c))" (lispy-out-forward 2))
(should (string= (lispy-with "((a) \"(|foo)\" (c))" (lispy-right 2))
"((a) \"(foo)\" (c))|"))
(should (string= (lispy-with "(defun foo ()\n (let ((a 1))\n (let ((b 2))\n (something)|)))" "l")
"(defun foo ()\n (let ((a 1))\n (let ((b 2))\n (something))|))"))
Expand All @@ -228,7 +228,7 @@ Insert KEY if there's no command."
(should (string= (lispy-with "(defun foo ()\n (let ((a 1))\n (let ((b 2))\n |(something))))" "9l")
"(defun foo ()\n (let ((a 1))\n (let ((b 2))\n (something))))|")))

(ert-deftest lispy-out-backward ()
(ert-deftest lispy-left ()
(should (string= (lispy-with "(|(a) (b) (c))" "h")
"|((a) (b) (c))"))
(should (string= (lispy-with "(|(a) (b) (c))" "hh")
Expand Down
49 changes: 28 additions & 21 deletions lispy.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Oleh Krehel <[email protected]>
;; URL: https://github.com/abo-abo/lispy
;; Version: 0.20.0
;; Version: 0.21.0
;; Keywords: lisp

;; This file is not part of GNU Emacs
Expand Down Expand Up @@ -58,8 +58,8 @@
;; To move the point into a special position, use:
;; "]" - calls `lispy-forward'
;; "[" - calls `lispy-backward'
;; "C-3" - calls `lispy-out-forward' (exit current list forwards)
;; ")" - calls `lispy-out-forward-nostring' (exit current list
;; "C-3" - calls `lispy-right' (exit current list forwards)
;; ")" - calls `lispy-right-nostring' (exit current list
;; forwards, but self-insert in strings and comments)
;;
;; These are the few Lispy commands that don't care whether the point
Expand Down Expand Up @@ -414,7 +414,7 @@ Use the command `%s' to change this variable."
(defun lispy-forward (arg)
"Move forward list ARG times or until error.
Return t if moved at least once,
otherwise call `lispy-out-forward' and return nil."
otherwise call `lispy-right' and return nil."
(interactive "p")
(when (= arg 0)
(setq arg 2000))
Expand Down Expand Up @@ -467,7 +467,7 @@ If couldn't move backward at least once, move up backward and return nil."
(backward-list))
(point))))

(defun lispy-out-forward (arg)
(defun lispy-right (arg)
"Move outside list forwards ARG times.
Return nil on failure, t otherwise."
(interactive "p")
Expand All @@ -483,7 +483,14 @@ Return nil on failure, t otherwise."
(t
(lispy--out-forward arg))))

(defun lispy-out-forward-nostring (arg)
(define-obsolete-function-alias 'lispy-out-forward
'lispy-right "0.21.0")
(define-obsolete-function-alias 'lispy-out-backward
'lispy-left "0.21.0")
(define-obsolete-function-alias 'lispy-out-forward-nostring
'lispy-right-nostring "0.21.0")

(defun lispy-right-nostring (arg)
"Call `lispy--out-forward' with ARG unless in string or comment.
Self-insert otherwise."
(interactive "p")
Expand All @@ -493,9 +500,9 @@ Self-insert otherwise."
(lispy--out-forward arg)))

(defvar lispy-pre-outline-pos 1
"Point position before moving to outline with `lispy-out-backward'.")
"Point position before moving to outline with `lispy-left'.")

(defun lispy-out-backward (arg)
(defun lispy-left (arg)
"Move outside list forwards ARG times.
Return nil on failure, t otherwise."
(interactive "p")
Expand Down Expand Up @@ -842,7 +849,7 @@ Return nil if can't move."
(delete-char arg))

((looking-at lispy-right)
(lispy-out-backward 1))
(lispy-left 1))

((looking-at lispy-left)
(when (looking-back "\\(?:\\s-\\|^\\)[`',@]+")
Expand Down Expand Up @@ -1400,7 +1407,7 @@ to all the functions, while maintaining the parens in a pretty state."
((looking-back lispy-right))
((looking-at lispy-right)
(when (looking-back " ")
(lispy-out-forward 1)))
(lispy-right 1)))
((looking-at lispy-left)
(lispy-different))
((looking-back "^ +")
Expand Down Expand Up @@ -1838,7 +1845,7 @@ When ARG is more than 1, pull ARGth expression to enclose current sexp."
(lispy-different)
(setq beg (point))
(setq end (lispy--out-forward arg))
(lispy-out-forward 1)
(lispy-right 1)
(lispy--swap-regions (cons beg end)
(cons (point) (point)))
(lispy--reindent (1+ arg))))
Expand Down Expand Up @@ -1883,7 +1890,7 @@ When ARG is more than 1, pull ARGth expression to enclose current sexp."
(delete-char 1)
(lispy-save-excursion
(forward-char 1)
(lispy-out-backward 2)
(lispy-left 2)
(lispy--normalize-1))))
((and (setq bnd (lispy--bounds-string))
(or (save-excursion
Expand Down Expand Up @@ -1917,7 +1924,7 @@ When ARG is more than 1, pull ARGth expression to enclose current sexp."
(lispy--out-forward 1))
(insert ")(")
(backward-char 2)
(lispy-out-forward 1))
(lispy-right 1))
(newline-and-indent)
(when (looking-at lispy-left)
(indent-sexp))))))
Expand Down Expand Up @@ -2845,7 +2852,7 @@ With ARG, use the contents of `lispy-store-region-and-buffer' instead."
(if (looking-back lispy-right)
(progn (backward-list)
nil)
(lispy-out-backward 1))))
(lispy-left 1))))
(bnd (lispy--bounds-list))
(str (lispy--string-dwim bnd))
(expr (lispy--read str))
Expand Down Expand Up @@ -2911,7 +2918,7 @@ With ARG, use the contents of `lispy-store-region-and-buffer' instead."
(lispy-move-down 1)
(iedit-mode)
(deactivate-mark)
(lispy-out-backward 1)
(lispy-left 1)
(lispy-delete 1)
(save-excursion
(lispy--out-backward 1)
Expand Down Expand Up @@ -3076,7 +3083,7 @@ Second region and buffer are the current ones."
(interactive)
(if (bound-and-true-p edebug-active)
(save-excursion
(lispy-out-backward 99)
(lispy-left 99)
(if (looking-at
"(\\(?:cl\\|\\)def\\(?:un\\|macro\\)\\s-+\\_<[^ ]+\\_>\\s-+(")
(progn
Expand Down Expand Up @@ -3549,7 +3556,7 @@ First, try to return `lispy--bounds-string'."

;;* Utilities: movement
(defvar lispy-ignore-whitespace nil
"When set to t, `lispy-out-forward' will not clean up whitespace.")
"When set to t, `lispy-right' will not clean up whitespace.")

(defun lispy--out-forward (arg)
"Move outside list forwards ARG times.
Expand Down Expand Up @@ -5225,7 +5232,7 @@ FUNC is obtained from (`lispy--insert-or-call' DEF PLIST)"
;; ——— globals: navigation ——————————————————
(define-key map (kbd "]") 'lispy-forward)
(define-key map (kbd "[") 'lispy-backward)
(define-key map (kbd ")") 'lispy-out-forward-nostring)
(define-key map (kbd ")") 'lispy-right-nostring)
;; ——— globals: kill-related ————————————————
(define-key map (kbd "C-k") 'lispy-kill)
(define-key map (kbd "C-y") 'lispy-yank)
Expand Down Expand Up @@ -5257,7 +5264,7 @@ FUNC is obtained from (`lispy--insert-or-call' DEF PLIST)"
(when lispy-use-ctrl-digits
(define-key map (kbd "C-1") 'lispy-describe-inline)
(define-key map (kbd "C-2") 'lispy-arglist-inline)
(define-key map (kbd "C-3") 'lispy-out-forward)
(define-key map (kbd "C-3") 'lispy-right)
(define-key map (kbd "C-4") lispy-mode-x-map)
(define-key map (kbd "C-7") 'lispy-cursor-down)
(define-key map (kbd "C-8") 'lispy-parens-down)
Expand All @@ -5271,8 +5278,8 @@ FUNC is obtained from (`lispy--insert-or-call' DEF PLIST)"
(define-key map (kbd "M-q") 'lispy-fill)
(define-key map (kbd "<backtab>") 'lispy-shifttab)
;; ——— locals: navigation ———————————————————
(lispy-define-key map "l" 'lispy-out-forward)
(lispy-define-key map "h" 'lispy-out-backward)
(lispy-define-key map "l" 'lispy-right)
(lispy-define-key map "h" 'lispy-left)
(lispy-define-key map "f" 'lispy-flow)
(lispy-define-key map "j" 'lispy-down)
(lispy-define-key map "k" 'lispy-up)
Expand Down

0 comments on commit f75b674

Please sign in to comment.