Abbrev do not offer this feature themselves, but they offer enough hooks to do it externally. E.g.
(define-skeleton my-orgfootnote "Docstring." nil
"fn::" _ "]")
and then use an abbrev like
("orgfootnote" "" my-orgfootnote)
Question
In Emacs, is there a way control where the cursor/point gets placed in abbrev-mode expansion?
You know, something like this?
("orgfootnote" "[fn:: %?]" nil 0)
Solution
Abbrev do not offer this feature themselves, but they offer enough hooks to do it externally. E.g.
(define-skeleton my-orgfootnote "Docstring." nil
"fn::" _ "]")
and then use an abbrev like
("orgfootnote" "" my-orgfootnote)
OTHER TIPS
If you mean the builtin abbrev feature then here's my take on the problem. With this deafdvice if you have an abbrev containing the string @@ then after exapnsion the cursor will be placed at that position in the expanded text where the @@ occurs.
(defadvice expand-abbrev (after my-expand-abbrev activate)
;; if there was an expansion
(if ad-return-value
;; start idle timer to ensure insertion of abbrev activator
;; character (e.g. space) is finished
(run-with-idle-timer 0 nil
(lambda ()
;; if there is the string "@@" in the
;; expansion then move cursor there and
;; delete the string
(let ((cursor "@@"))
(if (search-backward cursor last-abbrev-location t)
(delete-char (length cursor))))))))
If you need to fill out a template, then abbrev
is the wrong facility. I highly recommend yasnippet
. abbrev
is very useful for correcting frequent typos though.