From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#5809: 23.1.94; cross-reference by anchor yields in accurate position Date: Sun, 04 Apr 2010 01:04:45 +0300 Organization: JURTA Message-ID: <878w94dxf2.fsf@mail.jurta.org> References: <837hoszubi.fsf@gnu.org> <87hbnwy2un.fsf@mail.jurta.org> <83y6h8xz8a.fsf@gnu.org> <8739zf5bif.fsf@mail.jurta.org> <83y6h7vy6p.fsf@gnu.org> <87y6h7uitd.fsf@mail.jurta.org> <83wrwqx6r2.fsf@gnu.org> <83vdcax5hu.fsf@gnu.org> <87d3yi85sv.fsf@mail.jurta.org> <87eiix5u1a.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1270333571 7440 80.91.229.12 (3 Apr 2010 22:26:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 3 Apr 2010 22:26:11 +0000 (UTC) Cc: 5809@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 04 00:26:07 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NyBn4-0001g9-Mt for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Apr 2010 00:26:07 +0200 Original-Received: from localhost ([127.0.0.1]:58295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NyBn3-0003ZJ-Ja for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Apr 2010 18:26:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NyBmx-0003Z1-JO for bug-gnu-emacs@gnu.org; Sat, 03 Apr 2010 18:25:59 -0400 Original-Received: from [140.186.70.92] (port=60318 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NyBmv-0003Yj-2f for bug-gnu-emacs@gnu.org; Sat, 03 Apr 2010 18:25:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NyBmt-0002Lg-7h for bug-gnu-emacs@gnu.org; Sat, 03 Apr 2010 18:25:56 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49693) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NyBms-0002LZ-MX for bug-gnu-emacs@gnu.org; Sat, 03 Apr 2010 18:25:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NyBk6-00006K-7S; Sat, 03 Apr 2010 18:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Apr 2010 22:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5809 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5809-submit@debbugs.gnu.org id=B5809.1270333344374 (code B ref 5809); Sat, 03 Apr 2010 22:23:02 +0000 Original-Received: (at 5809) by debbugs.gnu.org; 3 Apr 2010 22:22:24 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NyBjU-00005y-1Y for submit@debbugs.gnu.org; Sat, 03 Apr 2010 18:22:24 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NyBjR-00005o-K0 for 5809@debbugs.gnu.org; Sat, 03 Apr 2010 18:22:22 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.28.129.cable.starman.ee [82.131.28.129]) by mx1.starman.ee (Postfix) with ESMTP id A9A443F40A1; Sun, 4 Apr 2010 01:22:11 +0300 (EEST) In-Reply-To: <87eiix5u1a.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 03 Apr 2010 02:11:45 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 03 Apr 2010 18:23:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:35902 Archived-At: >> IOW, using an after-string would probably be an OK compromise for 23.2 >> (better than dropping breadcrumbs altogether). > > I'll try to implement an after-string for 23.2. To be able to click on links that are not part of the Info file and don't have the "*Note" format, this patch adds two new commands `Info-mouse-follow-link' and `Info-follow-link' plus a new keymap `Info-link-keymap' (it's like `Info-up-link-keymap' and friends). `Info-insert-breadcrumbs' is renamed to `Info-breadcrumbs' that returns a string with links. There are still a problem. I can't find a way to move the cursor inside the overlay's after-string and click links inside it. Any suggestions? === modified file 'lisp/info.el' --- lisp/info.el 2010-03-03 19:23:20 +0000 +++ lisp/info.el 2010-04-03 22:03:23 +0000 @@ -1053,8 +1053,6 @@ (defun Info-find-node-2 (filename nodena (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 @@ -3551,6 +3549,20 @@ (defun Info-try-follow-nearest-node (&op ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) (Info-goto-node node fork))) node)) + +(defun Info-mouse-follow-link (click) + "Follow a link under point." + (interactive "e") + (mouse-set-point click) + (Info-follow-link)) + +(defun Info-follow-link () + "Follow a link under point." + (interactive) + (let ((link-args (get-text-property (point) 'link-args))) + (when link-args + (Info-goto-node link-args)))) + (defvar Info-mode-map (let ((map (make-keymap))) @@ -4141,11 +4153,23 @@ (defvar Info-up-link-keymap keymap) "Keymap to put on the Up link in the text or the header line.") -(defun Info-insert-breadcrumbs () +(defvar Info-link-keymap + (let ((keymap (make-sparse-keymap))) + (define-key keymap [header-line mouse-1] 'Info-mouse-follow-link) + (define-key keymap [header-line mouse-2] 'Info-mouse-follow-link) + (define-key keymap [header-line down-mouse-1] 'ignore) + (define-key keymap [mouse-2] 'Info-mouse-follow-link) + (define-key keymap [follow-link] 'mouse-face) + (define-key keymap "\r" 'Info-follow-link) + keymap) + "Keymap to put on the link in the text or the header line.") + +(defun Info-breadcrumbs () (let ((nodes (Info-toc-nodes Info-current-file)) (node Info-current-node) (crumbs ()) - (depth Info-breadcrumbs-depth)) + (depth Info-breadcrumbs-depth) + line) ;; Get ancestors from the cached parent-children node info (while (and (not (equal "Top" node)) (> depth 0)) @@ -4172,15 +4196,24 @@ (defun Info-insert-breadcrumbs () (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")))) + (setq line (concat + line + (if (null line) "" " > ") + (cond + ((null node) "...") + ((equal node Info-current-node) + ;; No point linking to ourselves. + (propertize text 'font-lock-face 'info-header-node)) + (t + (propertize text + 'mouse-face 'highlight + 'font-lock-face 'info-header-xref + 'help-echo "mouse-2: Go to node" + 'keymap Info-link-keymap + 'link-args text) + )))))) + (setq line (concat line "\n"))) + line)) (defun Info-fontify-node () "Fontify the node." @@ -4227,8 +4260,8 @@ (defun Info-fontify-node () ((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)) + ;; (when (> Info-breadcrumbs-depth 0) + ;; (insert (Info-breadcrumbs))) ;; Treat header line. (when Info-use-header-line @@ -4260,7 +4293,10 @@ (defun Info-fontify-node () ;; 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)) + (put-text-property (point-min) (1+ header-end) 'invisible t) + (overlay-put + (make-overlay header-end (1+ header-end)) + 'after-string (propertize (Info-breadcrumbs) 'cursor t))) ((not (bobp)) ;; Hide the punctuation at the end, too. (skip-chars-backward " \t,") -- Juri Linkov http://www.jurta.org/emacs/