diff options
| author | Kim F. Storm | 2005-01-11 00:12:09 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-01-11 00:12:09 +0000 |
| commit | 9bcb9ab086fb6a5468bcba98299568f30518df82 (patch) | |
| tree | 3cd51a9956e231a569210b45199fb16c9e3737db | |
| parent | 5304c40bc2eaeccefd3a2f14d10ce8ce135bdb13 (diff) | |
| download | emacs-9bcb9ab086fb6a5468bcba98299568f30518df82.tar.gz emacs-9bcb9ab086fb6a5468bcba98299568f30518df82.zip | |
(Text Properties): Add "Enable Mouse-1" to submenu.
(Enabling Mouse-1 to Follow Links): New subsection.
| -rw-r--r-- | lispref/text.texi | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/lispref/text.texi b/lispref/text.texi index b6e6c9670e0..e74303bb5dc 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -2431,6 +2431,8 @@ along with the characters; this includes such diverse functions as | |||
| 2431 | only when text is examined. | 2431 | only when text is examined. |
| 2432 | * Clickable Text:: Using text properties to make regions of text | 2432 | * Clickable Text:: Using text properties to make regions of text |
| 2433 | do something when you click on them. | 2433 | do something when you click on them. |
| 2434 | * Enabling Mouse-1 to Follow Links:: | ||
| 2435 | How to make @key{mouse-1} follow a link. | ||
| 2434 | * Fields:: The @code{field} property defines | 2436 | * Fields:: The @code{field} property defines |
| 2435 | fields within the buffer. | 2437 | fields within the buffer. |
| 2436 | * Not Intervals:: Why text properties do not use | 2438 | * Not Intervals:: Why text properties do not use |
| @@ -3388,6 +3390,110 @@ clickable pieces of text. Also, the major mode definition (or the | |||
| 3388 | global definition) remains available for the rest of the text in the | 3390 | global definition) remains available for the rest of the text in the |
| 3389 | buffer. | 3391 | buffer. |
| 3390 | 3392 | ||
| 3393 | @node Enabling Mouse-1 to Follow Links | ||
| 3394 | @subsection Enabling Mouse-1 to Follow Links | ||
| 3395 | @cindex follow links | ||
| 3396 | |||
| 3397 | Traditionally, Emacs uses a @key{mouse-1} click to set point and a | ||
| 3398 | @key{mouse-2} click to follow a link, whereas most other applications | ||
| 3399 | use a @key{mouse-1} click for both purposes, depending on whether you | ||
| 3400 | click outside or inside a link. | ||
| 3401 | |||
| 3402 | Starting with Emacs release 21.4, the user visible behaviour of a | ||
| 3403 | @key{mouse-1} click on a link has been changed to match this | ||
| 3404 | context-sentitive dual behaviour. The user can customize this | ||
| 3405 | behaviour through the variable @code{mouse-1-click-follows-link}. | ||
| 3406 | |||
| 3407 | However, at the Lisp level, @key{mouse-2} is still used as the | ||
| 3408 | action for the clickable text corresponding to the link, and the | ||
| 3409 | clickable text must be explicitly marked as a link for a @key{mouse-1} | ||
| 3410 | click to follow the link. | ||
| 3411 | |||
| 3412 | There are several methods that can be used to identify a clickable | ||
| 3413 | text as a link: | ||
| 3414 | |||
| 3415 | @table @asis | ||
| 3416 | @item follow-link property | ||
| 3417 | |||
| 3418 | If the clickable text has a non-nil @code{follow-link} text or overlay | ||
| 3419 | property, the value of that property determines what to do. | ||
| 3420 | |||
| 3421 | @item follow-link event | ||
| 3422 | |||
| 3423 | If there is a binding for the @code{follow-link} event, either on | ||
| 3424 | the clickable text or in the local keymap, the binding of that event | ||
| 3425 | determines whether the mouse click position is inside a link: | ||
| 3426 | |||
| 3427 | @table @asis | ||
| 3428 | @item mouse-face | ||
| 3429 | |||
| 3430 | If the binding is @code{mouse-face}, the mouse click position is | ||
| 3431 | inside a link if there is a non-nil @code{mouse-face} property at | ||
| 3432 | that position. A value of @code{t} is used to determine what to do next. | ||
| 3433 | |||
| 3434 | For example, here is how @key{mouse-1} are setup in info mode: | ||
| 3435 | |||
| 3436 | @example | ||
| 3437 | (define-key Info-mode-map [follow-link] 'mouse-face) | ||
| 3438 | @end example | ||
| 3439 | |||
| 3440 | @item a function | ||
| 3441 | |||
| 3442 | If the binding is a function, @var{func}, the mouse click position, | ||
| 3443 | @var{pos}, is inside a link if the call @code{(@var{func} @var{pos})} | ||
| 3444 | returns non-@code{nil}. The return value from that call determines | ||
| 3445 | what to do next. | ||
| 3446 | |||
| 3447 | For example, here is how pcvs enables @key{mouse-1} on file names only: | ||
| 3448 | |||
| 3449 | @example | ||
| 3450 | (define-key map [follow-link] | ||
| 3451 | (lambda (pos) | ||
| 3452 | (if (eq (get-char-property pos 'face) 'cvs-filename-face) t))) | ||
| 3453 | @end example | ||
| 3454 | |||
| 3455 | @item anthing else | ||
| 3456 | |||
| 3457 | If the binding is anything else, the binding determines what to do. | ||
| 3458 | @end table | ||
| 3459 | |||
| 3460 | @end table | ||
| 3461 | |||
| 3462 | @noindent | ||
| 3463 | The resulting value determined above is interpreted as follows: | ||
| 3464 | |||
| 3465 | @table @asis | ||
| 3466 | @item a string | ||
| 3467 | |||
| 3468 | If the value is a string, the @key{mouse-1} event is translated into | ||
| 3469 | the first character of the string, i.e. the action of the @key{mouse-1} | ||
| 3470 | click is the local or global binding of that character. | ||
| 3471 | |||
| 3472 | @item a vector | ||
| 3473 | |||
| 3474 | If the value is is a vector, the @key{mouse-1} event is translated | ||
| 3475 | into the first element of that vector, i.e. the action of the | ||
| 3476 | @key{mouse-1} click is the local or global binding of that event. | ||
| 3477 | |||
| 3478 | @item anthing else | ||
| 3479 | |||
| 3480 | For any other non-nil valule, the @key{mouse-1} event is translated | ||
| 3481 | into a @key{mouse-2} event at the same position. | ||
| 3482 | @end table | ||
| 3483 | |||
| 3484 | To use @key{mouse-1} on a button defined with @code{define-button-type}, | ||
| 3485 | give the button a @code{follow-link} property with a value as | ||
| 3486 | specified above to determine how to follow the link. | ||
| 3487 | |||
| 3488 | To use @key{mouse-1} on a widget defined with @code{define-widget}, | ||
| 3489 | give the widget a @code{:follow-link} property with a value | ||
| 3490 | as specified above to determine how to follow the link. | ||
| 3491 | |||
| 3492 | @defun mouse-on-link-p pos | ||
| 3493 | @tindex mouse-on-link-p | ||
| 3494 | Return non-@code{nil} if @var{pos} is on a link in the current buffer. | ||
| 3495 | @end defun | ||
| 3496 | |||
| 3391 | @node Fields | 3497 | @node Fields |
| 3392 | @subsection Defining and Using Fields | 3498 | @subsection Defining and Using Fields |
| 3393 | @cindex fields | 3499 | @cindex fields |