help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the TAB key for filename completion


From: Kevin Rodgers
Subject: Re: Getting the TAB key for filename completion
Date: Tue, 19 Aug 2008 23:21:43 -0600
User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707)

Davin Pearson wrote:
I have installed hippie-expand inside my Emacs.  Specifically I have
installed the following command:

(fset 'my-complete-file (make-hippie-expand-function
                         '(try-complete-file-name-partially
                           try-complete-file-name)))



My trouble is that I cannot bind this command to the TAB key when you
enter the command M-x compile RET.  Could someone please advise me how
to get file name completion with the TAB key online?

`M-x compile' reads its COMMAND argument by calling read-from-minibuffer
with a nil KEYMAP argument, which defaults to minibuffer-local-map:

(define-key minibuffer-local-map "\t" 'my-complete-file); or (kbd "TAB")

The tricky part would be trying to restrict that binding to `M-x compile'.
I think it'd be easier to define a new command:

(defun my-compile ()
  "Run `\\[compile]' with TAB temporarily bound to `my-complete-file'."
  (interactive)
  (let ((tab-command (lookup-key minibuffer-local-map "\t")))
    (define-key minibuffer-local-map "\t" 'my-complete-file)
    (unwind-protect
        (call-interactively 'compile)
      (define-key minibuffer-local-map "\t" tab-command))))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

[Prev in Thread] Current Thread [Next in Thread]