Questions tagged [insert]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
881 views

How to include a text verbatim in Emacs Lisp?

How to programmatically insert a text verbatim? The following function inserts ocumentclass and not \documentclass. (defun foo () (interactive) (insert "\documentclass")) Of course one can use (...
0 votes
1 answer
29 views

Calling c-electric-brace programmatically

I'm currently extending the tempo.el template insertion system to be sensitive to C styles. Specifically, I want to insert braces using c-electric-brace. How programmatically insertion of braces as ...
0 votes
1 answer
86 views

How can I insert some multiline text that respects the indentation at which it is inserted?

I have a function that reads a link from the clipboard and generates a metadata-ful markdown link from it, and inserts it: (defun night/unt () (interactive) (let* ((link (current-kill 0)) ...
0 votes
0 answers
12 views

Completing long words but inserting shortened version

Company mode can help me with completing long words. But I also want to be able to write a shortened version of a word without requiring me to use any keybinding command after writing a word. For ...
0 votes
1 answer
39 views

How to turn from command to insert mode at the end of my elisp interactive script?

I am using Evil (Vi keybindings) in Spacemacs. Let's say I have something like that: (defun myfunc-org-insert-custom-stuff () (interactive) (insert "This is custom stuff ")) but I would ...
0 votes
2 answers
238 views

AUCTeX LaTeX-math-mode outside a mathematical environment

Using AUCTeX with LaTeX-math-mode enabled, if I type (say) ` a inside a mathematical environment, it inserts \alpha, as I want. But if I do it outside a mathematical environment, it inserts \alpha{}. ...
0 votes
1 answer
38 views

Insert aligned multi-line text in current buffer regardless of position?

I'm creating a function to easily insert ditaa boxes while drafting reports in org-mode. I have the meat of the function accomplished, but not sure how to implement it so that boxes can be inserted ...
1 vote
1 answer
148 views

Insert path into buffer with vertico.el

I have recently switched from ivy to vertico for the file completion menu system (the new default in doom). Sometimes I want to insert the full path to a file into the current buffer (for example ...
2 votes
1 answer
218 views

How can I insert the backslash character ( \ ) before quotation marks (" ") in Emacs?

I am running Emacs and writing on the scratch-buffer. This is my config file. After executing describe-mode, this is the list of minor modes running: Enabled minor modes: Auto-Composition Auto-...
7 votes
1 answer
2k views

How to insert a new same-level headline after current one?

Suppose I have an org-mode buffer that contains the outline shown below, and that point is at the position indicated by the ▮ character. * foo ** bar *** baz - eenie - yabba - dabba▮ ...
0 votes
1 answer
33 views

How can I insert a character by its hex code in the minibuffer?

I've seen it's possible to insert characters with their hex codes by using ctrl+x 8 RET but on regular buffers. I'd like to insert in the minibuffer itself.
1 vote
1 answer
68 views

Insert space before link with org-insert-link

In Doom Emacs and org-mode, I want to use org-insert-link pressing the minimum amount of keys. So I want to combine two-four commands in one. The default behaviour doesn't leave space before or after. ...
1 vote
1 answer
30 views

Elisp: function to paste heading lines in an Org-mode buffer

I would like to have a function that pastes a certain heading: "#+TITLE:\n#+STARTUP: overview" I tried using insert-buffer-substring: (insert-buffer-substring "#+TITLE:\n#+STARTUP: ...
2 votes
1 answer
98 views

Modify the first element of the kill-ring

I have stored in my clipboard a path to an image, which I want to paste inside emacs. I would like to modify the path to change/postpone/prepone some stuff before yanking. Following my previous ...
0 votes
1 answer
68 views

Insert text and step

I want to copy text from one buffer to another. With point in the source buffer, I want to insert text in the target buffer. In the target, the text should insert at point, a new line be opened, and ...
0 votes
1 answer
39 views

How to end text-insert undo segment after cursor jump (caused by mouse)?

Coming from vim into (evil-mode) spacemacs, I sometimes get frustrated that undo segment is not ended when a mouse-caused cursor movement occurs. An example : While I am inserting text, touchpad gets ...
2 votes
1 answer
89 views

Evaluate a variable when inserting text into a buffer

When I open a fresh file for coding, I like to insert a header like this: ##################################################################### # Purpose: # Author: me (me@someplace.com) # Date: ###...
0 votes
1 answer
77 views

Use LaTeX accents with tex insert method

With this answer I learned how to insert math symbols with latex syntax directly into my buffer. What I can't figure out is how to make accents insert properly. I want \hat{\beta} to insert beta hat ( ...
1 vote
1 answer
307 views

How insert random number?

Suppose I has text: test hello The cursor is after word test. I need to insert random number? Also I need to set range of random (e.g. from 0 to 1000) The result maybe like this: test100 hello
0 votes
1 answer
51 views

How to insert text and activate the mark in the same function [duplicate]

I am trying to write a function where I insert some text, and then activate the mark at the end of the function. I have several use-cases where I would like to use this. I cannot figure out how do ...
0 votes
1 answer
135 views

Does Emacs have a standard function to insert or overwrite text depending of the state of overwrite-mode?

Context: using Emacs 26.2 I would like to write Emacs Lisp code that inserts or over-types text depending of the state of the overwrite-mode. I would call this function to insert text instead of the ...
16 votes
5 answers
3k views

Result of arithmetic evaluation in buffer, not echo area

Windows 10, Emacs 25.1 I want to do some arithmetic operation I do this: The result is in the echo area, but I want the result to be in cursor place in the buffer. Something like this: How do I do ...
2 votes
2 answers
1k views

How to insert character or word N times in a buffer or file?

Just curious to know how to do this, since i already know in other languages (bash, etc). I know how to insert a character in elisp, just not sure on how to do it when it's done nth time (in ...
4 votes
2 answers
652 views

Move to goal-column inserting spaces if necessary

I have a bunch of lines of text and I'm trying to insert text starting at a certain column on each line. For example: 'Some text' This is ok 'Another longer text' ask Ram 'weird stuff' ...
2 votes
2 answers
49 views

How do I add text to every new buffer that I create?

Suppose I want to put my name and the date at the top of every new buffer that I create. How would I do that? Furthermore, suppose I want to use the name of the new buffer in the text that I want to ...
1 vote
3 answers
204 views

How to create loops for inserting text?

Imagine I want to create a list with 10 items, i. e. 1. 2. 3. ... 10. In Vim I can use the command :for i in range(1,10) | put =i.'. ' | endfor for this. How can I do the same thing in Emacs? ...
1 vote
1 answer
458 views

Insert space but don't move point

Search didn't yield any success. Perhaps I'm using the wrong search terms... I'd like to insert a single space (just like when you hit SPC) but without changing point. I come up with an example (let |...
3 votes
3 answers
408 views

Quickly inserting a single Greek letter

How can I make it so that H-g followed by a gives an alpha etc.?
1 vote
1 answer
184 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/...
2 votes
1 answer
134 views

The insert function seems to be inheriting the read-only property

I'trying to insert a row of characters into a buffer, where the first four characters should be read-only. Here's the relevant part of the code : (insert (propertize "cn) " 'read-only t)) (insert (...
0 votes
0 answers
89 views

Have Emacs remember text properties of buffer [duplicate]

I am using the following code to insert colored text into an Emacs buffer. (insert (propertize "green" 'font-lock-face '(:strike-through t :foreground "green" :background "blue"))) ...
0 votes
1 answer
50 views

All Greek letters are capitals, no small Greek letters

So far, I need some Greek letter every now and then. I enter them through: C-x8RET GREEK SMALL LETTER LAMBDA RET → λ or simply by C-x8RET 03bb RET → λ However, I tried this after a long hiatus, ...
6 votes
1 answer
858 views

Mimic self-insert-command with insert/insert-char?

Due to various/extensive remappings I insert symbols with Control+key, for example Ctrl+9 inserts a left parenthesis (. This works fine with the remappings and the insert/insert-commands, however, ...
3 votes
2 answers
740 views

Is there a way to get a Unicode character by name?

Is there a way to get a character by name (e.g. GREEK SMALL LETTER LAMBDA) instead of by code point (\uX3BB)?
3 votes
1 answer
300 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
1 answer
430 views

Run command after each type/insert in particular buffer

I'm implementing a (optional, de-activable) real-time syntax checker. Each time the user types/deletes anything, I want to run my spell-checking funtion : I tried (add-hook 'post-self-insert-hook '...
0 votes
1 answer
598 views

How to programmatically insert a string at the end of some file?

How to silently (in background) create a new line at the end of a specific file, say /path/to/file.txt (which is not necessarily a visiting file and is not necessarily already open in emacs) and ...
1 vote
1 answer
152 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 ...
1 vote
0 answers
96 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
0 answers
513 views

Wanted: vim-like paste behavior from browse-kill-ring

When using the browse-kill-ring package to insert some text from the kill ring, the text always gets inserted before point. This is not intuitive to vim users who are used to pasted text being ...
5 votes
1 answer
1k views

How to insert a formatted string into a specific buffer?

I am looking for a way to insert a formatted text into a specific buffer (not the active buffer). As it seems to me, the only way to do so is to use a snippet as shown below: (insert (propertize (...
6 votes
1 answer
687 views

Spacemacs : insert single character in normal mode

I am using Spacemacs in Vim mode, and I would like to be able to insert a single character while remaining in normal mode, as described here for Vim. For example, typing SPC i k in normal mode would ...
1 vote
0 answers
44 views

Insert from ELisp code using quail

After evaluating the expressions in this code, I evaluated (activate-input-method "TeX"). When I type in the buffer \`a, the translation happens as expected and I get à. However, I cannot achieve the ...
2 votes
1 answer
443 views

Using quail input-method to insert a string

The standard way to define an abbreviation using quail is as follows: (quail-define-rules ("a" ?s )) Inserting "a" gives "s". I am wondering if one can insert an arbitrary string using quail, I ...
7 votes
1 answer
4k views

Insert line above/below

I have a couple of functions for inserting blank lines above and below the current line: (defun insert-line-below () (interactive) (move-end-of-line nil) (open-line 1)) (defun insert-line-...
5 votes
2 answers
689 views

Insert a string from eval-expression without the quotes

I want to use C-u M-:, then (format-time-string "%m/%d/%Y") to insert a customized date string. But it is inserted into the current buffer with double quotes. Any trick to remove these quotes?
4 votes
1 answer
422 views

How can I type simple underline "_" in Auctex

I am using Auctex in Aquamacs. Everytime I type underline "_", it will show as $_{}$ automatically which is very annoying. I am wondering how could I turn off this function. Thanks.
2 votes
1 answer
397 views

How do I insert the buffer's name at the beginning of the buffer?

I am trying to write a function that prints the name of the current buffer to the file in the current buffer in its first line. For example, if the file is called "test.el", when invoking such ...
6 votes
2 answers
200 views

Key bound to string does not handle some chars in string correctly

(I ask this question after reading this one.) The form (global-set-key (kbd "M-e") "e") is, as far as I can tell, equivalent to (global-set-key (kbd "M-e") (lambda () (interactive) (insert "e"))) ...
1 vote
0 answers
121 views

emacs multiple-cursors insert letters (numbers) issue

I've created an ascii video at https://asciinema.org/a/63b67gx2hm5pasdvjkhiyq4ud to demo my emacs issue with multiple-cursors. I created 4 lines of text and created 4 cursors (see 00:36). Then I use C-...