我正在编写一个例程来测试以查看点是否在实际行结束处。Elisp函数返回标记而不是正确的值
(defun end-of-line-p()
"T if there is only \w* between point and end of line"
(interactive)
(save-excursion
(set-mark-command nil) ;mark where we are
(move-end-of-line nil) ;move to the end of the line
(let ((str (buffer-substring (mark) (point)))) ;; does any non-ws text exist in the region? return false
(if (string-match-p "\W*" str)
t
nil))))
问题是,运行它时,我在minibuffer窗口中看到“标记集”,而不是T或nil。
的Emacs Lisp编程提示,如果你看的文档字符串'设置标记command'的底部,你会看到: 新手的Emacs Lisp程序员经常尝试使用大关错误的目的。有关更多信息,请参阅“set-mark”的文档。 – 2009-12-08 18:32:08