I'm trying to define a custom Python skeleton and have found there are two macros in python.el that might be of use here.
After poking around and looking at the value for python-skeleton-autoinsert it revealed there is...
python-define-skeleton
python-mode-skeleton-abbrev-table is a variable defined in
python.el.gz.
Value
[## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 def 0 0 class 0 0 0 0 0 0 0 0 0 0 0 0 try 0 0 0 0 0 0 0 0 0 0 0 0 0 0 while 0 0 0 for 0 0 0 0 0 0]
Set
Documentation
Abbrev table for Python mode skeletons.
Value is slightly confusing but I also found...
python-define-auxiliary-skeleton
python-define-auxiliary-skeleton is a macro defined in python.el.gz.
Signature
(python-define-auxiliary-skeleton NAME &optional DOC &rest SKEL)
Documentation
Define a python-mode auxiliary skeleton using NAME DOC and SKEL.
The skeleton will be bound to python-skeleton-NAME.
Aim
My aim is to have a skeleton that inserts the following (correctly indented for the position but I think that is taken care of by the functions), getting a prompt for the <value> and inserting it so that the output is...
print(f"{<value>=}")
First Attempt
Tried the following and it evaluated without error...
;; Define a skeleton for printing
(python-define-auxiliary-skeleton print-debug
"Insert a print statement that will show the value of the argument."
"Enter the variable/object name: "
"print(f\"{" str "=}\")")
Checking the value of python-mode-skeleton-abbrev-table this hasn't been added though.
Questions
I don't understand what the values of
&optionaland&restare so I'm unsure if I'm defining this correctly.Once I've got the definition correct how would I get this included in
python-mode-skeleton-abbrev-table(or otherwise registered/recognised) so that the skeleton is available with the others (so I can bind it to a key sequence)?