Subject: bug#52973: Adding a few context-menu-mode commands

From: Juri Linkov <[email-masked]>
Date: Mon, 03 Jan 2022 23:12:53 +0200

> I am attaching a few patches adding a few features for
> context-menu-mode, that I mentioned and explained here:
> https://ruzkuku.com/texts/emacs-mouse.html.
>
> Would it be OK to add these to Emacs itself?

Thanks, it would be beneficial to enrich the packages with the
context-menus.  Man-context-menu is a good addition to the package
man.el, and hi-lock-context-menu to hi-lock.el.  However,
mouse-online-search-at-point looks out of place in mouse.el.
Since it relies on eww, wouldn't the right place for it be
in eww.el?

> +(defun Man-at-mouse (e)
> ...
> +(defun Man-context-menu (menu click)
> +  "Populate MENU with commands that open a man page at point."
> +  (save-excursion
> +    (mouse-set-point click)
> +    (when (save-excursion

It seems the second 'save-excursion' is superfluous?

> +            (skip-syntax-backward "^ ")
> +            (and (looking-at
> +                  "[[:space:]]*\\([[:alnum:]_-]+([[:alnum:]]+)\\)")
> +                  (match-string 1)))
> +      (define-key-after menu [man-separator] menu-bar-separator)
> +      (define-key-after menu [man-at-mouse]
> +    '(menu-item "Open man page" man-at-mouse

Typo: the command name is capitalized 'Man-at-mouse'.

> +    (mouse-set-point click)
> +    (when (symbol-at-point)

This can be simplified to:

       (thing-at-mouse click 'symbol)