unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>,
	"'Juri Linkov'" <juri@jurta.org>,
	"'Eli Zaretskii'" <eliz@gnu.org>
Cc: 5809@debbugs.gnu.org
Subject: bug#5809: 23.1.94; cross-reference by anchor yields in accurate position
Date: Tue, 6 Apr 2010 10:46:01 -0700	[thread overview]
Message-ID: <FD8E19BDC6A54540B65D432CDC5C81F7@us.oracle.com> (raw)
In-Reply-To: <A97886A3EBBD448B81394D1097D55691@us.oracle.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

I hope you will take a minute to try the patch.

> Another possible change: Put `Info-scroll-up'/`down' on 
> mouse-1/mouse-3 for the current node name (similar to what
> is the case now).

I did that. Attached is a better patch:

. mouse-2: the breadcrumbs menu
. mouse-1/3: Info-scroll-* for the current node
             go-to-clicked-node for ancestor nodes

And it does the usual mouseover highlighting on a node name to show it is
mouse-active (which I had forgotten in the previous patch).

----

Better yet would be the following (I did not do this in the patch): Swap mouse-2
and mouse-3, and swap the scroll directions.

For the current node:
. mouse-1: Info-mouse-scroll-down
. mouse-2: Info-mouse-scroll-up
. mouse-3: breadcrumbs menu

For ancestor nodes:
. mouse-1: go to clicked node
. mouse-2: go to clicked node
. mouse-3: breadcrumbs menu

That would be better for these reasons:

1. mouse-1 and mouse-2 both go to the clicked ancestor node, just as they both
follow links (by default).

2. mouse-1 is to the left of mouse-2, so mouse-1 should move left and mouse-2
right. It is perverse to cross these directions. See bug #5841.

3. mouse-3 as a menu is very common outside Emacs and not unexpected for lots of
users. mouse-2 (in Emacs and outside it) is rarely used for a menu.

[-- Attachment #2: info-2010-04-06.patch --]
[-- Type: application/octet-stream, Size: 10692 bytes --]

diff -cw info-BZR-2010-04-05.el info-patched-2010-04-06.el
*** info-BZR-2010-04-05.el	Mon Apr  5 07:48:52 2010
--- info-patched-2010-04-06.el	Tue Apr  6 09:04:46 2010
***************
*** 240,245 ****
--- 240,248 ----
  0 means do not display breadcrumbs."
    :type 'integer)
  
+ (defvar Info-breadcrumbs-depth-internal Info-breadcrumbs-depth
+   "Current breadcrumbs depth for Info.")
+ 
  (defcustom Info-search-whitespace-regexp "\\s-+"
    "If non-nil, regular expression to match a sequence of whitespace chars.
  This applies to Info search for regular expressions.
***************
*** 1053,1061 ****
  	    (Info-select-node)
  	    (goto-char (point-min))
  	    (forward-line 1)		       ; skip header line
- 	    (when (> Info-breadcrumbs-depth 0) ; skip breadcrumbs line
- 	      (forward-line 1))
- 
  	    (cond (anchorpos
                     (let ((new-history (list Info-current-file
                                              (substring-no-properties nodename))))
--- 1056,1061 ----
***************
*** 1076,1082 ****
          (let ((hist (car Info-history)))
            (setq Info-history (cdr Info-history))
            (Info-find-node (nth 0 hist) (nth 1 hist) t)
!           (goto-char (nth 2 hist))))))
  
  ;; Cache the contents of the (virtual) dir file, once we have merged
  ;; it for the first time, so we can save time subsequently.
--- 1076,1083 ----
          (let ((hist (car Info-history)))
            (setq Info-history (cdr Info-history))
            (Info-find-node (nth 0 hist) (nth 1 hist) t)
!           (goto-char (nth 2 hist)))))
!   (if Info-breadcrumbs-mode (Info-insert-breadcrumbs) (Info-set-mode-line)))
  
  ;; Cache the contents of the (virtual) dir file, once we have merged
  ;; it for the first time, so we can save time subsequently.
***************
*** 3690,3695 ****
--- 3691,3698 ----
      :help "Go to final node in this file"]
     ("Menu Item" ["You should never see this" report-emacs-bug t])
     ("Reference" ["You should never see this" report-emacs-bug t])
