emacs-pretest-bug
[Top][All Lists]
Advanced

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

completing include files with complete.el not working (and also a read-f


From: Dan Nicolaescu
Subject: completing include files with complete.el not working (and also a read-file-name-function issue)
Date: Mon, 08 May 2006 11:36:58 -0700

Do emacs -q
M-x partial-completion-mode RET
C-x C-f <sys/ TAB

this will print "No Match"

in emacs-21.4 it used to give as completions the files in /usr/include/sys/

The code that implements this completion is a defadvice in complete.el:
(defadvice read-file-name-internal (around PC-include-file disable)
....

Unfortunately I could not figure out what is wrong...


Next I tried replacing that defadvice with a function that uses 
`read-file-name-function' (which is new in emacs-22).

I commented out the defadvice in complete.el and replaced it with this code:



(setq read-file-name-function 'read-file-name-mytest)

(defun read-file-name-mytest (prompt &optional dir default-filename
                                              mustmatch initial
                                              predicate)

  (if (string-match "<\\([^\"<>]*\\)>?\\'" prompt)
      (let* ((string prompt)
             (action mustmatch) ;(ad-get-arg 2))
             (name (substring string (match-beginning 1) (match-end
      1)))
           (str2 (substring string (match-beginning 0)))
                (completion-table
                      (mapcar (lambda (x) (format "<%s>" x))
                                    (PC-include-file-all-completions
                                               name
      (PC-include-file-path)))))
        (setq ad-return-value-2
              (cond
               ((not completion-table) nil)
               ((eq action 'lambda) (test-completion str2
      completion-table nil))
               ((eq action nil) (try-completion str2 completion-table
      nil))
               ((eq action t) (all-completions str2 completion-table
      nil)))))
    (let ((read-file-name-function nil))
      (read-file-name prompt dir default-filename mustmatch initial
      predicate)))  


which tries to do the same thing as the original defadvice. But this
does not work as the `read-file-name-mytest' function is not called
when needed. 

Looking at the code in fileio.c:Fread_file_name I am not sure I
understand how `read-file-name-function' is supposed to be used. :-(

Can somebody please look over this? 

Thanks

        --dan






reply via email to

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