emacs-devel
[Top][All Lists]
Advanced

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

Re: INSIDE_EMACS and Tramp


From: Michael Albinus
Subject: Re: INSIDE_EMACS and Tramp
Date: Mon, 13 Apr 2020 11:07:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Federico Tedin <address@hidden> writes:

Hi Federico,

> Aah OK, so then this mechanism for generating the value for INSIDE_EMACS
> needs to be more general. How about something like:
>
> (defvar inside-emacs-extras nil)
>
> (defun inside-emacs (&optional context)
>   (mapconcat #'identity `(,emacs-version
>                         ,@(when context (list context))
>                         ,@inside-emacs-extras)
>            ","))
>
> So in Eshell we would call (inside-emacs "eshell"), and Tramp could
> optionally add "tramp:2.5.0-pre" to inside-emacs-extras sometime before
> the function is called. Other parts of Emacs could add extras as well
> (and at some point remove them, I suppose). Do you think something like
> this would make sense given how Tramp works internally?

I don't believe a global variable would fly. In Eshell, for example,
this variable must be changed whenever the default-directory is changed
(being a local or a remote file name). Tramp is not involved, when you
change the default-directory.

Instead, there might be a hook which is called whenever your
inside-emacs function is applied. Something like this:

--8<---------------cut here---------------start------------->8---
(defvar inside-emacs-hook nil)

(defun inside-emacs (&optional context)
  (mapconcat
   #'identity
   (delq nil `(,emacs-version
               ,@(when (stringp context) (list context))
               ,(run-hook 'inside-emacs-hook)))
   ","))

(add-hook
 'inside-emacs-hook
 (lambda ()
   (when (file-remote-p default-directory) '("tramp:2.5.0-pre"))))
--8<---------------cut here---------------end--------------->8---

The add-hook call would be implemented in Tramp itself.

Best regards, Michael.



reply via email to

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