Questions tagged [mark]

is for marking the start of a region of text in a buffer. Emacs uses `mark` and `point` to highlight a region. Highlighting indicates that the mark and region are active.

Filter by
Sorted by
Tagged with
29
votes
6answers
4k views

Effectively using the mark ring

I have used the mark to select regions of a buffer. For example, I know the sequence C-<space> C-s foo can be used to select all text between the current point and the point after a search for ...
16
votes
4answers
1k views

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 ...
10
votes
1answer
891 views

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

I've replaced doc-view mode with pdf-tools. While it's easy to set a mark on a page with the mouse, how do you do it with the keyboard? The readme mentions the feature. "* Mark a region and kill the ...
9
votes
1answer
440 views

How to set mark in elisp and have shift selection?

The normal behavior of Emacs when transient-mark-mode is active is that when you make a shift-selection, then if the next command is a non-shift movement, the mark is deactivated. For example, after ...
8
votes
6answers
1k views

Selecting text without moving the cursor

I would like to grow a selection without moving point (the cursor) from its location. I know I can always use C-u C-spc to move to the previous location, but I would like to avoid that. More ...
7
votes
3answers
727 views

Is there a package to simplify clickable text?

I'm writing a debugger front end, and in that over the course of program execution a number of marks get added inside the source code. In other buffers such as a buffer showing execution history, or a ...
6
votes
3answers
659 views

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

I hope it's a simple problem.. I'd like to search for the regexp 'thisWord' only in the marked files of a dired buffer. Usually I used in the dired buffer: M-x grep and then in the mini-buffer grep ...
5
votes
3answers
1k views

select text to end of line, without moving point

