From 7cf8e8347a2cc46711efd4eea22eff4ba59e716a Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Mon, 8 Jul 2024 22:46:32 +0200 Subject: [PATCH] Add 'minibuffer-action' to some info.el commands --- lisp/info.el | 92 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/lisp/info.el b/lisp/info.el index 44da6d615a1..413af04f95f 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -786,6 +786,8 @@ in `Info-file-supports-index-cookies-list'." (format "*info*<%s>" current-prefix-arg)))) (info-pop-to-buffer file-or-node buffer t)) +(put 'info-other-window 'minibuffer-action 'info) + (defun info-pop-to-buffer (&optional file-or-node buffer-or-name other-window) "Put Info node FILE-OR-NODE in specified buffer and display it. Optional argument FILE-OR-NODE is as for `info'. @@ -866,6 +868,9 @@ See a list of available Info commands in `Info-mode'." (info-pop-to-buffer file-or-node buffer)) +(put 'info 'minibuffer-action + (cons (lambda (f) (save-selected-window (info f))) "info")) + (defun info-setup (file-or-node buffer) "Display Info node FILE-OR-NODE in BUFFER." (if (and buffer (not (derived-mode-p 'Info-mode))) @@ -1032,24 +1037,6 @@ If NOERROR, inhibit error messages when we can't find the node." Info-history)) (Info-find-node-2 filename nodename no-going-back strict-case)) -;;;###autoload -(defun Info-on-current-buffer (&optional nodename) - "Use Info mode to browse the current Info buffer. -With a prefix arg, this queries for the node name to visit first; -otherwise, that defaults to `Top'." - (interactive - (list (if current-prefix-arg - (completing-read "Node name: " (Info-build-node-completions) - nil t "Top")))) - (unless nodename (setq nodename "Top")) - (info-initialize) - (Info-mode) - (setq Info-current-file - (or buffer-file-name - ;; If called on a non-file buffer, make a fake file name. - (concat default-directory (buffer-name)))) - (Info-find-node-2 nil nodename)) - (defun Info-revert-find-node (filename nodename) "Go to an Info node FILENAME and NODENAME, re-reading disk contents. When *info* is already displaying FILENAME and NODENAME, the window position @@ -1840,9 +1827,6 @@ escaped (\\\",\\\\)." ;; Go to an Info node specified with a filename-and-nodename string ;; of the sort that is found in pointers in nodes. -;; Don't autoload this function: the correct entry point for other packages -;; to use is `info'. --Stef -;; ;;;###autoload (defun Info-goto-node (nodename &optional fork strict-case) "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file @@ -1858,7 +1842,8 @@ If FORK is a string, it is the name to use for the new buffer. This function first looks for a case-sensitive match for the node part of NODENAME; if none is found it then tries a case-insensitive match \(unless STRICT-CASE is non-nil)." - (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) + (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg) + Info-mode) (info-initialize) (if fork (set-buffer @@ -1878,6 +1863,12 @@ of NODENAME; if none is found it then tries a case-insensitive match (Info-find-node (if (equal filename "") nil filename) (if (equal nodename "") "Top" nodename) nil strict-case))) +(put 'Info-goto-node 'minibuffer-action + (cons (lambda (n) (save-selected-window + (with-current-buffer minibuffer--original-buffer + (Info-goto-node n t)))) + "goto")) + (defun Info-goto-node-web (node) "Use `browse-url' to go to the gnu.org web server's version of NODE. By default, go to the current Info node." @@ -1903,6 +1894,13 @@ By default, go to the current Info node." (browse-url-button-open-url (Info-url-for-node (format "(%s)%s" filename node))))) +(put 'Info-goto-node-web 'minibuffer-action + (cons (lambda (n) + (save-selected-window + (with-current-buffer minibuffer--original-buffer + (Info-goto-node-web n)))) + "surf")) + (defun Info-url-for-node (node) "Return the URL corresponding to NODE. @@ -2243,12 +2241,20 @@ If DIRECTION is `backward', search in the reverse direction." (setq Info-history (cons (list ofile onode opoint) Info-history)))))) +(put 'Info-search 'minibuffer-action + (cons (lambda (r) + (with-selected-window (minibuffer-selected-window) + (Info-search r))) + "search")) + (defun Info-search-case-sensitively () "Search for a regexp case-sensitively." (interactive nil Info-mode) (let ((case-fold-search nil)) (call-interactively 'Info-search))) +(put 'Info-search-case-sensitively 'minibuffer-action 'Info-search) + (defun Info-search-next () "Search for next regexp from a previous `Info-search' command." (interactive nil Info-mode) @@ -2267,6 +2273,8 @@ If DIRECTION is `backward', search in the reverse direction." Info-mode) (Info-search regexp bound noerror count 'backward)) +(put 'Info-search-backward 'minibuffer-action 'Info-search) + (defun Info-isearch-search () (if Info-isearch-search (lambda (string &optional bound noerror count) @@ -2794,6 +2802,13 @@ new buffer." (setq i (+ i 1))) (Info-goto-node target fork))) +(put 'Info-follow-reference 'minibuffer-action + (cons (lambda (f) + (save-selected-window + (with-current-buffer minibuffer--original-buffer + (Info-follow-reference f t)))) + "follow")) + (defconst Info-menu-entry-name-re "\\(?:[^:]\\|:[^:,.;() \t\n]\\)*" ;; We allow newline because this is also used in Info-follow-reference, ;; where the xref name might be wrapped over two lines. @@ -2962,6 +2977,13 @@ new buffer." (and fork (if (stringp fork) fork menu-item)))) +(put 'Info-menu 'minibuffer-action + (cons (lambda (m) + (save-selected-window + (with-current-buffer minibuffer--original-buffer + (Info-menu m t)))) + "goto")) + (defun Info-extract-menu-item (menu-item) (setq menu-item (regexp-quote menu-item)) (let ((case-fold-search t)) @@ -3535,6 +3557,13 @@ Give an empty topic name to go to the Index node itself." Info--current-index-alternative 0) (Info-index-next 0))))) +(put 'Info-index 'minibuffer-action + (cons (lambda (i) + (save-selected-window + (with-selected-window (minibuffer-selected-window) + (Info-index i)))) + "goto")) + (defun Info-index-next (num) "Go to the next matching index item from the last \\\\[Info-index] command. If given a numeric prefix, skip that many index items forward (or @@ -3691,7 +3720,14 @@ search results." (message ""))) (Info-find-node Info-current-file (format "*Index for ‘%s’*" topic)))) - + +(put 'Info-virtual-index 'minibuffer-action + (cons (lambda (i) + (save-selected-window + (with-selected-window (minibuffer-selected-window) + (Info-virtual-index i)))) + "goto")) + (add-to-list 'Info-virtual-files '("\\`\\*Apropos\\*\\'" (toc-nodes . Info-apropos-toc-nodes) @@ -3700,6 +3736,7 @@ search results." (slow . t) )) + (defvar Info-apropos-file "*Apropos*" "Info file name of the virtual manual for matches of `info-apropos'.") @@ -3985,11 +4022,6 @@ with a list of packages that contain all specified keywords." (Info-find-node Info-finder-file "Top"))) -(defun Info-undefined () - "Make command be undefined in Info." - (interactive nil Info-mode) - (ding)) - (defun Info-help () "Enter the Info tutorial." (interactive) @@ -5644,6 +5676,10 @@ completion alternatives to currently visited manuals." (info (Info-find-file manual) (generate-new-buffer-name "*info*"))))) +(put 'info-display-manual 'minibuffer-action + (cons (lambda (m) (save-selected-window (info-display-manual m))) + "display")) + (defun info--filter-manual-names (names) (cl-flet ((strip (name) (replace-regexp-in-string "\\([-.]info\\)?\\(\\.gz\\)?\\'" -- 2.39.2