边读 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)))
相关推荐
Masimaro1 天前
《elisp 每日一练》—— Minor Mode 变量生成机制与状态控制
emacs
Masimaro2 天前
《elisp 每日一练》——文件与目录的回顾与综合练习
emacs
Masimaro9 天前
《elisp 每日一练》——minibuffer输入读取和set-transient-map 临时热键状态机
emacs
Masimaro12 天前
《elisp 每日一练》——Window 树与布局状态恢复
emacs
典典分享指南14 天前
Windows 自动化踩坑实录
python·intellij-idea·pyqt·emacs·visual studio
辰辉创聚15 天前
重组细胞因子全解析:定义、分类与应用指南
人工智能·eclipse·emacs·白细胞介素·重组蛋白·重组细胞因子
Masimaro17 天前
《elisp 每日一练》—— 前缀按键
emacs
带娃的IT创业者20 天前
Emacs 31:一场静默而深刻的范式演进
编辑器·文本编辑器·开源软件·emacs·lisp·软件架构
Masimaro22 天前
《elisp 每日一练》——syntax-table
emacs
Masimaro1 个月前
《elisp 每日一练》—— overlay 机制
emacs