I find using abbrevs in Emacs confusing. Despite reading the manual and the EmacsWiki, I continue to have problems using them.
Goal:
Define a quick, throw-away abbrev for a single Emacs session.
Example:
When using Python and Numpy, outputs are sometimes shortened with an ellipsis:
array(['1007.65', '1007.63', '1007.66', ..., '993.40', '993.40', '993.57'],
dtype=object)
To display the array in full, you need to issue this mouthful of a statement:
with np.printoptions(threshold=np.inf): print(my_arr['field_name'])
This seems like a perfect situation for an abbrev!
Here's what I do:
- Type
fp
for "full print" - With point immediately after
p
infp
, issueC-x a g
(add-global-abbrev
) - In the minibuffer prompt for
Global abbrev for "fp":
, putwith np.printoptions(threshold=np.inf): print()
and press<RET>
- The minibuffer exits, returning me to my original buffer with point after
p
infp
- Issue
C-x a e
(expand-abbrev
)
Nothing happens.
If I check list-abbrevs
, there it is:
(global-abbrev-table)
"with np.printoptions(threshold=np.inf): print()" 0 "fp"
My understanding is that I don't need abbrev-mode
enabled, as that's only used for automatic expansion. Incidentally, enabling abbrev-mode
still doesn't expand fp
.
I'm at a loss for what I'm doing wrong and would appreciate some advice!