Here is how completion in company works (I am simplifying a bit a more detailed description can be found in documentation of company-backends C-hvcompany-backendsRET.
You have a list of backends (completion engines) company should try to provide completion at point. Company tries each of this backend one after the another and the first one that returns any ...
I'd use yasnippet for this, especially because of the desired cursor
The first snippet could be something like
# -*- mode: snippet -*-
# name: dots
# key: dots
You should store this file in a directory named latex-mode under a
directory that is listed in yas-snippet-dirs. I think the
official documentation is
probably the best ...
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:
with np.printoptions(threshold=np.inf): print()
Let me refer you to my post on this.
I've found that abbrevs are the best way to do correction on SPC,
you only need to define the corrections that you want. For that, I
take the following approach:
Add the code below to your init file.
Whever you type something wrong, hit C-x C-i and choose one of the corrections offered.
That's it! The correction will be ...
You could use a pre-abbrev-expand-hook to delete the extra space before the abbrev is expanded like this:
(defun delete-preceding-space-before-expand ()
(when (and (= (char-after) ?\s)
;; only do if expanded with space
(= last-command-event ?\s)
(message "%S" last-command-event)
You could either hack the syntax table so as not to treat the : as a non-word constituent, or you could write an :enable-function that will prevent expansion on the basis of :. This one works:
:enable-function (lambda ()
(let* ((vec (this-command-keys-...
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 to the docstring, reads:
(define-abbrev-table TABLENAME DEFINITIONS &optional DOCSTRING &rest PROPS)
Define TABLENAME (a symbol) as an abbrev ...
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:
Before insertion, ‘expand-abbrev’ is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
So we ...
The manual says the following.
Subskeletons are inserted recursively, not once, but as often as the user enters something at the subskeletons interactor. Thus there must be a str in the subskeleton. They can also be used non-interactively, when prompt is a lisp-expression that returns successive list-elements.
(Emphasis is mine, see section Skeleton ...
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)
(member (quail-name) '("TeX" "latin-1-prefix")))
(quail-defrule "uu" "ū")
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 abbrev, expand the abbrev"
(global-set-key "e" 'e-insert-or-expand)
If you want to refine this to only ...
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 put all my abbreviations in the global-abbrev-table and all my exceptions in text-mode-abbrev-table. Then have an enable-function that checks that the ...
define-abbrev accepts a predicate, just use it to specify the abbrev should only expand when requested explicitly.
(define-abbrev text-mode-abbrev-table "dem" "democracy" nil
:enable-function (lambda () (eq this-command 'expand-abbrev)))
The above abbrev will not expand when you hit SPC (or any other self-inserting character), but it will expand when you ...
Ha! There's a subtle bug in your code: the 3rd argument of define-abbrev-table is the docstring, so it treats :enable-function as the docstring and the subsequent function as a property name (with missing value).
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 option abbrev-additional-chars with an alist that maps major-mode symbols to the lists of characters that should be interpreted as word-consistent during ...
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 my-verilog-setup ()
(add-hook 'verilog-mode-hook #'my-verilog-setup)
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’. Easy
templates use an expansion mechanism, which is native to Org, in a
process similar to ‘yasnippet’ and other Emacs template expansion
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.
self-insert-command is an interactive built-in function in
Insert the character you type.
You need to remove the parenthesis from your custom function. It's calling for hook function name there, not its evaluation.
'(("td" "" insert-current-iso-date)))
Anyway, to my understanding, you should define your abbrevs the way it's intended which is using define-abbrev, whose syntax is easier to follow, and ...
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-expand-function (lambda ()
Yasnippet can do what you want. Either a shortcut key-binding or a prefix substring can expand to a particular snippet. And each snippet can present a list of options via yas-choose-value.
Here is an example snippet based on your example:
-- mode: snippet; require-final-newline: nil --
Here's a simple attempt:
(defun my-flyspell-correct-on-space ()
(local-set-key " " 'my-flyspell-correct-on-space)
It behaves strangely when you insert more than one space in a row, and sometimes it splits off part of the word being corrected. Thus this post ...
I'm not sure if this is what you are looking for, but the package you linked to can be extended to capture abbrev expansion like so:
(vhl/define-extension 'abbrev 'expand-abbrev)
Note: The accepted answer on this question is not the optimal solution!
Changing the syntax table is not neccesary to alter the behaviour of what is expanded and what not.
By default emacs uses indeed word syntax, i.e. non-word characters like _ and / etc. can not occur in an abbrev.
However, this behaviour can be customized per abrrev-table.
See Sect. ...