help-gnu-emacs
[Top][All Lists]
Advanced

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

shortcut to open header from c file


From: ckhan
Subject: shortcut to open header from c file
Date: Wed, 28 Mar 2012 19:25:04 -0000
User-agent: G2/1.0

I'd like to bind a keystroke to open foo.h when I'm visiting foo.c

I tried knocking something together with buffer-file-name, aset, and
find-file but somehow I'm winding up modifying the value of buffer-
file-name instead just opening a new file.

(global-set-key
 "\C-x7"
 (lambda ()
   (interactive "*")
   (let* ((name buffer-file-name))
     (aset name (- (length name) 1) ?h)
     (find-file name))))

Clearly my elisp skills are lacking, can someone tell me what I've
done wrong
(or if there's a completely different way to achieve this?)

Thanks,
ckhan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]