5
Trong defun sau ...Emacs lisp - làm thế nào để thử/bắt xử lý một lỗi?
(defun re-backward-match-group (rexp &optional n)
"Grab the previous matches of regexp and return the contents of
the n match group (first group match if no n arg is specified)"
(save-excursion
(unless n
(setq n 1))
(when (numberp n)
(when (re-search-backward-lax-whitespace rexp)
(when (= (+ 2 (* n 2)) (length (match-data)))
(match-string-no-properties n))))))
Nếu không phù hợp được tìm thấy, một lỗi được ném bởi re-search-backward-lax-whitespace
Làm thế nào tôi có thể bắt lỗi và trở về con số không hoặc ""
?
Tuyệt vời, cảm ơn @Barmar – ocodo