Hacker News new | ask | show | jobs
by m463 1907 days ago
sometimes it's printf, sometimes it's printk, sometimes it's echo, but yes I agree.

I had an emacs macro that would help. Simplified it was:

  (defun add-printf ()
    (interactive)
    (let ((s (word-near-point)))
      (when s
        (beginning-of-line)
        (insert "printf(\"@@@ %s:%d "
                s 
                ": 0x%x\\n\", __FUNCTION__, __LINE__,"
                s
                ");\n")
        (forward-line -1)
        (indent-for-tab-command)
        (end-of-line)
        (search-backward " \\n" nil t))))

  (global-set-key [f8] 'add-printf)
I had lots of variants (crafted while recompiling) with prompts, or marked regions or lots more throwaway printf silliness