unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Ryde <user42@zip.com.au>
To: emacs-devel@gnu.org
Subject: info-mode image alt text display (patch)
Date: Mon, 26 Mar 2007 07:27:04 +1000	[thread overview]
Message-ID: <87ejnd580n.fsf@zip.com.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

I'd like to propose this change to get Info-display-images-node
showing the the text alternative parts of @image blobs, if the tty
can't show the graphics.  Such text is of course provided specifically
for when the graphics can't be shown.  It can be an ascii art
rendition, or merely a few words about what you could have seen.

2007-03-25  Kevin Ryde  <user42@zip.com.au>

	* info.el (Info-display-images-node): On a text-only terminal, show
	the "text" or "alt" parts of the image blobs.


You can see the effect on the foo.info file below.  Currently the
images are only blank lines, with my change it comes out like

	This is an alt bit.

	This is a text bit from a .txt file.

	Or if no text parts at all then you get:
	[image:foo.png]

foo.texi and bar.txt below are the sources.  Copy any random png files
to create foo.png and bar.png.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: info.el.image-alts.diff --]
[-- Type: text/x-diff, Size: 2194 bytes --]

*** info.el.~1.497.~	2007-03-12 10:14:41.000000000 +1100
--- info.el	2007-03-25 11:23:26.000000000 +1000
***************
*** 1315,1330 ****
  	      nil t)
  	(let* ((start (match-beginning 1))
  	       (parameter-alist (Info-split-parameter-string (match-string 2)))
! 	       (src (cdr (assoc-string "src" parameter-alist)))
! 	       (image-file (if src (if (file-name-absolute-p src) src
! 				     (concat default-directory src))
! 			     ""))
! 	       (image (if (file-exists-p image-file)
! 			  (create-image image-file)
! 			"[broken image]")))
! 	  (if (not (get-text-property start 'display))
! 	      (add-text-properties
! 	       start (point) `(display ,image rear-nonsticky (display)))))))
      (set-buffer-modified-p nil)))
  
  ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
--- 1315,1339 ----
  	      nil t)
  	(let* ((start (match-beginning 1))
  	       (parameter-alist (Info-split-parameter-string (match-string 2)))
!                (src (cdr (assoc-string "src" parameter-alist))))
!           (if (display-images-p)
!               (let* ((image-file (if src (if (file-name-absolute-p src) src
!                                            (concat default-directory src))
!                                    ""))
!                      (image (if (file-exists-p image-file)
!                                 (create-image image-file)
!                               "[broken image]")))
!                 (if (not (get-text-property start 'display))
!                     (add-text-properties
!                      start (point) `(display ,image rear-nonsticky (display)))))
!             ;; text-only display, show alternative text if provided, or
!             ;; otherwise a clue that there's meant to be a picture
!             (delete-region start (point))
!             (insert (or (cdr (assoc-string "text" parameter-alist))
!                         (cdr (assoc-string "alt" parameter-alist))
!                         (and src
!                              (concat "[image:" src "]"))
!                         "[image]"))))))
      (set-buffer-modified-p nil)))
  
  ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].

[-- Attachment #3: foo.info --]
[-- Type: application/octet-stream, Size: 371 bytes --]

[-- Attachment #4: foo.texi --]
[-- Type: application/x-texinfo, Size: 253 bytes --]

[-- Attachment #5: bar.txt --]
[-- Type: text/plain, Size: 37 bytes --]

This is a text bit from a .txt file.

[-- Attachment #6: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-03-25 21:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-25 21:27 Kevin Ryde [this message]
2007-03-27 10:25 ` info-mode image alt text display (patch) Nick Roberts
2007-03-27 16:43 ` Richard Stallman
2007-03-27 22:19   ` Nick Roberts
2007-03-29 15:32     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ejnd580n.fsf@zip.com.au \
    --to=user42@zip.com.au \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).