Avoid "auto" short paths

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Avoid "auto" short paths

Cesar Martins
Hi ,

I'm using vim 8.1.1 in windows 8 at my work , corporate environment.
Here we have the %HOMEPATH%, %HOMEDRIVE% set to "H:" and "\"

What happen:

I open a file at my Documents, path : C:\Users\cinacio\Documents\tmp1.txt
Vim automatically short it to : ~\Documents\tmp1.txt
  I can see that with ":ls" and "let v:oldfiles"

The problem is, I use mksession and since I have HOMEPATH, HOMEDRIVE set , when I reopen vim and try recover my session, they don't found the file because they replace "~" to %HOMEDRIVE%+%HOMEPATH% , not %USERPROFILE% looking for the file at H:\Documents\tmp1.txt

So, I want set some option to force the use of absolute path "c:\Users\cinacio" and not "~".

Is this possible?


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Bram Moolenaar

Cesar Martins wrote:

> I'm using vim 8.1.1 in windows 8 at my work , corporate environment.
> Here we have the %HOMEPATH%, %HOMEDRIVE% set to "H:" and "\"
>
> What happen:
>
> I open a file at my Documents, path : C:\Users\cinacio\Documents\tmp1.txt
> Vim automatically short it to : ~\Documents\tmp1.txt
>   I can see that with ":ls" and "let v:oldfiles"
>
> The problem is, I use mksession and since I have HOMEPATH, HOMEDRIVE
> set , when I reopen vim and try recover my session, they don't found
> the file because they replace "~" to %HOMEDRIVE%+%HOMEPATH% , not
> %USERPROFILE% looking for the file at H:\Documents\tmp1.txt
>
> So, I want set some option to force the use of absolute path
> "c:\Users\cinacio" and not "~".
>
> Is this possible?

Why is there a difference in home directory?  Vim should get it right in
both cases, when storing and when reading the session.  Since you say
that the session stores "~\Documents\tmp1.txt" that looks correct, so
why is it different when you recover the session?

--
An indication you must be a manager:
You can explain to somebody the difference between "re-engineering",
"down-sizing", "right-sizing", and "firing people's asses".

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Cesar Martins
Hi Bram, 

This is the company environment, is very common users have they own disk areas at the network of the company, which usually is a drive mapping and set at HOMEDRIVE and HOMEPATH. 

When I open the file , at %USERPROFILE% which is my local drive , vim internally change the path references from c:\Users\cinacio (%USERPROFILE%) to "~" .
But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use it.

I know I can force my HOME setting %HOME%=%USERPROFILE% at windows environment.
But I have others programs at my desktop and I don't know how this can affect them, so I would to avoid set the %HOME%

That's why I would force vim works always with absolute path.

Quote from the help :

 |   $HOME
 | Using "~" is like using "$HOME", but it is only recognized at the start of an
 | option and after a space or comma.
 | 
 | On Unix systems "~user" can be used too.  It is replaced by the home directory
 | of user "user".  Example:
 |     :set path=~mool/include,/usr/include,.
 | 
 | On Unix systems the form "${HOME}" can be used too.  The name between {} can
 | contain non-id characters then.  Note that if you want to use this for the
 | "gf" command, you need to add the '{' and '}' characters to 'isfname'.
 | 
 | On MS-Windows, if $HOME is not defined as an environment variable, then
 | at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
 | 
 | NOTE: expanding environment variables and "~/" is only done with the ":set"
 | command, not when assigning a value to an option with ":let".
 | 
 | 
 | Note the maximum length of an expanded option is limited.  How much depends on
 | the system, mostly it is something like 256 or 1024 characters.



 | *$HOME-windows*
 | On MS-Windows, if $HOME is not defined as an environment variable, then
 | at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
 | If $HOMEDRIVE is not set then $USERPROFILE is used.
 | 
 | This expanded value is not exported to the environment, this matters when
 | running an external command: >
 | :echo system('set | findstr ^HOME=')
 | and >
 | :echo luaeval('os.getenv("HOME")')
 | should echo nothing (an empty string) despite exists('$HOME') being true.
 | When setting $HOME to a non-empty string it will be exported to the
 | subprocesses.
 | 
 | 
 | Note the maximum length of an expanded option is limited.  How much depends on
 | the system, mostly it is something like 256 or 1024 characters.


Em qui, 9 de ago de 2018 às 15:45, Bram Moolenaar <[hidden email]> escreveu:

Cesar Martins wrote:

