Emacsでは、カーソル/ポイントが略語モード拡張で配置される場所を制御する方法はありますか?
ほら、こんな感じ?
("orgfootnote" "[fn:: %?]" nil 0)
Emacsでは、カーソル/ポイントが略語モード拡張で配置される場所を制御する方法はありますか?
ほら、こんな感じ?
("orgfootnote" "[fn:: %?]" nil 0)
Abbrev 自体はこの機能を提供していませんが、外部で行うための十分なフックを提供しています。例えば
(define-skeleton my-orgfootnote "Docstring." nil
"fn::" _ "]")
そして、次のような略語を使用します
("orgfootnote" "" my-orgfootnote)
組み込みの略語機能を意味する場合は、ここに問題に対する私の見解があります。この deafdvice を使用すると、文字列 @@ を含む略語がある場合、展開後、@@ が出現する展開されたテキストの位置にカーソルが配置されます。
(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))))))))
テンプレートに記入する必要がある場合abbrev
は、間違った機能です。私は強くお勧めしyasnippet
ます。 abbrev
ただし、頻繁なタイプミスを修正するのに非常に役立ちます。