我想做的是
(destructuring-bind (start end) (bounds-of-thing-at-point 'symbol))但是bounds-of-thing-at-point返回的是一个cons单元格,而不是一个列表,所以destructuring-bind不起作用。在这种情况下,什么才是可行的?
发布于 2013-07-18 19:20:40
由于destructuring-bind是来自cl包的宏,因此可能值得查看Common Lisp文档中的更多示例。
This page显示宏的语法。请注意(wholevar reqvars optvars . var)。虽然我不确定destructuring-bind的cl版本是否真的支持所有不常见的情况(许多关键字只有在与common Lisp宏/函数一起使用时才有意义,但在Emacs Lisp中就没有意义)。
因此:
(destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) ;...)应该行得通。
发布于 2013-07-22 22:45:13
我会用
(pcase-let ((`(,start . ,end) (bounds-of-thing-at-point 'symbol)))
...)发布于 2013-07-18 17:49:20
我不能想到像destructuring bind这样优雅的东西,但这是可行的:
(let* ((b (bounds-of-thing-at-point 'symbol))
(start (car b))
(end (cdr b)))
...)https://stackoverflow.com/questions/17717546
复制相似问题