diff options
| author | Chong Yidong | 2007-04-01 17:10:11 +0000 |
|---|---|---|
| committer | Chong Yidong | 2007-04-01 17:10:11 +0000 |
| commit | 1106c41b1c730d937e7c5ad02b7fea0619b2fdc6 (patch) | |
| tree | 2fd23f9c299c1a29af05c47675b000e6ce90a9b0 | |
| parent | 574b081eca943cd8b4d82881808da4fdaaa2cc65 (diff) | |
| download | emacs-1106c41b1c730d937e7c5ad02b7fea0619b2fdc6.tar.gz emacs-1106c41b1c730d937e7c5ad02b7fea0619b2fdc6.zip | |
(previous-button): Rewrite to account for adjacent buttons.
| -rw-r--r-- | lisp/button.el | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lisp/button.el b/lisp/button.el index 05ea7aec5e2..9110b7867a1 100644 --- a/lisp/button.el +++ b/lisp/button.el | |||
| @@ -366,16 +366,29 @@ instead of starting at the next button." | |||
| 366 | (next-button pos)))) | 366 | (next-button pos)))) |
| 367 | 367 | ||
| 368 | (defun previous-button (pos &optional count-current) | 368 | (defun previous-button (pos &optional count-current) |
| 369 | "Return the Nth button before position POS in the current buffer. | 369 | "Return the previous button before position POS in the current buffer. |
| 370 | If COUNT-CURRENT is non-nil, count any button at POS in the search, | 370 | If COUNT-CURRENT is non-nil, count any button at POS in the search, |
| 371 | instead of starting at the next button." | 371 | instead of starting at the next button." |
| 372 | (unless count-current | 372 | (let ((button (button-at pos))) |
| 373 | (setq pos (previous-single-char-property-change pos 'button))) | 373 | (if button |
| 374 | (and (> pos (point-min)) | 374 | (if count-current |
| 375 | (or (button-at (1- pos)) | 375 | button |
| 376 | ;; We must have originally been on a button, and are now in | 376 | ;; We started out on a button, so move to its start and look |
| 377 | ;; the inter-button space. Recurse to find a button. | 377 | ;; for the previous button boundary. |
| 378 | (previous-button pos)))) | 378 | (setq pos (previous-single-char-property-change |
| 379 | (button-start button) 'button)) | ||
| 380 | (let ((new-button (button-at pos))) | ||
| 381 | (if new-button | ||
| 382 | ;; We are in a button again; this can happen if there | ||
| 383 | ;; are adjacent buttons (or at bob). | ||
| 384 | (unless (eq new-button button) new-button) | ||
| 385 | ;; We are now in the space between buttons. | ||
| 386 | (previous-button pos)))) | ||
| 387 | ;; We started out in the space between buttons. | ||
| 388 | (setq pos (previous-single-char-property-change pos 'button)) | ||
| 389 | (or (button-at pos) | ||
| 390 | (and (> pos (point-min)) | ||
| 391 | (button-at (1- pos))))))) | ||
| 379 | 392 | ||
| 380 | 393 | ||
| 381 | ;; User commands | 394 | ;; User commands |