2013-03-13 57 views
2

在Emacs中,有没有一种方法控制光标/点放在缩略模式扩展中?如何控制光标在Emacs中的缩位展开?

你知道吗?

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

这是emacs的那么当然可以做些什么!你能详细阐述一下光标在哪里结束,你希望结束的地方?此外,请仔细检查并确保您知道您正在使用哪种缩写模式,因为它们中有一些适用于emacs。 – 2013-03-13 09:21:36

回答

3

缩写本身不提供此功能,但它们提供了足够的挂钩来进行外部操作。 例如

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

,然后使用缩写像

("orgfootnote" "" my-orgfootnote) 
+0

完美!如果任何人有兴趣将它用于实际的脚注语法,我稍微调整了空格:'(define-skeleton my-orgfootnote“Docstring。”nil “[fn ::”_“] \ n \ n”)' – incandescentman 2013-03-14 00:51:02

0

如果你的意思是内建的abbrev功能,那么这里是我对这个问题的看法。有了这个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)))))))) 
1

如果您需要填写模板,那么abbrev是错误的设施。我强烈建议yasnippetabbrev对修正频繁输入错误非常有用。