在emacs-lisp中,如何将点放在文本字符串的中间?我希望我的光标在%s
处于以下函数的位置:
(defun web-research ()
(interactive)
(insert "#+BEGIN_QUOTE\n\n%s\n#+END_QUOTE\n")
(org-mac-chrome-insert-frontmost-url)
)
答案 0 :(得分:2)
有很多选择。 例如,
(defun web-research ()
(interactive)
(insert "#+BEGIN_QUOTE\n\n%s\n#+END_QUOTE\n")
(search-backward "%")
(org-mac-chrome-insert-frontmost-url))
或
(defun web-research ()
(interactive)
(insert "#+BEGIN_QUOTE\n\n")
(let ((p (point)))
(insert "\n\n#+END_QUOTE\n")
(org-mac-chrome-insert-frontmost-url)
(goto-char p))
或
(defun web-research ()
(interactive)
(insert "#+BEGIN_QUOTE\n\n%s")
(save-excursion (insert "\n#+END_QUOTE\n"))
(org-mac-chrome-insert-frontmost-url))
IMO第二个是最好的。
答案 1 :(得分:0)
你可以使用yasnippet这样的东西。
# -*- mode: snippet -*-
# name: web-research
# expand-env: ((yas-indent-line 'fixed))
# key: wr
# --
#+BEGIN_QUOTE
%s$0
#+END_QUOTE
`(if (boundp 'org-mac-chrome-get-frontmost-url) (org-mac-chrome-get-frontmost-url) "http://www.example.com/")`
我似乎没有org-mac-chrome-get-frontmost-url
或insert
变体,但经过快速搜索后,我猜测org-mac-chrome-get-frontmost-url
是与此解决方案一起使用的东西。