边读 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)))
相关推荐
小小打工人22214 天前
敏捷开发实践指南:从理论到落地的全面解析
人工智能·信息可视化·emacs
aluluka16 天前
Emacs折腾日记(十四)——buffer操作
编辑器·excel·emacs
一张假钞16 天前
MacOS安装Emacs
编辑器·emacs
星糖曙光22 天前
开发一个音响控制板程序,需要从硬件架构设计、通信协议选择、核心功能实现三个层面进行系统化开发。以下是基于工业级开发流程的实施方案
stm32·课程设计·emacs·ai编程·设计规范
一张假钞1 个月前
spacemacs gnuplot
linux·emacs
一张假钞1 个月前
Ubuntu 18.04安装Emacs 26.2问题解决
编辑器·emacs
十子木2 个月前
Emacs 中的缓冲区(Buffer)介绍
服务器·网络·emacs
键盘上的疯兔3 个月前
做异端中的异端 -- Emacs裸奔之路5: 条件反射式移动
编辑器·emacs·二分法定位
键盘上的疯兔3 个月前
做异端中的异端 -- Emacs裸奔之路4: 你不需要IDE
编辑器·emacs
键盘上的疯兔3 个月前
做异端中的异端 -- Emacs裸奔之路3: 上古神键Hyper
编辑器·emacs·qmk