From xemacs-m  Wed Aug  6 20:40:56 1997
Received: from bittersweet.inetarena.com (karlheg@bittersweet.inetarena.com [206.129.216.38])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id UAA27561
	for <xemacs-beta@xemacs.org>; Wed, 6 Aug 1997 20:40:52 -0500 (CDT)
Received: (from karlheg@localhost)
	by bittersweet.inetarena.com (8.8.6/8.8.6/Debian/GNU) id SAA25150;
	Wed, 6 Aug 1997 18:40:59 -0700
To: XEmacs Beta <xemacs-beta@xemacs.org>
Subject: [patch] `man.el'
X-Face: /Q}=yl}1_v7nP)xXo5XjG8+tl@=uVu7o5u6)f]zN?+<hB!K.m9:[|*p34jVN`O;:XZXVSy>/\R>qDt(t8w!-i{(y0"`jFw^uk8inzO9wXabd'CdjUWfC\GHi:6nO*YC89#-qD>Q4r%9!V"<RYJ=7D#$";q=zML5'!=wvXk^$`6FT=5CMofQX)WUKt0p:OKl.mFOXx/D
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Aug__6_18:40:55_1997-1"
Content-Transfer-Encoding: 7bit
From: karlheg+xemacs@inetarena.com (Karl M. Hegbloom)
Date: 06 Aug 1997 18:40:55 -0700
Message-ID: <87rac6n520.fsf@bittersweet.inetarena.com>
Lines: 311
X-Mailer: Gnus v5.4.64/XEmacs 20.3(beta16) - "Budapest"

--Multipart_Wed_Aug__6_18:40:55_1997-1
Content-Type: text/plain; charset=US-ASCII

 I plan to do some more with `man.el'.  I think it should have its own
toolbar, and better prev/next handling, like a WWW browser's or Info.
I would also like to add support for `zgrep', `rel' and/or `glimpse'
searches.  (Info could benefit from that too, perhaps.)

 I'm finding that manual pages look a lot better without `rman'
(Rosetta man), but take longer to process.  On an i486DX33 or
something, you'd not want to be without `rman'.  I think most of us
have fast enough computers to work without it, just to get nicer
font-locking and _better_hyphenation_.



--Multipart_Wed_Aug__6_18:40:55_1997-1
Content-Type: text/plain; charset=US-ASCII

1997-08-06  Karl M. Hegbloom  <karlheg@inetarena.com>

	* packages/man.el: Several modifications
	
		* (manual-entry) buffers are named without *'s, when
 		`buffers-menu-submenus-for-groups-p' is t, so they show up
 		in a subsection of the Buffer's menu now, rather than
 		lumped under *Misc*.
	
		* (Manual-mode) added a local `kill-buffer-hook' to remove
 		a killed manual from the `Manual-page-history'

		* (Manual-last-page) begun rewrite of manuvering and
 		viewing mode code
	
		* (Manual-mouseify-xrefs) hyphenated xrefs are highlighted
 		now, and properly handled when the second line is
 		indented.  They end up on the menus too.
	
		* (Manual-popup-menu) made the far button popup menus look
 		better by removing the prefix string and adding a title.


--Multipart_Wed_Aug__6_18:40:55_1997-1
Content-Type: text/plain; charset=US-ASCII

Index: lisp/packages/man.el
===================================================================
RCS file: /usr/local/cvsroot/xemacs-20/lisp/packages/man.el,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 man.el
--- man.el	1997/07/14 03:11:39	1.1.1.2
+++ man.el	1997/08/07 01:33:06
@@ -1,7 +1,7 @@
 ;;; man.el --- browse UNIX manual pages
 ;; Keywords: help
 
-;; Copyright (C) 1985, 1993, 1994, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
 ;;
 ;; This file is part of XEmacs.
 
@@ -180,34 +180,36 @@
 			nil 'Manual-page-minibuffer-history)))
 	   (if (equal thing "") default thing))
 	 (prefix-numeric-value current-prefix-arg)))
-  ;;(interactive "sManual entry (topic): \np")
   (or arg (setq arg 1))
   (let (section apropos-mode)
     (let ((case-fold-search nil))
       (if (and (null section)
 	       (string-match "\\`[ \t]*\\([^( \t]+\\)[ \t]*(\\(.+\\))[ \t]*\\'"
 			     topic))
-	  (setq section (substring topic (match-beginning 2)
-				   (match-end 2))
-		topic (substring topic (match-beginning 1)
-				 (match-end 1)))
+	  (setq section (match-string 2 topic)
+		topic (match-string 1 topic))
 	(if (string-match "\\`[ \t]*-k[ \t]+\\([^ \t]+\\)\\'" topic)
 	    (setq section "-k"
-		  topic (substring topic (match-beginning 1))))))
+		  topic (match-string 1 topic)))))
 
     (when Manual-snip-subchapter
       ;; jwz: turn section "3x11" and "3n" into "3".
       (if (and section (string-match "\\`\\([0-9]+\\)[^0-9]" section))
-	  (setq section (substring section 0 (match-end 1)))))
+	  (setq section (match-string 1 section))))
+
     (if (equal section "-k")
 	(setq apropos-mode t))
 
