[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Search]
making tables from free-form data
- To: emacspeak@xxxxxxxxxxx
- Subject: making tables from free-form data
- From: RAYNER Peter <ray060@xxxxxxxxxxx>
- Date: Mon, 9 Apr 2001 11:39:12 +1000 (EST)
- Resent-Date: Sun, 8 Apr 2001 21:47:14 -0400 (EDT)
- Resent-From: emacspeak@xxxxxxxxxxx
- Resent-Message-ID: <"t-8LUD.A.lzG.eKR06"@hub>
- Resent-Sender: emacspeak-request@xxxxxxxxxxx
I love the emacspeak table browsing mode but I found a little
difficulty generating data in the right format for the various set-up
functions. So I hacked Raman's comma-separated-value reading code to
use awk to generate the correct format. As it stands the code will
break each line into fields delimited by wite-space.
Feel free to correct bugs or suggest improvements
Peter Rayner
----------------------------------------------------------------------
(defun emacspeak-table-make-table-in-buffer (&optional buffer-name)
"process free format string data into a table.
The processed data and presented using emacspeak table
navigation. "
(interactive)
(or buffer-name
(setq buffer-name (current-buffer)))
(let ((scratch (get-buffer-create "*table-scratch*"))
(table nil)
(buffer (get-buffer-create
(format "*%s-table*" buffer-name))))
(save-excursion
(set-buffer scratch)
(erase-buffer)
(insert-buffer buffer-name)
(goto-char (point-min))
; now make sure any quotes are properly escaped
(while (search-forward "\"" nil t)
(replace-match "\\\"" nil t))
(goto-char (point-min))
(flush-lines "^ *$")
(call-process-region (point-min) (point-max) "awk" t t nil
"{print \"[\"; for(i=1;i<=NF;++i) printf(\"\\\"%s\\\" \", $i); print \"]\"}")
(goto-char (point-min))
(insert "[\n")
(goto-char (point-max))
(insert "]\n")
(goto-char (point-min))
(setq table (make-emacspeak-table (read scratch))))
(kill-buffer scratch)
(emacspeak-table-prepare-table-buffer table buffer)))
-----------------------------------------------------------------------------
To unsubscribe from the emacspeak list or change your address on the
emacspeak list send mail to "emacspeak-request@xxxxxxxxxxx" with a
subject of "unsubscribe" or "help"
Emacspeak Files |
Subscribe |
Unsubscribe | Search