]> git.eshelyaron.com Git - emacs.git/commitdiff
Fixes for Info link-following mouse commands.
authorChong Yidong <cyd@gnu.org>
Sat, 23 Jun 2012 13:27:40 +0000 (21:27 +0800)
committerChong Yidong <cyd@gnu.org>
Sat, 23 Jun 2012 13:27:40 +0000 (21:27 +0800)
* 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
lisp/info.el

index 8b17b543315007ce06a1d8956c9c53c5e25070e0..122013463dc1885ef68209fe227075d204229409 100644 (file)
@@ -1,3 +1,13 @@
+2012-06-23  Chong Yidong  <cyd@gnu.org>
+
+       * 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  <cyd@gnu.org>
 
        * mouse.el (mouse-drag-track): Deactivate the mark before popping.
index 112c90683534b81cc363a234aaafc38d006bc5cd..b3fb7917c7ddb13b9654971dcb01800ced6f5344 100644 (file)
@@ -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)))))
 
 \f
 (defvar Info-mode-map
@@ -4275,36 +4283,6 @@ the variable `Info-file-list-for-emacs'."
          (t
           (Info-goto-emacs-command-node command)))))
 \f
-(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)))