unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Troy Brown <brownts@troybrown.dev>
Cc: 64143@debbugs.gnu.org
Subject: bug#64143: 29.0.60; find-function-search-for-symbol truncates library path
Date: Sun, 18 Jun 2023 10:54:38 +0300	[thread overview]
Message-ID: <835y7lp5mp.fsf@gnu.org> (raw)
In-Reply-To: <CABvCZ41hp06Fw1358MwEMp9fP5a4pfp-zhecwrDASOMhXSSWeQ@mail.gmail.com> (message from Troy Brown on Sun, 18 Jun 2023 00:45:12 -0400)

> From: Troy Brown <brownts@troybrown.dev>
> Date: Sun, 18 Jun 2023 00:45:12 -0400
> 
> When user-emacs-directory contains "emacs.el" in it's path (e.g.,
> "~/.emacs.elpa"), which is much easier these days with the availability
> of --init-directory, the find-function-search-for-symbol truncates the
> library path after "emacs".

What do you mean by "truncates the library path"?  Do you mean
truncation of the file name 'emacs.el' to yield just 'emacs'? or do
you mean something else?  (To avoid confusion, please don't use "path"
to refer to file names, only to refer to lists of directories in the
style of PATH or load-path.)

> I was experimenting with a different user directory (i.e.,
> "--init-directory=~/.emacs.elpa") and was surprised to find out that the
> Help system was breaking when using this path.  When looking up a symbol
> in the Help system (e.g., "C-h f company-mode RET") and then attempting
> to visit the source file from the help window (i.e., help-view-source),
> if the symbol belongs to an installed package (where the source is
> under the "elpa" directory beneath user-emacs-directory), it will
> generate the following error message:
> 
>   Can't find library: /home/troy/.emacs

This says it cannot find ".emacs", not "emacs".  So is your init file
called ".emacs.el" or (as you mentioned above) "emacs.el"?

> Toggling "debug-on-error" and repeating the above, I can generate a
> backtrace for this as follows:
> 
> Debugger entered--Lisp error: (file-error "Can't find library"
> "/home/troy/.emacs")
>   find-library-name("/home/troy/.emacs")
>   #<subr find-function-search-for-symbol>(company-mode nil
> "/home/troy/.emacs.elpa/elpa/company-20230416.2034/company.el")
>   ad-Advice-find-function-search-for-symbol(#<subr
> find-function-search-for-symbol> company-mode nil
> "/home/troy/.emacs.elpa/elpa/company-20230416.2034/company.el")
>   apply(ad-Advice-find-function-search-for-symbol #<subr
> find-function-search-for-symbol> (company-mode nil
> "/home/troy/.emacs.elpa/elpa/company-20230416.2034/company.el"))
>   find-function-search-for-symbol(company-mode nil
> "/home/troy/.emacs.elpa/elpa/company-20230416.2034/company.el")
>   help-function-def--button-function(company-mode
> "/home/troy/.emacs.elpa/elpa/company-20230416.2034/company.el" nil)
>   help-view-source()
>   funcall-interactively(help-view-source)
>   call-interactively(help-view-source nil nil)
>   command-execute(help-view-source)
> 
> I believe the following snippet of code in
> find-function-search-for-symbol is to blame for this:
> 
>     (when (string-match "\\.emacs\\(.el\\)" library)
>       (setq library (substring library 0 (match-beginning 1))))
> 
> The regex likely should be improved to only match .emacs or .emacs.el at
> the end of the path, not in the middle of it.

Does the patch below fix this problem?

Also, I see that you have some advice installed for
find-function-search-for-symbol.  Would you please verify that
removing that advice still produces the problem in Emacs 29?

diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index f9f919a..bf890fc 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -407,7 +407,7 @@ find-function-search-for-symbol
       (setq library (substring library 0 (match-beginning 1))))
     ;; Strip extension from .emacs.el to make sure symbol is searched in
     ;; .emacs too.
-    (when (string-match "\\.emacs\\(.el\\)" library)
+    (when (string-match "\\.emacs\\(.el\\)\\'" library)
       (setq library (substring library 0 (match-beginning 1))))
     (let* ((filename (find-library-name library))
 	   (regexp-symbol (cdr (assq type find-function-regexp-alist))))





  reply	other threads:[~2023-06-18  7:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-18  4:45 bug#64143: 29.0.60; find-function-search-for-symbol truncates library path Troy Brown
2023-06-18  7:54 ` Eli Zaretskii [this message]
2023-06-18 17:39   ` Troy Brown
2023-06-20 13:36     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=835y7lp5mp.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=64143@debbugs.gnu.org \
    --cc=brownts@troybrown.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).