RSS | technovelty home | page of ian | ianw@ieee.org
Have you ever been in the middle of a really long function and wondered just exactly what it was called? Angus Lees came up with
(defun print-defun-name ()
(interactive)
(save-excursion
(beginning-of-defun)
(beginning-of-line 0)
(let ((start (point))
string)
(end-of-line 2)
(setq string (buffer-substring start (point)))
(message "%s" (replace-regexp-in-string "[ \t\n]" " " string)))))
I came up with a slightly different version that works a little better for C code
(defun c-print-defun-name ()
(interactive)
(save-excursion
(c-beginning-of-defun)
(end-of-line 0)
(let ((end (point)))
(c-beginning-of-statement)
(let ((start (point)))
(setq string (buffer-substring start end))
(message "%s" (replace-regexp-in-string "[ \t\n]+" " " string))))))
Add it to your .emacs and if you really want, bind it
to a key.
posted at: Tue, 12 Apr 2005 17:16 | in /code/hacks | permalink | add comment (0 others)

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.