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

时间:2013-03-13 02:02:04

标签: emacs expansion abbreviation pabbrev

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

你知道吗,这样的事情?

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

3 个答案:

答案 0 :(得分:3)

Abbrev本身不提供此功能,但它们提供了足够的钩子来进行外部操作。 E.g。

(define-skeleton my-orgfootnote "Docstring." nil
  "fn::" _ "]")

然后使用像

这样的缩写
("orgfootnote" "" my-orgfootnote)

答案 1 :(得分:1)

如果您需要填写模板,那么abbrev是错误的工具。我强烈推荐yasnippetabbrev对于纠正频繁的拼写错误非常有用。

答案 2 :(得分:0)

如果你的意思是内置的缩写功能,那么这就是我对这个问题的看法。如果您有一个包含字符串@@的缩写词,那么在使用该词时,光标将被放置在扩展文本中@@出现的位置。

 (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))))))))
相关问题