> I'm using vim 8.1.1 in windows 8 at my work , corporate environment.
> Here we have the %HOMEPATH%, %HOMEDRIVE% set to "H:" and "\"
>
> What happen:
>
> I open a file at my Documents, path : C:\Users\cinacio\Documents\tmp1.txt
> Vim automatically short it to : ~\Documents\tmp1.txt
>   I can see that with ":ls" and "let v:oldfiles"
>
> The problem is, I use mksession and since I have HOMEPATH, HOMEDRIVE
> set , when I reopen vim and try recover my session, they don't found
> the file because they replace "~" to %HOMEDRIVE%+%HOMEPATH% , not
> %USERPROFILE% looking for the file at H:\Documents\tmp1.txt
>
> So, I want set some option to force the use of absolute path
> "c:\Users\cinacio" and not "~".
>
> Is this possible?

Why is there a difference in home directory?  Vim should get it right in
both cases, when storing and when reading the session.  Since you say
that the session stores "~\Documents\tmp1.txt" that looks correct, so
why is it different when you recover the session?

--
An indication you must be a manager:
You can explain to somebody the difference between "re-engineering",
"down-sizing", "right-sizing", and "firing people's asses".

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Bram Moolenaar

> This is the company environment, is very common users have they own disk
> areas at the network of the company, which usually is a drive mapping and
> set at HOMEDRIVE and HOMEPATH.

So HOMEDRIVE and HOMEPATH are always set?  Then these should be used,
they are checked before USERPROFILE.

> When I open the file , at %USERPROFILE% which is my local drive , vim
> internally change the path references from c:\Users\cinacio (%USERPROFILE%)
> to "~" .
> But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use it.
>
> I know I can force my HOME setting %HOME%=3D%USERPROFILE% at windows
> environment.
> But I have others programs at my desktop and I don't know how this can
> affect them, so I would to avoid set the %HOME%
>
> That's why I would force vim works always with absolute path.

When HOMEDRIVE and HOMEPATH are set, then USERPROFILE should not be
used.  Are you saying that HOMEDRIVE and HOMEPATH are sometimes not set?
That effectively means your home directory moves around, so it's
expected that Vim doesn't handle that.

Using an absolute path has the opposite effect: If your home directory
is on a dynamically mounted drive, the drive letter can change while
it's still the same directory.  Then using "~/" is actually avoiding
problems.  Thus we can't use the full path as a default.

I think having to set $HOME is acceptable.


--
   Arthur pulls Pin out.  The MONK blesses the grenade as ...
ARTHUR:  (quietly) One, two, five ...
GALAHAD: Three, sir!
ARTHUR:  Three.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Cesar Martins
Em qui, 9 de ago de 2018 às 17:09, Bram Moolenaar <[hidden email]> escreveu:

> This is the company environment, is very common users have they own disk
> areas at the network of the company, which usually is a drive mapping and
> set at HOMEDRIVE and HOMEPATH.

So HOMEDRIVE and HOMEPATH are always set?  Then these should be used,
they are checked before USERPROFILE.

Yes , they are always set. 
 
> When I open the file , at %USERPROFILE% which is my local drive , vim
> internally change the path references from c:\Users\cinacio (%USERPROFILE%)
> to "~" .
> But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use it.
>
> I know I can force my HOME setting %HOME%=3D%USERPROFILE% at windows
> environment.
> But I have others programs at my desktop and I don't know how this can
> affect them, so I would to avoid set the %HOME%
>
> That's why I would force vim works always with absolute path.

When HOMEDRIVE and HOMEPATH are set, then USERPROFILE should not be
used.  Are you saying that HOMEDRIVE and HOMEPATH are sometimes not set?
That effectively means your home directory moves around, so it's
expected that Vim doesn't handle that.

As mentioned before , the HOMEPATH and HOMEDRIVE is always set. 
My home directory don't move around. 
I'm not obligated for the company to save everything at the network home dir. 
So , I have a lot of documents and files at my regular documents (USERPROFILE/Documents)
But vim get lost when I open a document on it.
 
Using an absolute path has the opposite effect: If your home directory
is on a dynamically mounted drive, the drive letter can change while
it's still the same directory.  Then using "~/" is actually avoiding
problems.  Thus we can't use the full path as a default.

Is not this situation.
 
I think having to set $HOME is acceptable.

I tried , but this mess configuration from few applications like cygwin and I use it a lot. 


--
   Arthur pulls Pin out.  The MONK blesses the grenade as ...
ARTHUR:  (quietly) One, two, five ...
GALAHAD: Three, sir!
ARTHUR:  Three.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Gary Johnson-4
On 2018-08-09, Cesar Martins wrote:

