aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lispref/ChangeLog11
-rw-r--r--lispref/text.texi60
2 files changed, 46 insertions, 25 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 2bb3f1b1874..f64f9eb56df 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,20 +1,25 @@
12006-07-31 Thien-Thi Nguyen <ttn@gnu.org>
2
3 * text.texi (Clickable Text): Mention `help-echo' text property.
4 Update intro, examples and associated explanations.
5
12006-07-31 Richard Stallman <rms@gnu.org> 62006-07-31 Richard Stallman <rms@gnu.org>
2 7
3 * commands.texi: Update xrefs. 8 * commands.texi: Update xrefs.
4 (Event Mod): New node, cut out from old Translating Input. 9 (Event Mod): New node, cut out from old Translating Input.
5 10
6 * maps.texi: Update xrefs. 11 * maps.texi: Update xrefs.
7 12
8 * keymaps.texi (Translation Keymaps): New node. 13 * keymaps.texi (Translation Keymaps): New node.
9 Update xrefs from Translating Input to Translation Keymaps. 14 Update xrefs from Translating Input to Translation Keymaps.
10 15
11 * elisp.texi (Top): Update subnode menu. 16 * elisp.texi (Top): Update subnode menu.
12 17
13 * display.texi (Face Functions): Fix explanations of FRAME=t or nil. 18 * display.texi (Face Functions): Fix explanations of FRAME=t or nil.
14 19
15 * os.texi (System Interface): Fix menu descriptions of some nodes. 20 * os.texi (System Interface): Fix menu descriptions of some nodes.
16 (Translating Input): Node deleted. 21 (Translating Input): Node deleted.
17 22
182006-07-31 Nick Roberts <nickrob@snap.net.nz> 232006-07-31 Nick Roberts <nickrob@snap.net.nz>
19 24
20 * modes.texi (Minor Mode Conventions): Update link for add-to-list. 25 * modes.texi (Minor Mode Conventions): Update link for add-to-list.
diff --git a/lispref/text.texi b/lispref/text.texi
index fccc72d3d0b..08e55f18f05 100644
--- a/lispref/text.texi
+++ b/lispref/text.texi
@@ -3480,25 +3480,31 @@ being called over and over for the same text.
3480@cindex clickable text 3480@cindex clickable text
3481 3481
3482 There are two parts of setting up @dfn{clickable text} in a buffer: 3482 There are two parts of setting up @dfn{clickable text} in a buffer:
3483(1) to make that text highlight when the mouse moves over it, and (2) 3483(1) to indicate clickability when the mouse moves over the text, and (2)
3484to make a mouse button do something when you click on that text. 3484to make a mouse button do something when you click on that text.
3485 3485
3486 For highlighting, use the @code{mouse-face} text property. Here is 3486 Indicating clickability usually involves highlighting the text, and
3487an example of how Dired does it: 3487often involves displaying helpful information about the action, such
3488as which mouse button to press, or a short summary of the action.
3489This can be done with the @code{mouse-face} and @code{help-echo}
3490text properties. @xref{Special Properties}.
3491Here is an example of how Dired does it:
3488 3492
3489@smallexample 3493@smallexample
3490(condition-case nil 3494(condition-case nil
3491 (if (dired-move-to-filename) 3495 (if (dired-move-to-filename)
3492 (put-text-property (point) 3496 (add-text-properties
3493 (save-excursion 3497 (point)
3494 (dired-move-to-end-of-filename) 3498 (save-excursion
3495 (point)) 3499 (dired-move-to-end-of-filename)
3496 'mouse-face 'highlight)) 3500 (point))
3501 '(mouse-face highlight
3502 help-echo "mouse-2: visit this file in other window")))
3497 (error nil)) 3503 (error nil))
3498@end smallexample 3504@end smallexample
3499 3505
3500@noindent 3506@noindent
3501The first two arguments to @code{put-text-property} specify the 3507The first two arguments to @code{add-text-properties} specify the
3502beginning and end of the text. 3508beginning and end of the text.
3503 3509
3504 The usual way to make the mouse do something when you click it 3510 The usual way to make the mouse do something when you click it
@@ -3508,24 +3514,34 @@ is done by the command definition. Here is how Dired does it:
3508 3514
3509@smallexample 3515@smallexample
3510(defun dired-mouse-find-file-other-window (event) 3516(defun dired-mouse-find-file-other-window (event)
3511 "In dired, visit the file or directory name you click on." 3517 "In Dired, visit the file or directory name you click on."
3512 (interactive "e") 3518 (interactive "e")
3513 (let (file) 3519 (let (window pos file)
3514 (save-excursion 3520 (save-excursion
3515 (set-buffer (window-buffer (posn-window (event-end event)))) 3521 (setq window (posn-window (event-end event))
3516 (save-excursion 3522 pos (posn-point (event-end event)))
3517 (goto-char (posn-point (event-end event))) 3523 (if (not (windowp window))
3518 (setq file (dired-get-filename)))) 3524 (error "No file chosen"))
3519 (select-window (posn-window (event-end event))) 3525 (set-buffer (window-buffer window))
3520 (find-file-other-window (file-name-sans-versions file t)))) 3526 (goto-char pos)
3527 (setq file (dired-get-file-for-visit)))
3528 (if (file-directory-p file)
3529 (or (and (cdr dired-subdir-alist)
3530 (dired-goto-subdir file))
3531 (progn
3532 (select-window window)
3533 (dired-other-window file)))
3534 (select-window window)
3535 (find-file-other-window (file-name-sans-versions file t)))))
3521@end smallexample 3536@end smallexample
3522 3537
3523@noindent 3538@noindent
3524The reason for the outer @code{save-excursion} construct is to avoid 3539The reason for the @code{save-excursion} construct is to avoid
3525changing the current buffer; the reason for the inner one is to avoid 3540changing the current buffer. In this case,
3526permanently altering point in the buffer you click on. In this case, 3541Dired uses the functions @code{posn-window} and @code{posn-point}
3527Dired uses the function @code{dired-get-filename} to determine which 3542to determine which buffer the click happened in and where, and
3528file to visit, based on the position found in the event. 3543in that buffer, @code{dired-get-file-for-visit} to determine which
3544file to visit.
3529 3545
3530 Instead of defining a mouse command for the major mode, you can define 3546 Instead of defining a mouse command for the major mode, you can define
3531a key binding for the clickable text itself, using the @code{keymap} 3547a key binding for the clickable text itself, using the @code{keymap}