📜 ⬆️ ⬇️

Emacs In Practice

Problem



The problem is that the environment variables in Windows XP are limited to 1024 characters. For most users, this is not a problem, but for some, including myself, the problems started suddenly. The programs that I used before in the command line suddenly stopped being located. An Internet search suggested that the problem is most likely a limitation on the length of environment variables.

Let's try to fix it using Emacs.
')


Decision



Since Emacs is running, let's see what we have in the PATH variable



A lot of things. Moreover, many paths include the full directory name, for example, C: \ Program Files or C: \ Documents and Settings . Check the length



It is clear that it would be nice to shorten all this. Let's do it right from Emacs. In the Windows version there is a function w32-short-file-name , which is an interface to the Win32 API function and when called with a string containing the file path, returns the path in the so-called 8.3 format.

To begin with we will break our variable PATH into components.



Apply the w32-short-file-name function to each element of the list and collect the elements back into a string using ';' as a connector, using the mapconcat function.



Check the length of the resulting string.



Anyway, the resulting string is too long. But you can delete duplicate elements with delete-dups . We split the string back into elements, remove duplicates and assemble it back using mapconcat . This time would use the identity function, which returns the list item itself.



The length suits us perfectly and we can already use this string. Print it into a temporary buffer.



Go to the resulting window Cx o and copy the line Ca, Cs ", Ret, C-space, Cs", Ret, Mw





Open Computer Properties, go to the Advanced tab, then the Environment Variables, go to the system variables, scroll to the Path variable, and change its value to a new one.



Voila Programs in the command line work again.

Although the main thing, of course, is that Emacs works.

Source: https://habr.com/ru/post/102082/


All Articles