Difference between revisions of "Keyboard macros"

From WikEmacs
Jump to navigation Jump to search
(精准医疗如何做 刘如银来分享)
m (Protected "Keyboard macros" ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
 
(17 intermediate revisions by 7 users not shown)
Line 1: Line 1:
精准医疗又叫个性化医疗,是指以个人基因组信息为基础,结合蛋白质组,代谢组等相关内环境信息,为病人量身设计出最佳治疗方案,以期达到治疗效果最大化和副作用最小化的一门定制医疗模式。因此相较传统医疗,精准医疗具有针对性、高效性及预防性等特征。
+
{{Manual|emacs|Basic-Keyboard-Macro|Basic Keyboard Macro}}
+
 
美国医学界在2011年首次提出了“精准医学”的概念,今年1月20日,奥巴马又在美国国情咨文中提出“精准医学计划”,希望精准医学可以引领一个医学新时代。10月8日,2015全球创新论坛纽约峰会在纽约穆迪总部大楼举办。乐土投资集团CEO刘如银在峰会上介绍了他的精准医疗生态圈的想法。
+
'''Keyboard macros''' can be used to automate or repeat tedious editing tasks in Emacs.
+
 
刘如银介绍了乐土投资在美国的国际化实践,包括在美国的地产投资拓展,以及最新投资的医疗健康项目。乐土投资集团(CLIG)定位以硅谷的高科技投资为引擎,以科技医疗和互联网金融为两翼,链接最具价值的深科技健康项目,服务国际大健康和科技发展。
+
 
+
==Basic Use==
美国财政预算计划在2016年拨付给美国国立卫生研究院(NIH)、美国食品药品监督管理局(FDA)、美国国家医疗信息技术协调办公室(ONC)等机构共2.15亿美元用于资助这方面的科学研究与创新发展。
+
 
   
+
; {{Keys|F3}}, or {{Keys|C-x (}}
刘如银说:美国的精准医疗主要是围绕着基因组、蛋白组等方面的检测,也就是围绕分子生物学的特性,针对个体化的病理特征进行治疗。而我们所关注的不仅如此,更是系统化的,全过程、全要素、全局性的对医疗过程和临床实践进行优化。我们所指的精准医疗也是针对每一个病人的具体病情,正确选择并精确的应用适当的治疗方法。刘如银认为:精准医疗的最终目标是以最小化的医源性损害、最低化的医疗资源耗费去获得最大化的病患的效益,其前景不可限量。
+
: Start defining a macro.
   
+
; {{Keys|F4}}, or {{Keys|C-x )}}
精准医疗要做到个性、高效及预防的关键在于筛查和诊断,因此基因测序等检测诊断技术的发展是关键。成本的下降让基因测序商业化市场的打开成为可能,基因测序技术的成熟和商用经过了多年的发展,1980 年自动测序仪出现,2001 年完成了人类基因组框架图标志着这一技术的成熟,2007 年二代基因测序技术大幅降低测序成本,使得这一技术应用出现可能,以走在前列的Illumina 公司为例,该公司自2007 年起把当时每个基因组的测序成本费用从1000万美元降到了当下的1000 美元, 根据Illumina 公司数据,全球NGS(二代基因测序)的应用市场规模预计为200 亿美元,药品研发和临床应用是增速最快的领域,增速超过15%,肿瘤诊断和个性化用药是最有应用前景的领域,市场规模120亿美元。乐土投资与Illumina以及新一代的基因检测公司Genalyte, Centrillion都有着合作关系。
+
: Stop defining a macro.
+
; {{Keys|F4}}, or {{Keys|C-x e}}
刘如银说:精准医疗作为医疗模式的革新对提高我国国民健康水平有重要意义,将在基因测序技术发展和国家政策的推动下迎来黄金发展期。精准治疗是下一个新兴朝阳行业,我们关注基因测序、肿瘤诊断及个性化用药等相关投资机会。
+
: Execute a macro
+
; {{Keys|C-u 37 C-x e}} or {{Keys|C-u 37 F4}}
全球创新论坛纽约峰会由全美华人金融协会(The Chinese Finance Association, TCFA) 主办。全美华人金融协会于一九九四年在美国成立。分布在世界各地的会员来自华尔街投行、基金、监管部门、和学术界,已成为联系中美金融界最重要的桥梁之一。协会定期举行学术年会。协会本部设在纽约,并在波士顿,华盛顿,旧金山,伦敦,香港,北京和上海等金融中心设有分会。
+
: Execute a macro multiple times, using [[prefix argument]]
+
; {{Keys|C-u 0 C-x e}}
原招商银行行长马蔚华,中信银行美国分行行长文兵,汉世纪投资管理有限公司合伙人吴皓,联合国南南合作办首席经济与投资专家杨庆宏等参加了本年度会议并发表了讲话。
+
: Execute a macro until the end of the buffer
 +
 
 +
==Example usage==
 +
 
 +
Consider the standard <code>*scratch*</code> buffer:
 +
 
 +
<pre>
 +
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
 +
;; If you want to create a file, visit that file with C-x C-f,
 +
;; then enter the text in that file's own buffer.
 +
</pre>
 +
 
 +
Suppose you want to remove the first occurrence of the letter "a" on every row in that piece of text. You could write a [[regular expression]] to do the job, but let's assume you want to use a keyboard macro this time.
 +
 
 +
# Make sure [[point]] is at the start of the buffer.
 +
# Hit <code>C-x (</code> to start recording your macro. '''Note:''' If you hit <code>C-g</code> or if an error occurs, your keyboard macro recording will stop.
 +
# Hit <code>C-s</code> followed by <code>a</code> to find the first "a". Now, point is right after the first "a" in the text.
 +
# Hit backspace to delete that "a".
 +
 
 +
The first occurrence of "a" of the first line has been deleted. Let's move point to the beginning of the next line and then stop recording.
 +
 
 +
<ol start="5">
 +
<li>Hit <code>C-e C-f</code> to move point to the beginning of the next line.</li>
 +
<li>Hit <code>C-x )</code> to finish the recording of our macro.</li>
 +
