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

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

bug#31357: 26.1; tramp-make-tramp-file-name: incompatible lisp changes i


From: Michael Albinus
Subject: bug#31357: 26.1; tramp-make-tramp-file-name: incompatible lisp changes in 26.1 ?
Date: Thu, 03 May 2018 17:26:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Phil Sainty <psainty@orcon.net.nz> writes:

Hi Phil,

> In Emacs 25 `tramp-make-tramp-file-name' takes 4-5 arguments:
> (method user host localname &optional hop)
>
> In Emacs 26.1 it takes 6-7
> (method user domain host port localname &optional hop)
>
> That can then trigger a "wrong-number-of-arguments" error.
>
> This should surely be covered in NEWS under the "Incompatible Lisp
> Changes in Emacs 26.1" section?

`tramp-make-tramp-file-name' has never been documented as public
function, it is intended for internal use. Granted, this should have
been signalled better.

> I have custom code where I am presently using the following construct
> to deal with this.
>
> (if (version< emacs-version "26")
>     (tramp-make-tramp-file-name
>      method user host localname hop)
>   (tramp-make-tramp-file-name
>    method user domain host port localname hop))
>
> (With a consequential complaint from the 26.1 byte-compiler about
> the first of those two calls.)

That's the way to go. You could use (funcall 'tramp-make-tramp-file-name ...)
in order to make the byte compiler quiet.

However, I wouldn't check for emacs-version. Tramp exist as separate
package, and the recent Tramp 2.4 runs with all Emacs 24, 25, 26 and
27. You might check for tramp-version.

> Is there a single approach which is backwards-compatible (at least with
> Emacs 25) ?

No.

> For my specific use-case, what I really wanted was a way to modify only
> a specific named component of a tramp file name, but I ended up using
> `tramp-dissect-file-name', extracting the components with the various
> `tramp-file-name-COMPONENT' functions, and using `tramp-make-file-name'
> to put it all back together.  I thought there might be a simpler way to
> do this, but I didn't see one.

Well, with Emacs 27 (Tramp 2.4) the function's signature has changed,
again. It is now (&rest ARGS). This is backwards compatible to Tramp 2.3
/ Emacs 26, that means (METHOD USER DOMAIN HOST PORT LOCALNAME &optional
HOP) still works. More interesting is the new signature, (VEC &optional
LOCALNAME HOP). Usually, you retrieve VEC by tramp-dissect-file-name, or
it is already provided as argument (many Tramp functions do so).

Then, most of the cases you want to change only the LOCALNAME, which you
could do directly in the function call. If you want to change another
component of VEC, you could do this via the access functions for the
tramp-file-name structure VEC, like

(setf (tramp-file-name-host vec) "whatever")
(tramp-make-tramp-file-name vec "/remote/dir")

So yes, if you want to support several Tramp versions, you must write
compatibility functions.

> -Phil

Best regards, Michael.





reply via email to

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