X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0c3aa29ef824c7ffabc7e3e1cbd04e29644753f2..e54faddb96acd3580d48b9db7c1746f17b824dd6:/lisp/info.el diff --git a/lisp/info.el b/lisp/info.el index 6deb7ca70c..424de35b58 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -139,7 +139,7 @@ These directories are searched after those in `Info-directory-list'." :type '(repeat directory) :group 'info) -(defcustom Info-scroll-prefer-subnodes t +(defcustom Info-scroll-prefer-subnodes nil "*If non-nil, \\\\[Info-scroll-up] in a menu visits subnodes. If this is non-nil, and you scroll far enough in a node that its menu appears on the screen, the next \\\\[Info-scroll-up] @@ -162,6 +162,14 @@ If value is non-nil but not t, the reference section is still shown." (other :tag "Replace only tag" tag)) :group 'info) +(defcustom Info-refill-paragraphs nil + "*If non-nil, attempt to refill paragraphs with hidden references. +This refilling may accidentally remove explicit line breaks in the info +file, so be prepared for a few surprises if you enable this feature." + :version "21.4" + :type 'boolean + :group 'info) + (defcustom Info-mode-hook ;; Try to obey obsolete Info-fontify settings. (unless (and (boundp 'Info-fontify) (null Info-fontify)) @@ -1130,8 +1138,8 @@ a case-insensitive match is tried." (set-buffer-modified-p nil))) (defun Info-select-node () -"Select the info node that point is in. -Bind this in case the user sets it to nil." + "Select the info node that point is in." + ;; Bind this in case the user sets it to nil. (let ((case-fold-search t)) (save-excursion ;; Find beginning of node. @@ -1536,20 +1544,21 @@ FOOTNOTENAME may be an abbreviation of the reference name." (error "No cross-reference named %s" footnotename)) (goto-char (+ (match-beginning 0) 5)) (setq target - (Info-extract-menu-node-name "Bad format cross reference" t))) + (Info-extract-menu-node-name t))) (while (setq i (string-match "[ \t\n]+" target i)) (setq target (concat (substring target 0 i) " " (substring target (match-end 0)))) (setq i (+ i 1))) (Info-goto-node target))) -(defun Info-extract-menu-node-name (&optional errmessage multi-line) +(defun Info-extract-menu-node-name (&optional multi-line) (skip-chars-forward " \t\n") (let ((beg (point)) str) - (while (not (looking-at ":*[,.;() \t\n]")) - (skip-chars-forward "^:") - (forward-char 1)) + (while (progn + (skip-chars-forward "^:") + (forward-char 1) + (not (looking-at ":*[,.;() \t\n]")))) (setq str (if (looking-at ":") (buffer-substring-no-properties beg (1- (point))) @@ -1567,6 +1576,9 @@ FOOTNOTENAME may be an abbreviation of the reference name." (defvar Info-complete-next-re nil) (defvar Info-complete-cache nil) +(defconst Info-node-spec-re "[^.,:(]*\\(([^)]*)[^.,:]*\\)?[,:.]" + "Regexp to match the text after a : until the terminating `.'.") + (defun Info-complete-menu-item (string predicate action) ;; This uses two dynamically bound variables: ;; - `Info-complete-menu-buffer' which contains the buffer in which @@ -1575,7 +1587,11 @@ FOOTNOTENAME may be an abbreviation of the reference name." ;; also look for menu items in subsequent nodes as long as those ;; nodes' names match `Info-complete-next-re'. This feature is currently ;; only used for completion in Info-index. - (with-current-buffer Info-complete-menu-buffer + + ;; Note that `Info-complete-menu-buffer' could be current already, + ;; so we want to save point. + (save-excursion + (set-buffer Info-complete-menu-buffer) (let ((completion-ignore-case t) (case-fold-search t) (orignode Info-current-node) @@ -1587,7 +1603,7 @@ FOOTNOTENAME may be an abbreviation of the reference name." (concat "\n\\* +" (regexp-quote string) ":") nil t) (let ((pattern (concat "\n\\* +\\(" (regexp-quote string) - "[^\t\n]*\\):")) + "[^\t\n]*?\\):" Info-node-spec-re)) completions) ;; Check the cache. (if (and (equal (nth 0 Info-complete-cache) Info-current-file) @@ -2459,7 +2475,7 @@ Moving within a node: \\[beginning-of-buffer] Go to beginning of node. Advanced commands: -\\[Info-exit] Quit Info: reselect previously selected buffer. +\\[Info-copy-current-node-name] Put name of current info node in the kill ring. \\[Info-edit] Edit contents of selected node. 1 Pick first item in node's menu. 2, 3, 4, 5 Pick second ... fifth item in node's menu. @@ -2740,7 +2756,7 @@ the variable `Info-file-list-for-emacs'." "Add the face `info-menu-header' to any header before a menu entry." (save-excursion (goto-char (point-min)) - (when (re-search-forward "\\* Menu:" nil t) + (when (re-search-forward "^\\* Menu:" nil t) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'info-menu-header) (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t) @@ -2852,7 +2868,7 @@ the variable `Info-file-list-for-emacs'." ;; on frames that can display the font above. (when (memq (framep (selected-frame)) '(x pc w32 mac)) (add-text-properties (1- (match-beginning 2)) (match-end 2) - '(invisible t)))) + '(invisible t front-sticky nil rear-nonsticky t)))) (goto-char (point-min)) (while (re-search-forward "\\(\\*Note[ \t]*\\)\n?[ \t]*\\([^:]*\\)\\(:[^.,:(]*\\(([^)]*)[^.,:]*\\)?[,:]?\n?\\)" nil t) (unless (= (char-after (1- (match-beginning 0))) ?\") ; hack @@ -2865,42 +2881,62 @@ the variable `Info-file-list-for-emacs'." (goto-char start) (skip-syntax-backward " ") (setq other-tag - (cond - ((or (<= (point) (point-min)) - (memq (char-after (1- (point))) '( ?\. ?! ))) - "See ") - ((memq (char-after (1- (point))) '( ?\( ?\[ ?\{ ?\, ?\; ?\: )) - "see ") - (t nil))) + (cond ((memq (char-before) '(nil ?\. ?! ??)) + "See ") + ((memq (char-before) '(?\, ?\; ?\: ?-)) + "see ") + ((memq (char-before) '(?\( ?\[ ?\{)) + ;; Check whether the paren is preceded by + ;; an end of sentence + (skip-syntax-backward " (") + (if (memq (char-before) '(nil ?\. ?! ??)) + "See " + "see ")) + ((save-match-data (looking-at "\n\n")) + "See "))) (goto-char next)) (if hide-tag (add-text-properties (match-beginning 1) (match-end 1) - '(invisible t))) - (add-text-properties (match-beginning 2) (match-end 2) - '(font-lock-face info-xref - mouse-face highlight - help-echo "mouse-2: go to this node")) + '(invisible t front-sticky nil rear-nonsticky t))) + (add-text-properties + (match-beginning 2) (match-end 2) + (cons 'help-echo + (cons (if (match-end 4) + (concat "mouse-2: go to " (match-string 4)) + "mouse-2: go to this node") + '(font-lock-face info-xref + mouse-face highlight)))) (when (eq Info-hide-note-references t) (add-text-properties (match-beginning 3) (match-end 3) - '(invisible t))) + '(invisible t front-sticky nil rear-nonsticky t))) (when other-tag (save-excursion (goto-char (match-beginning 1)) (insert other-tag))) - (when (or hide-tag (eq Info-hide-note-references t)) + (when (and Info-refill-paragraphs + (or hide-tag (eq Info-hide-note-references t))) (push (set-marker (make-marker) start) paragraph-markers))))) - (let ((fill-nobreak-invisible t)) - (goto-char (point-max)) - (while paragraph-markers - (let ((m (car paragraph-markers))) - (setq paragraph-markers (cdr paragraph-markers)) - (when (< m (point)) - (goto-char m) - (fill-paragraph nil) - (backward-paragraph 1)) - (set-marker m nil)))) + (when (and Info-refill-paragraphs + paragraph-markers) + (let ((fill-nobreak-invisible t) + (fill-individual-varying-indent nil) + (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$") + (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))))) (goto-char (point-min)) (when (and (search-forward "\n* Menu:" nil t) @@ -2909,22 +2945,30 @@ the variable `Info-file-list-for-emacs'." (< (- (point-max) (point)) Info-fontify-maximum-menu-size)) (let ((n 0) cont) - (while (re-search-forward "^\\* +\\([^:\t\n]*\\)\\(:[^.,:(]*\\(([^)]*)[^.,:]*\\)?[,:.]\\([ \t]*\\)\\)" nil t) + (while (re-search-forward (concat "^\\* +\\([^:\t\n]*\\)\\(:" + Info-node-spec-re + "\\([ \t]*\\)\\)") + nil t) (setq n (1+ n)) - (if (zerop (% n 3)) ; visual aids to help with 1-9 keys + (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys (put-text-property (match-beginning 0) (1+ (match-beginning 0)) 'font-lock-face 'info-menu-5)) - (add-text-properties (match-beginning 1) (match-end 1) - '(font-lock-face info-xref - mouse-face highlight - help-echo "mouse-2: go to this node")) + (add-text-properties + (match-beginning 1) (match-end 1) + (cons 'help-echo + (cons + (if (match-end 3) + (concat "mouse-2: go to " (match-string 3)) + "mouse-2: go to this node") + '(font-lock-face info-xref + mouse-face highlight)))) (when (eq Info-hide-note-references t) - (put-text-property (match-beginning 2) (match-beginning 4) + (put-text-property (match-beginning 2) (1- (match-end 4)) 'invisible t) ;; We need a stretchable space like :align-to but with ;; a minimum value. - (put-text-property (match-beginning 4) (match-end 4) 'display + (put-text-property (1- (match-end 4)) (match-end 4) 'display (if (>= 22 (- (match-end 1) (match-beginning 0))) '(space :align-to 24) @@ -2932,7 +2976,10 @@ the variable `Info-file-list-for-emacs'." (setq cont (looking-at ".")) (while (and (= (forward-line 1) 0) (looking-at "\\([ \t]+\\)[^*\n]")) - (put-text-property (match-beginning 1) (match-end 1) 'display + (put-text-property (match-beginning 1) (1- (match-end 1)) + 'invisible t) + (put-text-property (1- (match-end 1)) (match-end 1) + 'display (if cont '(space :align-to 26) '(space :align-to 24))) @@ -3122,6 +3169,7 @@ Optional THISFILE represends the filename of" (nreverse completions)))) ;;; Info mode node listing +;; FIXME: Seems not to be used. -stef (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."