我正在阅读 Robert J. Chassell 的“ An Introduction to Programming in Emacs Lisp ”。我有一个问题。在节点“ fwd-para while ”(while
循环的解释forward-paragraph
)中,它说:
有趣的是,在我们离开段落之间的空间之前,循环计数不会减少,除非我们到达缓冲区的末尾或停止查看段落分隔符的本地值。
看不懂,谁能给我解释一下?谢谢。
while
循环如下所示:
;; going forwards and not at the end of the buffer
(while (and (> arg 0) (not (eobp)))
;; between paragraphs
;; Move forward over separator lines...
(while (and (not (eobp))
(progn (move-to-left-margin) (not (eobp)))
(looking-at parsep))
(forward-line 1))
;; This decrements the loop
(unless (eobp) (setq arg (1- arg)))
;; ... and one more line.
(forward-line 1)
(if fill-prefix-regexp
;; There is a fill prefix; it overrides parstart;
;; we go forward line by line
(while (and (not (eobp))
(progn (move-to-left-margin) (not (eobp)))
(not (looking-at parsep))
(looking-at fill-prefix-regexp))
(forward-line 1))
;; There is no fill prefix;
;; we go forward character by character
(while (and (re-search-forward sp-parstart nil 1)
(progn (setq start (match-beginning 0))
(goto-char start)
(not (eobp)))
(progn (move-to-left-margin)
(not (looking-at parsep)))
(or (not (looking-at parstart))
(and use-hard-newlines
(not (get-text-property (1- start) 'hard)))))
(forward-char 1))
;; and if there is no fill prefix and if we are not at the end,
;; go to whatever was found in the regular expression search
;; for sp-parstart
(if (< (point) (point-max))
(goto-char start))))
感谢您的编辑和回答。关于前段,我还有另外三个问题:
是什么意思
(progn (move-to-left-margin) (not (eobp)))
?如果(not (eobp))
是真的,不应该(progn (move-to-left-margin) (not (eobp)))
总是真的吗?关于这一行:
;; ... and one more line. (forward-line 1)
为什么要多转一行?
关于本段:
这个
while
循环让我们向前搜索“sp-parstart”,它是可能的空白与段落开头或段落分隔符的本地值的组合。为什么
the local value of the start of a paragraph or of a paragraph separator
呢?就我而言,段落分隔符的条件已经while
在while
.