Changeset 4200 for trunk/lisp/button.el
- Timestamp:
- 04/07/07 15:49:28 (2 years ago)
- Files:
-
- trunk/lisp/button.el (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/button.el
r4190 r4200 90 90 ;; inheriting its properties. 91 91 (put 'default-button 'rear-nonsticky t) 92 ;; Text property buttons don't have a `button' property of their own, so93 ;; they inherit this.94 (put 'default-button 'button t)95 92 96 93 ;; A `category-symbol' property for the default button type … … 317 314 (button-category-symbol (car (cdr type-entry)))))) 318 315 ;; Now add all the text properties at once 319 (add-text-properties beg end properties) 316 (add-text-properties beg end 317 ;; Each button should have a non-eq `button' 318 ;; property so that next-single-property-change can 319 ;; detect boundaries reliably. 320 (cons 'button (cons (list t) properties))) 320 321 ;; Return something that can be used to get at the button. 321 322 beg) … … 366 367 367 368 (defun previous-button (pos &optional count-current) 368 "Return the Nthbutton before position POS in the current buffer.369 "Return the previous button before position POS in the current buffer. 369 370 If COUNT-CURRENT is non-nil, count any button at POS in the search, 370 371 instead of starting at the next button." 371 (unless count-current 372 (setq pos (previous-single-char-property-change pos 'button))) 373 (and (> pos (point-min)) 374 (or (button-at (1- pos)) 375 ;; We must have originally been on a button, and are now in 376 ;; the inter-button space. Recurse to find a button. 377 (previous-button pos)))) 372 (let ((button (button-at pos))) 373 (if button 374 (if count-current 375 button 376 ;; We started out on a button, so move to its start and look 377 ;; for the previous button boundary. 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 (= pos (button-start 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))))))) 378 392 379 393
