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

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

Re: Surrounding statements with conditionals in C mode.


From: Joakim Hove
Subject: Re: Surrounding statements with conditionals in C mode.
Date: Fri, 05 Sep 2003 14:36:33 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux)

Saurabh Kapoor <address@hidden> writes:


> So, all that i have to do is to write the macro name.
> Is there a way to do this. 

There might be proper included functionality for this already, but the
following solution seems to work reasonably well:


(defun ifdef-region (p1 p2)
  (interactive "r")
  (let* ((macro (read-from-minibuffer "Macro: "))
         (ifdef (concat "#ifdef " macro "\n")))
    (goto-char p1)
    (beginning-of-line)
    
    (insert ifdef)
    (goto-char (+ p2 (length ifdef)))
    (end-of-line)
    (newline 1)
    (insert "#endif"))) 


Joakim 


-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / address@hidden  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/


reply via email to

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