Struggling with Indenting Region - emacs

I can't get Emacs to indent a region. I have tried everything and the region (that I have marked) never gets indented.
1. quick brown fox
2. quick brown fox
Move cursor to 1.
Hit C-SPC, down, down, down: Emacs highlights the two lines.
Hit C-M-\: I get a nice message "Indenting Region...Done".
But nothing gets indented. Am I doing something stupid?
I even ran the command via M-x indent-region and the selected region never gets indented.

Give a numeric prefix arg to tell indent-region how many columns to indent: C-3 indent-region indents 3 columns (chars); C-- 2 indents -2 columns (i.e., it reduces the indentation by 2 columns); and so on.
The behavior of indent-region depends on the mode you are in. C-h f indent-region tells you that with no prefix arg it has the effect of hitting TAB on each line in the region. If you are in a mode where TAB indents in such a way that it does not indent either of those lines, then they are not indented. See the Emacs manual, node Indentation Commands.

Related

How to get Contex reveal work in org mode

Having a hard time figuring out what C-c C-r does context reveal
Manual says "With a prefix argument show, on each level, all sibling headings. With a double prefix argument, also show the entire subtree of the parent."
When all the Headings are collapsed and I do C-c C-r on a Heading 1
nothing happens
If I try it on a Heading2 or Heading3 when it is collapsed
nothing happens
If I try C-u 2 C-c C-r on a second level heading
Do I get to see all Heading 2 siblings with the current heading fully expanded ?
How can I make this work ?
Or does this work only in agenda views or sparse trees only ?
Got it. its for sparse trees.
After C-c / when the cursor is on the the highlighted entry, C-c C-r works. :)

Emacs cursor jumps before period on Proof General

I only encounter this problem when running Proof General. I'm assuming this is some random minor mode that is started by Proof General, but can't figure out which one! I include a list of minor modes bellow, in case you can recognise the name.
If I place a period in Emacs, the cursor will jump before it, like so:
Writing something|
Writing something.|
Writing something|.
Where | represents cursor and the last two lined happen immediately one after the other.
the same happens if I click at the end of a line with a period. The cursor will appear after the period and immediately jump before the period.
Some sentence. (click here)
Some sentence. |
Some sentence|.
Where the last two lined happen immediately one after the other.
Here is the list of minor modes, in case you can spot the name:
Aquamacs-Autoface Auto-Composition
Auto-Compression Auto-Encryption Blink-Cursor Column-Number Cua
Delete-Selection Electric-Indent File-Name-Shadow Font-Lock
Global-Font-Lock Holes Line-Number Menu-Bar Mouse-Wheel Osx-Key
Recentf Savehist Show-Paren Smart-Frame-Positioning Tabbar
Tabbar-Mwheel Tool-Bar Tooltip Transient-Mark
key binding
--- -------
^C Prefix Command
ESC Prefix Command
. proof-electric-terminator
<C-M-down> pg-move-region-down
<C-M-mouse-3> proof-mouse-goto-point
<C-M-up> pg-move-region-up
<C-S-mouse-1> pg-identifier-under-mouse-query
<C-return> proof-script-complete
(that binding is currently shadowed by another mode)
<M-down> proof-forward-command
<M-up> proof-backward-command
<remap> Prefix Command
... then a bunch of Proof specific minor modes...
Proof General is incompatible with show-paren-mode. You can turn it off with M-x show-paren-mode or by putting (add-hook 'proof-ready-for-assistant-hook (lambda () (show-paren-mode 0))) in the appropriate place in your .emacs.
See http://proofgeneral.inf.ed.ac.uk/trac/ticket/496.

Insert complete lines with Emacs + Evil

In Vim, I often move lines by deleting them (either with dd or visual line mode), moving my cursor to the new position, then p to put them in:
first
second
third
And if my cursor is on the line second, I can use ddp to move it down:
first
third
second
But with Emacs + Evil mode, putting the line back doesn't work as expected: if, for example, my cursor is on the i in third when I hit p, I end up with:
first
thisecondrd
How can I make Emacs + Evil mode insert new lines when putting entire yanked lines?
I use C-a to go to the beginning of the line (^ in evil-mode, probably) before yanking, if I want that behaviour. If you do this often, you can probably come up with your own thing for yank, although you have to figure out during the kill part if you're doing that. (Or you can check if the yanked thing has newlines, I guess?)
There's a transpose-lines command, by the way (C-x C-t in regular Emacs binding - someone suggested binding this to xtl - https://github.com/syl20bnr/spacemacs/blob/master/my-keybindings.el).
If I find my cursor on a line that I want to move, my natural response is to first delete the line into the kill ring with either C-a C-k C-k or C-a C-space C-n C-w (either of which can also grab several-line sequences by duplicating either the C-k or C-n or prefixing the C-n with a numeric argument) and then travel to the beginning of the line where I want to paste and doing a C-y yank.
Note that Emacs considers a file to be a steam of characters, in which newline or carriage return is not special. Unlike in vi, you can C-f forward right over a newline exactly as though it is a normal character; backspace over it; or include it in a deleted and yanked buffer. It is exactly like any other character. Perhaps Emacs is for people who think of files as sequences of characters — some of which happen to be newlines — and vi is for people who think of their file as lines, that are magically separated by who-knows-what but it certainly is not like any other character.
If the main use case you are trying to address is moving lines up or down (as opposed to the more general question of how to "make Emacs + Evil mode insert new lines when putting entire yanked lines"), I suggest you try out move-text.
It is a very small add-on package that provides two commands (move-text-up and move-text-down) for moving lines up and down, respectively. You can be anywhere on a line and call these; there is no need to kill or yank anything, and they work for regions as well.
For example, calling move-line-down in this situation (point right after second):
first line
second| line
third line
will produce
first line
third line
second| line
As you would expect, moving the current line (or region) up or down n lines works by calling the appropriate command with a numeric prefix.
The commands are bound to M-up and M-down by default but you should be able to rebind them to key sequences of your liking via
(define-key evil-normal-state-map "mu" 'move-line-up)
(define-key evil-normal-state-map "md" 'move-line-down)
move-text is package-installable from MELPA.

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 move-end-of-line, [END], or C-e not moving to end of line?

I've noticed that C-e <END> or M-x move-end-of-line doesn't always move the cursor to the end of the line.
Specifically this happens lines wider than the current window, it appears to move to some arbitrary point midway along the line.
Does anyone know if this is expected and more importantly, how to switch it off and make move-end-of-line, really move to the END of the line?
(Note: this is also happening in regular non-macro use.)
Emacs version in this example is GNU Emacs 23.1.97.1 (i386-mingw-nt6.1.7601)
Update.
The cursor is moving to the char that is on the edge of the window, (the display then re-centers around the cursor.)
Make sure visual-line-mode is off for the buffer.
Agree with #Slomojo here (it seems I cannot comment yet).
To add, here is the quote from the Emacs manual:
In Visual Line mode, some editing commands work on screen lines instead of logical lines: C-a (beginning-of-visual-line) moves to the beginning of the screen line, C-e (end-of-visual-line) moves to the end of the screen line, and C-k (kill-visual-line) kills text to the end of the screen line.
C-e is mapped to end-of-visual-line, the best solution isn't to deactivate visual-line-mode (don't do that especially if you're coding) but to remap C-e to end-of-line in your init file like this:
(global-set-key (kbd "C-e") 'end-of-line)
Of course I advise you to do the same for C-a and to remap it to beginning-of-line.
If you think you need to use end-of-visual-line and beginning-of-visual-line they're still mapped to end and home buttons respectively.