Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy/move line to an initial window #131

Merged
merged 1 commit into from
Jan 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 39 additions & 35 deletions avy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1117,47 +1117,51 @@ Otherwise, forward to `goto-line' with ARG."
"Copy a selected line above the current line.
ARG lines can be used."
(interactive "p")
(avy-with avy-copy-line
(let* ((start (avy--line))
(str (buffer-substring-no-properties
start
(save-excursion
(goto-char start)
(move-end-of-line arg)
(point)))))
(cond ((eq avy-line-insert-style 'above)
(beginning-of-line)
(save-excursion
(insert str "\n")))
((eq avy-line-insert-style 'below)
(end-of-line)
(insert "\n" str)
(beginning-of-line))
(t
(user-error "Unexpected `avy-line-insert-style'"))))))
(let ((initial-window (selected-window)))
(avy-with avy-copy-line
(let* ((start (avy--line))
(str (buffer-substring-no-properties
start
(save-excursion
(goto-char start)
(move-end-of-line arg)
(point)))))
(select-window initial-window)
(cond ((eq avy-line-insert-style 'above)
(beginning-of-line)
(save-excursion
(insert str "\n")))
((eq avy-line-insert-style 'below)
(end-of-line)
(insert "\n" str)
(beginning-of-line))
(t
(user-error "Unexpected `avy-line-insert-style'")))))))

;;;###autoload
(defun avy-move-line (arg)
"Move a selected line above the current line.
ARG lines can be used."
(interactive "p")
(avy-with avy-move-line
(let ((start (avy--line)))
(save-excursion
(goto-char start)
(kill-whole-line arg))
(cond ((eq avy-line-insert-style 'above)
(beginning-of-line)
(save-excursion
(insert
(current-kill 0))))
((eq avy-line-insert-style 'below)
(end-of-line)
(newline)
(save-excursion
(insert (substring (current-kill 0) 0 -1))))
(t
(user-error "Unexpected `avy-line-insert-style'"))))))
(let ((initial-window (selected-window)))
(avy-with avy-move-line
(let ((start (avy--line)))
(save-excursion
(goto-char start)
(kill-whole-line arg))
(select-window initial-window)
(cond ((eq avy-line-insert-style 'above)
(beginning-of-line)
(save-excursion
(insert
(current-kill 0))))
((eq avy-line-insert-style 'below)
(end-of-line)
(newline)
(save-excursion
(insert (substring (current-kill 0) 0 -1))))
(t
(user-error "Unexpected `avy-line-insert-style'")))))))

;;;###autoload
(defun avy-copy-region (arg)
Expand Down