summaryrefslogtreecommitdiff
path: root/lisp/info.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/info.el')
-rw-r--r--lisp/info.el200
1 files changed, 162 insertions, 38 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 39ca88c358c..1e478cdbee9 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -213,6 +213,54 @@ a version of Emacs without installing it.")
These directories are searched after those in `Info-directory-list'."
:type '(repeat directory))
+(defcustom Info-url-alist
+ '((("auth" "autotype" "bovine" "calc" "ccmode" "cl" "dbus" "dired-x"
+ "ebrowse" "ede" "ediff" "edt" "efaq" "efaq-w32" "eglot" "eieio"
+ "eintr" "elisp" "emacs" "emacs-gnutls" "emacs-mime" "epa" "erc"
+ "ert" "eshell" "eudc" "eww" "flymake" "forms" "gnus"
+ "htmlfontify" "idlwave" "ido" "info" "mairix-el" "message"
+ "mh-e" "modus-themes" "newsticker" "nxml-mode" "octave-mode"
+ "org" "pcl-cvs" "pgg" "rcirc" "reftex" "remember" "sasl" "sc"
+ "semantic" "ses" "sieve" "smtpmail" "speedbar" "srecode"
+ "todo-mode" "tramp" "transient" "url" "use-package" "vhdl-mode"
+ "vip" "viper" "vtable" "widget" "wisent" "woman") .
+ "https://www.gnu.org/software/emacs/manual/html_node/%m/%e"))
+ "Alist telling `Info-mode' where manuals are accessible online.
+
+Each element of this list has the form (MANUALs . URL-SPEC).
+MANUALs represents the name of one or more manuals. It can
+either be a string or a list of strings. URL-SPEC can be a
+string in which the substring \"%m\" will be expanded to the
+manual-name and \"%n\" to the node-name. \"%e\" will expand to
+the URL-encoded node-name, including the `.html' extension; in
+case of the Top node, it will expand to the empty string. (The
+URL-encoding of the node-name mimics GNU Texinfo, as documented
+at Info node `(texinfo)HTML Xref Node Name Expansion'.)
+Alternatively, URL-SPEC can be a function which is given
+manual-name, node-name and URL-encoded node-name as arguments,
+and is expected to return the corresponding URL as a string.
+
+This variable particularly affects the command
+`Info-goto-node-web', which see.
+
+The default value of this variable refers to the official,
+HTTPS-accessible HTML-representations of all manuals that Emacs
+includes. These URLs refer to the most recently released version
+of Emacs, disregarding the version of the running Emacs. In
+other words, the content of your local Info node and the
+associated online node may differ. The resource represented by
+the generated URL may even be not found by the gnu.org server."
+ :version "30.1"
+ :type '(alist
+ :tag "Mapping from manual-name(s) to URL-specification"
+ :key-type (choice
+ (string :tag "A single manual-name")
+ (repeat :tag "List of manual-names" string))
+ :value-type (choice
+ (string :tag "URL-specification string")
+ (function
+ :tag "URL-specification function"))))
+
(defcustom Info-scroll-prefer-subnodes nil
"If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
@@ -452,6 +500,7 @@ or `Info-virtual-nodes'."
(".info.bz2" . ("bzip2" "-dc"))
(".info.xz" . "unxz")
(".info.zst" . ("zstd" "-dc"))
+ (".info.lz" . ("lzip" "-dc"))
(".info" . nil)
("-info.Z" . "uncompress")
("-info.Y" . "unyabba")
@@ -460,6 +509,7 @@ or `Info-virtual-nodes'."
("-info.z" . "gunzip")
("-info.xz" . "unxz")
("-info.zst" . ("zstd" "-dc"))
+ ("-info.lz" . ("lzip" "-dc"))
("-info" . nil)
("/index.Z" . "uncompress")
("/index.Y" . "unyabba")
@@ -468,6 +518,7 @@ or `Info-virtual-nodes'."
("/index.bz2" . ("bzip2" "-dc"))
("/index.xz" . "unxz")
("/index.zst" . ("zstd" "-dc"))
+ ("/index.lz" . ("lzip" "-dc"))
("/index" . nil)
(".Z" . "uncompress")
(".Y" . "unyabba")
@@ -476,6 +527,7 @@ or `Info-virtual-nodes'."
(".bz2" . ("bzip2" "-dc"))
(".xz" . "unxz")
(".zst" . ("zstd" "-dc"))
+ (".lz" . ("lzip" "-dc"))
("" . nil)))
"List of file name suffixes and associated decoding commands.
Each entry should be (SUFFIX . STRING); the file is given to
@@ -732,8 +784,53 @@ in `Info-file-supports-index-cookies-list'."
(read-file-name "Info file name: " nil nil t))
(if (numberp current-prefix-arg)
(format "*info*<%s>" current-prefix-arg))))
- (info-setup file-or-node
- (switch-to-buffer-other-window (or buffer "*info*"))))
+ (info-pop-to-buffer file-or-node buffer t))
+
+(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'.
+
+If the optional argument BUFFER-OR-NAME is a buffer, use that
+buffer. If it is a string, use that string as the name of the
+buffer, creating it if it does not exist. Otherwise, use a
+buffer with the name `*info*', creating it if it does not exist.
+
+Optional argument OTHER-WINDOW nil means to prefer the selected
+window. OTHER-WINDOW non-nil means to prefer another window.
+Select the window used, if it has been made."
+ (let ((buffer (cond
+ ((bufferp buffer-or-name)
+ buffer-or-name)
+ ((stringp buffer-or-name)
+ (get-buffer-create buffer-or-name))
+ (t
+ (get-buffer-create "*info*")))))
+ (with-current-buffer buffer
+ (unless (derived-mode-p 'Info-mode)
+ (Info-mode)))
+
+ (let* ((window
+ (display-buffer buffer
+ (if other-window
+ '(nil (inhibit-same-window . t))
+ '(display-buffer-same-window)))))
+ (with-current-buffer buffer
+ (if file-or-node
+ ;; If argument already contains parentheses, don't add another set
+ ;; since the argument will then be parsed improperly. This also
+ ;; has the added benefit of allowing node names to be included
+ ;; following the parenthesized filename.
+ (Info-goto-node
+ (if (and (stringp file-or-node) (string-match "(.*)" file-or-node))
+ file-or-node
+ (concat "(" file-or-node ")")))
+ (if (and (zerop (buffer-size))
+ (null Info-history))
+ ;; If we just created the Info buffer, go to the directory.
+ (Info-directory))))
+
+ (when window
+ (select-window window)))))
;;;###autoload (put 'info 'info-file (purecopy "emacs"))
;;;###autoload
@@ -768,8 +865,8 @@ See a list of available Info commands in `Info-mode'."
;; of names that might have been wrapped (in emails, etc.).
(setq file-or-node
(string-replace "\n" " " file-or-node)))
- (info-setup file-or-node
- (pop-to-buffer-same-window (or buffer "*info*"))))
+
+ (info-pop-to-buffer file-or-node buffer))
(defun info-setup (file-or-node buffer)
"Display Info node FILE-OR-NODE in BUFFER."
@@ -789,6 +886,8 @@ See a list of available Info commands in `Info-mode'."
;; If we just created the Info buffer, go to the directory.
(Info-directory))))
+(make-obsolete 'info-setup "use `info-pop-to-buffer' instead" "30.1")
+
;;;###autoload
(defun info-emacs-manual ()
"Display the Emacs manual in Info mode."
@@ -927,7 +1026,7 @@ If NOERROR, inhibit error messages when we can't find the node."
(setq nodename (info--node-canonicalize-whitespace nodename))
(setq filename (Info-find-file filename noerror))
;; Go into Info buffer.
- (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*"))
+ (or (derived-mode-p 'Info-mode) (info-pop-to-buffer filename))
;; Record the node we are leaving, if we were in one.
(and (not no-going-back)
Info-current-file
@@ -957,7 +1056,7 @@ otherwise, that defaults to `Top'."
"Go to an Info node FILENAME and NODENAME, re-reading disk contents.
When *info* is already displaying FILENAME and NODENAME, the window position
is preserved, if possible."
- (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*"))
+ (or (derived-mode-p 'Info-mode) (info-pop-to-buffer filename))
(let ((old-filename Info-current-file)
(old-nodename Info-current-node)
(window-selected (eq (selected-window) (get-buffer-window)))
@@ -1807,33 +1906,52 @@ By default, go to the current Info node."
(Info-url-for-node (format "(%s)%s" filename node)))))
(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)))
- (unless (member manual '("emacs" "elisp"))
- (error "Only emacs/elisp manuals are supported"))
- ;; 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 "https://www.gnu.org/software/emacs/manual/html_node/"
- manual "/"
- (and (not (equal node "Top"))
+ "Return the URL corresponding to NODE.
+
+NODE should be a string of the form \"(manual)Node\"."
+ ;; GNU Texinfo skips whitespaces and newlines between the closing
+ ;; parenthesis and the node-name, i.e. space, tab, line feed and
+ ;; carriage return.
+ (unless (string-match "\\`(\\(.+\\))[ \t\n\r]*\\(.+\\)\\'" node)
+ (error "Invalid node-name %s" node))
+ ;; Use `if-let*' instead of `let*' so we check if an association was
+ ;; found.
+ (if-let* ((manual (match-string 1 node))
+ (node (match-string 2 node))
+ (association (seq-find
+ (lambda (pair)
+ (seq-contains-p (ensure-list (car pair))
+ manual #'string-equal-ignore-case))
+ Info-url-alist))
+ (url-spec (cdr association))
+ (encoded-node
+ ;; Reproduce GNU Texinfo's way of URL-encoding.
+ ;; (info "(texinfo) HTML Xref Node Name Expansion")
+ (if (equal node "Top")
+ ""
(concat
- (url-hexify-string (string-replace " " "-" node))
- ".html")))))
+ (url-hexify-string
+ (string-replace " " "-"
+ (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 "")))
+ ".html"))))
+ (cond
+ ((stringp url-spec)
+ (format-spec url-spec
+ `((?m . ,manual) (?n . ,node) (?e . ,encoded-node))))
+ ((functionp url-spec)
+ (funcall url-spec manual node encoded-node))
+ (t (error "URL-specification neither string nor function")))
+ (error "No URL-specification associated with manual-name `%s'"
+ manual)))
(defvar Info-read-node-completion-table)
@@ -2056,7 +2174,7 @@ If DIRECTION is `backward', search in the reverse direction."
(re-search-forward regexp nil t))
(signal 'user-search-failed (list regexp))))))
- (if (and bound (not found))
+ (if (and (or bound (not Info-current-subfile)) (not found))
(signal 'user-search-failed (list regexp)))
(unless (or found bound)
@@ -2290,7 +2408,7 @@ This command doesn't descend into sub-nodes, like \\<Info-mode-map>\\[Info-forwa
(interactive nil Info-mode)
;; In case another window is currently selected
(save-window-excursion
- (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*"))
+ (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
(Info-goto-node (Info-extract-pointer "next"))))
(defun Info-prev ()
@@ -2299,7 +2417,7 @@ This command doesn't go up to the parent node, like \\<Info-mode-map>\\[Info-bac
(interactive nil Info-mode)
;; In case another window is currently selected
(save-window-excursion
- (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*"))
+ (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
(Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
(defun Info-up (&optional same-file)
@@ -2308,7 +2426,7 @@ If SAME-FILE is non-nil, do not move to a different Info file."
(interactive nil Info-mode)
;; In case another window is currently selected
(save-window-excursion
- (or (derived-mode-p 'Info-mode) (switch-to-buffer "*info*"))
+ (or (derived-mode-p 'Info-mode) (info-pop-to-buffer))
(let ((old-node Info-current-node)
(old-file Info-current-file)
(node (Info-extract-pointer "up")) p)
@@ -4686,8 +4804,14 @@ the variable `Info-file-list-for-emacs'."
(eq command 'execute-extended-command))
(Info-goto-emacs-command-node
(read-command "Find documentation for command: ")))
+ ((symbolp command)
+ (Info-goto-emacs-command-node command))
(t
- (Info-goto-emacs-command-node command)))))
+ (message
+ (substitute-command-keys
+ (format
+ "\\`%s' invokes an anonymous command defined with `lambda'"
+ (key-description key))))))))
(defvar Info-link-keymap
(let ((keymap (make-sparse-keymap)))
@@ -5485,7 +5609,7 @@ completion alternatives to currently visited manuals."
(raise-frame (window-frame window))
(select-frame-set-input-focus (window-frame window))
(select-window window))
- (switch-to-buffer found)))
+ (info-pop-to-buffer nil found)))
;; The buffer doesn't exist; create it.
(info-initialize)
(info (Info-find-file manual)