From efb21aabfa83f3be921da770c6c20952871e0229 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Wed, 12 Jun 2002 15:50:25 +0000 Subject: [PATCH] (Info-fontify-node): Compute header line specially if node has no next, previous or up links. Hide the part of the first line that is used in the header. Use Info-next-link-keymap, etc. (Info-next-link-keymap, Info-prev-link-keymap) (Info-up-link-keymap): New variables. --- lisp/ChangeLog | 7 ++++ lisp/info.el | 87 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 70 insertions(+), 24 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4dfc1b2ab91..bd29cd50c29 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,12 @@ 2002-06-12 Richard M. Stallman + * info.el (Info-fontify-node): Compute header line specially + if node has no next, previous or up links. + Hide the part of the first line that is used in the header. + Use Info-next-link-keymap, etc. + (Info-next-link-keymap, Info-prev-link-keymap) + (Info-up-link-keymap): New variables. + * international/mule-diag.el (describe-char-after): Doc fix. * view.el (view-mode-enter): Clarify echo area message. diff --git a/lisp/info.el b/lisp/info.el index 19bb7d0cf31..afc4433a253 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -2580,6 +2580,34 @@ the variable `Info-file-list-for-emacs'." (put-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'info-menu-header))))) +(defvar Info-next-link-keymap + (let ((keymap (make-sparse-keymap))) + (define-key keymap [header-line mouse-1] 'Info-next) + (define-key keymap [header-line mouse-2] 'Info-next) + (define-key keymap [header-line down-mouse-1] 'ignore) + (define-key keymap [mouse-2] 'Info-next) + keymap) + "Keymap to put on the Next link in the text or the header line.") + +(defvar Info-prev-link-keymap + (let ((keymap (make-sparse-keymap))) + (define-key keymap [header-line mouse-1] 'Info-prev) + (define-key keymap [header-line mouse-2] 'Info-prev) + (define-key keymap [header-line down-mouse-1] 'ignore) + (define-key keymap [mouse-2] 'Info-prev) + keymap) + "Keymap to put on the Prev link in the text or the header line.") + + +(defvar Info-up-link-keymap + (let ((keymap (make-sparse-keymap))) + (define-key keymap [header-line mouse-1] 'Info-up) + (define-key keymap [header-line mouse-2] 'Info-up) + (define-key keymap [header-line down-mouse-1] 'ignore) + (define-key keymap [mouse-2] 'Info-up) + keymap) + "Keymap to put on the Up link in the text or the header line.") + (defun Info-fontify-node () ;; Only fontify the node if it hasn't already been done. [We pass in ;; LIMIT arg to `next-property-change' because it seems to search past @@ -2607,33 +2635,44 @@ the variable `Info-file-list-for-emacs'." (concat "Go to node " (buffer-substring nbeg nend))) ;; Always set up the text property keymap. - ;; It will be used either in the buffer + ;; It will either be used in the buffer ;; or copied in the header line. - (let ((fun (cdr (assoc tag '(("Prev" . Info-prev) - ("Next" . Info-next) - ("Up" . Info-up)))))) - (when fun - (let ((keymap (make-sparse-keymap))) - (define-key keymap [header-line mouse-1] fun) - (define-key keymap [header-line mouse-2] fun) - (define-key keymap [header-line down-mouse-1] 'ignore) - (define-key keymap [mouse-2] fun) - (put-text-property tbeg nend 'keymap keymap)))) - ))) + (cond ((equal tag "Prev") + (put-text-property tbeg nend 'keymap + Info-prev-link-keymap)) + ((equal tag "Next") + (put-text-property tbeg nend 'keymap + Info-next-link-keymap)) + ((equal tag "Up") + (put-text-property tbeg nend 'keymap + Info-up-link-keymap)))))) (goto-char (point-min)) - (let* ((header-end (save-excursion (end-of-line) (point))) - ;; 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. - (header-beg (if (re-search-forward - "\\(next\\|prev[ious]*\\): " - header-end t) - (match-beginning 1) - (point)))) + (let ((header-end (save-excursion (end-of-line) (point))) + 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]*" nil t) + (setq header + (concat "No next, prev or up links -- " + (buffer-substring (point) header-end))) + (setq header (buffer-substring (point) header-end)))) + (put-text-property (point-min) (1+ (point-min)) - 'header-line - (buffer-substring header-beg header-end)))) + 'header-line header) + ;; Hide the part of the first line + ;; that is in the header, if it is just part. + (unless (bobp) + ;; Hide the punctuation at the end, too. + (skip-chars-backward " \t,") + (put-text-property (point) header-end 'invisible t)))) (goto-char (point-min)) (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$" nil t) -- 2.39.2