+    ["Toggle Breadcrumbs" Info-breadcrumbs-mode
+     :help "Toggle showing breadcrumbs in the mode line"]
     ["Search..." Info-search
      :help "Search for regular expression in this Info file"]
     ["Search Next" Info-search-next
***************
*** 4196,4237 ****
    (let ((nodes (Info-toc-nodes Info-current-file))
  	(node Info-current-node)
          (crumbs ())
!         (depth Info-breadcrumbs-depth))
! 
      ;; Get ancestors from the cached parent-children node info
      (while (and (not (equal "Top" node)) (> depth 0))
        (setq node (nth 1 (assoc node nodes)))
!       (if node (push node crumbs))
        (setq depth (1- depth)))
- 
      ;; Add bottom node.
!     (when Info-use-header-line
!       ;; Let it disappear if crumbs is nil.
!       (nconc crumbs (list Info-current-node)))
!     (when (or Info-use-header-line crumbs)
        ;; Add top node (and continuation if needed).
!       (setq crumbs
! 	    (cons "Top" (if (member (pop crumbs) '(nil "Top"))
! 			    crumbs (cons nil crumbs))))
!       ;; Eliminate duplicate.
!       (forward-line 1)
        (dolist (node crumbs)
! 	(let ((text
! 	       (if (not (equal node "Top")) node
! 		 (format "(%s)Top"
  			 (if (stringp Info-current-file)
  			     (file-name-nondirectory Info-current-file)
  			   ;; Some legacy code can still use a symbol.
! 			   Info-current-file)))))
! 	  (insert (if (bolp) "" " > ")
! 		  (cond
! 		   ((null node) "...")
! 		   ((equal node Info-current-node)
! 		    ;; No point linking to ourselves.
! 		    (propertize text 'font-lock-face 'info-header-node))
! 		   (t
! 		    (concat "*Note " text "::"))))))
!       (insert "\n"))))
  
  (defun Info-fontify-node ()
    "Fontify the node."
--- 4199,4286 ----
    (let ((nodes   (Info-toc-nodes Info-current-file))
  	(node    Info-current-node)
          (crumbs  ())
!         (depth   Info-breadcrumbs-depth-internal)
!         (text    ""))
      ;; Get ancestors from the cached parent-children node info
      (while (and (not (equal "Top" node)) (> depth 0))
        (setq node  (nth 1 (assoc node nodes)))
!       (when node (push node crumbs))
        (setq depth  (1- depth)))
      ;; Add bottom node.
!     (setq crumbs  (nconc crumbs (list Info-current-node)))
!     (when crumbs
        ;; Add top node (and continuation if needed).
!       (setq crumbs  (cons "Top" (if (member (pop crumbs) '(nil "Top"))
!                                     crumbs
!                                   (cons nil crumbs))))
        (dolist (node  crumbs)
!         (let ((crumbs-map  (make-sparse-keymap))
!               (menu-map    (make-sparse-keymap "Breadcrumbs")))
!           (define-key crumbs-map [mode-line mouse-2] menu-map)
!           (when node
!             (define-key menu-map [Info-prev]
!               `(menu-item "Previous Node" Info-prev
!                           :visible ,(Info-check-pointer "prev[ious]*")
!                           :help "Go to the previous node"))
!             (define-key menu-map [Info-next]
!               `(menu-item "Next Node" Info-next
!                           :visible ,(Info-check-pointer "next")
!                           :help "Go to the next node"))
!             (define-key menu-map [separator] '("--"))
!             (define-key menu-map [Info-breadcrumbs-mode]
!               `(menu-item "Toggle Breadcrumbs" Info-breadcrumbs-mode
!                           :help "Toggle displaying breadcrumbs in the Info mode-line"
!                           :button (:toggle . Info-breadcrumbs-mode)))
!             (define-key menu-map [Info-set-breadcrumbs-depth]
!               `(menu-item "Set Breadcrumbs Depth" Info-set-breadcrumbs-depth
!                           :help "Set depth of breadcrumbs to show in the mode-line"))
!             (setq node  (if (equal node Info-current-node)
!                             (propertize (replace-regexp-in-string "%" "%%" Info-current-node)
!                                         'face 'mode-line-buffer-id
!                                         'help-echo "mouse-1: scroll forward, mouse-2: menu, mouse-3: scroll back"
!                                         'mouse-face 'mode-line-highlight
!                                         'local-map
!                                         (progn
!                                           (define-key crumbs-map [mode-line mouse-1] 'Info-mouse-scroll-up)
!                                           (define-key crumbs-map [mode-line mouse-3] 'Info-mouse-scroll-down)
!                                           crumbs-map))
!                           (propertize node
!                                       'local-map (progn
!                                                    (define-key crumbs-map [mode-line mouse-1]
!                                                      `(lambda () (interactive) (Info-goto-node ,node)))
!                                                    (define-key crumbs-map [mode-line mouse-3]
!                                                      `(lambda () (interactive) (Info-goto-node ,node)))
!                                                    crumbs-map)
!                                       'mouse-face 'mode-line-highlight
!                                       'help-echo "mouse-1, mouse-3: Go to this node; mouse-2: Menu")))))
! 	(let ((nodetext  (if (not (equal node "Top"))
!                              node
!                            (concat (format "(%s)"
                                             (if (stringp Info-current-file)
                                                 (file-name-nondirectory Info-current-file)
                                               ;; Some legacy code can still use a symbol.
!                                              Info-current-file))
!                                    node))))
!           (setq text  (concat text (if (equal node "Top") "" " > ") (if node nodetext "...")))))
!       (make-local-variable 'mode-line-format) ; Needed for Emacs 21+.
!       (setq mode-line-format  text))))
! 
! (define-minor-mode Info-breadcrumbs-mode
!     "Toggle the use of breadcrumbs in Info mode line.
! With arg, show breadcrumbs iff arg is positive."
!   :group 'mode-line :group 'info
!   (if (not Info-breadcrumbs-mode)
!       (setq Info-breadcrumbs-depth-internal  0
!             mode-line-format                 default-mode-line-format)
!     (setq Info-breadcrumbs-depth-internal  Info-breadcrumbs-depth)
!     (Info-insert-breadcrumbs)))
! 
! (defun Info-set-breadcrumbs-depth ()
!   "Set current breadcrumbs depth to a value read from user."
!   (interactive)
!   (setq Info-breadcrumbs-depth-internal  (read-number "New breadcrumbs depth: "
!                                                       Info-breadcrumbs-depth-internal))
!   (Info-insert-breadcrumbs))
  
  (defun Info-fontify-node ()
    "Fontify the node."
***************
*** 4278,4286 ****
  		((string-equal (downcase tag) "next") Info-next-link-keymap)
  		((string-equal (downcase tag) "up"  ) Info-up-link-keymap))))))
  
-         (when (> Info-breadcrumbs-depth 0)
-           (Info-insert-breadcrumbs))
- 
          ;; Treat header line.
          (when Info-use-header-line
            (goto-char (point-min))
--- 4327,4332 ----
***************
*** 4307,4321 ****
  				"%"
  				;; 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.
!             (cond
!              ((> Info-breadcrumbs-depth 0)
!               (put-text-property (point-min) (1+ header-end) 'invisible t))
!              ((not (bobp))
                ;; Hide the punctuation at the end, too.
                (skip-chars-backward " \t,")
!               (put-text-property (point) header-end 'invisible t))))))
  
        ;; Fontify titles
        (goto-char (point-min))
--- 4353,4363 ----
  				"%"
  				;; 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.
              ;; Hide the punctuation at the end, too.
+             (unless (bobp)
                (skip-chars-backward " \t,")
!               (put-text-property (point) header-end 'invisible t)))))
  
        ;; Fontify titles
        (goto-char (point-min))

Diff finished.  Tue Apr 06 09:10:17 2010

  reply	other threads:[~2010-04-06 17:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31  9:58 bug#5809: 23.1.94; cross-reference by anchor yields in accurate position Eli Zaretskii
2010-03-31 11:17 ` Eli Zaretskii
2010-03-31 15:08 ` Juri Linkov
2010-03-31 15:55   ` Eli Zaretskii
2010-04-01 18:06     ` Juri Linkov
2010-04-01 18:13       ` Eli Zaretskii
2010-04-01 18:30         ` Juri Linkov
2010-04-01 20:22           ` Eli Zaretskii
2010-04-01 20:49             ` Eli Zaretskii
2010-04-01 21:10               ` Juri Linkov
2010-04-01 22:16               ` Stefan Monnier
2010-04-02  7:07                 ` Eli Zaretskii
2010-04-02 14:17                   ` Drew Adams
2010-04-02 14:39                     ` Eli Zaretskii
2010-04-02 15:26                       ` Drew Adams
2010-04-04 20:39                         ` Drew Adams
2010-04-04 20:47                           ` Eli Zaretskii
2010-04-04 22:51                             ` Drew Adams
2010-04-04 23:58                               ` Juri Linkov
2010-04-05  7:01                                 ` Drew Adams
2010-04-05 16:42                                   ` Juri Linkov
2010-04-05 20:11                                     ` Stefan Monnier
2010-04-05 23:17                                       ` Drew Adams
2010-04-06  5:49                                         ` Drew Adams
2010-04-06 17:46                                           ` Drew Adams [this message]
2010-04-05 16:45                               ` Juri Linkov
2010-04-05 17:12                                 ` Drew Adams
2010-04-05 21:55                                 ` Eli Zaretskii
2010-04-05  6:38                   ` Drew Adams
2010-04-02 16:14                 ` Juri Linkov
2010-04-02 16:31                   ` Drew Adams
2010-04-02 17:41                   ` Eli Zaretskii
2010-04-02 18:01                   ` Stefan Monnier
2010-04-02 23:11                     ` Juri Linkov
2010-04-03 22:04                       ` Juri Linkov
2010-04-04  6:12                         ` Eli Zaretskii
2010-04-04 11:07                           ` Juri Linkov
2010-04-04 12:12                             ` Eli Zaretskii
2010-04-04 23:51                               ` Juri Linkov
2010-04-05  5:26                                 ` Eli Zaretskii
2010-04-04 14:31                         ` Stefan Monnier
2010-04-04 23:52                           ` Juri Linkov
2010-04-05  2:06                             ` Stefan Monnier
2010-04-05 16:50                               ` Juri Linkov
2010-04-05 20:09                                 ` Stefan Monnier
2010-04-05 22:17                                   ` Juri Linkov
2010-04-01 21:09             ` Juri Linkov
2010-04-02 18:03               ` Stefan Monnier
2010-04-25 18:28 ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FD8E19BDC6A54540B65D432CDC5C81F7@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=5809@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@jurta.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).