2013-08-31 9 views
5

...Emacs lisp - Bir hata nasıl ele geçirilir/yakalanır? eşleşme bulunursa aşağıdaki <strong>defun</strong> yılında

(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)))))) 

bir hata

re-search-backward-lax-whitespace tarafından atılır Bunu nasıl hatayı yakalamak ve nil veya "" dönecekti? Opsiyonel bir noerror argümanına sahip

cevap

3

. Bir hata bildirmeyecektir.

Daha genel hata işleme için ignore-errors veya condition-case'u kullanabilirsiniz. İkincisi hakkında bilgi için,

Error Handling in Emacs Lisp

+0

Yüksek, bkz size @Barmar teşekkür – ocodo

İlgili konular