如何控制Emacs abbrev扩展中的光标位置?

如何控制Emacs abbrev扩展中的光标位置?,emacs,expansion,abbreviation,pabbrev,Emacs,Expansion,Abbreviation,Pabbrev,在Emacs中,是否有一种方式控制光标/点在abbrev模式扩展中的位置 你知道,像这样的事 ("orgfootnote" "[fn:: %?]" nil 0) 如果你指的是内置的abbrev功能,那么下面是我对这个问题的看法。使用此设备,如果您有一个包含字符串@的缩写,则在检查后,光标将放置在展开文本中出现@的位置 (defadvice expand-abbrev (after my-expand-abbrev activate) ;; if there was an expansi

在Emacs中,是否有一种方式控制光标/点在abbrev模式扩展中的位置

你知道,像这样的事

("orgfootnote" "[fn:: %?]" nil 0)

如果你指的是内置的abbrev功能,那么下面是我对这个问题的看法。使用此设备,如果您有一个包含字符串@的缩写,则在检查后,光标将放置在展开文本中出现@的位置

 (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
对于纠正频繁的打字错误非常有用。

abbrev本身不提供此功能,但它们提供了足够的钩子在外部执行此功能。 例如

然后使用类似abbrev的

("orgfootnote" "" my-orgfootnote)

这是emacs,所以当然可以做一些事情!你能不能详细说明一下光标现在在哪里结束以及你希望它在哪里结束?另外,仔细检查并确保您知道您使用的是哪种abbrev模式,因为emacs有两种模式。太好了!如果有人对实际的脚注语法感兴趣,我稍微调整了间距:
(定义脚注“Docstring.”nil“[fn::“\u”]\ n\n”)
这非常有效!谢谢:)Tom仅供参考我在最近的视频中引用了你的评论:
("orgfootnote" "" my-orgfootnote)