Subject: bug#60190: 29.0.50; Improve `Info-goto-node-web'

From: Eduardo Ochs <[email-masked]>
Date: Mon, 19 Dec 2022 04:02:47 -0300

On Mon, 19 Dec 2022 at 03:24, Marcin Borkowski <[email-masked]> wrote:
>
> Hi all,
>
> I am extremely happy because of `Info-goto-node-web', but it would be
> even better if two changes were made.
>
> 1. It could work in "An Introduction to Programming in Emacs Lisp" and
> Org mode manual, too.
>
> 2. It could put the URL on the kill ring when called with a prefix
> argument.
>
> I would code these myself, but I changed jobs since I signed the FSF
> paperwork long time ago, and I don't want to contribute to Emacs since
> then because it could be a legal gray area then.  I think these two
> changes are pretty low hanging fruit anyway.
>
> Thanks!
>
> PS. Please CC me on any replies to this request - I'm no longer
> subscribed to the bug-gnu-emacs list.

Hi Marcin and all,
what about this?

  (defvar Info-url-base
    '(("emacs"  . "http://www.gnu.org/software/emacs/manual/html_node/emacs/")
      ("elisp"  . "http://www.gnu.org/software/emacs/manual/html_node/elisp/")
      ("eintr"  .
"http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/")
      ("efaq"   . "https://www.gnu.org/software/emacs/manual/html_node/efaq/")
      ("cl"     . "http://www.gnu.org/software/emacs/manual/html_node/cl/")
      ("eshell" . "https://www.gnu.org/software/emacs/manual/html_node/eshell/")
      ("org"    . "http://www.gnu.org/software/emacs/manual/html_node/org/")))

  (defun Info-get-base-url (manual)
    (alist-get manual Info-url-base nil nil 'equal))

  (defun Info-url-for-node (node)
    "Return a URL for NODE, a node in the GNU Emacs or Elisp manual.
  NODE should be a string on the form \"(manual)Node\".  Only emacs
  and elisp manuals are supported."
    (unless (string-match "\\`(\\(.+\\))\\(.+\\)\\'" node)
      (error "Invalid node name %s" node))
    (let* ((manual (match-string 1 node))
           (node (match-string 2 node))
           (base-url (Info-get-base-url manual))) ; <- new
      ;; Old:
      ;; (unless (member manual '("emacs" "elisp"))
      ;;   (error "Only emacs/elisp manuals are supported"))
      ;; New:
      (if (not base-url)
          (error "Unsupported manual"))
      ;;
      ;; Encode a bunch of characters the way that makeinfo does.
      (setq node
            (mapconcat (lambda (ch)
                         (if (or (< ch 32)        ; ^@^A-^Z^[^\^]^^^-
                                 (<= 33 ch 47)    ; !"#$%&'()*+,-./
                                 (<= 58 ch 64)    ; :;<=>?@
                                 (<= 91 ch 96)    ; [\]_`
                                 (<= 123 ch 127)) ; {|}~ DEL
                             (format "_00%x" ch)
                           (char-to-string ch)))
                       node
                       ""))
      (concat base-url                    ; new
              (url-hexify-string (string-replace " " "-" node))
              ".html")))

Now the fruit hangs a little bit lower...
Cheers =),
  Eduardo Ochs
  http://angg.twu.net/eepitch.html