我正在編寫一個例程來測試以查看點是否在實際行結束處。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