3

私はup-list: Scan error: "Unbalanced parentheses"この位置から取得しています:

(foo "bar|")

up-listドキュメントからのスニペット:

このコマンドは、ポイントが文字列またはコメント内にないことを前提としています。

したがって、これは予想される動作です。しかし、私は気にしません。リストから上に行きたいだけです。誰かがup-list適切なことをするクローンを提案できますか?

この単純なコードよりも優れたものを探しています:

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

2 に答える 2

1

与えられた回答の延長で:コメントも扱い、それ以上リストが見つからない場合は「nil」を送信します。対話的に呼び出されると、メッセージが返されます。

(defun ar-up-list (arg)
  "Move forward out of one level of parentheses.
With ARG, do this that many times.

A negative argument means move backward but still to a less deep spot."
  (interactive "p")
  (let ((orig (point))
        (pps (syntax-ppss))
        erg)
    (and (nth 8 pps) (goto-char (nth 8 pps)))
    (ignore-errors (up-list arg))
    (and (< orig (point)) (setq erg (point)))
    (when (interactive-p) (message "%s" erg))
    erg))

そしてそれは補足です:

(defun ar-down-list (arg)
"Move forward down one level of parentheses.
With ARG, do this that many times.

A negative argument means move backward but still go down a level. "
  (interactive "p")
  (let ((orig (point))
        (pps (syntax-ppss))
        erg)
    (and (nth 8 pps) (goto-char (nth 8 pps)))
    (ignore-errors (down-list arg))
    (and (< orig (point)) (setq erg (point)))
    (when (interactive-p) (message "%s" erg))
    erg))
于 2013-09-21T07:19:07.020 に答える