From xemacs-m  Tue Feb 18 13:30:09 1997
Received: from loiosh.kei.com (ckd@loiosh.kei.com [192.88.144.32])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id NAA00275
	for <xemacs-beta@xemacs.org>; Tue, 18 Feb 1997 13:30:07 -0600 (CST)
Received: (from ckd@localhost)
	by loiosh.kei.com (8.8.5/8.8.5) id OAA00636;
	Tue, 18 Feb 1997 14:28:56 -0500 (EST)
To: Holger Franz <hfranz@cuci.nl>
Cc: 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>
X-Attribution: ckd
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: text/plain; charset=US-ASCII
From: Christopher Davis <ckd@loiosh.kei.com>
Date: 18 Feb 1997 14:28:56 -0500
In-Reply-To: Holger Franz's message of 18 Feb 1997 11:53:24 +0100
Message-ID: <w4914l7w1z.fsf@loiosh.kei.com>
Lines: 60
X-Mailer: Gnus v5.4.13/XEmacs 19.15

Jens> == Jens Lautenbacher <jens@metrix.de>
HF>   == Holger Franz <hfranz@cuci.nl>

 Jens> Just a little advanced version... this one actually works
 Jens> (view-mode-enter instead of view-mode ) without annoying messages
 Jens> and removes the binary garbage.

 HF> I never thought that this hack would make it into the general XEmacs
 HF> public. It now looks very good indeed, maybe it could qualify as a
 HF> /micro-package/ for the 19.15 release?

I certainly hope so; it's just plain cool.

 HF> 'view-image-mode' and 'view-image' could use a (require 'view), just
 HF> to be sure that view-mode-enter is defined (it isn't autoloaded at
 HF> least in my 19.14er).

 HF> Now I get an error "Symbol's value as variable is void:
 HF> view-prev-buffer" when I press 'q' to exit view-image-mode. Does
 HF> anybody else see this behaviour?

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

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

(defun view-image (file) "\
Interactively view image \"file\" in view-mode. \"q\" exits view-mode
and kills the buffer to free up colormap entries.\n\ 
Author: Holger Franz <hfranz@physik.rwth-aachen.de>"
  (interactive "fFile: ")
  (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-enter nil '(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.\n\
Idea: Holger Franz <hfranz@physik.rwth-aachen.de>
This version: Jens Lautenbacher <jens@lemming0.lem.uni-karlsruhe.de>"
  (interactive)
  (let ((file buffer-file-truename) ext)
    (require 'atomic-extents)
    (view-mode-enter 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))))

