diff options
| author | Miles Bader | 2001-10-07 17:14:34 +0000 |
|---|---|---|
| committer | Miles Bader | 2001-10-07 17:14:34 +0000 |
| commit | d6bc0bdc4a8bee466b3885a5b2099fd80f9957fe (patch) | |
| tree | e13891a9d2107b8cf5c8dc3291b1d9d02610134d | |
| parent | e664497b5f023561ed2bfe12f4335cff999fb9ad (diff) | |
| download | emacs-d6bc0bdc4a8bee466b3885a5b2099fd80f9957fe.tar.gz emacs-d6bc0bdc4a8bee466b3885a5b2099fd80f9957fe.zip | |
(next-button, previous-button): Respect `skip' property.
(push-button, button-activate): Add USE-MOUSE-ACTION argument.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/button.el | 30 |
2 files changed, 27 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 59e6451fd04..8916b4a34cb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2001-10-08 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * button.el (next-button, previous-button): Respect `skip' property. | ||
| 4 | (push-button, button-activate): Add USE-MOUSE-ACTION argument. | ||
| 5 | |||
| 1 | 2001-10-07 Miles Bader <miles@gnu.org> | 6 | 2001-10-07 Miles Bader <miles@gnu.org> |
| 2 | 7 | ||
| 3 | * woman.el (woman-mode-map): Copy button-buffer-map instead of | 8 | * woman.el (woman-mode-map): Copy button-buffer-map instead of |
diff --git a/lisp/button.el b/lisp/button.el index d3506091597..ed2ea106366 100644 --- a/lisp/button.el +++ b/lisp/button.el | |||
| @@ -184,9 +184,14 @@ Buttons inherit them by setting their `category' property to that symbol." | |||
| 184 | (point-max)) | 184 | (point-max)) |
| 185 | prop val))) | 185 | prop val))) |
| 186 | 186 | ||
| 187 | (defsubst button-activate (button) | 187 | (defsubst button-activate (button use-mouse-action) |
| 188 | "Call BUTTON's action property." | 188 | "Call BUTTON's action property. |
| 189 | (funcall (button-get button 'action) button)) | 189 | If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
| 190 | instead of its normal action; if the button has no mouse-action, | ||
| 191 | the normal action is used instead." | ||
| 192 | (funcall (or (and use-mouse-action (button-get button 'mouse-action)) | ||
| 193 | (button-get button 'action)) | ||
| 194 | button)) | ||
| 190 | 195 | ||
| 191 | (defun button-label (button) | 196 | (defun button-label (button) |
| 192 | "Return BUTTON's text label." | 197 | "Return BUTTON's text label." |
| @@ -314,7 +319,10 @@ If COUNT-CURRENT is non-nil, count any button at POS in the search, | |||
| 314 | ;; Search for the next button boundary. | 319 | ;; Search for the next button boundary. |
| 315 | (setq pos (next-single-char-property-change pos 'button))) | 320 | (setq pos (next-single-char-property-change pos 'button))) |
| 316 | (let ((button (button-at pos))) | 321 | (let ((button (button-at pos))) |
| 317 | (cond ((and button (>= n 2)) | 322 | (cond ((and button (button-get button 'skip)) |
| 323 | ;; Found a button, but the button declines to be found; recurse. | ||
| 324 | (next-button (button-start button) n wrap)) | ||
| 325 | ((and button (>= n 2)) | ||
| 318 | ;; Found a button, but we want a different one; recurse. | 326 | ;; Found a button, but we want a different one; recurse. |
| 319 | (next-button (button-start button) (1- n) wrap)) | 327 | (next-button (button-start button) (1- n) wrap)) |
| 320 | (button | 328 | (button |
| @@ -344,7 +352,10 @@ If COUNT-CURRENT is non-nil, count any button at POS in the search, | |||
| 344 | (unless count-current | 352 | (unless count-current |
| 345 | (setq pos (previous-single-char-property-change pos 'button))) | 353 | (setq pos (previous-single-char-property-change pos 'button))) |
| 346 | (let ((button (and (> pos (point-min)) (button-at (1- pos))))) | 354 | (let ((button (and (> pos (point-min)) (button-at (1- pos))))) |
| 347 | (cond ((and button (>= n 2)) | 355 | (cond ((and button (button-get button 'skip)) |
| 356 | ;; Found a button, but the button declines to be found; recurse. | ||
| 357 | (previous-button (button-start button) n wrap)) | ||
| 358 | ((and button (>= n 2)) | ||
| 348 | ;; Found a button, but we want a different one; recurse. | 359 | ;; Found a button, but we want a different one; recurse. |
| 349 | (previous-button (button-start button) (1- n) wrap)) | 360 | (previous-button (button-start button) (1- n) wrap)) |
| 350 | (button | 361 | (button |
| @@ -362,9 +373,12 @@ If COUNT-CURRENT is non-nil, count any button at POS in the search, | |||
| 362 | 373 | ||
| 363 | ;; User commands | 374 | ;; User commands |
| 364 | 375 | ||
| 365 | (defun push-button (&optional pos) | 376 | (defun push-button (&optional pos use-mouse-action) |
| 366 | "Perform the action specified by a button at location POS. | 377 | "Perform the action specified by a button at location POS. |
| 367 | POS may be either a buffer position or a mouse-event. | 378 | POS may be either a buffer position or a mouse-event. |
| 379 | If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action | ||
| 380 | instead of its normal action; if the button has no mouse-action, | ||
| 381 | the normal action is used instead. | ||
| 368 | POS defaults to point, except when `push-button' is invoked | 382 | POS defaults to point, except when `push-button' is invoked |
| 369 | interactively as the result of a mouse-event, in which case, the | 383 | interactively as the result of a mouse-event, in which case, the |
| 370 | mouse event is used. | 384 | mouse event is used. |
| @@ -376,12 +390,12 @@ return t." | |||
| 376 | ;; POS is a mouse event; switch to the proper window/buffer | 390 | ;; POS is a mouse event; switch to the proper window/buffer |
| 377 | (let ((posn (event-start pos))) | 391 | (let ((posn (event-start pos))) |
| 378 | (with-current-buffer (window-buffer (posn-window posn)) | 392 | (with-current-buffer (window-buffer (posn-window posn)) |
| 379 | (push-button (posn-point posn)))) | 393 | (push-button (posn-point posn) t))) |
| 380 | ;; POS is just normal position | 394 | ;; POS is just normal position |
| 381 | (let ((button (button-at (or pos (point))))) | 395 | (let ((button (button-at (or pos (point))))) |
| 382 | (if (not button) | 396 | (if (not button) |
| 383 | nil | 397 | nil |
| 384 | (button-activate button) | 398 | (button-activate button use-mouse-action) |
| 385 | t)))) | 399 | t)))) |
| 386 | 400 | ||
| 387 | (defun forward-button (n &optional wrap display-message) | 401 | (defun forward-button (n &optional wrap display-message) |