all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "Simon Tournier" <zimon.toutoune@gmail.com>
Cc: "Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Ricardo Wurmus" <rekado@elephly.net>,
	"Nathan Dehnel" <ncdehnel@gmail.com>,
	"Felix Lechner" <felix.lechner@lease-up.com>,
	"guix-devel" <guix-devel@gnu.org>
Subject: Useful Info related Emacs functions (was Re: more than 1,800 dependent packages: website out of date)
Date: Wed, 18 Oct 2023 20:41:19 +0200	[thread overview]
Message-ID: <18b441799eb.10e14e0da958031.6053092172065193271@excalamus.com> (raw)
In-Reply-To: <87zg0folx6.fsf@gmail.com>


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

 > On Sat, 14 Oct 2023 at 12:11, Maxim Cournoyer maxim.cournoyer@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	other threads:[~2023-10-18 18:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  6:28 more than 1,800 dependent packages: website out of date Nathan Dehnel
2023-09-28  6:35 ` Ricardo Wurmus
2023-09-28 14:11   ` Nathan Dehnel
2023-09-29  7:32   ` Simon Tournier
2023-10-04 15:33     ` Ludovic Courtès
2023-10-04 17:50       ` Simon Tournier
2023-10-14 16:11     ` Maxim Cournoyer
2023-10-18 17:55       ` Simon Tournier
2023-10-18 18:41         ` Matt [this message]
2023-10-19  8:59           ` Useful Info related Emacs functions (was Re: more than 1,800 dependent packages: website out of date) Simon Tournier

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=18b441799eb.10e14e0da958031.6053092172065193271@excalamus.com \
    --to=matt@excalamus.com \
    --cc=felix.lechner@lease-up.com \
    --cc=guix-devel@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    --cc=ncdehnel@gmail.com \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /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/guix.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.