unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Format with %-*
@ 2024-07-08 16:07 Heime
  2024-07-08 17:47 ` Bruno Barbier
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2024-07-08 16:07 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Why do I get "error: Invalid format operation %*" and how can I fix it ?



(defun insert-labels-in-columns (monbf col1-labels col2-labels col3-labels)
  "Insert three lists of labels into BUFFER-NAME in three columns."

  (with-current-buffer (get-buffer-create monbf)

    (erase-buffer)  ; Clear the buffer before inserting new labels

    (let ((max-rows (max (length col1-labels)
                         (length col2-labels)
                         (length col3-labels)))
          (col-width 20))  ; Width of each column

      (dotimes (i max-rows)
        (insert (format "%-*s" col-width (or (nth i col1-labels) "")))
        (insert (format "%-*s" col-width (or (nth i col2-labels) "")))
        (insert (or (nth i col3-labels) ""))
        (insert "\n"))))

    (pop-to-buffer monbf))



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-09 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-08 16:07 Format with %-* Heime
2024-07-08 17:47 ` Bruno Barbier
2024-07-08 19:53   ` Heime
2024-07-09  8:07     ` Bruno Barbier
2024-07-09  8:59     ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-07-09 13:39       ` Emanuel Berg

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).