From 136e1c1d50c2f7d857e37d07606a44c17954aaf6 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 23 Jun 2012 21:27:40 +0800 Subject: [PATCH] Fixes for Info link-following mouse commands. * lisp/info.el (Info-mouse-follow-link): Accept symbol values of the link-args property. Select the window. (Info-fontify-node): Use Info-link-keymap for all navigation buttons, with link-args property to perform the desired action. (Info-link-keymap): Doc fix. (Info-next-link-keymap, Info-prev-link-keymap) (Info-up-link-keymap): Delete now-unused keymaps. Fixes: debbugs:11672 --- lisp/ChangeLog | 10 +++++++ lisp/info.el | 71 ++++++++++++++++++-------------------------------- 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8b17b543315..122013463dc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2012-06-23 Chong Yidong + + * info.el (Info-mouse-follow-link): Accept symbol values of the + link-args property. Select the window (Bug#11672). + (Info-fontify-node): Use Info-link-keymap for all navigation + buttons, with link-args property to perform the desired action. + (Info-link-keymap): Doc fix. + (Info-next-link-keymap, Info-prev-link-keymap) + (Info-up-link-keymap): Delete now-unused keymaps. + 2012-06-23 Chong Yidong * mouse.el (mouse-drag-track): Deactivate the mark before popping. diff --git a/lisp/info.el b/lisp/info.el index 112c9068353..b3fb7917c7d 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -3695,12 +3695,20 @@ If FORK is non-nil, it is passed to `Info-goto-node'." (interactive "e") (let* ((position (event-start click)) (posn-string (and position (posn-string position))) - (string (car-safe posn-string)) - (string-pos (cdr-safe posn-string)) - (link-args (and string string-pos - (get-text-property string-pos 'link-args string)))) - (when link-args - (Info-goto-node link-args)))) + (link-args (if posn-string + (get-text-property (cdr posn-string) + 'link-args + (car posn-string)) + (get-char-property (posn-point position) + 'link-args)))) + (select-window (posn-window position)) + (cond ((stringp link-args) + (Info-goto-node link-args)) + ;; These special values of the `link-args' property are used + ;; for navigation; see `Info-fontify-node'. + ((eq link-args 'prev) (Info-prev)) + ((eq link-args 'next) (Info-next)) + ((eq link-args 'up) (Info-up))))) (defvar Info-mode-map @@ -4275,36 +4283,6 @@ the variable `Info-file-list-for-emacs'." (t (Info-goto-emacs-command-node command))))) -(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) - (define-key keymap [follow-link] 'mouse-face) - 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) - (define-key keymap [follow-link] 'mouse-face) - 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) - (define-key keymap [follow-link] 'mouse-face) - keymap) - "Keymap to put on the Up link in the text or the header line.") - (defvar Info-link-keymap (let ((keymap (make-sparse-keymap))) (define-key keymap [header-line mouse-1] 'Info-mouse-follow-link) @@ -4313,7 +4291,9 @@ the variable `Info-file-list-for-emacs'." (define-key keymap [mouse-2] 'Info-mouse-follow-link) (define-key keymap [follow-link] 'mouse-face) keymap) - "Keymap to put on the link in the text or the header line.") + "Keymap to put on Info links. +This is used for the \"Next\", \"Prev\", and \"Up\" links in the +first line or header line, and for breadcrumb links.") (defun Info-breadcrumbs () (let ((nodes (Info-toc-nodes Info-current-file)) @@ -4402,15 +4382,14 @@ the variable `Info-file-list-for-emacs'." 'help-echo (concat "mouse-2: Go to node " (buffer-substring nbeg nend))) - ;; Always set up the text property keymap. - ;; It will either be used in the buffer - ;; or copied in the header line. - (put-text-property - tbeg nend 'keymap - (cond - ((string-equal (downcase tag) "prev") Info-prev-link-keymap) - ((string-equal (downcase tag) "next") Info-next-link-keymap) - ((string-equal (downcase tag) "up" ) Info-up-link-keymap)))))) + ;; Set up the text property keymap. Depending on + ;; `Info-use-header-line', it is either used in the + ;; buffer, or copied to the header line. A symbol value + ;; of the `link-args' property is handled specially by + ;; `Info-mouse-follow-link'. + (put-text-property tbeg nend 'keymap Info-link-keymap) + (put-text-property tbeg nend 'link-args + (intern (downcase tag)))))) ;; (when (> Info-breadcrumbs-depth 0) ;; (insert (Info-breadcrumbs))) -- 2.39.5