边读 Emacs Lisp Intro 边做题(五)

文章目录

  • [边读`Emacs Lisp Intro`边做题(五)](#边读Emacs Lisp Intro边做题(五))

边读Emacs Lisp Intro边做题(五)

打开emacs,按C-h i打开Info页,找到Emacs Lisp Intro

  1. 这里的\\b\\([^@ \n\t]+\\)[ \n\t]+\\1\\b抄自题目描述中提供的链接,即Appendix A The 'the-the' Function
  2. 该链接中也提供了答案,但是我没有照抄,下面是我自己写的:
  3. (save-excursion (goto-char (point-max)))是指将光标移至buffer最后,返回它的位置,为re-search-forward提供搜索界限。
emacs-lisp 复制代码
(defun exercise-12.6.2 ()
  "exercise 12.6.2

Write a function to search for duplicated words, such as "the
the". *Note Syntax of Regular Expressions: (emacs)Regexps, for
information on how to write a regexp (a regular expression) to
match a string that is composed of two identical halves.  You can
devise several regexps; some are better than others.  The
function I use is described in an appendix, along with several
regexps. *Note 'the-the' Duplicated Words Function: the-the."
  (interactive)
  (let ((pattern "\\b\\([^@ \n\t]+\\)[ \n\t]+\\1\\b"))
    (re-search-forward pattern (save-excursion (goto-char (point-max))) nil 1)))
相关推荐
aluluka1 天前
Emacs折腾日记(三十六)——打造个人笔记系统
笔记·python·emacs
yTfDRlpl5 天前
直流电机速度单闭环控制系统:Matlab/Simulink 仿真与实现
emacs
aluluka9 天前
Emacs 折腾日记(三十五)——归档
编辑器·emacs
aluluka19 天前
Emacs 折腾日记(三十四)—— org todo
编辑器·emacs
OopspoO19 天前
Emacs 笔记
emacs
2501_941664961 个月前
面向微服务分布式限流与动态降级的互联网系统高可用设计与多语言工程实践分享
ide·emacs·visual studio
dwp11471706071 个月前
在Windows上编译Emacs源码
学习·emacs·gnu
2501_941884612 个月前
多语言微服务架构下的微服务事件溯源与审计日志实践
emacs
2501_941802482 个月前
互联网与物联网:从智能家居到智慧城市的数字化转型
emacs
2501_941144422 个月前
Nginx与HAProxy在高并发互联网系统负载均衡优化与实践经验分享
emacs