Hot answers tagged

3

There are many ways to write loops/iterative/repetitive behaviour in elisp. C-hig (elisp)Iteration has the basic options, including dotimes, which is the canonical way to repeat something N times. E.g.: (dotimes (_ 10) (insert "X")) For the specific example of repeating a character N times, you might alternatively use make-string. (insert (make-string ...


3

If you want to insert the character interactively, do C-u 10 X. This will give you XXXXXXXXXX. This repeats the self-insert-command (here, for "X"), 10 times. See the manual node on repeating.


2

There's no built-in command to insert a character before the point, presumably because any key binding for it would have to include at least one key stroke in addition to the character, and if you're going to type two keystrokes then the feature already exists: SPC Left or SPC Ctrl+B. There is a built-in command open-line to insert a newline before the ...


1

Define a function that inserts the boilerplate code you want, at the buffer position you want. Put that function on a relevant hook. For #2, one of these might be a relevant hook: window-configuration-change-hook - used when you change buffers write-file-hooks - used when you write a file to disk find-file-hook - used when you visit a file A major mode ...


1

Using org mode You're in luck! Org mode natively supports lists in the format you're looking for! Even if you're not using an org file, you could still copy the list from an org file into your document. To do that: 1. Switch to a new org mode buffer. C-x temp.org You might^1 have to switch that buffer to org mode. M-x org-mode RET 2. Insert the first ...


1

Using a macro counter We can record a macro that inserts text, and run it multiple times. Each time through the macro, we can use the Emacs feature called the macro counter, which is a number that can be incremented throughout the lifespan of the macro, and inserted into the buffer. So we want to do these steps: Because the macro counter normally starts ...


1

Using eval-expression You can run arbitrary Emacs Lisp code with eval-expression, by default bound to M-: M-: runs the command eval-expression (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’. When called interactively, read an Emacs Lisp expression and evaluate it. So we need to give an Emacs Lisp expression ...


1

It seems it is intentional according to read-only's info manual (info "(elisp) Special Properties"): read-only Insertion next to a read-only character is an error if inserting ordinary text there would inherit the read-only property due to stickiness. Thus, you can control permission to insert next to read-only text by controlling the ...


1

;; Here we create the concept of a 'tab-column.' ;; Set the tab column where you want by positioning the cursor and typeing M-+ ;; Then move to another line and type M-=, and EMACS will insert enough spaces ;; to get you to the column. This is useful for alinging columns of text without tabs. ;; tab-column is a silly name; I need a better one. (defun set-...


1

You can access one input method from another. Switch to your Greek input method and evaluate (setq greek-map (quail-map)) Switch to your standard Latin input method and evaluate (quail-defrule ",." greek-map) Now, if you type ,.a, that will produce an alpha, &c.


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