nonsequitur / git-gutter-plus

146 stars 17 forks source link

BUG: `tramp-dissect-file-name' apparently used to return an array #39

Open KarlHegbloom opened 6 years ago

KarlHegbloom commented 6 years ago

... but now it returns an object of type tramp-file-name', which is a cl-structure-class'.

marienz commented 6 years ago

Thanks for sending a PR for this (I just ran into this issue myself).

Note that the tramp-file-name-* functions you're now calling if you don't get an array aren't new in Emacs 26. They were introduced in 2010 (see https://github.com/emacs-mirror/emacs/commit/0f34aa7719df0621663d41defa5deaf79004c52c), implemented using aref up until now. So I think you don't need to check if you got a vector and keep the old code for those: just always use those helpers.

yangsheng6810 commented 6 years ago

I ran into the same bug, and here is my workaround (it also adds the missing support for non-default port):

(defun git-gutter+-remote-default-directory (dir file)
  (let* ((vec (tramp-dissect-file-name file))
          (method (tramp-file-name-method vec))
          (user (tramp-file-name-user vec))
          (domain (tramp-file-name-domain vec))
          (host (tramp-file-name-host vec))
          (port (tramp-file-name-port vec)))
     (tramp-make-tramp-file-name method user domain host port dir)))

(defun git-gutter+-remote-file-path (dir file)
  (let ((file (tramp-file-name-localname (tramp-dissect-file-name file))))
    (replace-regexp-in-string (concat "\\`" dir) "" file)))
coroa commented 5 years ago

Can @yangsheng6810 's or @KarlHegbloom solution be merged into the package? What's holding it back?

It'd be nice if magit-gutter-plus worked with TRAMP off-the-shelf.

beyondpie commented 5 years ago

@yangsheng6810
The same issue for me. After adding your codes, it works now. Thanks a lot!

Could you please merge it into the package?

yangsheng6810 commented 5 years ago

@beyondpie I am not the owner of this repo so I do not have the permission. I will submit a PR with my workaround though, after checking backward compatibility with older versions of Emacs

yangsheng6810 commented 5 years ago

@beyondpie PR submitted.