;; Insert the entire original dir file as a start; note that we've
;; already saved its default directory to use as the default
;; directory for the whole concatenation.
- (goto-char (prog1 (point) (insert-buffer-substring buffer)))
+ (save-excursion (insert-buffer-substring buffer))
;; Look at each of the other buffers one by one.
(dolist (other others)
If DIRECTION is `backward', search in the reverse direction."
(interactive (list (read-string
(if Info-search-history
- (format "Regexp search%s (default `%s'): "
- (if case-fold-search "" " case-sensitively")
+ (format "Regexp search%s (default %s): "
+ (if case-fold-search "" " case-sensitively")
(car Info-search-history))
(format "Regexp search%s: "
- (if case-fold-search "" " case-sensitively")))
+ (if case-fold-search "" " case-sensitively")))
nil 'Info-search-history)))
(when transient-mark-mode
(deactivate-mark))
"Search for REGEXP in the reverse direction."
(interactive (list (read-string
(if Info-search-history
- (format "Regexp search%s backward (default `%s'): "
- (if case-fold-search "" " case-sensitively")
+ (format "Regexp search%s backward (default %s): "
+ (if case-fold-search "" " case-sensitively")
(car Info-search-history))
(format "Regexp search%s backward: "
- (if case-fold-search "" " case-sensitively")))
+ (if case-fold-search "" " case-sensitively")))
nil 'Info-search-history)))
(Info-search regexp bound noerror count 'backward))
(lambda (string &optional bound noerror count)
(if isearch-word
(Info-search (concat "\\b" (replace-regexp-in-string
- "\\W+" "\\\\W+"
+ "\\W+" "\\W+"
(replace-regexp-in-string
- "^\\W+\\|\\W+$" "" string)) "\\b")
+ "^\\W+\\|\\W+$" "" string)
+ nil t)
+ "\\b")
bound noerror count
(unless isearch-forward 'backward))
(Info-search (if isearch-regexp string (regexp-quote string))
(defun Info-next ()
"Go to the next node of this node."
(interactive)
- (Info-goto-node (Info-extract-pointer "next")))
+ ;; In case another window is currently selected
+ (save-window-excursion
+ (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
+ (Info-goto-node (Info-extract-pointer "next"))))
(defun Info-prev ()
"Go to the previous node of this node."
(interactive)
- (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
+ ;; In case another window is currently selected
+ (save-window-excursion
+ (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
+ (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
(defun Info-up (&optional same-file)
"Go to the superior node of this node.
If SAME-FILE is non-nil, do not move to a different Info file."
(interactive)
- (let ((old-node Info-current-node)
- (old-file Info-current-file)
- (node (Info-extract-pointer "up")) p)
- (and (or same-file (not (stringp Info-current-file)))
- (string-match "^(" node)
- (error "Up node is in another Info file"))
- (Info-goto-node node)
- (setq p (point))
- (goto-char (point-min))
- (if (and (search-forward "\n* Menu:" nil t)
- (re-search-forward
- (if (string-equal old-node "Top")
- (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")")
- (concat "\n\\* +\\(" (regexp-quote old-node)
- ":\\|[^:]+: +" (regexp-quote old-node) "\\)"))
- nil t))
- (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
- (goto-char p)
- (Info-restore-point Info-history))))
+ ;; In case another window is currently selected
+ (save-window-excursion
+ (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
+ (let ((old-node Info-current-node)
+ (old-file Info-current-file)
+ (node (Info-extract-pointer "up")) p)
+ (and (or same-file (not (stringp Info-current-file)))
+ (string-match "^(" node)
+ (error "Up node is in another Info file"))
+ (Info-goto-node node)
+ (setq p (point))
+ (goto-char (point-min))
+ (if (and (search-forward "\n* Menu:" nil t)
+ (re-search-forward
+ (if (string-equal old-node "Top")
+ (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")")
+ (concat "\n\\* +\\(" (regexp-quote old-node)
+ ":\\|[^:]+: +" (regexp-quote old-node) "\\)"))
+ nil t))
+ (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
+ (goto-char p)
+ (Info-restore-point Info-history)))))
(defun Info-history-back ()
"Go back in the history to the last node visited."
(if completions
(let ((input (completing-read (if default
(concat
- "Follow reference named: (default "
- default ") ")
+ "Follow reference named (default "
+ default "): ")
"Follow reference named: ")
completions nil t)))
(list (if (equal input "")
(car (car Info-index-alternatives))
(nth 2 (car Info-index-alternatives))
(if (cdr Info-index-alternatives)
- "(`,' tries to find next)"
+ (format "(%s total; use `,' for next)"
+ (length Info-index-alternatives))
"(Only match)")))
(defun Info-find-index-name (name)
:help "Look for another occurrence of previous item"]
["Lookup a string in all indices..." info-apropos
:help "Look for a string in the indices of all manuals"])
- ["Edit" Info-edit :help "Edit contents of this node"
- :active Info-enable-edit]
["Copy Node Name" Info-copy-current-node-name
:help "Copy the name of the current node into the kill ring"]
["Clone Info buffer" clone-buffer
(if (display-graphic-p)
(let ((map (make-sparse-keymap)))
(tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-history-back "back_arrow" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-history-forward "fwd_arrow" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-prev "left-arrow" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-next "right-arrow" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-up "up-arrow" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-history-back "back-arrow" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-history-forward "fwd-arrow" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
- (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map)
+ (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
map)))
\\[Info-menu] Pick menu item specified by name (or abbreviation).
Picking a menu item causes another node to be selected.
\\[Info-directory] Go to the Info directory node.
+\\[Info-top-node] Go to the Top node of this file.
+\\[Info-final-node] Go to the final node in this file.
+\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
+\\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
+\\[Info-next-reference] Move cursor to next cross-reference or menu item.
+\\[Info-prev-reference] Move cursor to previous cross-reference or menu item.
\\[Info-follow-reference] Follow a cross reference. Reads name of reference.
\\[Info-history-back] Move back in history to the last node you were at.
\\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
\\[Info-history] Go to menu of visited nodes.
\\[Info-toc] Go to table of contents of the current Info file.
-\\[Info-top-node] Go to the Top node of this file.
-\\[Info-final-node] Go to the final node in this file.
-\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
-\\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
-\\[Info-index] Look up a topic in this file's Index and move to that node.
-\\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
-\\[info-apropos] Look for a string in the indices of all manuals.
Moving within a node:
\\[Info-scroll-up] Normally, scroll forward a full screen.
\\[beginning-of-buffer] Go to beginning of node.
Advanced commands:
-\\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
-\\[clone-buffer] Select a new cloned Info buffer in another window.
-\\[Info-edit] Edit contents of selected node.
-1 .. 9 Pick first ... ninth item in node's menu.
- Every third `*' is highlighted to help pick the right number.
-\\[Info-goto-node] Move to node specified by name.
- You may include a filename as well, as (FILENAME)NODENAME.
-\\[universal-argument] \\[info] Move to new Info file with completion.
-\\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>.
\\[Info-search] Search through this Info file for specified regexp,
and select the node in which the next occurrence is found.
\\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
\\[Info-search-next] Search for another occurrence of regexp
from a previous \\<Info-mode-map>\\[Info-search] command.
-\\[Info-next-reference] Move cursor to next cross-reference or menu item.
-\\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
+\\[Info-index] Look up a topic in this file's Index and move to that node.
+\\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
+\\[info-apropos] Look for a string in the indices of all manuals.
+\\[Info-goto-node] Move to node specified by name.
+ You may include a filename as well, as (FILENAME)NODENAME.
+1 .. 9 Pick first ... ninth item in node's menu.
+ Every third `*' is highlighted to help pick the right number.
+\\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
+\\[clone-buffer] Select a new cloned Info buffer in another window.
+\\[universal-argument] \\[info] Move to new Info file with completion.
+\\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
(kill-all-local-variables)
(setq major-mode 'Info-mode)
(setq mode-name "Info")
(t
(Info-goto-emacs-command-node command)))))
\f
-(defun Info-escape-percent (string)
- "Double all occurrences of `%' in STRING.
-
-Return a new string with all `%' characters replaced by `%%'.
-Preserve text properties."
- (let ((start 0)
- (end (length string))
- mb me m matches)
- (save-match-data
- (while (and (< start end) (string-match "%" string start))
- (setq mb (match-beginning 0)
- me (1+ mb)
- m (substring string mb me)
- matches (cons m
- (cons m
- (cons (substring string start mb)
- matches)))
- start me))
- (push (substring string start end) matches)
- (apply #'concat (nreverse matches)))))
-
(defvar Info-next-link-keymap
(let ((keymap (make-sparse-keymap)))
(define-key keymap [header-line mouse-1] 'Info-next)
((equal tag "Up") Info-up-link-keymap))))))
(when Info-use-header-line
(goto-char (point-min))
- (let ((header-end (line-end-position))
- header)
- ;; If we find neither Next: nor Prev: link, show the entire
- ;; node header. Otherwise, don't show the File: and Node:
- ;; parts, to avoid wasting precious space on information that
- ;; is available in the mode line.
- (if (re-search-forward
- "\\(next\\|up\\|prev[ious]*\\): "
- header-end t)
- (progn
- (goto-char (match-beginning 1))
- (setq header (buffer-substring (point) header-end)))
- (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*" header-end t)
- (setq header
+ (let* ((header-end (line-end-position))
+ (header
+ ;; If we find neither Next: nor Prev: link, show the entire
+ ;; node header. Otherwise, don't show the File: and Node:
+ ;; parts, to avoid wasting precious space on information that
+ ;; is available in the mode line.
+ (if (re-search-forward
+ "\\(next\\|up\\|prev[ious]*\\): "
+ header-end t)
+ (progn
+ (goto-char (match-beginning 1))
+ (buffer-substring (point) header-end))
+ (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*"
+ header-end t)
(concat "No next, prev or up links -- "
- (buffer-substring (point) header-end)))
- (setq header (buffer-substring (point) header-end))))
+ (buffer-substring (point) header-end))
+ (buffer-substring (point) header-end)))))
(put-text-property (point-min) (1+ (point-min))
- 'header-line (Info-escape-percent header))
+ 'header-line
+ (replace-regexp-in-string
+ "%"
+ ;; Preserve text properties on duplicated `%'.
+ (lambda (s) (concat s s)) header))
;; Hide the part of the first line
;; that is in the header, if it is just part.
(unless (bobp)
;; Fontify titles
(goto-char (point-min))
- (when not-fontified-p
- (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
- nil t)
+ (when (and font-lock-mode not-fontified-p)
+ (while (and (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
+ nil t)
+ ;; Only consider it as an underlined title if the ASCII
+ ;; underline has the same size as the text. A typical
+ ;; counter example is when a continuation "..." is alone
+ ;; on a line.
+ (= (- (match-end 1) (match-beginning 1))
+ (- (match-end 2) (match-beginning 2))))
(let* ((c (preceding-char))
(face
(cond ((= c ?*) 'info-title-1)
(paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
(adaptive-fill-mode nil))
(goto-char (point-max))
- (while paragraph-markers
- (let ((m (car paragraph-markers)))
- (setq paragraph-markers (cdr paragraph-markers))
- (when (< m (point))
- (goto-char m)
- (beginning-of-line)
- (let ((beg (point)))
- (when (zerop (forward-paragraph))
- (fill-individual-paragraphs beg (point) nil nil)
- (goto-char beg))))
- (set-marker m nil)))))
+ (dolist (m paragraph-markers)
+ (when (< m (point))
+ (goto-char m)
+ (beginning-of-line)
+ (let ((beg (point)))
+ (when (zerop (forward-paragraph))
+ (fill-individual-paragraphs beg (point) nil nil)
+ (goto-char beg))))
+ (set-marker m nil))))
;; Fontify menu items
(goto-char (point-min))
"mouse-2: go to this node")
'mouse-face 'highlight)))
(when (or not-fontified-p fontify-visited-p)
- (add-text-properties
+ (put-text-property
(match-beginning 1) (match-end 1)
- (list
- 'font-lock-face
- ;; Display visited menu items in a different face
- (if (and Info-fontify-visited-nodes
- (save-match-data
- (let ((node (if (equal (match-string 3) "")
- (match-string 1)
- (match-string 3)))
- (file (file-name-nondirectory Info-current-file))
- (hl Info-history-list)
- res)
- (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
- (setq file (file-name-nondirectory
- (match-string 1 node))
- node (if (equal (match-string 2 node) "")
- "Top"
- (match-string 2 node))))
- (while hl
- (if (and (string-equal node (nth 1 (car hl)))
- (string-equal file
- (file-name-nondirectory
- (nth 0 (car hl)))))
- (setq res (car hl) hl nil)
- (setq hl (cdr hl))))
- res))) 'info-xref-visited 'info-xref))))
+ 'font-lock-face
+ ;; Display visited menu items in a different face
+ (if (and Info-fontify-visited-nodes
+ (save-match-data
+ (let ((node (if (equal (match-string 3) "")
+ (match-string 1)
+ (match-string 3)))
+ (file (file-name-nondirectory Info-current-file))
+ (hl Info-history-list)
+ res)
+ (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
+ (setq file (file-name-nondirectory
+ (match-string 1 node))
+ node (if (equal (match-string 2 node) "")
+ "Top"
+ (match-string 2 node))))
+ (while hl
+ (if (and (string-equal node (nth 1 (car hl)))
+ (string-equal file
+ (file-name-nondirectory
+ (nth 0 (car hl)))))
+ (setq res (car hl) hl nil)
+ (setq hl (cdr hl))))
+ res))) 'info-xref-visited 'info-xref)))
(when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
(put-text-property (match-beginning 2) (1- (match-end 6))
'invisible t)
(speedbar-change-initial-expansion-list "Info")
)
-(eval-when-compile (defvar speedbar-attached-frame))
-
(defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
"Display an Info directory hierarchy in speedbar.
DIRECTORY is the current directory in the attached frame.
;; being known at creation time.
(if (not node)
(speedbar-with-writable (insert "Info Nodes:\n")))
- (let ((completions nil)
- (cf (selected-frame)))
- (select-frame speedbar-attached-frame)
+ (let ((completions nil))
+ (speedbar-select-attached-frame)
(save-window-excursion
(setq completions
(Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
- (select-frame cf)
+ (select-frame (speedbar-current-frame))
(if completions
(speedbar-with-writable
(dolist (completion completions)
(defun Info-speedbar-goto-node (text node indent)
"When user clicks on TEXT, go to an info NODE.
The INDENT level is ignored."
- (select-frame speedbar-attached-frame)
+ (speedbar-select-attached-frame)
(let* ((buff (or (get-buffer "*info*")
(progn (info) (get-buffer "*info*"))))
(bwin (get-buffer-window buff 0)))
(raise-frame (window-frame bwin)))
(if speedbar-power-click
(let ((pop-up-frames t)) (select-window (display-buffer buff)))
- (select-frame speedbar-attached-frame)
+ (speedbar-select-attached-frame)
(switch-to-buffer buff)))
(if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
(error "Invalid node %s" node)
(nreverse completions))))
;;; Info mode node listing
-;; FIXME: Seems not to be used. -stef
+;; This is called by `speedbar-add-localized-speedbar-support'
(defun Info-speedbar-buttons (buffer)
"Create a speedbar display to help navigation in an Info file.
BUFFER is the buffer speedbar is requesting buttons for."
(let ((case-fold-search t))
(not (looking-at "Info Nodes:"))))
(erase-buffer))
- (Info-speedbar-hierarchy-buttons nil 0)
- )
+ (Info-speedbar-hierarchy-buttons nil 0))
(dolist (mess '("^First node in file$"
"^No `.*' in index$"
(Info-find-node first second)
(current-buffer))))
-(eval-after-load 'desktop
- '(add-to-list 'desktop-buffer-mode-handlers
- '(Info-mode . Info-restore-desktop-buffer)))
+(add-to-list 'desktop-buffer-mode-handlers
+ '(Info-mode . Info-restore-desktop-buffer))
(provide 'info)