Chinaunix首页 | 论坛 | 博客
  • 博客访问: 437636
  • 博文数量: 205
  • 博客积分: 5630
  • 博客等级: 大校
  • 技术积分: 1945
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-06 20:28
文章分类

全部博文(205)

文章存档

2016年(1)

2015年(6)

2014年(9)

2013年(10)

2012年(53)

2011年(25)

2010年(87)

2009年(14)

分类:

2010-06-23 16:53:01

** eamcs中快速复制一个词、一行文字、一个段落,而不用先选中它们

** eamcs中快速复制一个词、一行文字、一个段落,而不用先选中它们

这个方法是有效的。可以参考它定义你想要的类似功能。

Copy Word

Put these code into your lisp file and a global key binding into your .emacs file. Then just put your point at the word and press “Ctrl-c w”, the word at your point will be copied into the kill-ring.

 (defun copy-word (&optional arg)
"Copy words at point into kill-ring"
(interactive "P")
(let ((beg (progn (if (looking-back "[a-zA-Z0-9]" 1) (backward-word 1)) (point)))
(end (progn (forward-word arg) (point))))
(copy-region-as-kill beg end))
)

Key binding

 (global-set-key (kbd "C-c w")         (quote copy-word))

Copy Line

Put these code into your lisp file and a global key binding into your .emacs file. Then just put your point at the line and press “Ctrl-c l”, the whole line at your point will be copied into the kill-ring.

 (defun copy-line (&optional arg)
"Save current line into Kill-Ring without mark the line "
(interactive "P")
(let ((beg (line-beginning-position))
(end (line-end-position arg)))
(copy-region-as-kill beg end))
)

Key binding

  (global-set-key (kbd "C-c l")         (quote copy-line))

Copy Paragraph

Put these code into your lisp file and a global key binding into your .emacs file. Then just put your point at the paragraph and press “Ctrl-c p”, the whole paragraph at your point will be copied into the kill-ring.

 (defun copy-paragraph (&optional arg)
"Copy paragraphes at point"
(interactive "P")
(let ((beg (progn (backward-paragraph 1) (point)))
(end (progn (forward-paragraph arg) (point))))
(copy-region-as-kill beg end))
)

Key binding

  (global-set-key (kbd "C-c p")         (quote copy-paragraph))

Copy String

Put these code into your lisp file and a global key binding into your .emacs file. Then just put your point at the word and press “Ctrl-c s”, the text string at your point will be copied into the kill-ring.

  (defun copy-string (&optional arg)
"Copy a sequence of string into kill-ring"
(interactive)
(setq onPoint (point))
(let (
( beg (progn (re-search-backward "[\t ]" (line-beginning-position) 3 1)
(if (looking-at "[\t ]") (+ (point) 1) (point) ) )
)
( end (progn (goto-char onPoint) (re-search-forward "[\t ]" (line-end-position) 3 1)
(if (looking-back "[\t ]") (- (point) 1) (point) ) )
))
(copy-region-as-kill beg end)
)
)

Key binding

  (global-set-key (kbd "C-c s")         (quote copy-string))

That’s all.

阅读(1168) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~