-    (let ((bufname (cond (apropos-mode
-			  (concat "*man apropos " topic "*"))
-			 (t
-			  (concat "*man " topic
-				  (if section (concat "." section) "")
-				  "*"))))
+    (let ((bufname (flet ((maybe-star ()
+			    (if buffers-menu-submenus-for-groups-p
+				""
+			      "*")))
+		     (if apropos-mode
+			 (concat (maybe-star) "man apropos " topic (maybe-star))
+		       (concat (maybe-star)
+			       topic
+			       (if section (concat "(" section ")") "")
+			       (maybe-star)))))
 	  (temp-buffer-show-function 
 	   (cond ((eq 't Manual-buffer-view-mode)
 		  'view-buffer)
@@ -255,15 +257,23 @@
 
 		   (message "%s (cleaning...)" args-string)
 		   (Manual-nuke-nroff-bs apropos-mode)
-		   (message "%s (done.)" args-string)
-		   )
-
+		   (message "%s (done.)" args-string))
 		 (set-buffer-modified-p nil)
-		 (Manual-mode)
-		 ))))
-      (setq Manual-page-history
-	    (cons (buffer-name)
-		  (delete (buffer-name) Manual-page-history)))))
+		 (Manual-mode)))))
+
+      (let ((page (flet ((maybe-star ()
+			   (if buffers-menu-submenus-for-groups-p
+			       ""
+			     "*")))
+		    (if section
+			(concat (maybe-star) topic "(" section ")" (maybe-star))
+		      topic))))
+	(setq Manual-page-history
+	      (cons (buffer-name)
+		    (delete (buffer-name) Manual-page-history))
+	      Manual-page-minibuffer-history
+	      (cons page (delete page Manual-page-minibuffer-history))))))
+
   (message nil)
   t)
 