> Em qui, 9 de ago de 2018 às 17:09, Bram Moolenaar escreveu:
>
>
>     > This is the company environment, is very common users have they own disk
>     > areas at the network of the company, which usually is a drive mapping and
>     > set at HOMEDRIVE and HOMEPATH.
>
>     So HOMEDRIVE and HOMEPATH are always set?  Then these should be used,
>     they are checked before USERPROFILE.
>
>
> Yes , they are always set. 
>  
>
>     > When I open the file , at %USERPROFILE% which is my local drive , vim
>     > internally change the path references from c:\Users\cinacio
>     (%USERPROFILE%)
>     > to "~" .
>     > But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use
>     it.
>     >
>     > I know I can force my HOME setting %HOME%=3D%USERPROFILE% at windows
>     > environment.
>     > But I have others programs at my desktop and I don't know how this can
>     > affect them, so I would to avoid set the %HOME%
>     >
>     > That's why I would force vim works always with absolute path.
>
>     When HOMEDRIVE and HOMEPATH are set, then USERPROFILE should not be
>     used.  Are you saying that HOMEDRIVE and HOMEPATH are sometimes not set?
>     That effectively means your home directory moves around, so it's
>     expected that Vim doesn't handle that.
>
>
> As mentioned before , the HOMEPATH and HOMEDRIVE is always set. 
> My home directory don't move around. 
> I'm not obligated for the company to save everything at the network home dir. 
> So , I have a lot of documents and files at my regular documents (USERPROFILE/
> Documents)
> But vim get lost when I open a document on it.
>  
>
>     Using an absolute path has the opposite effect: If your home directory
>     is on a dynamically mounted drive, the drive letter can change while
>     it's still the same directory.  Then using "~/" is actually avoiding
>     problems.  Thus we can't use the full path as a default.
>
>
> Is not this situation.
>  
>
>     I think having to set $HOME is acceptable.
>
>
> I tried , but this mess configuration from few applications like cygwin and I
> use it a lot. 

I'm in the same kind of corporate Windows environment and I can
replicate your results.

When %HOMEDRIVE%, %HOMEPATH% and %USERPROFILE% are all defined in
the environment, and %HOME% is not, I don't think I particularly
care whether Vim synthesizes %HOME% from %HOMEDRIVE% and %HOMEPATH%
or from %USERPROFILE%, but I do think it should be consistent.  When
Vim is started, it should look at %HOMEDRIVE%, %HOMEPATH%,
%USERPROFILE% and %HOME%, and if %HOME% is not defined, set it
according to some algorithm and leave it alone.  It appears that Vim
is instead creating %HOME% differently for different purposes.
That's not good.

For the record, the environment of my cmd.exe includes:

    HOMEDRIVE=G:
    HOMEPATH=\
    USERPROFILE=C:\Users\gary

but no HOME.  From the Start menu, Windows runs cmd.exe in my
%USERPROFILE% directory.

I first run gvim like this:

    "C:\Program Files (x86)\vim\vim81\gvim.exe" -N -u NONE Documents\tmp3.txt

Vim's title bar says:

    tmp3.txt (~\Documents) - GVIM

I enter some text in the file, then

    :w
    :mksession
    :q

Then I run gvim like this:

    "C:\Program Files (x86)\vim\vim81\gvim.exe" -N -u NONE -S

Vim's title bar says:

    tmp3.txt (G:\Documents) - GVIM

The status line says:

    "Documents\tmp3.txt" [New File]

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Avoid "auto" short paths

Ken Takata-2
In reply to this post by Bram Moolenaar
Hi,

2018/8/10 Fri 5:09:25 UTC+9 Bram Moolenaar wrote:

> > This is the company environment, is very common users have they own disk
> > areas at the network of the company, which usually is a drive mapping and
> > set at HOMEDRIVE and HOMEPATH.
>
> So HOMEDRIVE and HOMEPATH are always set?  Then these should be used,
> they are checked before USERPROFILE.
>
> > When I open the file , at %USERPROFILE% which is my local drive , vim
> > internally change the path references from c:\Users\cinacio (%USERPROFILE%)
> > to "~" .
> > But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use it.
> >
> > I know I can force my HOME setting %HOME%=3D%USERPROFILE% at windows
> > environment.
> > But I have others programs at my desktop and I don't know how this can
> > affect them, so I would to avoid set the %HOME%
> >
> > That's why I would force vim works always with absolute path.
>
> When HOMEDRIVE and HOMEPATH are set, then USERPROFILE should not be
> used.  Are you saying that HOMEDRIVE and HOMEPATH are sometimes not set?
> That effectively means your home directory moves around, so it's
> expected that Vim doesn't handle that.
>
> Using an absolute path has the opposite effect: If your home directory
> is on a dynamically mounted drive, the drive letter can change while
> it's still the same directory.  Then using "~/" is actually avoiding
> problems.  Thus we can't use the full path as a default.
>
> I think having to set $HOME is acceptable.
I found inconsistency in misc1.c.

init_homedir() initialises the static variable homedir by checking the
following environment variables:

1. HOME
2. HOMEDRIVE + HOMEPATH
3. USERPROFILE

And vim_getenv("HOME") returns a value with the homedir variable.
However home_replace() uses mch_getenv("HOME") and it doesn't uses
vim_getenv("HOME") nor homedir.

Maybe home_replace() should use homedir instead of mch_getenv("HOME")?

Regards,
Ken Takata

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.