Hot answers tagged

39 votes
Accepted

set-mark-command (C-SPC) not recognised/broken

System Preferences > Keyboard > Shortcuts > Input Sources > Select the previous input source and uncheck saltycraig's tip on C-h k C-SPC did nothing when I typed it. So, thanks to Kaushal Modi for ...
user avatar
  • 863
26 votes
Accepted

Effectively using the mark ring

Helm has an interface for browsing both local and global mark-rings: helm-all-mark-rings. See the mini-guide for a brief description and a screenshot. And if you prefer Ivy/Swiper/Counsel, see ...
user avatar
21 votes
Accepted

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

There are two cases I can think of: reactivating the region, and adjusting the size of the region. I most often use this binding to reactivate the region after performing some command that ...
user avatar
  • 19.1k
17 votes

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

Ask Emacs: C-h r i exchange-point-and-mark RET or, better, C-h r i C-x C-x RET. This takes you to the information shown below. This is what the Emacs manual, node Setting Mark says in answer to your ...
user avatar
  • 69.1k
16 votes

Effectively using the mark ring

When you set set-mark-command-repeat-pop to t via (setq set-mark-command-repeat-pop t) you can keep pressing C-SPC after the first invocation of C-u C-SPC to jump to previous locations stored in the ...
user avatar
  • 14.2k
14 votes

Effectively using the mark ring

I find it easier to use registers to mark locations: C-x r <space> and then a letter to mark, C-x r j and a letter to jump back. I can maintain a number of marks, very useful when alternating ...
user avatar
  • 353
12 votes
Accepted

Selecting text without moving the cursor

There is a separate answer for each of the points you listed: The emacs default binding C-x h will select the whole buffer regardless of where the cursor is. The expand-region package will help ...
user avatar
  • 24.2k
11 votes
Accepted

select text to end of line, without moving point

Save-excursion restores point AND mark (as of emacs 24.4), so it is no help for you here. You could save the point manually with this idiom: (let ((pos (point))) ... (goto-char pos)) However, in ...
user avatar
  • 536
11 votes

Effectively using the mark ring

Apart from the other tips you have got here I thought I should mention that C-s sets the mark for you, so there is no need to do it explicitly. Also, many commands that "move a potentially long way" (...
user avatar
11 votes

Effectively using the mark ring

C-x C-x for exchange-mark-and-point has similar use to C-u C-space. It lets you bounce between a point and the last mark. It's a little weird for bouncing with transient-mark-mode as it activates the ...
user avatar
  • 3,954
11 votes

How to unmark selection in elisp?

Ok, I found the answer almost immediately after posting question. The function name is deactivate-mark if anyone has the same question. Its described here. Updated code: (defun sandric/swiper-or-...
user avatar
  • 1,151
10 votes
Accepted

mark text with keyboard in PDFView (pdf-tools) mode

That would require some notion of a cursor, which is currently not implemented. So marking by keyboard is not available (except the whole page).
user avatar
  • 3,266
10 votes

Best way to select a word

I usually use C-M-SPC or, with easy-kill installed, M-w w.
user avatar
9 votes

Selecting text without moving the cursor

If the region grows then the cursor changes position. This is because the cursor is always at one end of the region. If you select all of the buffer text (C-x h and then use C-x C-x to swap point ...
user avatar
  • 69.1k
9 votes
Accepted

How to set mark in elisp and have shift selection?

Because shift translation and temporary activation of the mark is handled by the command loop, you will need to call the interactive versions of the movement functions in order to get the appropriate ...
user avatar
  • 7,763
8 votes

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

I use this when I've lost a selection due to some operation that removed it, and I want to restore selection. One such scenario would be: Select rectangle. Kill it. Undo killing rectangle. C-x C-x to ...
user avatar
  • 10.8k
8 votes
Accepted

Is there a package to simplify clickable text?

Emacs provides buttons to abstract away these steps, I'd suggest looking at the Emacs sources for instances of make-button and insert-button.
user avatar
  • 20.9k
8 votes

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

The other answers focus on the usefulness of C-x C-x when transient-mark-mode is active. But C-x C-x predates transient-mark-mode, and is useful independently of it. The main role of C-x C-x is to ...
user avatar
  • 5,480
8 votes
Accepted

Mysterious highlight in emacs

It's the secondary selection. Clicking and dragging sets the primary selection, and middle click pastes from that selection. Holding alt while clicking and dragging sets the secondary selection, and M-...
user avatar
  • 11.3k
7 votes

set-mark-command (C-SPC) not recognised/broken

One of the installed packages you have there may be overriding the C-SPC keybinding for something else. Try starting emacs without loading your init file: $ emacs -Q Now try doing the key ...
user avatar
7 votes

Best way to select a word

You can use the expand-region package to do this and more. Let | be point and (...) indicate that ... is marked. foo-|bar Calling er/expand-region once: foo-(|bar) Calling it again: (|foo-bar)
user avatar
6 votes

Effectively using the mark ring

(Your question is pretty open-ended, so it might get closed as being primarily opinion-based.) What I use: Icicles multi-command icicle-goto-marker (bound to C-- C-SPC) to trip around the marks in ...
user avatar
  • 69.1k
6 votes
Accepted

pop-mark not working as expected

From pop-mark's documentation: ...This does not move point in the buffer I think you want: ;; do some stuff (goto-char (mark)) (pop-mark) But if all you care about is returning to a previous ...
user avatar
  • 176
6 votes
Accepted

How to mark current line and move cursor to next line?

Below works with brief testing: If no region is selected to begin with, the current line will be selected and the cursor will move to the next line (default, if no prefix arg is used). If a region is ...
user avatar
  • 24.2k
6 votes

How to grep marked files in the dired mode of emacs?

If you use library Dired+ (dired+.el) then you can use command dired-do-grep (bound by default to M-g in Dired mode) to do what you request. diredp-do-grep is an interactive compiled Lisp function ...
user avatar
  • 69.1k
6 votes

Is it possible to disable automatic "mark"ing in emacs?

Not as such. You certainly can't prevent things from calling push-mark and set-mark and friends. There's nothing stopping you from redefining the standard functions to do nothing, however. You would ...
user avatar
  • 43.1k
6 votes
Accepted

delete-selection-mode not a default?

I've argued the same thing for a long time: delete-selection-mode should be turned on by default. I argued for turning on transient-mark-mode by default, and after decades that eventually happened. ...
user avatar
  • 69.1k
6 votes
Accepted

Making a region without point

(You say "a region", not "the region", so a guess is that you do not really mean the Emacs region.) If your question is really about the Emacs region then the answer is no. Point (the cursor position)...
user avatar
  • 69.1k
5 votes
Accepted

Can you mark-word backwards?

Use a negative prefix argument to mark backwards, for example: M-- M-@ Note that you can also mark a number of words forwards or backwards. For example, mark backwards four words: M-- M-4 M-@ Note ...
user avatar
  • 19.1k
5 votes

Only allow kill-ring-save if there is highlighted text

Do not worry about the kill ring ("clipboard") being overwritten: you can recover previous kill ring entries by typing C-y M-y (repeat M-y as many times as you need). See Section 12.2.2 of the Emacs ...
user avatar
  • 5,480

Only top scored, non community-wiki answers of a minimum length are eligible