comparison lisp/wid-edit.el @ 65837:3a0debccbfea

(widget-file-complete): Get the widget start point the right way. Default directory to `/' if file has none.
author Richard M. Stallman <rms@gnu.org>
date Tue, 04 Oct 2005 20:31:13 +0000
parents ed770a0a7846
children fb90b962c3cb
comparison
equal deleted inserted replaced
65836:c502b2c18f47 65837:3a0debccbfea
2989 2989
2990 (defun widget-file-complete () 2990 (defun widget-file-complete ()
2991 "Perform completion on file name preceding point." 2991 "Perform completion on file name preceding point."
2992 (interactive) 2992 (interactive)
2993 (let* ((end (point)) 2993 (let* ((end (point))
2994 (beg (save-excursion 2994 (beg (widget-field-start widget))
2995 (skip-chars-backward "^ ")
2996 (point)))
2997 (pattern (buffer-substring beg end)) 2995 (pattern (buffer-substring beg end))
2998 (name-part (file-name-nondirectory pattern)) 2996 (name-part (file-name-nondirectory pattern))
2999 (directory (file-name-directory pattern)) 2997 ;; I think defaulting to root is right
2998 ;; because these really should be absolute file names.
2999 (directory (or (file-name-directory pattern) "/"))
3000 (completion (file-name-completion name-part directory))) 3000 (completion (file-name-completion name-part directory)))
3001 (cond ((eq completion t)) 3001 (cond ((eq completion t))
3002 ((null completion) 3002 ((null completion)
3003 (message "Can't find completion for \"%s\"" pattern) 3003 (message "Can't find completion for \"%s\"" pattern)
3004 (ding)) 3004 (ding))