Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [region]

The text between the point and mark in a buffer.

0
votes
0answers
9 views

counsel-org-tag on region

How can I use counsel-org-tag, or some similar command that uses counsel, to apply/remove tags to all headlines in the region? I would like the tags to be changed only at the highest selected ...
1
vote
1answer
40 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
51 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
62 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 ...
0
votes
0answers
28 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
47 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
34 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
22 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
34 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
34 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 ...
4
votes
0answers
41 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 ...
0
votes
0answers
39 views

Interactively matching beginning of region

Short version: If i bound the scope of a search/replace to a region in the buffer (via the second/third optional argument of search-forward and its derivates), how can i match the beginning of that ...
0
votes
0answers
58 views

TAB region indentation (python)

I'm working on a .py document using a fresh apt install of emacs 25.2.2 on Ubuntu 18.04. When typing TAB with several lines selected, the behavior is not what I remember getting previously, and not ...
2
votes
1answer
29 views

Allow C-w to kill a region only if it is selected

Sometimes (rarely I would say) I press C-w by mistake and if the mark defines a non empty region, it gets deleted. The few times this happened I just pressed undo, but I am afraid that sooner or ...
1
vote
0answers
55 views

How can I execute a python script on a given region of my buffer?

I have a .tex source and a python script called comments.py. This script reads my .tex source as input, does some operations on it and write a .com file as output. Then I have to reneame .com as .tex ...
1
vote
1answer
34 views

Insert text or overwrite region

In an Emacs Lisp function, I would like to insert some text at point or - if the region is active - overwrite it with such text. How to do it?
0
votes
1answer
52 views

How to use flush-lines in a script?

I want to use flush-lines in a selected region, but I have troubles. Here it is my code: (defun delete-empty-lines () "Delete empty lines in bibliography." (interactive) ;; set point-min (...
1
vote
1answer
41 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 ...
0
votes
1answer
43 views

Call helm on region

I just found out about helm-surfraw by reading Tuhdo's Helm guide. For those familiar with Helm, is there a way for me to call helm-surfraw on a selected region, i.e., using the region as the input ...
0
votes
1answer
486 views

How to count the number of lines in the region?

Is there a command similar to count-words-region to count the total number of lines of a selected region?
5
votes
1answer
74 views

Asynchronous version of shell-command-on-region?

I have a problem which is very similar to this one. I have some text that I'd like to listen to with macOS's say utility. Unfortunately, Emacs locks up when I use shell-command-on-region because it is ...
0
votes
0answers
43 views

C-S-a doesn't select text to the line beginning

The Key combination Ctrl + Shift + a doesn't work in my GUI-Emacs to select a region from the position of pointer to the line start. Doing C-h k and the above key combination shows no documentation.
5
votes
3answers
109 views

How to select (and highlight) non-consecutive blocks? [duplicate]

The title says it all. I'm looking for a C- or M- built-in way to select non-consecutive lines and blocks of text, like usual consecutive lines with Shift or C-SPC. I.e. I need a switch that turn ...
0
votes
1answer
33 views

How to find all active bindings which act on a region?

As explained https://emacs.stackexchange.com/a/733/ C-h b lists all bindings available in a buffer. Is there a way to list all bindings which act on a region? For example C-w (kill-region) is one of ...
0
votes
1answer
40 views

Cover the active region with a character

Called with an active region, it will replace all spaces in that region with the character corresponding to the subsequent key press. E.g., if cover-active-region is bound to C-c /, then C-c / h will ...
4
votes
1answer
207 views

Reversing the order of letters/characters of a selected region

How can one reverse the letters/characters in a selected region? xyz --> zyx ab cde --> edc ba
2
votes
3answers
436 views

Send region to shell in another buffer

Is this possible with stock emacs: I'm editing a .txt file that has a snippet of bash code When I do C-x b RET I can switch to a preopened M-x shell buffer named guesuser@...
3
votes
1answer
72 views

Move selected sentence, word left/right by equivalent unit?

More broadly, should work by the selected semantic unit (incl. paragraphs in text mode, and the relevant units in other modes). I.e., if a sentence is selected, then the notional "move-left" would ...
1
vote
0answers
41 views

Make `insert` follow `(delete-selection-mode t)`

When I call helm-copy-to-buffer (which calls insert) with active region in my current buffer, the marked helm candidate is added after the active region. But I expect the active region to be replaced ...
0
votes
1answer
24 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
39 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
52 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
30 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
455 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
196 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
536 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
55 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
153 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
46 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)?
4
votes
0answers
113 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
29 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
44 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 ...
2
votes
2answers
249 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
93 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
37 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
326 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
519 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
157 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
152 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
128 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 ...