Thanks for all the answers. I added a redraw-display call so that the change is reflected immediately. (Tried posting this as a comment, but can't.)
(global-set-key (kbd "<f8>") 'tf-toggle-tab-width-setting)
(defun tf-toggle-tab-width-setting () "toggle setting tab widths between 4 and 8"
(interactive)
(setq tab-width (if (= tab-width 8) 4 8))
(message "set tab-width to %d." tab-width)
(redraw-display)
)
And along the same lines. :(
(global-set-key (kbd "<f7>") 'tf-toggle-indent-mode-setting)
(defun tf-toggle-indent-mode-setting ()
"toggle indenting modes"
(interactive)
(setq indent-tabs-mode (if (eq indent-tabs-mode t) nil t))
(message "Indenting using %s." (if (eq indent-tabs-mode t) "tabs" "spaces"))
)