Skip to main content
Share Your Experience: Take the 2024 Developer Survey
47 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 ...
m__'s user avatar
  • 993
15 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-...
sandric's user avatar
  • 1,271
14 votes

Best way to select a word

I usually use C-M-SPC or, with easy-kill installed, M-w w.
Manuel Uberti's user avatar
10 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 ...
nispio's user avatar
  • 8,235
10 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-...
db48x's user avatar
  • 18.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 ...
cmaceachern's 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)
Tianxiang Xiong's user avatar
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. ...
Drew's user avatar
  • 77.9k
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 ...
phils's user avatar
  • 51.6k
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 ...
Drew's user avatar
  • 77.9k
6 votes

Best way to select a word

M-@ is mark-word, but it does not grab the part of the word that is before point. You can write a command (or create a keyboard macro) that does M-<left> (which is command left-word) followed ...
Drew's user avatar
  • 77.9k
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)...
Drew's user avatar
  • 77.9k
5 votes
Accepted

What is the problem with this yank function in elisp in emacs?

Why mark-end-of-sentence? I'd do it like this: (defun vim-line-yank-func() (interactive) (save-excursion (beginning-of-visual-line) (copy-region-as-kill (point) (...
Stefan's user avatar
  • 26.5k
5 votes
Accepted

emacs mark from point to start of buffer?

I would do this: C-SPC to set the mark M-< to go to the beginning of the buffer Or, if you want to finish with point where you started: M-< to go to the beginning of the buffer (which sets ...
glucas's user avatar
  • 20.6k
4 votes

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

The mark is designed to be fleeting to enable jumping back (using C-x C-x) after a search or a end-of-buffer. Note however that the previous mark is not forgotten - you can use pop-mark to trace back ...
sds's user avatar
  • 6,124
4 votes
Accepted

What are the differences mark-ring and global-mark-ring?

You should pose only one question per question here. For your first question: *What are the differences between the mark-ring and the global-mark-ring: This is answered very well in the Emacs manual,...
Drew's user avatar
  • 77.9k
4 votes

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

(defun dired-grep-marked-files () "`i` case insensitive; `n` print line number; `I` ignore binary files; `E` extended regular expressions." (interactive) (let* ((files (dired-get-marked-files)) ...
lawlist's user avatar
  • 19.2k
4 votes

Best way to select a word

The simplest way I've come up with to mark "around" a word is the fully built in combo of C-M-SPC C-M-b (hold down Ctrl+Meta then press Space and b), AKA mark-sexp and backward-sexp. Once ...
Micah Elliott's user avatar
4 votes
Accepted

(interactive "r") can't be used directly after Emacs startup

The use-region-p test should be within the interactive spec. "r" is for functions that always use the region. You probably want to use something like: (defun try-region (&optional begin end) (...
Stefan's user avatar
  • 26.5k
4 votes
Accepted

How to go to the beginning of a selection?

You need to call exchange-point-and-mark, bound to C-x C-x.
aadcg's user avatar
  • 1,248
4 votes
Accepted

How to count the number of characters in the marked (selected) region?

The command name count-words is a bit misleading. It shows the number of words. But, it also counts the number of lines and the number of characters. An output illustration: Region has 1 line, 51 ...
Pedro Delfino's user avatar
3 votes
Accepted

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

Eshell's grep is compatible with grep(1) and uses Emacs's internal grep interface, thus you can try something like the following: M-x dired-do-eshell-command RET grep -nH --color your-search--pattern ...
xuchunyang's user avatar
  • 14.6k
3 votes

Making it so that cursor movement after command will deactivate region

End your command with this: (setq deactivate-mark t) or this: (deactivate-mark) C-h v deactivate-mark: deactivate-mark is a variable defined in C source code. Its value is nil ...
Drew's user avatar
  • 77.9k
3 votes
Accepted

How to automatically set marks on all of the edited lines?

There's a built-in package hilit-chg which tracks and highlights the changes applied to a buffer. I disable its highlight and but just use as a change-tracker. The mode automatically put text-...
zk_phi's user avatar
  • 446
3 votes

Storing previous cursor positions

You are describing a use case of bookmarks. For example, have a look at the visual bookmark package at https://github.com/joodland/bm. You get functions to toggle bookmarks at point and move back and ...
Heikki's user avatar
  • 3,076
3 votes

Storing previous cursor positions

The simplest option, although it does not keep positions in a ring, is to save positions to registers. The docstring for the command point-to-register: It is bound to C-x r SPC, C-x r C-SPC, C-x r ...
Dan's user avatar
  • 33.1k
3 votes
Accepted

Select Within Quotes

You can use the expand-region or emacs-surround packages to select the text and then delete it. Watch an intro to expand-region on: Emacs Rocks. Or take a look at the examples of emacs-surround on ...
Alexandro de Oliveira's user avatar
3 votes

Best way to select a word

A solution for users of evil: In normal state, just type: viw
izkon's user avatar
  • 1,878
3 votes

Best way to select a word

Place the cursor on either side of the word, then hold the shift key down and hold the alt/option key down, and then use the left or right arrow. If the cursor is not on either side of the word, then ...
lawlist's user avatar
  • 19.2k
3 votes
Accepted

Popping the mark in Emacs

global-mark-ring is a list with marker objects. In programming and computer science "popping" something from a list simply means removing the first element of the list (and usually returning ...
Tephra's user avatar
  • 831

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