</ol>
 +
 
 +
The macro you have just recorded performs the operation of removing the first occurrence of "a" it can find and then moving point to the next line.
 +
 
 +
<ol start="7">
 +
<li>Hit <code>C-x e</code> once to call that macro.</li>
 +
<li>Continue hitting <code>e</code> to call it several times. Hit any other key to get out of the macro repetition.</li>
 +
</ol>
 +
 
 +
== Naming and saving macros ==
 +
 
 +
You can:
 +
* give a name to the most recently defined macro (<code>C-x C-k n</code>)
 +
* bind it to a key sequence (<code>C-x C-k b</code>)
 +
* insert it in the current buffer as lisp code (<code>M-x insert-kbd-macro</code>).
 +
 
 +
{{Manual|emacs|Save-Keyboard-Macro|Save Keyboard Macro}}
 +
 
 +
 
 +
To bind a keyboard macro to a key use <code>C-x C-k b</code>. To avoid problems caused by overriding existing bindings, the key sequences <code>C-x C-k 0</code> through <code>C-x C-k 9</code> and <code>C-x C-k A</code> through <code>C-x C-k Z</code> are reserved for your own keyboard macro bindings.  You can, however, bind a keyboard macro to whatever you like.
 +
 
 +
==Variables==
 +
 
 +
Variables can be stored in lisp or in [[registers]]. Here's an example using lisp:
 +
 
 +
<pre>
 +
[M-: (setq x 1)]
 +
<F3>
 +
Line number [C-u M-: x]
 +
[M-: (setq x (+ x 1))]
 +
<F4>
 +
</pre>
 +
 
 +
Now execute the macro four times with the command <code>C-x e e e e</code> and you get:
 +
 
 +
line number 1<br />
 +
line number 2<br />
 +
line number 3<br />
 +
line number 4
 +
 
 +
 
 +
= See also =
 +
 
 +
* [https://github.com/Silex/elmacro elmacro], to show keyboard macros as emacs-lisp
 +
* [https://github.com/abo-abo/centimacro centimacro] to (temporarily) bind any number of macros to any global shortcuts.
 +
* You can use keyboard macros à la vim in [[evil]].
 +
 
 +
 
 +
[[Category:Intermediate]]
 +
[[Category:Editing]]

Latest revision as of 15:27, 4 July 2016

Basic Keyboard Macro (`(info "(emacs) Basic Keyboard Macro")')

Keyboard macros can be used to automate or repeat tedious editing tasks in Emacs.


Basic Use

[F3], or [C-x (]
Start defining a macro.
[F4], or [C-x )]
Stop defining a macro.
[F4], or [C-x e]
Execute a macro
[C-u 37 C-x e] or [C-u 37 F4]
Execute a macro multiple times, using prefix argument
[C-u 0 C-x e]
Execute a macro until the end of the buffer

Example usage

Consider the standard *scratch* buffer:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

Suppose you want to remove the first occurrence of the letter "a" on every row in that piece of text. You could write a regular expression to do the job, but let's assume you want to use a keyboard macro this time.

  1. Make sure point is at the start of the buffer.
  2. Hit C-x ( to start recording your macro. Note: If you hit C-g or if an error occurs, your keyboard macro recording will stop.
  3. Hit C-s followed by a to find the first "a". Now, point is right after the first "a" in the text.
  4. Hit backspace to delete that "a".

The first occurrence of "a" of the first line has been deleted. Let's move point to the beginning of the next line and then stop recording.

  1. Hit C-e C-f to move point to the beginning of the next line.
  2. Hit C-x ) to finish the recording of our macro.

The macro you have just recorded performs the operation of removing the first occurrence of "a" it can find and then moving point to the next line.

  1. Hit C-x e once to call that macro.
  2. Continue hitting e to call it several times. Hit any other key to get out of the macro repetition.

Naming and saving macros

You can:

  • give a name to the most recently defined macro (C-x C-k n)
  • bind it to a key sequence (C-x C-k b)
  • insert it in the current buffer as lisp code (M-x insert-kbd-macro).

Save Keyboard Macro (`(info "(emacs) Save Keyboard Macro")')


To bind a keyboard macro to a key use C-x C-k b. To avoid problems caused by overriding existing bindings, the key sequences C-x C-k 0 through C-x C-k 9 and C-x C-k A through C-x C-k Z are reserved for your own keyboard macro bindings. You can, however, bind a keyboard macro to whatever you like.

Variables

Variables can be stored in lisp or in registers. Here's an example using lisp:

[M-: (setq x 1)]
<F3>
Line number [C-u M-: x]
[M-: (setq x (+ x 1))]
<F4>

Now execute the macro four times with the command C-x e e e e and you get:

line number 1
line number 2
line number 3
line number 4


See also

  • elmacro, to show keyboard macros as emacs-lisp
  • centimacro to (temporarily) bind any number of macros to any global shortcuts.
  • You can use keyboard macros à la vim in evil.