Questions tagged [region]

The text between the point and mark in a buffer.

Filter by
Sorted by
Tagged with
0
votes
1answer
37 views

How do I update this defun to select region

I wrote this function which takes a string and writes out self.var for each entry in the string. This helps me create python classes faster. (defun elf-python-self (str) "Parse the arguemnts in STR ...
1
vote
1answer
89 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 ...
0
votes
1answer
78 views

Can I programmatically get access to the yanked region?

You are likely to want to do things to the text that you just yanks / pasted (wrap it in brackets etc). Is there a way to know what you just yanked? If so I would quite like select it (put the mark ...
1
vote
1answer
72 views

What is the mode or the command to selectively display selected region?

There seems to be a command to display only the text in the selected region, leaving the rest of the text hidden. What is the command?
1
vote
1answer
775 views

How to execute a command on the selection (shell-command-on-region) in evil mode, without losing the selection?

I'd like to use shell-command-on-region on the region, in a way that keeps the selection, even in the case the length of the output changes, and works in regular emacs and in evil mode? Note, I've ...
0
votes
1answer
381 views

How to set the evil-visual-line region (selection) programmatically in Emacs Lisp using indices?

Given 2 absolute numbers (compatible with region-beginning, region-end). How can these numbers be used to set the evil-mode line visual selection? (note, I originally asked this question, but found ...
7
votes
1answer
1k views

How to set the region (selection) programmatically in Emacs Lisp using indices?

Given 2 absolute numbers (compatible with region-beginning, region-end). How can these numbers be used to set the selection? Edit: If you use evil mode you may want to check this question, at the ...
1
vote
1answer
94 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 ...
2
votes
4answers
279 views

Search/replace inside a rectangular region, without CUA mode

I want to use search/replace (string or regexp) inside a rectangular region (aka column selection?). Consider this question: Search and replace inside a rectangle in emacs That's what I want, except ...
2
votes
2answers
65 views

What's the most reliable way to get the start and end positions of current symbol under cursor?

What's the most reliable way to get the start and end positions of the symbol at the cursor location (point)?
3
votes
0answers
161 views

Region face foreground color as function of original faces

I know you can set the :foreground of the region face so that it simply uses the :foreground of whatever is selected, while using the region's :background. And I know you can just set the foreground ...
1
vote
1answer
50 views

Incorrect value of region-end in function that calls replace-string

I am writing a function to do replacements on a highlighted region. It appears that while region-end changes after each replace, the value is not correct. That is, it does not point to the last ...
0
votes
2answers
62 views

Function to duplicate and mark duplicated text

In order to be able to chain the following command, I need the yanked text to be marked. That is because the end goal is to call (pop kill-ring) so that I can still use whatever was at the top of the ...
3
votes
2answers
453 views

Undo region spacemacs

I really appreciate the undo in region command in standard emacs, where you can just mark a region and only changes made in that region are undone. This doesn't seem to work in the default spacemacs ...
1
vote
1answer
129 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
0answers
49 views

What is the cause of this inconsistent behaviour of TeX-command-buffer when narrowing?

When editing medium sized .tex files, I often find it convenient to make use of the narrow command C-x n n (narrow-to-region), usually in combination with the mark section command C-c * (LaTeX-mark-...
9
votes
2answers
458 views

Selecting (i.e., as the region) the current match in incremental search

When searching for a string with C-s, I want to be able to hit some key to exit search mode but still maintain the selection of the match. That way I can immediately start typing and replace the last ...
5
votes
2answers
774 views

Copy text as rectangle

This is the block of text that I intend to copy as rectangle (without the line numbers). 1. ALM_KRmet_DCDO_RPMP_START 2. ALM_KRmet_DCDO_RPMP_STOP 3. ALM_KRmet_DIDC_RPMP_TRIP 4. ...
4
votes
2answers
191 views

Use shift-up/down keys to mark/unmark lines in dired?

The default in dired is to mark files and folders with m, and to unmark them with u. Instead of this, I'd rather like to use shift-up and shift-down for marking or unmarking lines (in a DWIM fashion). ...
3
votes
2answers
248 views

How to move the cursor to the beginning/end of a shift-selected region by a left/right motion?

In most modern editors, after canceling a selection by a left/right motion, the cursor will be moved to the beginning/end of the previously-selected region correspondingly. Similarly, if we cancel a ...
5
votes
2answers
284 views

How many bytes are in the region?

After far too many years of counting the number of characters in the region by doing M-: (- (point) (mark)), I just discovered M-= (count-words-region). Much better! But now I'm looking for a way to ...
2
votes
1answer
87 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 ...
-1
votes
1answer
183 views

Non-shell command on region?

I know about shell-command-on-region. Is there any way to pipe a region through a non-shell command? The start-process and call-process functions invoke executables directly, without using the shell. ...
0
votes
2answers
83 views

Tab key getting bounded to forward-button

Launching emacs with the -Q option (default settings) shows TAB being correctly bound to indent-for-tab-command. If I launch emacs without the -Q, TAB is always being bound to forward-button which is ...
1
vote
0answers
50 views

Launch functions one after another

I wrote a function that pastes in the currently selected color from the palette to the buffer: (defun palette-paste-in-current-color () (interactive) (cua-paste (palette-current-rgb-to-kill-ring))...
4
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 ...
2
votes
0answers
22 views

Is it possible to highlight the region uniformly across different sizes/fonts?

Highlighting the region when it includes text with different heights/fonts shows gaps and different highlighting heights as follows: Is there any way of highlighting continuously (no gaps) and ...
2
votes
0answers
41 views

Are there any packages or configuration snippets for better whitespace traversal?

Whitespace traversal in Emacs is atrocious. By "traversal" I mean: Moving the point with C-<direction> Expanding a selection (with either a package or region mark) Deleting with C- or M- ...
2
votes
1answer
137 views

How to prevent the active region from setting the primary selection?

After switching to 24.5.11 from some ancient version, Emacs started to spam my primary selection: Whenever I mark a region, or even move the point using e.g. arrow keys when the mark is active, a new ...
1
vote
1answer
72 views

How to retain selection after command run (indent-code-rigidly)?

I found a neat code snippet for ~/.emacs configuration: (global-set-key (kbd "C->") (lambda (b e &optional n) (interactive "r") (...
1
vote
1answer
72 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.
0
votes
1answer
104 views

defun completion and region

Is it possible to write a function with completion that act on region? A mix of: (defun function-style (style) (interactive (list (completing-read "Style: " styles-list))) ... And (...
3
votes
1answer
101 views

How to use one binding to call different functions depending on whether the region is active?

As I only use kill-ring-save after I used set-mark-command, I wanted to try using its binding also for another command. However I'm not able to get this to work with an additional if. I don't know how ...
0
votes
1answer
102 views

Unable to deactivate the selection mode with C-SPC

Sometimes I can't deactivate the mode of selecting text which is C-SPC. Even if I press it a second time and move the cursor, the text still gets selected. I press C-SPC one more time, it activates ...
1
vote
2answers
512 views

Highlight text equivalent to the marked region and search and replace on the fly

Edit: Highlight text that matches the marked region, without the use of any key, but just by having a region marked. Then have two commands to directly move across the highlighted text, forward and ...
3
votes
1answer
72 views

kill-region deletes entire buffer content instead of selected text

In emacs, i have a small text selected as shown in the picture. When i do eval-buffer, i like the kill-region to remove only the highlighted text. But this code empties the buffer. ;;this is a ...
1
vote
2answers
279 views

er/expand-region not working as previously under Emacs 25.1

I've got er/expand-region behaving very strangely and I don't understand what I did wrong (besides upgrading to Emacs 25.1.50). If I've got this in an elisp file: (defun foo (p) (* 2 2) p) (that ...
2
votes
1answer
206 views

Highlighting selected region in same buffer, displayed in multiple windows

Q:  I am seeking a proposed modification of simple.el at lines 5251 to 5308 of the master branch relating to highlighting a selected region to achieve a better visual representation when the same ...
11
votes
1answer
444 views

How to copy text without losing selection?

When I copy some selected text (kill-ring-save with M-w), I automatically lose my selection. I have tried with Transient Mark Mode with no luck. (Note that I'm not using CUA Mode.)
4
votes
2answers
137 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 ...
3
votes
1answer
179 views

Right-click to select one character under the mouse pointer?

I'm using GUI emacs 24.4.9.0, so I can click to move the cursor, and double-click to select a word under the mouse pointer as a region. How can I configure emacs so that right-click selects a ...
5
votes
2answers
140 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 ...
2
votes
1answer
569 views

how to modify the active region highlighting color

Gray text highlighting no longer works on my Debian/stretch system. While this is particularly annoying in Emacs, it's not a specific Emacs problem; gray background is also gone from other ...
0
votes
4answers
333 views

elisp pattern for handling region || buffer || file

summary Elisp newbie has been given interactive code (aka commands, called with M-x whatever) that "does stuff" on the currently-selected region in the current buffer. What is an/the "elispish way" ...
4
votes
1answer
351 views

How do I expand the region-beginning and region-end?

Solution: With the help of @Drew, I figure out a solution. I am not good at elisp. The code may not be a good design but at least is working. I use this code to add 4 white space so I can copy a ...
1
vote
2answers
98 views

delete-c-electric-paren deletes active region in CC mode with delete-selection-mode enabled

I've the delete-selection-mode enabled. In programming modes like Python and Lua, or in general modes like Fundamental or Text, when there's an active region, pressing ( rightly wraps the region with ...
6
votes
2answers
3k views

How to auto copy when a region is selected?

Chrome browser has an excellent extension called autocopy, which copies text whenever some text is selected/highlighted. To copy a region in emacs, I have to select the region and then press M-w to ...
1
vote
5answers
104 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 |...
2
votes
1answer
131 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. ...
3
votes
2answers
1k views

How to select text found by `re-search-forward`?

The following function searches buffer text for string STR, in the same way as search-forward. How to modify it in order that it selects the text found? (defun my-search-forward (str) (interactive "...