I often want to quickly mark everything from point to the end of line, leaving point at the same place. I tried to write simple function for that purpose: (defun mark-from-point-to-end-of-line () "...
5
votes
0answers
45 views

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 ...
4
votes
5answers
4k views

Best way to select a word

I want to select current word under the cursor without using mouse. After searching this forum, I learned how double click works. (I noticed that it is a bit complicated and there were no direct key ...
4
votes
3answers
432 views

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

I would like to wrap kill-ring-save in order to only execute kill-ring-save if text has been highlighted - same as in most text editors. Sometimes I accidentally hit copy instead of paste and then my ...
4
votes
3answers
607 views

delete-selection-mode not a default?

If you enable Delete Selection mode, a minor mode, then inserting text while the mark is active causes the selected text to be deleted first. This also deactivates the mark. Many graphical ...
4
votes
2answers
116 views

Activating the region without altering the mark ring

Setting the mark and moving point activates the region, which appears highlighted (assuming transient-mark-mode is enabled). Once the mark is set it's location is sent to the mark ring, thus changing ...
4
votes
2answers
116 views

Keep region activated upon completion of my command

I'm using the following functions to speed up some regexps replacements I frequently use. jc-replace-regexp-in-region can be called by several functions like jc-dollar-to-paren. At the moment, when ...
3
votes
2answers
329 views

Is it possible to disable automatic “mark”ing in emacs?

I would like to set the marks myself, rather than emacs doing it automatically for me. I've experienced emacs setting the mark automatically when I search, or move to the top/bottom of the buffer. ...
3
votes
1answer
1k views

How to unmark selection in elisp?

I wish to remove selection programatically, what is the proper way of doing this? Specifically I wish to write a function to make swiper search in buffer with selected text, but it needs to remove ...
3
votes
1answer
53 views

Making a region without point

From my understanding, Emacs creates a region my setting a mark and then anything between 'mark' and 'point' is the current region. I'm wondering if there is a way to create a region with only marks, ...
3
votes
3answers
732 views

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

How do I mark the current line and then move the cursor to the beginning of the next line? I'd like it to behave like Sublime Text's Ctrl-L.
3
votes
1answer
175 views

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

I have just explore how to use mark rings in emacs. There are two kind of mark type mark-ring and global-mark-ring. What are the differences between them and is there any option to push all marks ...
2
votes
2answers
177 views

Highlighting and keyboard-quit

Why does (keyboard-quit) (bound to C-g) unmark the selected region? And is there a way to stop Emacs from doing so? The sceneraio I have in mind is the following: suppose I select a region and begin ...
2
votes
1answer
185 views

pop-mark not working as expected

I have some sample code like this: (defun some-function () (interactive) (push-mark) (goto-char (point-min)) ; do some stuff (pop-mark)) Now I'm expecting pop-mark to get me back to the ...
2
votes
2answers
438 views

How to jump to a mark using Elisp

Suppose I store the current mark into a variable using mark or (mark-marker). Then I move point elsewhere and insert some text. Which function should I use to jump to the saved mark?
2
votes
1answer
74 views

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

Idea I will like to construct a simple emacs function that copies the yy functionality in vim. The function should yank a visual-line into kill ring without deleting the line. Function Here is ...
2
votes
1answer
228 views

Can you mark-word backwards?

There is a very convenient function M-@ Mark-word. However, I usually find my self typing things, than marking things backwards to copy it some place else. Is there something equivalent for mark-...
2
votes
1answer
176 views

emacs mark from point to start of buffer?

I know one can mark the whole buffer with mark-whole-buffer. but how does one mark from point (that line) to start of buffer?
2
votes
3answers
162 views

Storing previous cursor positions

I would like the ability to go back and forth through a series of stored recent cursor positions, say up to 100 of them. Specifically, a position should be recorded when I click somewhere, or when I ...
2
votes
2answers
220 views

Selecting inner-most scope in C/C++

I would like to be able to mark the current block scope. In other words, given some piece of code like: ... if (1) { ... } ... If my cursors was sitting somewhere inside the if-body, it would mark ...
2
votes
1answer
54 views

how to fix an overlay at end-of-line highlighting too much?

I have added the following definitions to my initialization file in order to make the mark show up as a red highlight: (defface mmv-face '((t :inherit default :background "red")) "Face used for ...
2
votes
1answer
90 views

Since upgrading to emacs 26.1 C-SPC behaviour changed and I have to press it twice to set-mark

Since upgrading to Emacs 26.1 C-SPC behaviour changed and I have to press it twice (most of the time) to set mark, which disrupts my flow and is hard on my thumb joint (don't ask). I'd like to ...
2
votes
1answer
51 views

command to mark a block comment as region

Is there an existing EMACS command to select a block comment? That is, I have /** * A Comment */ I want to set the mark ahead of the /** and set the point after */. I realize there are several ...
2
votes
1answer
109 views

Error using the Emacs Spreadsheet

I have started to use the Simple Emacs Spreadsheet (SES) with GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-09-17. When I try to mark/highlight a column with (ses-mark-column), the selection doesn'...
2
votes
1answer
124 views

What changed with Mark/Region behavior between GNU Emacs 24.3.1 and 24.5.1?

I wrote a little search function a long time ago, binded to ctrl-f. It has been working perfectly until I tried Emacs 24.4. The purpose of the function is to highlight (region) the found word. ...
1
vote
5answers
98 views

Leave point in original position when C-g is pressed?

I am writing a function to select a region (say 2 lines). (defun select-some-region () (interactive) (push-mark (point) nil t) (forward-line 2)) When point is in a buffer like this |...
1
vote
1answer
39 views

Select Within Quotes

Supposing I have my cursor resting somewhere in a bunch of text within quotes, is there a key binding that will mark or highlight just the text within the quotes so I can delete it? This would be ...
1
vote
1answer
110 views

Making it so that cursor movement after command will deactivate region

I'm overriding double-mouse-1 to do additional stuff on top of its default behavior. To this end, I have a function that (1) does my additional stuff and then (2) calls another function, ora-mark-like-...
1
vote
1answer
137 views

Yanking without moving the mark, but still be able to `yank-pop`

I would like to change C-y to not move the mark, but still be able to yank-pop. I looked at the source code and saw that the major change needed was to remove the (push-mark (point)) command: (defun ...
1
vote
1answer
129 views

How to detect if in the current buffer some text is selected (marked)?

How to determine if in the current buffer some text is selected?
1
vote
1answer
35 views

Make region transient in elisp function

I'm trying to write a function that exits isearch leaving the current match selected "transiently", so that the mark is deactivated by any unshifted movement command. I've tried to modify this ...
1
vote
1answer
46 views

Cannot mark text when inserting into buffer within post-command-hook

When I add this post-command-hook: (defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer ...
1
vote
1answer
62 views

Region does not get deselected on move commands using `push-mark` from Elisp

By using shift-select-mode, I can select some region via holding down Shift + arrow keys. When I then stop pushing Shift and press other keys the region get deselected. But this is not the case when ...
1
vote
1answer
77 views

deactivate active region after `eval-region`

I do the following to activate the region and evaluate it M-x spc to begin mark C-n C-n C-n M-x eval-region The region is still active (highlighted) after the eval-region is performed. I would ...
1
vote
2answers
141 views

wanderlust: save all attachments in a group of messages

I'm using wanderlust in emacs-25.1.x I'm looking for a way to select a group of messages and have all of their MIME attachments extracted and saved into a specified folder. I assume that I can mark ...
1
vote
1answer
65 views

highlight blank spaces only under the marked region

Is there a way to only highlight blank spaces/tabs under the marked region? Basically if I have whitespace-mode turned off and if a select a region all the spaces and tabs get highlighted.
1
vote
1answer
37 views

Cutting selection with CUA-mode bindings after searching

I want to cut/copy some code with this method: setting a mark with C-SPC, searching with C-s, then cutting/copying the selection. Check the following image: I can copy selected code with M-w or ...
1
vote
1answer
266 views

How to bind meta-shift-arrow to mark one word at a time

I am having trouble of marking one word at a time (ctrl-shift-arrow or meta-shift f/b) when connecting from one of my terminals. I would like to bind it also to meta-shift-arrow. I couldn't find what ...
1
vote
1answer
100 views

Delete marked region with py-electric-backspace py-electric-delete

In my python-mode the backspace and delete keys gets remapped to py-electric-backspace, etc. This breaks the behaviour set by the variable delete-active-region. Is there a way to unify the behaviour ...
1
vote
1answer
455 views

“Marker does not point anywhere” error when using (message)

I'm running into the error "Marker does not point anywhere" when I try to print a message both in after-change-functions and buffer-list-update-hook. Curiously if only one hook or the other is active ...
1
vote
1answer
17 views

Mark isearch results

I'd like to mark regex isearch results so that they can be copied or cut (killed) via M-w and C-w. Is there a ready-made function for this? The solution below provided by @danielpoe over here copies ...
1
vote
0answers
51 views

How to delete a long region by setting a mark and then searching for the location of the end of the region?

I have a long document. I placed two unique identifiers, in the form of short strings of printable English letter, in two positions in the document. The identifiers are far apart. My task is to delete ...
0
votes
1answer
101 views

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

I would like to automatically set marks on all of the edited lines so that I can go back to any of my previous edited lines using helm-mark-ring.