Skip to main content
Share Your Experience: Take the 2024 Developer Survey
8 votes
Accepted

How to use abbrevs

You defined your abbrev backwards - "with np.printoptions(threshold=np.inf): print()" will expand to "fp" with what you've done! To define a multi-word abbrev, you should do: M-x define-global-...
Tyler's user avatar
  • 22.3k
5 votes
Accepted

Is it possible to have conditional abbrev expansion?

Yes, you can tell the abbrev table to use an explicit function to test whether or not to fire in a given instance. The relevant argument in define-abbrev-table is :enable-function, which, according ...
Dan's user avatar
  • 33.1k
5 votes
Accepted

Prevent abbrev expansion on capitalization

Yes: just put a non-nil value for the :case-fixed property. (define-abbrev my-foo-abbrev-table "r" "EmacsRocks" nil :case-fixed t) See C-h v define-abbrev RET for more details.
Stefan's user avatar
  • 26.5k
5 votes

How to expand abbrevs without hitting another extra key?

Out of the box it is not possible with the abbrev system since self-insert-command calls expand-abbrev only when a non-word character is to be inserted. Citation from the doc string of expand-abbrev: ...
Tobias's user avatar
  • 33.2k
4 votes
Accepted

Abbreviation expansion without spaces

I asked the same question recently on emacs-devel and Kenichi Handa told me I could do: (defvar my-TeX-input-method-tweaked nil) (defun my-quail-activate-hook () (when (and (not (member (quail-name)...
Stefan's user avatar
  • 26.5k
4 votes
Accepted

Alternative to abbrev-mode that supports special characters in abbreviations?

You can continue to use abbrev-mode. The following elisp snippet allows you to specify additional characters as word-consistent when abbreviation takes place. After running the snippet customize the ...
Tobias's user avatar
  • 33.2k
4 votes

How to expand abbrevs without hitting another extra key?

You could try something like this: add additional behavior to "e" itself. Make it insert by default, but try to expand otherwise (defun e-insert-or-expand () "Insert 'e', and if it is part of an ...
Edward Minnix's user avatar
4 votes
Accepted

How to insert the current date into a file using abbrev or similar?

You need to remove the parenthesis from your custom function. It's calling for hook function name there, not its evaluation. (define-abbrev-table 'global-abbrev-table '(("td" "" insert-current-iso-...
Muihlinn's user avatar
  • 2,634
4 votes
Accepted

Different abbrevs for each major mode

As you've seen, abbrev normally requires the abbreviation to contain only word-constituent characters, and that doesn't normally include `. You could make that character word-constituent by changing ...
phils's user avatar
  • 51.5k
3 votes
Accepted

Quick/electric text expansion

In Org, you're looking for (org) Easy Templates; try typing <sTAB: With just a few keystrokes, Org’s easy templates inserts empty pairs of structural elements, such as ‘#+BEGIN_SRC’ and ‘#+END_SRC’...
Basil's user avatar
  • 12.4k
3 votes
Accepted

Disable "Autocompletion"/"Abbreviation" in Verilog-Mode

Found the Solution: the verilog-mode does fill the "abbrev-table" every time it gets initialized. I added a hook to my spacemacs-dotfile which clears the table after the mode is initialized: (defun ...
Jounathaen's user avatar
3 votes
Accepted

How to inherit one abbrev table in another abbrev table?

Use the :parents property to hold a list of tables from which to inherit abbrevs. In your case, you can do: (abbrev-table-put org-mode-abbrev-table :parents (list latex-mode-abbrev-...
Dan's user avatar
  • 33.1k
3 votes
Accepted

emacs ABBRV command break for new line

Insert "\n" where you want the newline. This works for me: ("8rt" "#+ATTR_HTML: :style color:green\n *lets try it on your computer!*") I don't think the nil and 0 are necessary.
jtgd's user avatar
  • 964
3 votes
Accepted

Do not expand abbreviation if preceded by "."

I ended up solving this question using the :enable-function in define-abbrev-table (similar to what's recommended here: Do not expand a given abbrev when followed by ":"). My solution is to ...
scaramouche's user avatar
  • 1,744
3 votes
Accepted

Expand abbrev on two spaces

First, note that abbrevs expand when typing a word separator character, not just space. Looking at the doc for self-insert-command suggests that's no way to easily change the behavior of abbrev-mode. ...
JeanPierre's user avatar
  • 7,475
3 votes
Accepted

Org-mode: disable abbrev-mode in source blocks

One way might be like this, where expansion only occurs conditionally. Put this statement in an init file, or in an org-mode hook function and you should not get expansion in src-blocks. (setq abbrev-...
John Kitchin's user avatar
  • 11.9k
2 votes

Adding abbrevs in ess-mode

I'm working on abbrev as well and it seems only word-constituent characters can be part of an abbrev. Thus I don't think you can use "-=" as an abbrev. Have you tried using other characters?
joon's user avatar
  • 700
2 votes
Accepted

How to make all abbrev table case sensitive?

(dolist (table abbrev-table-name-list) (abbrev-table-put (symbol-value table) :case-fixed t))
Saddle Point's user avatar
2 votes

Regexp only matching one character when using abbreviations

The regexp used in the tutorial will match one or more characters, and its stopping when it matches one. You need to force it to match back to the previous word break. That's what the \\< pattern ...
Tyler's user avatar
  • 22.3k
2 votes

How to disable `abbrev-mode`?

You disable abbrev-mode the same way you disable any minor mode. Interactively: M-- abbrev-mode From Lisp: (abbrev-mode -1) C-h f abbrev-mode tells you: abbrev-mode is an interactive compiled ...
Drew's user avatar
  • 77.9k
2 votes

How do I set the directory-abbrev-alist values?

I also needed this in order to change the directory-abbrev-list so that the function abbreviate-file-name would shorten paths that are not children of my 'home' path. Managed to do it with the ...
Ioanna's user avatar
  • 121
2 votes
Accepted

Using a common set of abbreviation for multiple major modes

I don't think there's a good UI to access it, but abbrev-tables can have parents, so you could create a new abbrev-table to hold your shared abbrevs and then setup those different major-mode abbrev-...
Stefan's user avatar
  • 26.5k
2 votes

How to use abbrevs

What about Put point immediately after p in fp. Issue C-x a i g (inverse-add-global-abbrev). Enter with np.printoptions(threshold=np.inf): print() and press RET. C-x a e BTW I have abbrev-mode ...
Marco Wahl's user avatar
  • 2,876
2 votes

Use abbrev to expand "-->"

From emacs manual: More precisely, any character that is not a word constituent expands an abbrev, and any word-constituent character can be part of an abbrev. So the answer is no because ...
Heikki's user avatar
  • 3,076
2 votes
Accepted

Best pratice advices for abbrev vs. completion vs. snippets

As you already said, this is more a request for opinions than a question. I think what you're doing is totally fine and done by many others, too. To me, one of Emacs' main advantages is that it can ...
Stefan Kamphausen's user avatar
2 votes
Accepted

Why does emacs add a tab to the current line when I use "expand abbreviation" feature?

When you enter bmTAB, abbrev expands and then inserts the tab you entered. If you had hit SPACE instead, it would have entered a space. Emacs links process of expanding abbreviations to a couple of ...
Andreas Röhler's user avatar
2 votes
Accepted

Don't consider space and tab as abbrev-expand commands, but keep the C-x whatever shortcuts intact

When abbrev-mode is on, it expands abbreviations anytime you enter a character with non-word syntax, such as a space, a tab, or a period. If you don't like that behavior, turn off abbrev-mode. ...
Dan's user avatar
  • 33.1k
2 votes

Is it possible to have expand abbreviations when calling a skeleton-read?

skeleton-read will read from the minibuffer, which is a separate buffer that's not using latex-mode, which is why your abbrev isn't working there. You could put your abbrev in global-abbrev-table so ...
Stefan's user avatar
  • 26.5k
2 votes
Accepted

Abbrevs and UTF-8

Curious. add-abbrev scans backward by words using forward-word to find out what abbrev to define. I'm not entirely sure why, but even though both "y" and "α" are defined as word characters in the ...
db48x's user avatar
  • 18.2k
2 votes
Accepted

Multiple files for reading abbreviations?

An abbrev file contains regular Lisp code and is evaluated using load. Therefore all you need to do is to add (load B) (with B being the full path to file B) to your init file wherever appropriate.
wasamasa's user avatar
  • 22.2k

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