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: Mon, 5 Apr 2010 16:17:04 -0700	[thread overview]
Message-ID: <BA7BB62BFF2C4334B3E271BD406FC7C7@us.oracle.com> (raw)
In-Reply-To: <jwvy6h11x0e.fsf-monnier+emacs@gnu.org>

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

OK, FWIW, here's another idea. This doesn't respond to a general need for
multi-line headers or multiple headers or any of the other things discussed so
far. This is just an alternative breadcrumbs approach for Info.

The idea is to use the mode line, not a header line, for breadcrumbs. Please try
the attached patch, which is against info.el from today (it also works fine
against the 95 pretest). It will take you only a moment to try.

By default (in this patch at least) breadcrumbs are turned off. You can turn
them on using `Info-breadcrumbs-mode', which is in the Info menu as `Toggle
Breadcrumbs'. (That menu is of course also on the `Info' minor-mode lighter in
the mode line.)

When breadcrumbs are shown, they are all that is shown in the mode line. Mouse-2
on a node of the breadcrumbs path takes you to that node. Mouse-1 anywhere on
the breadcrumbs brings up a `Breadcrumbs' menu, with these items:

 Set Breadcrumbs Depth
 Toggle Breadcrumbs
 Previous Node
 Next Node

The previous and next items are there only when there is really a previous or
next node. Setting the depth here (first menu item) does not change the value of
option `Info-breadcrumbs-depth'.

It's pretty simple - give it a try; you might like it. The mode line, like the
header line, is always handy - no need to scroll.

A possible change: Add a menu item `Customize Breadcrumbs Depth' for customizing
`Info-breadcrumbs-depth', the default depth.

Another possible change: Put back the size indication mode when breadcrumbs are
shown. I don't miss it (the scroll bar is enough), but you might want it. There
is probably room for it, even for manuals that have several levels and long node
names.

Another possible change: put back the read-only/writable indicator. Or perhaps
just turn off breadcrumbs mode whenever someone edits an Info node.

I don't think you'll miss any of the other stuff that is normally in the mode
line. I don't.

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

diff -cw info-BZR-2010-04-05.el info-patched-2010-04-05.el
*** info-BZR-2010-04-05.el	Mon Apr  5 07:48:52 2010
--- info-patched-2010-04-05.el	Mon Apr  5 15:41:04 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,4275 ----
    (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)
!         (when node
!           (setq node                    ; Breadcrumbs map
!                 (propertize node
!                             'local-map (let ((map       (make-sparse-keymap))
!                                              (menu-map  (make-sparse-keymap "Breadcrumbs")))
!                                          (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"))
!                                          (define-key map [mode-line down-mouse-1] menu-map)
!                                          (define-key map [mode-line down-mouse-2]
!                                            `(lambda () (interactive) (Info-goto-node ,node)))
!                                          map)
!                             'help-echo (concat "mouse-1: Menu"
!                                                (if (equal node Info-current-node)"" ", mouse-2: Go to this node")))))
! 	(let ((nodetext  (if (not (equal node "Top"))
!                              node
!                            (format "(%s)%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))
--- 4316,4321 ----
***************
*** 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))
--- 4342,4352 ----
  				"%"
  				;; 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.  Mon Apr 05 15:41:59 2010

  reply	other threads:[~2010-04-05 23:17 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 [this message]
2010-04-06  5:49                                         ` Drew Adams
2010-04-06 17:46                                           ` Drew Adams
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=BA7BB62BFF2C4334B3E271BD406FC7C7@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).