Hot answers tagged

6

The documentation string for the command text-clone-create: (text-clone-create START END &optional SPREADP SYNTAX) Create a text clone of START...END at point. Text clones are chunks of text that are automatically kept identical: changes done to one of the clones will be immediately propagated to the other. The buffer’s content at point ...


5

highlight-nonselected-windows is a variable defined in xdisp.c. Its default value is nil. A non-nil value means highlight region even in nonselected windows. You can customize this variable, e.g.: (setq highlight-nonselected-windows t)


3

It's only you're having syntax issues, try this: (defun copybuffer () "function takes current region, and writes it to specified file" (interactive) (write-region (region-beginning) (region-end) "~/copybuffer.txt")) Summary: region-beginning and region-end are functions, so they have to be between parenthesis to be recognized as ...


3

The first backspace kills the whole region. You'll want to set delete-active-region to nil (it was introduced in 24.1). delete-backward-char is an interactive compiled Lisp function in ‘simple.el’. [...] If Transient Mark mode is enabled, the mark is active, and N is 1, delete the text in the region and deactivate the mark instead. To disable this, set ...


3

M-| (M-x shell-command-on-region) runs a shell command using the region as stdin, display the output in the echo area, with a prefix arg, replace the region with the output. Unlike your shell in a terminal, each use of M-! or M-|: start a shell such as bash, run the shell command, then kill the shell. And the region is data passed to the shell command, the ...


2

Command mark-end-of-sentence does what you request. It's not bound to a key by default, but you can bind it to one. C-h f mark-end-of-sentence tells you: mark-end-of-sentence is an interactive compiled Lisp function in paragraphs.el. (mark-end-of-sentence ARG) Put mark at end of sentence. Arg works as in forward-sentence. If this command ...


2

Count lines does the trick, it is defined in simple.el (count-lines (point-min) (point-max))


2

Use (mouse-region-match). C-h f mouse-region-match says: mouse-region-match is a compiled Lisp function in mouse.el. (mouse-region-match) Return non-nil if there's an active region that was set with the mouse.


2

You can hide multiple regions, or you can have separate indirect buffers for them (one per narrowing). If you want to hide multiple regions, e.g. make them invisible, you can use libraries zones.el (code)and isearch-prop.el (code). A set of zones is a set of regions, i.e., multiple regions. You can make a set of zones or its complement (the set of anti-...


2

Try adjusting downward the value for show-paren-priority -- "[p]riority of paren highlighting overlays" -- which has a default value of 1000. The priority for the active region is '(nil . 100), which is hard-coded in redisplay-highlight-region-function. https://www.gnu.org/software/emacs/manual/html_node/elisp/Overlay-Properties.html priority This ...


1

Have a look in ibm-box-drawing-hydra.el library, maybe isn't exactly what is seeked, but gives a north.


1

I think you have transient-mark-mode switched off. Without transient-mark-mode you do not get a highlighted region after setting mark with C-SPC and successive motion commands. If the region is not highlighted, it is not active and (region-active-p) returns nil. Even if the region is not active (point) and (mark) can give differing positions. That is the ...


1

Not 100% sure what you want to check for but if you wish to do something when the mouse has selected a region then here is one way to do it using Emacs advice functionality. (defun register-mouse-select(&rest args) (message "mouse select")) (advice-add 'mouse-set-region :after #'register-mouse-select) ;;(advice-remove 'mouse-set-region #'register-...


1

Use S-C-e and S-M-e, that is holding Shift while typing C-e and M-e, see (emacs) Shift Selection.


1

[ I'll answer the second question. ] Yes, Emacs resets mark-active to nil automatically after executing a command which modified the buffer (or more specifically, after executing a command which set deactivate-mark to a non-nil value). To prevent that you can use (setq deactivate-mark nil) in your function (after performing the buffer modification).


1

Yes. Here are some ways. With just vanilla Emacs you can narrow the buffer to the text between your two "markers", using C-x n n. You need only one marker - the mark, at one end of that bit of text, and point (the cursor position) at the other end of that bit of text. With library Isearch+ you can just search the active region - no need to narrow the ...


1

To invoke a function, don't quote it: (kill-whole-line), not ('kill-whole-line). You're looking for function use-region-p, so (use-region-p), not region-selected. (There is no predefined variable region-selected.) You need to pass functions the arguments they require. So (kill-region (region-beginning) (region-end). If you want it to be a function then ...


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