@@ -280,15 +290,24 @@
   ;; turn off horizontal scrollbars in this buffer
   (when (featurep 'scrollbar)
     (set-specifier scrollbar-height (cons (current-buffer) 0)))
+  (make-local-hook 'kill-buffer-hook)
+  (add-hook 'kill-buffer-hook #'(lambda ()
+				  (setq Manual-page-history
+					(delete (buffer-name)
+						Manual-page-history)))
+	    nil t)
   (run-hooks 'Manual-mode-hook))
 
 (defun Manual-last-page ()
   (interactive)
-  (while (or (not (get-buffer (car (or Manual-page-history
-				       (error "No more history.")))))
-	     (eq (get-buffer (car Manual-page-history)) (current-buffer)))
-    (setq Manual-page-history (cdr Manual-page-history)))
-  (switch-to-buffer (car Manual-page-history)))
+  (if Manual-page-history
+      (let ((page (pop Manual-page-history)))
+	(if page
+	    (progn
+	      (get-buffer page)
+	      (cons Manual-page-history page)
+	      (switch-to-buffer page))))
+    (error "No manual page buffers found. Use `M-x manual-entry'")))
 
 
 (defmacro Manual-delete-char (n)
@@ -394,6 +413,7 @@
 
 
 (defun Manual-nuke-nroff-bs-footers ()
+  "For info see comments in packages/man.el"
   ;; Nuke headers and footers.
   ;;
   ;; nroff assumes pages are 66 lines high.  We assume that, and that the
@@ -492,7 +512,7 @@
 (defun Manual-mouseify-xrefs ()
   (goto-char (point-min))
   (let ((case-fold-search nil)
-	s e name extent)
+	s e name splitp extent)
     ;; possibly it would be faster to rewrite this expression to search for
     ;; a less common sequence first (like "([0-9]") and then back up to see
     ;; if it's really a match.  This function is 15% of the total time, 13%
@@ -501,29 +521,49 @@
 			      nil t)
       (setq s (match-beginning 0)
 	    e (match-end 0)
-	    name (buffer-substring s e))
+	    name (buffer-substring s e)
+	    splitp nil)
+
       (goto-char s)
-      (skip-chars-backward " \t")
-      (if (and (bolp) (not (bobp))
-	       (progn (backward-char 1) (equal (char-before) ?-)))
-	  (progn
-	    (setq s (point))
-	    (skip-chars-backward "-a-zA-Z0-9_.:")
-	    (setq name (concat (buffer-substring (point)
-						 (if (>= s 0)
-						     (1- s)
-						   0))
-			       name))
-	    (setq s (point))))
+      ;; if this is a hyphenated xref, we're on the second line, 1st char now.
+
+      (when (progn
+	      (beginning-of-line)
+	      (and (looking-at (concat "^[ \t]+" (regexp-quote name)))
+		   (progn
+		     (backward-char 1)
+		     (or (equal (char-before) ?-)
+			 (equal (char-before) ?\255)))
+		   (setq s (progn
+			     (skip-chars-backward "-\255_a-zA-Z0-9")
+			     (point))
+			 name (buffer-substring s e))))
+	(setq splitp t)
+	;; delete the spaces and dash from `name'
+	(let (i)
+	  (while (setq i (string-match "[-\255 \n\t]+" name i))
+	    (setq name (concat (substring name 0 i)
+			       (substring name (match-end 0)))
+		  i (1+ i)))))
+
       ;; if there are upper case letters in the section, downcase them.
       (if (string-match "(.*[A-Z]+.*)$" name)
 	  (setq name (concat (substring name 0 (match-beginning 0))
 			     (downcase (substring name (match-beginning 0))))))
-      ;; (setq already-fontified (extent-at s))
-      (setq extent (make-extent s e))
+
+      ;; if the xref was hyphenated, don't highlight the indention spaces.
+      (if splitp
+	  (progn
+	    (setq extent (make-extent s (progn (goto-char s) (end-of-line) (point))))
+	    (set-extent-property extent 'man (list 'Manual-follow-xref name))
+	    (set-extent-property extent 'highlight t)
+	    (set-extent-face extent 'man-xref)
+	    (goto-char e)
+	    (skip-chars-backward "-_a-zA-Z0-9()")
+	    (setq extent (make-extent (point) e)))
+	(setq extent (make-extent s e)))
       (set-extent-property extent 'man (list 'Manual-follow-xref name))
       (set-extent-property extent 'highlight t)
-      ;; (if (not already-fontified)...
       (set-extent-face extent 'man-xref)
       (goto-char e))))
 
@@ -561,7 +601,6 @@
   (interactive "e")
   (let ((buffer (current-buffer))
 	(sep "---")
-	(prefix "Show Manual Page for ")
 	xref items)
     (cond (event
 	   (setq buffer (event-buffer event))
@@ -579,13 +618,14 @@
 		    nil))
 		 buffer)
     (if (eq sep (car items)) (setq items (cdr items)))
-    (let ((popup-menu-titles nil))
+    (let ((popup-menu-titles t))
+      (and (null items) (setq popup-menu-titles nil))
       (popup-menu
        (cons "Manual Entry"
 	     (mapcar #'(lambda (item)
 			 (if (eq item sep)
 			     item
-                           (vector (concat prefix item)
+                           (vector item
                                    (list 'Manual-follow-xref item) t)))
 		     (nreverse items)))))))
 
@@ -606,9 +646,15 @@
 		  (setq manpage (buffer-substring (match-beginning 1)
 						  (match-end 1)))
 		(setq manpage "???"))
-	      (setq buffer
-		    (rename-buffer
-		     (generate-new-buffer-name (concat "*man " manpage "*"))))
+	      (flet ((maybe-star ()
+		       (if buffers-menu-submenus-for-groups-p
+			   "*"
+			 "")))
+		(setq buffer
+		      (rename-buffer
+		       (generate-new-buffer-name (concat (maybe-star)
+							 manpage
+							 (maybe-star))))))
 	      (setq buffer-file-name nil)
 	      (goto-char (point-min))
 	      (insert (format "%s\n" buf-name))


--Multipart_Wed_Aug__6_18:40:55_1997-1
Content-Type: text/plain; charset=US-ASCII

mailto:karlheg+sig@inetarena.com (Karl M. Hegbloom)
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.3  Linux 2.0.30+parport AMD K5 PR-133

--Multipart_Wed_Aug__6_18:40:55_1997-1--

