Subject: Re: bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, not files)

From: Stefan Monnier <[email-masked]>
Date: Sun, 05 Dec 2021 18:13:56 -0500

> +    (with-current-buffer (window-buffer)
> +      (when (let* ((pos (posn-point (event-end click)))
> +                   (char (when pos (char-after pos))))
> +              (or (and char (eq (char-syntax char) ?\"))
> +                  (nth 3 (save-excursion (syntax-ppss pos)))))
> +        (define-key-after submenu [mark-string]
> +          `(menu-item "String"
> +                      ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'string))
> +                      :help "Mark the string at click for a subsequent cut/copy"))))

I think it would be more "obviously correct" if we switched to
(window-buffer (posn-window (event-end click))) instead.

>    ;; Include text-mode select menu only in strings and comments.
> -  (when (nth 8 (save-excursion (syntax-ppss (posn-point (event-end click)))))
> +  (when (nth 8 (save-excursion
> +                 (with-current-buffer (window-buffer)
> +                   (syntax-ppss (posn-point (event-end click))))))

Same here.

> An alternative is the patch that I proposed earlier:
>
> diff --git a/lisp/help-fns.el b/lisp/help-fns.el
> index 2c7956d968..85f305617d 100644
> --- a/lisp/help-fns.el
> +++ b/lisp/help-fns.el
> @@ -1898,6 +1898,8 @@ help-fns--list-local-commands
>      (mapatoms
>       (lambda (sym)
>         (when (and (commandp sym)
> +                  ;; Ignore 'ignore'.
> +                  (not (eq sym 'ignore))
>                    ;; Ignore aliases.
>                    (not (symbolp (symbol-function sym)))
>                    ;; Ignore everything bound.

I'm not sure what to think of this because I don't understand
its motivation.  IOW at the very least it should come with a comment
explaining why we need to ignore `ignore`.

        Stefan