all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 60628@debbugs.gnu.org
Subject: bug#60628: 29.0.60; apropos-documentation does not work for preloaded symbols
Date: Fri, 13 Jan 2023 15:10:02 -0500	[thread overview]
Message-ID: <jwvv8laryj9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvbkn2qxj7.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 13 Jan 2023 10:46:21 -0500")

> For `emacs-29` the better option is probably to just revert the
> above commit.

Then again, since \n#@ can also match false positives, we may as well
keep the above commit and just search for #@ instead.

The patch below should fix both problems in a kind of "minimalist" way
(i.e. meant for `emacs-29`).
Can someone confirm it also works for them while I clean it up?


        Stefan


diff --git a/lisp/apropos.el b/lisp/apropos.el
index b260d889955..b66f27b8a9e 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -913,8 +913,19 @@
           (apropos-sort-by-scores apropos-documentation-sort-by-scores)
           f v sf sv)
       (apropos-documentation-check-doc-file)
-      (if do-all
-          (mapatoms
+      (funcall
+       (if do-all #'mapatoms
+         (lambda (f)
+           (let ((preloaded-regexp
+                  (concat "\\`"
+                          (regexp-quote lisp-directory)
+                          (regexp-opt preloaded-file-list)
+                          "\\.elc?\\'")))
+             (dolist (x load-history)
+               (when (string-match preloaded-regexp (car x))
+                 (dolist (def (cdr x))
+                   (when (eq 'defun (car-safe def))
+                     (funcall f (cdr def)))))))))
            (lambda (symbol)
              (setq f (apropos-safe-documentation symbol)
                    v (get symbol 'variable-documentation))
@@ -939,7 +950,7 @@
                          (cons (list symbol
                                      (+ (apropos-score-symbol symbol 2) sf sv)
                                      f v)
-                               apropos-accumulator)))))))
+                           apropos-accumulator))))))
       (apropos-print nil "\n----------------\n" nil t))))
 
 \f
@@ -1064,10 +1064,12 @@
       (setq apropos-files-scanned (cons file apropos-files-scanned))
       (erase-buffer)
       (insert-file-contents file)
-      (while (search-forward "\n#@" nil t)
+      (while (search-forward "#@" nil t)
 	;; Read the comment length, and advance over it.
-	(setq end (read)
-	      beg (1+ (point))
+	;; This #@ may be a false positive, so don't get upset if
+	;; it's not followed by the expected number of bytes to skip.
+	(when (and (setq end (ignore-errors (read))) (natnump end))
+	  (setq beg (1+ (point))
 	      end (+ (point) end -1))
 	(forward-char)
 	(if (save-restriction
@@ -1110,7 +1112,7 @@
 					       'face apropos-match-face doc)))
 		      (setcar (nthcdr (if this-is-a-variable 3 2)
 				      apropos-item)
-			      doc))))))))))
+				doc)))))))))))
 
 
 






  reply	other threads:[~2023-01-13 20:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 13:20 bug#60628: 29.0.60; apropos-documentation does not work for preloaded symbols Eli Zaretskii
2023-01-12  9:36 ` Eli Zaretskii
2023-01-13 15:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-13 20:10   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-01-14  9:29     ` Eli Zaretskii
2023-01-14 14:27       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

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

  git send-email \
    --in-reply-to=jwvv8laryj9.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60628@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 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.