- (condition-case nil
- (save-excursion
- ;; Try moving forward, then back.
- (funcall ;; First move to end.
- (or (get thing 'end-op)
- (lambda () (forward-thing thing 1))))
- (funcall ;; Then move to beg.
- (or (get thing 'beginning-op)
- (lambda () (forward-thing thing -1))))
- (let ((beg (point)))
- (if (<= beg orig)
- ;; If that brings us all the way back to ORIG,
- ;; it worked. But END may not be the real end.
- ;; So find the real end that corresponds to BEG.
- ;; FIXME: in which cases can `real-end' differ from `end'?
- (let ((real-end
- (progn
- (funcall
- (or (get thing 'end-op)
- (lambda () (forward-thing thing 1))))
- (point))))
- (when (and (<= orig real-end) (< beg real-end))
- (cons beg real-end)))
- (goto-char orig)
- ;; Try a second time, moving backward first and then forward,
- ;; so that we can find a thing that ends at ORIG.
- (funcall ;; First, move to beg.
- (or (get thing 'beginning-op)
- (lambda () (forward-thing thing -1))))
- (funcall ;; Then move to end.
- (or (get thing 'end-op)
- (lambda () (forward-thing thing 1))))
- (let ((end (point))
- (real-beg
+ (ignore-errors
+ (save-excursion
+ ;; Try moving forward, then back.
+ (funcall ;; First move to end.
+ (or (get thing 'end-op)
+ (lambda () (forward-thing thing 1))))
+ (funcall ;; Then move to beg.
+ (or (get thing 'beginning-op)
+ (lambda () (forward-thing thing -1))))
+ (let ((beg (point)))
+ (if (<= beg orig)
+ ;; If that brings us all the way back to ORIG,
+ ;; it worked. But END may not be the real end.
+ ;; So find the real end that corresponds to BEG.
+ ;; FIXME: in which cases can `real-end' differ from `end'?
+ (let ((real-end