From xemacs-m  Wed Feb 19 03:32:56 1997
Received: from minerva.tentstraat.nl (root@d06.din.cuci.nl [195.240.25.39])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id DAA27542
	for <xemacs-beta@xemacs.org>; Wed, 19 Feb 1997 03:32:52 -0600 (CST)
Received: (from hfranz@localhost) by minerva.tentstraat.nl (8.7.5/8.7.3) id KAA00709; Wed, 19 Feb 1997 10:23:59 +0100
Sender: hfranz@minerva.cuci.nl
To: Christopher Davis <ckd@loiosh.kei.com>
Cc: Holger Franz <hfranz@cuci.nl>, jens@lemming0.lem.uni-karlsruhe.de,
        xemacs-beta@xemacs.org
Subject: Re: Loose ends -- tm in-line image patch/fun with glyphs
References: <199702171850.NAA03658@spacely.icd.teradyne.com> <m3d8tzt733.fsf@jens.metrix.de> <m3iv3qidwb.fsf@minerva.tentstraat.nl> <w4914l7w1z.fsf@loiosh.kei.com>
From: Holger Franz <hfranz@cuci.nl>
In-Reply-To: Christopher Davis's message of 18 Feb 1997 14:28:56 -0500
Mime-Version: 1.0 (generated by tm-edit 7.101)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Feb_19_10:23:57_1997-1"
Content-Transfer-Encoding: 7bit
Date: 19 Feb 1997 10:23:57 +0100
Message-ID: <m320ad87yp.fsf@minerva.tentstraat.nl>
Lines: 113
X-Mailer: Gnus v5.4.12/XEmacs 20.1

--Multipart_Wed_Feb_19_10:23:57_1997-1
Content-Type: text/plain; charset=US-ASCII

>>>>> "Christopher" == Christopher Davis <ckd@loiosh.kei.com> writes:

 Christopher> I think this is skew between view-less.el and view.el.
 Christopher> view-prev-buffer is a view-less variable;
 Christopher> view-mode-enter is a view function.  Since view-less is
 Christopher> the "official" method for XEmacs, we should either put a
 Christopher> view-mode-enter into it, or use whatever functions it
 Christopher> wants (view-minor-mode, it looks like).

Yes, I understand now: 'view-minor-mode' does the same for 'view-less'
as 'view-mode-enter' for 'view'. XEmacs-20.1b1 autoloads
'view-mode-enter', XEmacs-19.14 does not so. Now which package should
we use? The comments in view.el say that we should use 'view-less', so
let's just use 'view-mode' from 'view-less' which is autoloaded
correctly on 19.14.

 Christopher> Please try these; I tried them in a vanilla (-q -l
 Christopher> test-viewimg.el) XEmacs and they seem to work well.
 Christopher> (However, I have no idea if they do colormaps right; I
 Christopher> don't use colormaps ever since I ran "netscape -install"
 Christopher> in front of the boss and he said "why are the colors
 Christopher> like that?" to which I responded "this display doesn't
 Christopher> have enough bit depth"...and he said "so upgrade it."
 Christopher> :-)

You lucky b******, I have been trying in vain to convince our system
administrator that a memory upgrade to 32MB is a Good Thing(TM).  

Try this:


--Multipart_Wed_Feb_19_10:23:57_1997-1
Content-Type: application/octet-stream; type=emacs-lisp
Content-Disposition: attachment; filename="view-image.el"
Content-Transfer-Encoding: 7bit

;;; view-image.el --- Minor mode for viewing images with keybindings like `less'

;; Author: Holger Franz <hfranz@cuci.nl>

;;; Commentary:

;; This mode is for browsing images without changing them.  It uses
;; 'view-mode' from the 'view-less' package as the actual minor mode.
;;
;; Code for using extents to hide the alphanumerical file contents
;; by Jens Lautenbacher <jens@lemming0.lem.uni-karlsruhe.de>
;;
;; If you would like all image files to be visited in view-image-mode, 
;; then add something like this to your .emacs file:
;;
;; (require 'view-image)
;; (setq auto-mode-alist (cons '("\\.\\(png\\|gif\\|jpg\\|xpm\\|xbm\\)$"
;;			      . view-image-mode) auto-mode-alist))
;; 
;; You can then use all the view-file-* commands to access image files
;; or just press 'v' in dired.

;;; Code:

(require 'view-less)

(defun view-image (file) "\
Interactively view image \"file\" in view-mode. \"q\" exits view-mode
and kills the buffer to free up colormap entries.
If you would like all image files to be visited in view-image-mode, 
then add something like this to your .emacs file:

(require 'view-image)
(setq auto-mode-alist (cons '(\"\\\\.\\\\(png\\\\|gif\\\\|jpg\\\\|xpm\\\\|xbm\\\\)$\"
     		      . view-image-mode) auto-mode-alist))

You can then use all the view-file-* commands to access image files or
just press 'v' in dired.
"
  (interactive "fFile: ")
  (let ((prev-buffer (current-buffer)))
	(switch-to-buffer (generate-new-buffer
			   (generate-new-buffer-name file)))
	(make-annotation 
	 (set-glyph-property (make-glyph-internal) 'image file) nil 'text)
	(view-mode prev-buffer '(lambda (buf) (kill-buffer buf)))))

(defun view-image-mode () "\
Display buffer contents as an inline glyph in view-mode.
\"q\" exits view-mode and kills the buffer to free up colormap entries."
  (interactive)
  (let ((file buffer-file-truename) ext)
    (require 'atomic-extents)
    (view-mode nil '(lambda (buf) (kill-buffer buf)
			    (garbage-collect)))
    (setq ext (make-extent 1 (point-max)))
    (set-extent-property ext 'invisible t)
    (set-extent-property ext 'atomic t)
    (set-extent-property (make-extent (point-max) (point-max))
			 'begin-glyph (make-glyph file))))

(provide 'view-image)


--Multipart_Wed_Feb_19_10:23:57_1997-1
Content-Type: text/plain; charset=US-ASCII



-- 
Holger Franz <hfranz@cuci.nl>
             <hfranz@physik.rwth-aachen.de>

--Multipart_Wed_Feb_19_10:23:57_1997-1--

