* line-move-down-up @ 2011-04-18 13:26 A Soare 2011-04-18 13:36 ` line-move-down-up Deniz Dogan 2011-04-18 14:30 ` line-move-down-up Stephen J. Turnbull 0 siblings, 2 replies; 14+ messages in thread From: A Soare @ 2011-04-18 13:26 UTC (permalink / raw) To: emacs-devel (defun line-move-down (n) (let ((column (current-column)) (line (delete-and-extract-region (prog2 (beginning-of-line) (point)) (prog2 (end-of-line) (1+ (point)) )))) (next-line n) (beginning-of-line) (insert-string line) (backward-char) (move-to-column column) 'down )) (define-key global-map [(meta up)] (lambda (&optional n) (interactive "P") (line-move-down (if (numberp n) (- n) -1)))) (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") (line-move-down (if (numberp n) n 1)))) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 13:26 line-move-down-up A Soare @ 2011-04-18 13:36 ` Deniz Dogan 2011-04-18 13:40 ` line-move-down-up A Soare 2011-04-18 14:30 ` line-move-down-up Stephen J. Turnbull 1 sibling, 1 reply; 14+ messages in thread From: Deniz Dogan @ 2011-04-18 13:36 UTC (permalink / raw) To: A Soare; +Cc: emacs-devel 2011/4/18 A Soare <as1789@gmail.com>: > > (defun line-move-down (n) > (let ((column (current-column)) > (line (delete-and-extract-region > (prog2 (beginning-of-line) (point)) > (prog2 (end-of-line) (1+ (point)) )))) > (next-line n) > (beginning-of-line) > (insert-string line) > (backward-char) > (move-to-column column) > 'down > )) > > (define-key global-map [(meta up)] (lambda (&optional n) (interactive "P") > (line-move-down (if (numberp n) (- n) -1)))) > > (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") > (line-move-down (if (numberp n) n 1)))) > I'm not sure what this post is all about, but you could replace (prog2 (beginning-of-line) (point)) with (point-at-bol) and respectively for the end. Also, (next-line n) (beginning-of-line) could be replaced with (beginning-of-line (1+ n)). -- Deniz Dogan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 13:36 ` line-move-down-up Deniz Dogan @ 2011-04-18 13:40 ` A Soare 2011-04-18 14:51 ` line-move-down-up A Soare 0 siblings, 1 reply; 14+ messages in thread From: A Soare @ 2011-04-18 13:40 UTC (permalink / raw) To: emacs-devel > > > > (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") > > (line-move-down (if (numberp n) n 1)))) > > > > I'm not sure what this post is all about, but you could > replace (prog2 (beginning-of-line) (point)) with (point-at-bol) > and respectively for the end. I proposed some useful function that do not exist. Yes, if they are useful, many improvments can be done. For example, what to happen at the end of the buffer. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 13:40 ` line-move-down-up A Soare @ 2011-04-18 14:51 ` A Soare 2011-04-18 15:31 ` line-move-down-up Deniz Dogan 0 siblings, 1 reply; 14+ messages in thread From: A Soare @ 2011-04-18 14:51 UTC (permalink / raw) To: emacs-devel > > I have just received a reponse that transpose-line does the same job. Yes, this is almost identical to transpose-line. But transpose-line behaves a little different. This is why I forget all the time about that function, and never use it. > Also, (next-line n) (beginning-of-line) could be replaced > with (beginning-of-line (1+ n)). > This is wrong in general. Alin ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 14:51 ` line-move-down-up A Soare @ 2011-04-18 15:31 ` Deniz Dogan 2011-04-18 15:37 ` line-move-down-up A Soare 0 siblings, 1 reply; 14+ messages in thread From: Deniz Dogan @ 2011-04-18 15:31 UTC (permalink / raw) To: A Soare; +Cc: emacs-devel 2011/4/18 A Soare <as1789@gmail.com>: >> Also, (next-line n) (beginning-of-line) could be replaced >> with (beginning-of-line (1+ n)). >> > > This is wrong in general. > Care to elaborate? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 15:31 ` line-move-down-up Deniz Dogan @ 2011-04-18 15:37 ` A Soare 0 siblings, 0 replies; 14+ messages in thread From: A Soare @ 2011-04-18 15:37 UTC (permalink / raw) To: emacs-devel Deniz Dogan <deniz.a.m.dogan <at> gmail.com> writes: > > 2011/4/18 A Soare <as1789 <at> gmail.com>: > >> Also, (next-line n) (beginning-of-line) could be replaced > >> with (beginning-of-line (1+ n)). > >> > > > > This is wrong in general. > > > > Care to elaborate? > > (progn (goto-char (point-max)) (insert ? ) (beginning-of-line 4)) The definitive version I keep in .emacs is so: ;; move line (defun line-move-down (n) (if (> (point-max) (point-at-eol)) (let ((column (current-column) ) (line (delete-and-extract-region (point-at-bol) (1+ (point-at-eol))))) (forward-line n) (insert-string line) (backward-char) (move-to-column column) ) ) ) (define-key global-map [(meta up)] (lambda (&optional n) (interactive "P") (line-move-down (if (numberp n) (- n) -1) ) ) ) (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") (line-move-down (if (numberp n) n 1) ) ) ) ^ permalink raw reply [flat|nested] 14+ messages in thread
* line-move-down-up 2011-04-18 13:26 line-move-down-up A Soare 2011-04-18 13:36 ` line-move-down-up Deniz Dogan @ 2011-04-18 14:30 ` Stephen J. Turnbull 2011-04-18 14:53 ` line-move-down-up A Soare [not found] ` <BANLkTimKts-mZSMmbeo=rOCeP8+Un2aZjA@mail.gmail.com> 1 sibling, 2 replies; 14+ messages in thread From: Stephen J. Turnbull @ 2011-04-18 14:30 UTC (permalink / raw) To: A Soare; +Cc: emacs-devel A Soare writes: > > (defun line-move-down (n) > (let ((column (current-column)) Oops, no interactive declaration. I gather you haven't even tried these functions at home? Proposing two global bindings is a little early I suppose.... Besides, if I understand what the function actually does, it's mostly subsumed by transpose-lines, which already has a binding C-x C-t, and (at least in the Emacsen I'm using) a nifty feature of exchanging the lines containing point and mark respectively when the argument is 0. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 14:30 ` line-move-down-up Stephen J. Turnbull @ 2011-04-18 14:53 ` A Soare [not found] ` <BANLkTimKts-mZSMmbeo=rOCeP8+Un2aZjA@mail.gmail.com> 1 sibling, 0 replies; 14+ messages in thread From: A Soare @ 2011-04-18 14:53 UTC (permalink / raw) To: emacs-devel > > (defun line-move-down (n) > > (let ((column (current-column)) > > Oops, no interactive declaration. I gather you haven't even tried > these functions at home? Proposing two global bindings is a little > early I suppose.... > Please read more carefully. (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") (line-move-down (if (numberp n) n 1)))) ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <BANLkTimKts-mZSMmbeo=rOCeP8+Un2aZjA@mail.gmail.com>]
[parent not found: <87d3kjpnef.fsf@uwakimon.sk.tsukuba.ac.jp>]
* Re: line-move-down-up [not found] ` <87d3kjpnef.fsf@uwakimon.sk.tsukuba.ac.jp> @ 2011-04-18 15:56 ` Alin Soare 2011-04-18 19:24 ` line-move-down-up Davis Herring 2011-04-19 8:20 ` line-move-down-up Ivan Andrus 0 siblings, 2 replies; 14+ messages in thread From: Alin Soare @ 2011-04-18 15:56 UTC (permalink / raw) To: Stephen J. Turnbull; +Cc: Emacs Dev [-- Attachment #1: Type: text/plain, Size: 946 bytes --] 2011/4/18 Stephen J. Turnbull <turnbull@sk.tsukuba.ac.jp> > Alin Soare writes: > > > > look better: > > > > (define-key global-map [(meta up)] (lambda (&optional n) (interactive > "P") > > (line-move-down (if (numberp n) (- n) -1)))) > > Yeah, sorry about that. > > > But, yes. You are right. > > > > Transpose-lines does the job, but not as I wish. > > Of course it doesn't. All defaults suck for somebody. That's what > .emacs is for. > > If you want to impose the burden of maintenance on the team, you need > to explain why your version is an improvement for a lot of people. > > I used the meta + up-down, using the model of spreadsheets of org-mode, that I use. It is the most convenient conbination for me. If I use C-x C-t, the cursor goes down, while the line goes up. I cannot move the line the second time. And this only transposes the line, not move the line. I need move, not transpose, and I cannot find this in emacs. [-- Attachment #2: Type: text/html, Size: 1454 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 15:56 ` line-move-down-up Alin Soare @ 2011-04-18 19:24 ` Davis Herring 2011-04-20 17:22 ` line-move-down-up Alin Soare 2011-04-19 8:20 ` line-move-down-up Ivan Andrus 1 sibling, 1 reply; 14+ messages in thread From: Davis Herring @ 2011-04-18 19:24 UTC (permalink / raw) To: Alin Soare; +Cc: Stephen J. Turnbull, Emacs Dev > If I use C-x C-t, the cursor goes down, while the line goes up. I cannot > move the line the second time. Which line? Obviously one line is moving down if another is moving up. If you want point to move along with the upward-moving line rather than the downward-moving one, use C-- C-x C-t (and then C-x z z ... as needed). > And this only transposes the line, not move the line. What's the difference? Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 19:24 ` line-move-down-up Davis Herring @ 2011-04-20 17:22 ` Alin Soare 0 siblings, 0 replies; 14+ messages in thread From: Alin Soare @ 2011-04-20 17:22 UTC (permalink / raw) To: herring; +Cc: Stephen J. Turnbull, Emacs Dev [-- Attachment #1: Type: text/plain, Size: 1352 bytes --] > > > If I use C-x C-t, the cursor goes down, while the line goes up. I cannot > > move the line the second time. > > Which line? Obviously one line is moving down if another is moving up. > If you want point to move along with the upward-moving line rather than > the downward-moving one, use C-- C-x C-t (and then C-x z z ... as needed). > > > And this only transposes the line, not move the line. > > What's the difference? > > This is a good question. Please, can you write 2 lambda functions that behaves exactly like the code below, and attach them to M-up , M-down ? You should use only transpose-line, and none other function that deletes text, like delete-and-extract-region, kill-line, etc. (defun line-move-- (n) (if (> (point-max) (point-at-eol)) (let ((column (current-column) ) (line (delete-and-extract-region (point-at-bol) (1+ (point-at-eol))))) (forward-line n) (insert-string line) (backward-char) (move-to-column column) ) ) ) (define-key global-map [(meta up)] (lambda (&optional n) (interactive "P") (line-move-- (- (if (numberp n) n 1) ) ) ) ) (define-key global-map [(meta down)] (lambda (&optional n) (interactive "P") (line-move-- (if (numberp n) n 1) ) ) ) ;;;;; Using transpose-line , it is much direct to simulate line-move--down than I did. [-- Attachment #2: Type: text/html, Size: 1821 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-18 15:56 ` line-move-down-up Alin Soare 2011-04-18 19:24 ` line-move-down-up Davis Herring @ 2011-04-19 8:20 ` Ivan Andrus 2011-04-19 9:34 ` line-move-down-up Deniz Dogan 1 sibling, 1 reply; 14+ messages in thread From: Ivan Andrus @ 2011-04-19 8:20 UTC (permalink / raw) To: Emacs Dev [-- Attachment #1: Type: text/plain, Size: 1523 bytes --] On Apr 18, 2011, at 5:56 PM, Alin Soare wrote: > 2011/4/18 Stephen J. Turnbull <turnbull@sk.tsukuba.ac.jp> > Alin Soare writes: > > > > look better: > > > > (define-key global-map [(meta up)] (lambda (&optional n) (interactive "P") > > (line-move-down (if (numberp n) (- n) -1)))) > > Yeah, sorry about that. > > > But, yes. You are right. > > > > Transpose-lines does the job, but not as I wish. > > Of course it doesn't. All defaults suck for somebody. That's what > .emacs is for. > > If you want to impose the burden of maintenance on the team, you need > to explain why your version is an improvement for a lot of people. > > I used the meta + up-down, using the model of spreadsheets of org-mode, that I use. It is the most convenient conbination for me. > > If I use C-x C-t, the cursor goes down, while the line goes up. I cannot move the line the second time. > > And this only transposes the line, not move the line. > > I need move, not transpose, and I cannot find this in emacs. I also use this functionality, but I get it from drag-stuff.el (not written by me) which has the advantage of being on http://tromey.com/elpa/ . It also has functionality for dragging words and region, though I rarely use it. The only problem it has (for me) is that it interferes with org-mode's M-up/down, but you can fix that by setting `drag-stuff-except-modes'. I have thought about adding the ability to drag defun's and such, but so far haven't taken the time. -Ivan [-- Attachment #2: Type: text/html, Size: 2378 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-19 8:20 ` line-move-down-up Ivan Andrus @ 2011-04-19 9:34 ` Deniz Dogan 2011-04-21 9:28 ` line-move-down-up Ivan Andrus 0 siblings, 1 reply; 14+ messages in thread From: Deniz Dogan @ 2011-04-19 9:34 UTC (permalink / raw) To: Ivan Andrus; +Cc: Emacs Dev 2011/4/19 Ivan Andrus <darthandrus@gmail.com>: > On Apr 18, 2011, at 5:56 PM, Alin Soare wrote: > > 2011/4/18 Stephen J. Turnbull <turnbull@sk.tsukuba.ac.jp> >> >> Alin Soare writes: >> >> > > look better: >> > >> > (define-key global-map [(meta up)] (lambda (&optional n) (interactive >> "P") >> > (line-move-down (if (numberp n) (- n) -1)))) >> >> Yeah, sorry about that. >> >> > But, yes. You are right. >> > >> > Transpose-lines does the job, but not as I wish. >> >> Of course it doesn't. All defaults suck for somebody. That's what >> .emacs is for. >> >> If you want to impose the burden of maintenance on the team, you need >> to explain why your version is an improvement for a lot of people. > > I used the meta + up-down, using the model of spreadsheets of org-mode, that > I use. It is the most convenient conbination for me. > > If I use C-x C-t, the cursor goes down, while the line goes up. I cannot > move the line the second time. > > And this only transposes the line, not move the line. > > I need move, not transpose, and I cannot find this in emacs. > > I also use this functionality, but I get it from drag-stuff.el (not written > by me) which has the advantage of being on http://tromey.com/elpa/ . It > also has functionality for dragging words and region, though I rarely use > it. The only problem it has (for me) is that it interferes with org-mode's > M-up/down, but you can fix that by setting `drag-stuff-except-modes'. > I have thought about adding the ability to drag defun's and such, but so far > haven't taken the time. I can't find drag-stuff when I do M-x package-list-packages. Where can I find it? -- Deniz Dogan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: line-move-down-up 2011-04-19 9:34 ` line-move-down-up Deniz Dogan @ 2011-04-21 9:28 ` Ivan Andrus 0 siblings, 0 replies; 14+ messages in thread From: Ivan Andrus @ 2011-04-21 9:28 UTC (permalink / raw) To: Emacs Dev On Apr 19, 2011, at 11:34 AM, Deniz Dogan wrote: > > I can't find drag-stuff when I do M-x package-list-packages. > Where can I find it? It's not on http://elpa.gnu.org/packages/ but rather on http://tromey.com/elpa/ or http://marmalade-repo.org/packages/ You have to set `package-archives' to include one of those addresses. If you have already done so, then I don't know. -Ivan ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-04-21 9:28 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-04-18 13:26 line-move-down-up A Soare 2011-04-18 13:36 ` line-move-down-up Deniz Dogan 2011-04-18 13:40 ` line-move-down-up A Soare 2011-04-18 14:51 ` line-move-down-up A Soare 2011-04-18 15:31 ` line-move-down-up Deniz Dogan 2011-04-18 15:37 ` line-move-down-up A Soare 2011-04-18 14:30 ` line-move-down-up Stephen J. Turnbull 2011-04-18 14:53 ` line-move-down-up A Soare [not found] ` <BANLkTimKts-mZSMmbeo=rOCeP8+Un2aZjA@mail.gmail.com> [not found] ` <87d3kjpnef.fsf@uwakimon.sk.tsukuba.ac.jp> 2011-04-18 15:56 ` line-move-down-up Alin Soare 2011-04-18 19:24 ` line-move-down-up Davis Herring 2011-04-20 17:22 ` line-move-down-up Alin Soare 2011-04-19 8:20 ` line-move-down-up Ivan Andrus 2011-04-19 9:34 ` line-move-down-up Deniz Dogan 2011-04-21 9:28 ` line-move-down-up Ivan Andrus
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.