[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Search]

making tables from free-form data



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