Show
Ignore:
Timestamp:
08/10/06 11:19:54 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lispref/text.texi

    r4131 r4140  
    34813481 
    34823482  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) 
    34843484to make a mouse button do something when you click on that text. 
    34853485 
    3486   For highlighting, use the @code{mouse-face} text property.  Here is 
    3487 an example of how Dired does it: 
     3486  Indicating clickability usually involves highlighting the text, and 
     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: 
    34883492 
    34893493@smallexample 
    34903494(condition-case nil 
    34913495    (if (dired-move-to-filename) 
    3492         (put-text-property (point) 
    3493                            (save-excursion 
    3494                              (dired-move-to-end-of-filename) 
    3495                              (point)) 
    3496                            'mouse-face 'highlight)) 
     3496        (add-text-properties 
     3497         (point) 
     3498         (save-excursion 
     3499           (dired-move-to-end-of-filename) 
     3500           (point)) 
     3501         '(mouse-face highlight 
     3502           help-echo "mouse-2: visit this file in other window"))) 
    34973503  (error nil)) 
    34983504@end smallexample 
    34993505 
    35003506@noindent 
    3501 The first two arguments to @code{put-text-property} specify the 
     3507The first two arguments to @code{add-text-properties} specify the 
    35023508beginning and end of the text. 
    35033509 
     
    35093515@smallexample 
    35103516(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." 
    35123518  (interactive "e") 
    3513   (let (file) 
     3519  (let (window pos file) 
    35143520    (save-excursion 
    3515       (set-buffer (window-buffer (posn-window (event-end event)))) 
    3516       (save-excursion 
    3517         (goto-char (posn-point (event-end event))) 
    3518         (setq file (dired-get-filename)))) 
    3519     (select-window (posn-window (event-end event))) 
    3520     (find-file-other-window (file-name-sans-versions file t)))) 
     3521      (setq window (posn-window (event-end event)) 
     3522            pos (posn-point (event-end event))) 
     3523      (if (not (windowp window)) 
     3524          (error "No file chosen")) 
     3525      (set-buffer (window-buffer window)) 
     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))))) 
    35213536@end smallexample 
    35223537 
    35233538@noindent 
    3524 The reason for the outer @code{save-excursion} construct is to avoid 
    3525 changing the current buffer; the reason for the inner one is to avoid 
    3526 permanently altering point in the buffer you click on.  In this case, 
    3527 Dired uses the function @code{dired-get-filename} to determine which 
    3528 file to visit, based on the position found in the event. 
     3539The reason for the @code{save-excursion} construct is to avoid 
     3540changing the current buffer.  In this case, 
     3541Dired uses the functions @code{posn-window} and @code{posn-point} 
     3542to determine which buffer the click happened in and where, and 
     3543in that buffer, @code{dired-get-file-for-visit} to determine which 
     3544file to visit. 
    35293545 
    35303546  Instead of defining a mouse command for the major mode, you can define 
     
    36983714 
    36993715  In all of these functions, if @var{pos} is omitted or @code{nil}, the 
    3700 value of point is used by default. 
     3716value of point is used by default.  If narrowing is in effect, then 
     3717@var{pos} should fall within the accessible portion.  @xref{Narrowing}. 
    37013718 
    37023719@defun field-beginning &optional pos escape-from-edge limit