在linux上使用emacs 23.3.1的两个相关问题:
首先,为什么我不能使用setq将show-trailing-whitespace的值设置为t,如下所示?当我把setq版本放到我的.emacs中时,它不会改变这个值(从功能上和使用M-x describe-variable都可以看到)。
(setq show-trailing-whitespace t) ; Does not change variable value or give error
(custom-set-variables ; Sets show-trailing-whitespace as expected
'(show-trailing-whitespace t))其次,如何在t和nil之间切换该值?我认为this answer正是我所需要的,但它在这种情况下不起作用。我使用:
(global-set-key "\M-ow" 'tf-toggle-show-trailing-whitespace)
(defun tf-toggle-show-trailing-whitespace ()
"Toggle show-trailing-whitespace between t and nil"
(interactive)
(setq show-trailing-whitespace (if (= show-trailing-whitespace nil) t nil))
(redraw-display))当我点击M-ow时,我得到了一个错误的Wront type argument: number-or-marker-p, nil。有什么想法吗?
发布于 2012-07-28 22:32:20
首先:正如describe-variable告诉您的那样,show-trailing-whitespace是一个缓冲区变量。这意味着执行setq仅为当前缓冲区设置它,因此在.emacs文件中执行时没有任何效果。为了拥有类似的东西,你需要使用setq-default而不是setq。这将适用于所有缓冲区。
第二:对于切换,如果您希望在每个缓冲区的基础上进行切换,则可能需要使用setq。您得到的错误是您使用=,它是用来测试两个数字是否相等。切换是通过使用not以更简洁的方式完成的。顺便说一句,(redraw-display)命令似乎什么也没做。
(defun tf-toggle-show-trailing-whitespace ()
"Toggle show-trailing-whitespace between t and nil"
(interactive)
(setq show-trailing-whitespace (not show-trailing-whitespace)))发布于 2012-07-28 20:39:24
write (eq show-trailing空白空格nil)
或者更短--但颠倒过来--
(如果显示尾随空格
https://stackoverflow.com/questions/11700934
复制相似问题