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

Line joining and opening #339

Closed
tuhdo opened this issue Mar 13, 2015 · 7 comments
Closed

Line joining and opening #339

tuhdo opened this issue Mar 13, 2015 · 7 comments

Comments

@tuhdo
Copy link

tuhdo commented Mar 13, 2015

@xahlee @mlf176f2 These are the two editing commands that I found really useful.

  • Line joining is the ability to merge next line into the current line without moving point. For example, you have a list of function parameters or a list of sexp on multiple lines and feel we can save space by moving them all within a line. Suppose we have 4 lines to merge. Then we simply execute join command 4 times. Without it, we have to move cursor to the end, run kill-line, then move point to the end again. At least we need to execute between 8 commands, and we have to alternate our hands between two different command. Emacs already has stock join-line, but it joins from the bottom. We can write a little function to easily achieve the reverse. You can take a look at this post for join-top-line command. I suggest the key bindings for joining lines are Alt + [ to join-top-line and Alt + ] for stock join-line.
  • Line opening is the ability to insert a new line and move point to the beginning of next line, preferably at the beginning of indentation. It is useful when you are in the middle of a line and decide to add something to the next line, without having to move to the beginning or end of line and press RET, then press Alt + i or k to finally move to where you want to insert. I suggest bind it to Alt + Enter for opening line below and Alt + Shift + Enter for opening line above, since those key bindings are used for newline-and-indent, which is bound to RET in ErgoEmacs by default.
@xahlee
Copy link
Member

xahlee commented Mar 15, 2015

line joining you can do by calling ergoemacs-shrink-whitespaces
or xah-shrink-whitespaces.
i recently modified xah-shrink-whitespaces so it actually join lines in the
last repeat.

line opening, if you mean emacs's open-line command. (but it doesn't match
your description) I find open-line useful in recent years.

Xah

On Fri, Mar 13, 2015 at 2:59 PM, Tu Do notifications@github.com wrote:

@xahlee https://github.com/xahlee @mlf176f2
https://github.com/mlf176f2 These are the two editing commands that I
found really useful.

Line joining is the ability to merge next line into the current line
without moving point. For example, you have a list of function parameters
or a list of sexp on multiple lines and feel we can save space by moving
them all within a line. Suppose we have 4 lines to merge. Then we simply
execute join command 4 times. Without it, we have to move cursor to the
end, run kill-line, then move point to the end again. At least we need
to execute between 8 commands, and we have to alternate our hands between
two different command. Emacs already has stock join-line, but it joins
from the bottom. We can write a little function to easily achieve the
reverse. You can take a look at this post
http://emacsredux.com/blog/2013/05/30/joining-lines/ for
join-top-line command. I suggest the key bindings for joining lines
are Alt + [ to join-top-line and Alt + ] for stock join-line.

Line opening is the ability to insert a new line and move point to the
beginning of next line, preferably at the beginning of indentation. It is
useful when you are in the middle of a line and decide to add something to
the next line, without having to move to the beginning or end of line and
press RET, then press Alt + i or k to finally move to where you want
to insert. I suggest bind it to Alt + Enter for opening line below and Alt

  • Shift + Enter for opening line above.


Reply to this email directly or view it on GitHub
#339.

@tuhdo
Copy link
Author

tuhdo commented Mar 15, 2015

@xahlee Oh sorry about the open-line. I meant the open-line feature in Prelude:

(defun prelude-smart-open-line (arg)
  "Insert an empty line after the current line.
Position the cursor at its beginning, according to the current mode.
With a prefix ARG open line above the current line."
  (interactive "P")
  (if arg
      (prelude-smart-open-line-above)
    (progn
      (move-end-of-line nil)
      (newline-and-indent))))

As for line joining, ergoemacs-shrink-whitespaces doesn't seem to join the next line. It only erases spaces.

@xahlee
Copy link
Member

xahlee commented Mar 15, 2015

As for line joining, ergoemacs-shrink-whitespaces doesn't seem to join
the next line. It only erases spaces.

no, it doesn't, but as i said, the modified version xah-shrink-whitespaces
does.

about prelude-smart-open-line, in my opinion it is not general enough to be
a core ~30 commands that warrant a key. Right now, in ergoemacs-mode, there
are i think 2 or 3 key spot left. But anyway, it's Matt's call.

Xah

On Sat, Mar 14, 2015 at 9:46 PM, Tu Do notifications@github.com wrote:

@xahlee https://github.com/xahlee Oh sorry about the open-line. I meant
the open-line feature in Prelude
https://github.com/bbatsov/prelude/blob/b24bea01bf4e8a34307be9e5aaa119192ceb97be/core/prelude-core.el#L114
:

(defun prelude-smart-open-line (arg)
"Insert an empty line after the current line.Position the cursor at its beginning, according to the current mode.With a prefix ARG open line above the current line."
(interactive "P")
(if arg
(prelude-smart-open-line-above)
(progn
(move-end-of-line nil)
(newline-and-indent))))

As for line joining, ergoemacs-shrink-whitespaces doesn't seem to join
the next line. It only erases spaces.


Reply to this email directly or view it on GitHub
#339 (comment)
.

@mattfidler
Copy link
Member

There are many people who may use prelude, so many people may want the option. I really don't have much time to code up the open-line function and add some tests for it. If you would like to do this I'm fine with it, but I am afraid that you would have had to sign the gnu licence agreement if you want to have it included in ergoemacs-mode since it is on gnu elpa.

For now you should be able to work-around it with a global-set-key in your start-up.

@mattfidler
Copy link
Member

I don't think that I would add it to the core-theme, but an option you can enable/disable.

mattfidler added a commit that referenced this issue Sep 2, 2015
mattfidler added a commit that referenced this issue Sep 2, 2015
@mattfidler
Copy link
Member

I have added the functionality. It is disabled on the standard theme, by default.

You may enable it by

(ergoemacs-require '(join-line open-line))

Or select it from the ergoemacs-mode menu.

I have used your suggested bindings. This implies that RET is no longer bound to newline, but newline-and-indent when you enable this component.

I'm not sure I like the keys since they aren't that ergonomic... In the reduction theme, the join line statements take a little less stretching.

@mattfidler mattfidler reopened this Sep 3, 2015
@mattfidler
Copy link
Member

By adding this component, many of my convenient Alt+RET key bindings have disappeared. I can't stand that ido-mode no longer opens the directory in dired without Alt+RET.

Probably needs more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants