Emacs:防弹列表? [英] Emacs: bulletproof up-list?

查看:115
本文介绍了Emacs:防弹列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获得 up-list:扫描错误:不平衡括号从此位置:

(foo "bar|")

up-list doc:


此命令假设点不在字符串或注释中。 / p>

This command assumes point is not in a string or comment.

所以这是预期的行为。
但我不在乎。我只想从列表中向上移动。
有人可以建议一个上面列表克隆,这样做正确吗?

So this is the expected behavior. But I don't care. I just want to go upwards from a list. Could someone suggest an up-list clone that does the proper thing?

我在看比这个天真的代码更好:

I'm looking for something better than this naive code:

(defun up-list-naive ()
  (interactive)
  (while (not (ignore-errors (up-list) t))
    (forward-char)))


推荐答案

编辑:并入Andreas Rohler的建议:

incorporated Andreas Rohler's suggestion:

这在您的测试用例中适用于我: / p>



This works for me in your test case:

(defun my-up-list ()
  (interactive)
  (let ((s (syntax-ppss)))
    (when (nth 3 s)
      (goto-char (nth 8 s))))
  (ignore-errors (up-list)))

syntax-ppss 返回一个列表,如果你在一个字符串中,第三个元素存在,第八个元素是字符串的开头(如果你在一个,否则为零)。

syntax-ppss returns a list, the third element of which exists if you're inside a string, and the 8th element is the beginning of the string (if you're in one, otherwise nil).

这篇关于Emacs:防弹列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