all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path
@ 2022-12-02 12:47 Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-03 10:25 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-02 12:47 UTC (permalink / raw)
  To: 59795

[-- Attachment #1: Type: text/plain, Size: 3999 bytes --]

When launching emacs with --init-directory option set to a relative path, I noticed that locate-user-emacs-file refers to a relative path.
This means that every library that uses that function spawns files in visited directories instead that in the init-directory.

1) Open shell in home (~)

2) emacs -Q --init-directory .my-emacs.d
3) C-x C-f ~/other-directory RET

4) M-: (locate-user-emacs-file "some-file") RET

result: ~/other-directory/.my-emacs.d/some-file
expected: ~/.my-emacs.d/some-file

It happens both starting with -Q or not.
The problem does not happen when an absolute path is passed as --init-directory option argument.

Perhaps the user-emacs-directory should be parsed as absolute path at startup?

Thanks,
Tommaso

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2022-11-30 built on xubuntu-new
Repository revision: 26c2ebd0ddcea2c64715dbb33b21e04e4e3dc136
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.1 LTS

Configured using:
'configure --with-cairo --with-modules --with-gnutls
--with-native-compilation --with-json --with-harfbuzz
--with-imagemagick --with-jpeg --with-png --with-rsvg --with-tiff'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG JSON LCMS2 LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
value of $LC_MONETARY: it_IT.UTF-8
value of $LC_NUMERIC: it_IT.UTF-8
value of $LC_TIME: it_IT.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp comp-cstr
warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode
cl-loaddefs cl-lib bytecomp byte-compile rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 72312 10187)
(symbols 48 7132 0)
(strings 32 21167 3230)
(string-bytes 1 662685)
(vectors 16 17623)
(vector-slots 8 311090 14918)
(floats 8 39 37)
(intervals 56 224 0)
(buffers 984 11))

[-- Attachment #2: Type: text/html, Size: 8467 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path
  2022-12-02 12:47 bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-03 10:25 ` Eli Zaretskii
  2022-12-03 11:31   ` Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-03 10:25 UTC (permalink / raw)
  To: Tommaso Rossi; +Cc: 59795-done

> Date: Fri, 02 Dec 2022 12:47:43 +0000
> From:  Tommaso Rossi via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> When launching emacs with --init-directory option set to a relative path, I noticed that locate-user-emacs-file
> refers to a relative path.
> This means that every library that uses that function spawns files in visited directories instead that in the
> init-directory.
> 
> 1) Open shell in home (~)
> 2) emacs -Q --init-directory .my-emacs.d
> 3) C-x C-f ~/other-directory RET
> 4) M-: (locate-user-emacs-file "some-file") RET
> 
> result: ~/other-directory/.my-emacs.d/some-file
> expected: ~/.my-emacs.d/some-file
> 
> It happens both starting with -Q or not.
> The problem does not happen when an absolute path is passed as --init-directory option argument.
> 
> Perhaps the user-emacs-directory should be parsed as absolute path at startup?

I made --init-directory=DIR be interpreted relative to the directory where
Emacs is started.

Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path
  2022-12-03 10:25 ` Eli Zaretskii
@ 2022-12-03 11:31   ` Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-03 12:12     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-03 11:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 59795-done

Thanks for your reply.
I think I didn't explained the problem very well, sorry for my english.

It is right that the init directory is interpreted relative to the 
directory where Emacs is started, what feels a bit strange is that
when you change directory inside Emacs, the init directory becomes 
relative to the current directory for the function 
locate-user-emacs-file.  I realized that when I found folders 
named as my init directory spawned everywhere in my filesystem, for
example containing Transient (Magit) history or other files that should 
be in the real init directory.

In Emacs Lisp code, it becomes difficult to locate the real init 
directory, because the user-emacs-directory is not absolute: if some 
library or package uses the locate-user-emacs-file function, like 
Transient, than this "init directory spawned everywhere" problem will 
raise.

Thanks,
Tommaso


------- Original Message -------
On Saturday, December 3rd, 2022 at 11:25, Eli Zaretskii <eliz@gnu.org> wrote:


> > Date: Fri, 02 Dec 2022 12:47:43 +0000
> > From: Tommaso Rossi via "Bug reports for GNU Emacs,
> > the Swiss army knife of text editors" bug-gnu-emacs@gnu.org
> > 
> > When launching emacs with --init-directory option set to a relative path, I noticed that locate-user-emacs-file
> > refers to a relative path.
> > This means that every library that uses that function spawns files in visited directories instead that in the
> > init-directory.
> > 
> > 1) Open shell in home (~)
> > 2) emacs -Q --init-directory .my-emacs.d
> > 3) C-x C-f ~/other-directory RET
> > 4) M-: (locate-user-emacs-file "some-file") RET
> > 
> > result: ~/other-directory/.my-emacs.d/some-file
> > expected: ~/.my-emacs.d/some-file
> > 
> > It happens both starting with -Q or not.
> > The problem does not happen when an absolute path is passed as --init-directory option argument.
> > 
> > Perhaps the user-emacs-directory should be parsed as absolute path at startup?
> 
> 
> I made --init-directory=DIR be interpreted relative to the directory where
> Emacs is started.
> 
> Thanks.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path
  2022-12-03 11:31   ` Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-03 12:12     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-03 12:12 UTC (permalink / raw)
  To: Tommaso Rossi; +Cc: 59795

> Date: Sat, 03 Dec 2022 11:31:59 +0000
> From: Tommaso Rossi <tommaso.rossi1@protonmail.com>
> Cc: 59795-done@debbugs.gnu.org
> 
> Thanks for your reply.
> I think I didn't explained the problem very well, sorry for my english.

You have nothing to apologize about, I understood you completely.

> It is right that the init directory is interpreted relative to the 
> directory where Emacs is started, what feels a bit strange is that
> when you change directory inside Emacs, the init directory becomes 
> relative to the current directory for the function 
> locate-user-emacs-file.  I realized that when I found folders 
> named as my init directory spawned everywhere in my filesystem, for
> example containing Transient (Magit) history or other files that should 
> be in the real init directory.
> 
> In Emacs Lisp code, it becomes difficult to locate the real init 
> directory, because the user-emacs-directory is not absolute: if some 
> library or package uses the locate-user-emacs-file function, like 
> Transient, than this "init directory spawned everywhere" problem will 
> raise.

The latest code should produce an absolute file name in
user-emacs-directory, which I believe fixes the problem you described.  My
response just explained how will Emacs produce an absolute file name from a
relative one when it processes the --init-directory= option.

The fix is in the emacs-29 branch, soon to be merged to master, so you can
try the fix if you want.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-03 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 12:47 bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-03 10:25 ` Eli Zaretskii
2022-12-03 11:31   ` Tommaso Rossi via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-03 12:12     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.