Questions tagged [point]

is the location where most editing commands take effect, which is by default indicated by the cursor in the selected window. Emacs remembers the last location of the point for each buffer and when a buffer is activated, Emacs returns the cursor to the last known point.

Useful Links:

73 questions
19
votes
4 answers

What is the usefulness of `exchange-point-and-mark`?

The exchange-point-and-mark command is bound to C-x C-x, but I cannot think of any use cases that would make it deserving of such a prominent binding. How can I use the exchange-point-and-mark to improve my editing technique?
Matthew Piziak
  • 5,958
  • 3
  • 29
  • 77
15
votes
4 answers

Emacs point(cursor) movement lag

When running previous-line, C-p or the cursor jumps up a line without any issues or lags. When running next-line, C-n or the cursor properly jumps down a line, but with a significant lag. When I hold the down key I can't even see the…
9
votes
1 answer

How to save last place of point in a buffer?

I would like to save the last position of point in the buffer I am visiting, so to have point still there when I go back to that file. I understand I can use saveplace for this, so I added this snippet in my configuration: (use-package saveplace ;…
Manuel Uberti
  • 3,150
  • 18
  • 36
8
votes
2 answers

How to insert text after point?

I'd like to insert (programmatically) some text right after the point (without moving it). I came up with this: (save-excursion (insert "my text")) It seems to work. Is it a good way to do what I want? E.g., are there situations where this could…
mbork
  • 1,647
  • 1
  • 13
  • 23
8
votes
2 answers

Why is my function not identifying the end of the region correctly?

I have the following function, adapted slightly from here: ;; Insert text around a region. In this case, it's ;; the LaTeX code environment from the listings package (defun wrap-code (start end) "Insert a \begin{code} and \end{code} around a…
terdon
  • 745
  • 6
  • 21
6
votes
1 answer

How to preserve the visual height of the cursor after an operation?

Q: How do I find the visual line number of point (so that I can restore it after an operation)? By “visual line number”, I'm referring to the number N of lines between the top of the window (or the screen) and the cursor, not the top of the…
Malabarba
  • 22,878
  • 6
  • 78
  • 163
6
votes
6 answers

Quick jump to a specific line of a file

After opening a .txt file with Emacs, when the point is at the line /folder/subfolder/file.xml:435 How can I fast jump to line 435 of the above mentioned file? What I tried: dired-at-point and find-file-at-point
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
6
votes
1 answer

How does previous-line/next-line "know" the column it should move to from the end of the line

When I am on a long line, beyond the end of an adjacent line, if I move up or down to the other line the point will go to end of the line, naturally. Then when I move back to the longer line, it goes to the same position I was originally…
Random832
  • 578
  • 3
  • 11
5
votes
0 answers

Point belongs to window - mark belongs to buffer

In Emacs the point belongs to a window: this allows a buffer to be displayed in two different windows at the same time. The mark belongs however to the buffer. Conceptually the mark and a point determines a region. Since the mark belongs to the…
soegaard
  • 151
  • 5
5
votes
1 answer

(progn (scroll-up 1) (goto-char 0)) is different from (scroll-up 1) then (goto-char 0)

In any buffer, try to eval-expression the expression (scroll-up 1) and then eval (goto-char 0). The window scrolls up, then point is moved to the beginning of the buffer. Now, try eval-ing (progn (scroll-up 1) (goto-char 0)). Here, point is not…
jcarpenter2
  • 227
  • 1
  • 6
5
votes
1 answer

Navigate cursor position history with line-based jumps

I use point-undo to jump between positions in the cursor history. However, point-undo uses every previous position of the cursor, and I often experience that what I actually want is to jump just to the last/next line where my cursor was. So I don't…
Timm
  • 1,549
  • 12
  • 23
5
votes
1 answer

Is there a hook I can use to run my function when point moves?

I'd like to add some navigation context to the modeline. I can figure out where I am just fine and give the name of my function, but I don't know how to run this every time point moves. post-command-hook is the only thing I've found, but it sounds…
Sean Allred
  • 6,861
  • 16
  • 85
5
votes
3 answers

Mouse pointer between characters and the text cursor misplacement

Mouse cursor position interpretation in emacs drives me nuts. Why draw the mouse cursor in emacs window with vertical thin bar if you cannot effectively position it between characters? Selecting text with mouse in emacs is drastically different from…
4
votes
1 answer

How to get buffer position given line number and column number?

I'm trying to swap the contents of a region with the text of the same width region below it. I think I should be able to atleast correctly capture the region on the next line using the code below, assuming I can get the positions for them. Any…
wdkrnls
  • 3,657
  • 2
  • 27
  • 46
4
votes
2 answers

Why save-excursion doesn't save point position?

I have the following code: (defun test-save-excursion () (interactive) (let ((buffer "*test*") (text "Lorem Ipsum is simply dummy text Lorem Ipsum has |been the industry's standard dummy text It was popularised in the 1960s")) …
Andrii Tykhonov
  • 452
  • 2
  • 13
1
2 3 4 5