🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #1232

mouse bindings for info

#1232
From: Brian L. Kahn
Date: Wed, 17 Jun 1992 17:38
96 lines
3629 bytes
There are other mouse bindings and enhancements for info mode.  This
one works really well for me, and it has been stable for a while.

Basically, clicking with the middle button on a menu item or cross
reference takes you to that place.  Clicking on one of the header
things (next, prev, up) takes you to the node.


---------snip snip-------------------

;;; info-mode mouse bindings for epoch
;;; Brian L. Kahn, blk@mitre.org, Tue Jun  9 12:53:52 1992


(defun Info-remove-cr (string)
  "Replaces newline in STRING with a space."
  (mapconcat 
   (function (lambda (x) 
	       (char-to-string (if (char-equal x ?\n) ?  x))))
   string 
   ""))

  
(defun x-Info-select (args)
  "Selects menu item, follows *Note: reference, Up/Next/Prev/File."
  (mouse::set-point args)
  (cond ; check if line 1 or menu area or main text
   ((save-excursion (not (re-search-backward "$" nil t)))
    ;; we are on the first line
    (if (not (re-search-backward "[, ] " nil t))
	;; back up to last field or margin
	(beginning-of-line))
    ;; onto field name
    (re-search-forward "\\<" nil t)
    (cond ((looking-at "Up") (Info-up))
	  ((looking-at "Next") (Info-next))
	  ((looking-at "Prev") (Info-prev))
	  ((looking-at "Node") (Info-goto-node "Top"))
	  ((looking-at "File") (Info-directory))
	  ))
   ((save-excursion (re-search-backward "^\* Menu:" nil t))
    ;; we are in the menu area
    (end-of-line) ; limit of node name search
    (push-mark (point))
    (re-search-backward "^\*")
    (cond
     ((save-excursion (re-search-forward "::\\s-" (mark) 'no-err))
      ;; node name is first
      (re-search-forward "^\\*\\s-*\\(.*\\)::\\s-" (mark))
      )
     ((save-excursion (re-search-forward ":\\s-" (mark) 'no-err))
      ;; node name comes second
      (re-search-forward ":\\s-*\\([^.]*\\)" (mark))
      )
     (t (error "Unrecognized menu format.")
	))
    (Info-goto-node 
     (buffer-substring (match-beginning 1) (match-end 1))
     )
    (pop-mark)
    )
   (t
    ;; in main text, look for footnote
    (forward-word 1) ; in case mouse is on the word "*note"
    (if (not (re-search-backward "\*note" nil t))
	(error "Can't find a menu item or footnote."))
    (forward-word 2)
    (forward-word -1)
    (re-search-forward "[^:]*" nil t)
    (Info-follow-reference 
     (Info-remove-cr
      (buffer-substring (match-beginning 0) (match-end 0)))))
   ))


;;; Info doesn't call an info mode hook - fix that!
(require 'info)
(defvar Info-mode-orig (symbol-function 'Info-mode))
(defun Info-mode ()
  "Info mode with Info-mode-hook."
  (funcall Info-mode-orig)
  (run-hooks 'Info-mode-hook)
  )


(setq Info-mode-hook
      (func
       (local-set-mouse mouse-middle mouse-down 'x-Info-select)
       (local-set-mouse mouse-middle mouse-up ())
       (message
	"[middle]-Go to menu item, follow reference, File/Next/Prev/Up.")))


--
B<   Brian Kahn   blk@security.mitre.org   "may the farce be with you"
Technical Details
Message-ID: <BLK.92Jun17123845@vanity.mitre.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!mips!spool.mu.edu!agate!linus!linus.mitre.org!news!mbunix!blk

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,69f29a8749b027f9,start
X-Google-Attributes: gidfc7ee,public
X-Google-ArrivalTime: 1992-06-17 04:15:38 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!mips!spool.mu.edu!agate!linus!linus.mitre.org!news!mbunix!blk
From: blk@mitre.org (Brian L. Kahn)
Newsgroups: gnu.epoch.misc
Subject: mouse bindings for info
Message-ID: <BLK.92Jun17123845@vanity.mitre.org>
Date: 17 Jun 92 17:38:45 GMT
Sender: news@linus.mitre.org (News Service)
Distribution: gnu
Organization: The MITRE Corp. Bedford, MA
Lines: 96
Nntp-Posting-Host: vanity.mitre.org