Get back behaviour of C-j from older version of Emacs [duplicate] - emacs

This question already has answers here:
Emacs version 24.4: New obnoxious loss of indentation on hitting RETURN
(3 answers)
Closed 7 years ago.
Not a duplicate of Emacs version 24.4: New obnoxious loss of indentation on hitting RETURN
Turning off electric-indent-mode doesn't solve the issues I am having. Notice that that question doesn't have an accepted answer.
Original question:
Currently using Emacs version 24.5.1 on Windows 7, and the changed behaviour of C-j is extremely irritating. I am sure the designers must have thought it a good idea, but I don't.
Is there any way to get back the behaviour of C-j from older versions? More specifically, I am thinking of v21.x (installed it a few years back on my Mac).
Explanation:
This is what I get in my older version (imagine hitting C-j at the end of each line:
Line 01: Some text.
Line 02: Some more text.
Line 03:
Line 04: Yet more text (notice the indentation stays the same despite
Line 05: the empty line in-between).
In 24.5.1 by default I get (again imagine hitting C-j at the end of each line):
Line 01: Some text.
Line 02: Some more text.
Line 03:
Line 04: Yet more text (notice the indentation goes to zero because of
Line 05: the empty line in-between).
The key binding C-j runs newline-and-indent in Emacs 24.5.1.

You might want to use the built in function default-indent-new-line. Try it by M-x default-indent-new-line. At least in text-mode it does what you describe.
To overwrite C-j in every mode you can just use this snippet in your .emacs file.
(global-set-key (kbd "C-j") 'default-indent-new-line)

Related

Emacs C-x C-; comment line is not working [duplicate]

This question already has an answer here:
Why does Ctrl+. not work when I bind it to a command in Emacs?
(1 answer)
Closed 2 years ago.
I am using emacs26.3 with the major mode "Javascript-IDE" activated. When I type M-x comment-line the desired effects happen in the editor. However, when I type the shortcut C-x C-; I have this output:
Comment column set to 2
And the line is not commented/uncommented. C-h b shows that is the key binding is correct.
Here is my emacs configuration: https://github.com/Amine27/dotfiles/blob/master/emacs.el
Are you using emacs in a terminal? A terminal cannot transmit all combinations of keys and modifiers you could press. I can reproduce this behavior when I run emacs in my terminal (pressing C-; just produces an ordinary ;), but when run in my OS's windowing system emacs registers the C-; chord as desired.

What happened to my Emacs? It doesn't auto-indent or detect parentheses correctly anymore

I worked in Emacs at a company for a few years. It worked just fine. For a given mode, it would automatically indent the next lines where they should be (or could be, in the case of Python). When typing a closing parenthesis, bracket, or brace, it would highlight the corresponding opening one.
I took a break from that company for a few months, and now I'm back. Emacs no longer indents automatically for any file or mode; each new line starts at the beginning of the line. The parenthesis highlighting also only highlights the latest opening parenthesis no matter how many closing parentheses I type.
Nothing seems to have changed for anyone else; just me. What can I do to fix it?
Using global-set-key (kbd "RET") 'newline-and-indent) in my .emacs file helps somewhat, but the behavior is entirely off and annoying.
Edit: The parenthesis matching problem has been solved. The show-paren-mode has been disabled by default, so I added (show-paren-mode 1) to my .emacs file.

EMACS, text seems to be shifted

Using,
EMACS 24.5.1 (encoding: UTF-8 (dos/unix))
OS: Windows 8
Terminal: mintty with UTF-8 under Cygwin
Problem:
Any existing text file that I open in EMACS does not hold its indentation (text is shifted either left or right of its original position). The same text file if I open it in VIM in the same terminal session, seems to be have the correct alignment.
This happens to every text file that I open in EMACS.
I assumed the problem might be with encoding or EOL. So I tried changing the encoding of the terminal output in EMACS(using C-x RET r RET | C-x RET t RET) but that did not help.
I have been reading the official manual but can't seem to solve this issue.
Has anybody got any suggestion of how I should correct this indentation/alignment/EOL problem?
Thanks in advance.
P.S. I saw some similar emacs encoding problems on here but none of them seemed to have helped.
The problem was with the tab size and nothing to do with the encoding.
Emacs is actually pretty awesome in detecting the encoding.
The tab size = 8 white space character in Emacs by default. All my other editors I had set to 4 white space characters hence they all seem to be shifted or lost their indentation when opened in Emacs.
I have used the below configuration in my .emacs file to correct this to tabs = 4 white space char.
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
Thanks again Chris for the solution

emacs next-screen-context-lines ignored

This is probably a very obvious question, but I seem to have missed something. When I first started using emacs about a month ago, pressing C-v would scroll down and leave two line at the top of the screen, à la tutorial. Somewhere along the line I must have upgraded packages, and it now places the cursor at the top of the screen - no context lines.
Running C-u -2 C-v works as expected, so I tried M-x set-variable RET next-screen-context-lines RET 2, which had absolutely no effect. According to C-h v RET next-screen-context-lines, I can set the variable to any positive or negative number I choose, but pressing C-v always results in the cursor moving to the top of the screen and now context lines. Incidentally, M-v has the same problem. I can't find a relevant setting in my .emacs, but I tried mv .emacs .emacs.bak and noticed no difference.
I'm running GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.22) of 2013-12-22 on binet, modified by Debian according to C-h C-a
Other than that, emacs is an amazing program I wish I'd used before, and which has now all but replaced libreoffice for me (with the help of RST). Now to learn to touch type...
Many thanks in advance for your time.
[EDIT]: I was wrong, the point moves as well and I hadn't noticed (see below). The variables suggested below are useful, however.
Check your value of user option scroll-margin: C-h v RET scroll-margin RET. The default value is 0. Try setting it to 2.
There are also other scrolling-related options whose values you can check. Try M-x apropos-option RET ^scroll RET. (Ignore any hits for scroll-bar.)

emacs evil mode moving up

I have a weird behaviour with evil-mode in emacs.
When I move up by 'k' or up arrow after empty line I jump by 2 lines.
Something like evil-mode after empty line ignores one line above.
With moving down there is no problem at all.
GNU Emacs 24.3.1 (Arch Linux) evil-mode from elpa.
Just starting with emacs so I have only basic .emacs and only a few extensions.
Thanks a lot for help.