tramp-devel
[Top][All Lists]
Advanced

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

Re: Find-file at point cannot manage tramp file syntax


From: Michael Albinus
Subject: Re: Find-file at point cannot manage tramp file syntax
Date: Fri, 07 Sep 2012 08:51:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Michael Albinus <address@hidden> writes:

Hi Stéphane

>> First and second syntax (i.e. abosulte pathname and tilde prefix) do
>> not work well, as shown in the mini-buffer : they seem to generate a
>> search on the local machine
>> Third syntax (relative path) works well
>
> Thanks, now I've got it.
>
> In fact, it is not an error. ffap offers you what it gets: opening an
> absolute file name in the first two cases. The reason that it works with
> relative file names, is a collateral damage: It uses `expand-file-name'
> towards the default directory, which is remote.
>
>> This does not occur with the ftp method, but occurs also with the ssh
>> method
>
> Reading the code of ffap.el, there is some special handling for
> ange-ftp. This explains, why it works for that method.

I've extended this special handling to remote file names in general. The
rules are now for an absolute file name w/o Tramp file name syntax:

- If that file exists on the local machine, it is offered as such.

- If default-directory is remote, and the file exists on the remote
  machine, it is offered in Tramp file name syntax.

- Otherwise, "/" is offered.

Could you, please, check the patch whether it works for you?

--8<---------------cut here---------------start------------->8---
*** ~/src/emacs/lisp/ffap.el.~109871~   2012-09-07 08:40:40.662026727 +0200
--- ~/src/emacs/lisp/ffap.el    2012-09-07 08:39:26.876763148 +0200
***************
*** 482,499 ****

  (defun ffap-replace-file-component (fullname name)
    "In remote FULLNAME, replace path with NAME.  May return nil."
!   ;; Use ange-ftp or efs if loaded, but do not load them otherwise.
!   (let (found)
!     (mapc
!      (function (lambda (sym) (and (fboundp sym) (setq found sym))))
!      '(
!        efs-replace-path-component
!        ange-ftp-replace-path-component
!        ange-ftp-replace-name-component
!        ))
!     (and found
!        (fset 'ffap-replace-file-component found)
!        (funcall found fullname name))))
  ;; (ffap-replace-file-component "/address@hidden:/whatever" "/new")

  (defun ffap-file-suffix (file)
--- 482,493 ----

  (defun ffap-replace-file-component (fullname name)
    "In remote FULLNAME, replace path with NAME.  May return nil."
!   ;; Use efs if loaded, but do not load it otherwise.
!   (if (fboundp 'efs-replace-path-component)
!       (funcall efs-replace-path-component fullname name)
!     (and (stringp fullname)
!        (stringp name)
!        (concat (file-remote-p fullname) name))))
  ;; (ffap-replace-file-component "/address@hidden:/whatever" "/new")

  (defun ffap-file-suffix (file)
--8<---------------cut here---------------end--------------->8---

>> Thanks for your help

Best regards, Michael.



reply via email to

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