Questions tagged [region]

The text between the point and mark in a buffer.

Filter by
Sorted by
Tagged with
3
votes
1answer
149 views

Highlight rectangle and non-rectangle selection at the same time

By default, Emacs highlights the non-rectangular selection; alternatively, you can use (rectangle-mark-mode) to show the rectangular selection. Instead, I'd like to always show both, by highlighting ...
1
vote
0answers
25 views

Combine `flyspell-region` with`writegood-mode`

I would like to combine flyspell-region with writegood-mode, but writegood-mode does not provide a function to check a region of text. This is what I came up with to work around the limitation: (defun ...
1
vote
0answers
21 views

How to write functions that only operate on characters within a rectangular-region?

I've found emacs has support for rectangular selection, however I didn't see references to API's for only operating on contents within the rectangle mark. How would this be acomplished? Take this ...
1
vote
2answers
45 views

How to make query-replace automatically fill what I want to replace with marked text?

I want to select some text somewhere in a buffer, call query-replace and then type (or paste from kill-ring) only the second argument, TO-STRING, (and make the selected text count as FROM-STRING). I ...
0
votes
1answer
37 views

How to write a portion of text from current file to the beginning of another file?

I have written a function that extracts a portion of text from current file and writes it in another one: (defun foobar () (interactive) ;; re-search "beg" point ;; re-search "...
0
votes
1answer
68 views

How to get the real line number of a selection?

I am trying to figure out the line numbers referring to the actual selection. What I came up with is something like this (let ((start (line-number-at-pos (region-beginning))) (end (line-number-...
1
vote
1answer
50 views

Searching in a subtree in orgmode without narrowing

Is there a way to search in org mode in emacs in a certain subtree without narrowing or "narrowing" and "widening" the way to go?
1
vote
1answer
41 views

Any possibility to show multiple narrowed regions at the same time in a buffer?

As title self-explains, I would like to show multiple regions in different places. narrow-to-region could be a possible solution, but as documentation indicated, only one region from begin to end ...
0
votes
0answers
38 views

How to highlight whitespace only in the active region?

I have global-whitespace-mode enabled which is configured to display TAB and SPC characters with (setq whitespace-style '(space-mark tab-mark)) How can I highlight whitespace characters only on ...
0
votes
0answers
76 views

How can I provide the first-error and next-error initial positions as region selection in order to save to the kill-ring?

I am running a make command. I'd like to capture the first error and output it to a file. How can I select as a region from the beginning of first-error position to the position right before the next-...
1
vote
1answer
75 views

How to code a command to `write-region` to a particular file?

I have a system that I am not allowed permissions to install software but need to copy text from the remote server to the host computer's system clipboard. Because I can't install xclip or xsel and I ...
3
votes
0answers
35 views

Is there a way to move region with arrow keys or similar?

Say I have a function int calc(int that, int this); I want to mark int that and then move it right across words by hitting modifier arrow key (or similar) twice to get int calc(int this, int that); ...
2
votes
1answer
55 views

Background color of matching parentheses overlays the region background color

I have set lime as a background color for my region, and I also have enabled to highlight matching parens using (show-paren-mode 1). The issue I have is that when I exactly select the contents ...
0
votes
1answer
41 views

How to delete the text between the tags of an XML element?

I need to delete a block of text between 2 tags, including tags themselves. I tried this: (defun my-delete () (interactive) (beginning-of-buffer) (search-forward "<%ARGS>") ...
1
vote
1answer
26 views

Add a border around the region by inserting a given character

There's here, for example, given text: WASP-41b 0.94 1.18 3.052404 0.04 1244 transit 590 0.93 5545 WASP-42b 0.527 1.122 4.9816819 0.0561 ...
5
votes
1answer
421 views

Is there an emacs package which can mirror a region?

Say, I have a buffer A in which there is a region of text from some position pos1 to an other position pos2. I switch to buffer B, call a function with buffer A, pos1 and pos2 as parameters and it ...
1
vote
3answers
180 views

How to check if a region is selected by mouse?

Usually a mouse selected region is highlighted and a region set by (set-mark-command) is not highlighted. But I don't know a programmatic way to check it. Could anyone help?
3
votes
1answer
50 views

How to leave mark region highlighted when switching windows

I usually have my Emacs frame split into windows. I'll select something in one window and then switch to another buffer. When I do this Emacs removes the active-region highlghting in the original ...
0
votes
1answer
223 views

Run current line or selection in shell then insert result in Emacs buffer (Acme workflow)

Given lines like these: pwd echo "Hello \ World" in a buffer, I would like to do the following: Put the cursor to the first line, then press C-` Select lines 3-4 then press C-` to send the line ...
1
vote
0answers
37 views

(octave-mode) highlighted region remains highlighted after command

I am in octave-mode running an inferior octave shell. Now I mark a region and issue 'octave-send-region'. All commands are executed as expected and echoed in the shell buffer, and the highlighting is ...
1
vote
2answers
299 views

Select to the sentence of line in a shortcut

C-k and M-k could delete forward to the end of line and sentence respectively. How could only select to the end in a shortcut? Usually select a sentence and append it to a file for further ...
1
vote
0answers
40 views

Add whitespace as indentation with `indent-region`

When using indent-region, emacs will indent code and leave bank spaces untouched. It seems to me that the majority prefer to delete whitespace. However I prefer white space indented with the code. An ...
2
votes
0answers
51 views

show white spaces only when region is selected

whitespace-mode will show the whitespace all the time in entire buffer, Is there the way to show whitespaces only when the region is selected. which is pretty cool to have, does there mode exist for ...
3
votes
1answer
181 views

How to stop backspace from doing kill-region?

(I'm using Emacs for more than 25 years, starting in version 18.58 I think) Recently Emacs received changes that make an old-time user quite desperate, and I wonder how to revert some of those ...
1
vote
1answer
64 views

How to prevent deactivating the region after a command?

When a function is called on a region, I want a visual indication of affected area (a blink for ex.). Say, I've written a function upcasing previous word, and after evaluation I immediately get the ...
1
vote
1answer
43 views

Searching text between markers as in Nota Bene

The Word Processor Nota Bene has a feature which I would like if possible to emulate within Emacs. One can insert into a document non-printing markers which are then used to delineate areas of text or ...
1
vote
1answer
42 views

Command that does different things based on whether something is selected

I am trying to make emacs function somewhat like sublime text, where C-x cuts text that is selected and cuts the whole line when nothing is selected. I got the full-line cut to work using (global-set-...
1
vote
1answer
116 views

Search within column or rectangle

Is there a simple way to search within the current column or within a rectangle? I am navigating a CSV file and would like to find the value "10" in a particular column. Searching the entire file is ...
0
votes
1answer
196 views

Set value of a variable to region text

I would like to write a script where I can select some text as the region, extract the selected region as a string, modify it, and pass it to another program. I am playing around with ielm and see ...
1
vote
1answer
81 views

(goto-char (region-end)) doesn't set the point to the end of the region

I have written a small elisp script which should put oneline or multiline comments based on the current buffer's major mode. The source file is here: https://github.com/amirteymuri/Com/blob/master/...
0
votes
1answer
117 views

How can I apply a keyboard macro to every line that starts with rectangle mark region

Lets suppose I would like to edit my text and to add comments to the column in the text. This is my text: something-text1 foobar1 something-text1 something-text2 foobar2 something-text2 --- ...
1
vote
1answer
66 views

Mark isearch result

I'd like to mark the current isearch result so that it 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 ...
7
votes
3answers
587 views

changing todo state of multiple headings at once

I've got a list of todo's, and I'd like to change all of the todo's in that list with a single command, instead of moving point to each item and changing the status manually. For example. * TODO Item ...
3
votes
2answers
109 views

Is it possible to apply a function to every region between two “marker” lines?

I have a .tex file that looks something like this: $ cat foo.tex \begin{document} \begin{question} lots of multiline text with several paragraphs of information \end{question} other text \begin{...
-1
votes
1answer
151 views

mark-whole-buffer followed by kill-ring-save not working correctly

I'm using Emacs 26.1 on MacOS. Instead of copying the entire buffer I get a warning: Saved text until "text where is stopped saving with whitespace seemingly to the end of the buffer " I'm ...
3
votes
1answer
63 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, ...
2
votes
2answers
52 views

Shortcut to put the selected region in an ordinary LaTeX environment (not with begin-end style) using auctex

In auctex if one has a selected region and then apply the command c-c c-e (LaTeX-environment) then by selecting an environment, the selected region will be folded between that environment. Is there a ...
1
vote
2answers
87 views

Sort lines in a string

Given I have a string that maybe came from a buffer, or a clipboard, or wherever; how do I sort-lines in it? Given that sort-lines only works with a region, I assume I have to put it to a temporary ...
3
votes
1answer
239 views

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

The proper way to deal with region is using (interactive "r"). But in my case, (interactive "r") always complaints: The mark is not set now, so there is no region after fresh ...
0
votes
2answers
376 views

Change foreground color of a region (temporarily)

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the ...
0
votes
1answer
34 views

How faster show multicursors on the end of all lines?

Som teext 1111111111 2 33333 4444444444444 5555 9999 6666 aaaa aaaaaa zzzzzzzzz hello prev do this My steps: Put cursor to the beginning of first line (1111111111) Press C-> (mc/mark-next-...
1
vote
1answer
113 views

Custom function to apply bold face to a region

I know there is a function called: facemenu-set-bold, which is bound to M-o b, but I'm trying to write my own as an exercise. Here is my code: (defun my-function() "this is my function" (...
1
vote
2answers
117 views

Count the number of paragraphs

There are plenty of ways to count lines, words, and characters in Emacs. For instance, invoking M-= (AKA count-words-region) does that very thing on a given region. However, I am having trouble ...
3
votes
1answer
148 views

Unfill `mu4e` message before sending

I would like to unfill all paragraphs before sending a message with mu4e. This is because format=flowed is not respected by all platforms (particularly Gmail). I figure that message-send-hook is the ...
1
vote
0answers
93 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 ...
2
votes
1answer
139 views

making specific regions of a buffer read-only

I know it's possible to make a "portion" of a buffer read-only. As an effect, the whole line becomes uneditable. What I would like it to make a specific region uneditable, for exemple a rectangle ...
1
vote
1answer
45 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 ...
4
votes
1answer
27 views

Idiomatic handling of region boundaries while modifying its content

I want to write a function to indent SQL embedded in a markdown file. It seems to make sense to use the region for this. However, the looping form I am using is: (defun rr/sql-indent-region (...
0
votes
2answers
141 views

Commands or shortcuts to put a selected region between parentheses or brackets in auctex

If some region is selected region, then applying a command (such as the commands which insert an environment) provided by auctex results in putting the region in the corresponding environment. Is ...
0
votes
1answer
101 views

How to convert paragraph into the line?

I've need a function which convert a paragraph into the line, sort each space separated set of characters and fill it back to paragraph. In: Supposedly there are over one million words in the ...