---- On Wed, 18 Oct 2023 19:55:17 +0200  Simon Tournier  wrote --- 

 > On Sat, 14 Oct 2023 at 12:11, Maxim Cournoyer maxim.courno...@gmail.com> 
 > wrote:
 > 
 > > Not to preach, but I've spent some time looking at 'info info' once and
 > > I'm sold to it now.  I basically use these keys: 'g' to navigate to
 > > nodes, 'm' to select a menu, 'space' to page down and 'backspace' to
 > > page up.
 > 
 > Yeah the tutorial is really good!  Well, I did it several times over the
 > past 10 years and, as I said, my muscle memory has hard time with
 > keybindings.  Hum, let try once again. :-)
 > 
 > Well, I added this to my configuration:
 > 
 > --88---
 > (define-key Info-mode-map (kbd "W")
 >     #'(lambda ()
 >         "Stash the current node name as URL for online manual."
 >         (interactive)
 >         (Info-copy-current-node-name)
 >         (let* ((node (pop kill-ring))
 >                (that (if (string-match "(\\([[:alnum:]]+\\)) \\(.*\\)" node)
 >                          (if (string= "guix" (match-string 1 node))
 >                              (concat
 >                               
 > "https://guix.gnu.org/manual/devel/en/guix.html#";
 >                               (replace-regexp-in-string " " "-"
 >                                                         (match-string 2 
 > node)))
 >                            node)
 >                        node)))
 >           (kill-new that)
 >           (message "%s" that))))
 > --88---
 > 
 > Let see if I use it. ;-)

Three unasked for tips:

1. There is also 'i' to search index topics
2. In the Emacs info browser, there is the command 'info-apropos' which (as far 
as I know) isn't bound to anything by default.  I bind it to 'a'.  It searches 
across *all* manuals on your system for a regex and presents a menu of results.
3.  I have a similar function to yours that I've expanded over the years which 
you may appreciate.  It's set up to work with the Guix, Guile, and Emacs 
manuals and will format a link as a URL or an Org mode link and place it in the 
kill-ring.  There is also an option to open the web version with the default 
browser.

(defun xc/Info-link-to-current-node (&optional arg)
  "Format current info node as url.

With no prefix, place the url corresponding to the current Info
node into the kill ring.

With universal prefix, visit url with default web browser and do
not put url into the kill ring.

With numeric prefix, create Org link with node name as
description into the kill ring."
  (interactive "p")
  (unless Info-current-node
    (user-error "No current Info node"))
  (let* ((info-file (if (stringp Info-current-file)
                        (file-name-sans-extension
                         (file-name-nondirectory Info-current-file))))
         (node Info-current-node)
         (url (cond
               ((or (string= info-file "emacs") (string= info-file "org"))
                (concat "https://www.gnu.org/software/emacs/manual/html_node/";
                        info-file "/"
                        (if (string= node "Top") ""
                          (concat (replace-regexp-in-string " " "-" node t) 
".html"))))
               ((string= info-file "guile")
                (concat "https://www.gnu.org/software/guile/manual/html_node/";
                        (if (string= node "Top") ""
                          (concat (replace-regexp-in-string " " "-" node t) 
".html"))))
               ((string= info-file "guix")
                (concat "https://guix.gnu.org/en/manual/devel/en/html_node/";
                        (if (string= node "Top") ""
                          (concat (replace-regexp-in-string " " "-" node t) 
".html"))))
               )))
    (cond
     ((eq arg 1)  ; no prefix
      (kill-new url)
      (message "%s" (car kill-ring)))
     ((eq arg 4)  ; universal prefix
      (browse-url-default-browser url))
     (t           ; any other prefix
      (kill-new (format "[[%s][%s]]" url node))
      (message "%s" (car kill-ring))))))

I have it bound as:

    (general-def :keymaps 'Info-mode-map
      "a" 'info-apropos
      "U" 'xc/Info-link-to-current-node                                         
         ; [U]rl
      "G" '(lambda () (interactive) (xc/Info-link-to-current-node 4))     ; 
[G]o to web version
      "O" '(lambda () (interactive) (xc/Info-link-to-current-node 16))  ; [O]rg 
link formatted
      "h" 'nil  ; hitting 'h' by accident kills all window arrangement
      )




Reply via email to